mirror of
https://github.com/vinliao/nashboard-old.git
synced 2025-12-17 04:35:15 +01:00
to sveltekit
This commit is contained in:
11
.svelte-kit/generated/client-manifest.js
Normal file
11
.svelte-kit/generated/client-manifest.js
Normal file
@@ -0,0 +1,11 @@
|
||||
export { matchers } from './client-matchers.js';
|
||||
|
||||
export const components = [
|
||||
() => import("../../src/routes/__layout.svelte"),
|
||||
() => import("../runtime/components/error.svelte"),
|
||||
() => import("../../src/routes/index.svelte")
|
||||
];
|
||||
|
||||
export const dictionary = {
|
||||
"": [[0, 2], [1]]
|
||||
};
|
||||
1
.svelte-kit/generated/client-matchers.js
Normal file
1
.svelte-kit/generated/client-matchers.js
Normal file
@@ -0,0 +1 @@
|
||||
export const matchers = {};
|
||||
56
.svelte-kit/generated/root.svelte
Normal file
56
.svelte-kit/generated/root.svelte
Normal file
@@ -0,0 +1,56 @@
|
||||
<!-- This file is generated by @sveltejs/kit — do not edit it! -->
|
||||
<script>
|
||||
import { setContext, afterUpdate, onMount } from 'svelte';
|
||||
|
||||
// stores
|
||||
export let stores;
|
||||
export let page;
|
||||
|
||||
export let components;
|
||||
export let props_0 = null;
|
||||
export let props_1 = null;
|
||||
export let props_2 = null;
|
||||
|
||||
setContext('__svelte__', stores);
|
||||
|
||||
$: stores.page.set(page);
|
||||
afterUpdate(stores.page.notify);
|
||||
|
||||
let mounted = false;
|
||||
let navigated = false;
|
||||
let title = null;
|
||||
|
||||
onMount(() => {
|
||||
const unsubscribe = stores.page.subscribe(() => {
|
||||
if (mounted) {
|
||||
navigated = true;
|
||||
title = document.title || 'untitled page';
|
||||
}
|
||||
});
|
||||
|
||||
mounted = true;
|
||||
return unsubscribe;
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if components[1]}
|
||||
<svelte:component this={components[0]} {...(props_0 || {})}>
|
||||
{#if components[2]}
|
||||
<svelte:component this={components[1]} {...(props_1 || {})}>
|
||||
<svelte:component this={components[2]} {...(props_2 || {})}/>
|
||||
</svelte:component>
|
||||
{:else}
|
||||
<svelte:component this={components[1]} {...(props_1 || {})} />
|
||||
{/if}
|
||||
</svelte:component>
|
||||
{:else}
|
||||
<svelte:component this={components[0]} {...(props_0 || {})} />
|
||||
{/if}
|
||||
|
||||
{#if mounted}
|
||||
<div id="svelte-announcer" aria-live="assertive" aria-atomic="true" style="position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px">
|
||||
{#if navigated}
|
||||
{title}
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
20
.svelte-kit/runtime/app/env.js
Normal file
20
.svelte-kit/runtime/app/env.js
Normal file
@@ -0,0 +1,20 @@
|
||||
export { prerendering } from '../env.js';
|
||||
|
||||
/**
|
||||
* @type {import('$app/env').browser}
|
||||
*/
|
||||
const browser = !import.meta.env.SSR;
|
||||
/**
|
||||
* @type {import('$app/env').dev}
|
||||
*/
|
||||
const dev = !!import.meta.env.DEV;
|
||||
/**
|
||||
* @type {import('$app/env').mode}
|
||||
*/
|
||||
const mode = import.meta.env.MODE;
|
||||
/**
|
||||
* @type {import('$app/env').amp}
|
||||
*/
|
||||
const amp = !!import.meta.env.VITE_SVELTEKIT_AMP;
|
||||
|
||||
export { amp, browser, dev, mode };
|
||||
24
.svelte-kit/runtime/app/navigation.js
Normal file
24
.svelte-kit/runtime/app/navigation.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import { client } from '../client/singletons.js';
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
*/
|
||||
function guard(name) {
|
||||
return () => {
|
||||
throw new Error(`Cannot call ${name}(...) on the server`);
|
||||
};
|
||||
}
|
||||
|
||||
const ssr = import.meta.env.SSR;
|
||||
|
||||
const disableScrollHandling = ssr
|
||||
? guard('disableScrollHandling')
|
||||
: client.disable_scroll_handling;
|
||||
const goto = ssr ? guard('goto') : client.goto;
|
||||
const invalidate = ssr ? guard('invalidate') : client.invalidate;
|
||||
const prefetch = ssr ? guard('prefetch') : client.prefetch;
|
||||
const prefetchRoutes = ssr ? guard('prefetchRoutes') : client.prefetch_routes;
|
||||
const beforeNavigate = ssr ? () => {} : client.before_navigate;
|
||||
const afterNavigate = ssr ? () => {} : client.after_navigate;
|
||||
|
||||
export { afterNavigate, beforeNavigate, disableScrollHandling, goto, invalidate, prefetch, prefetchRoutes };
|
||||
1
.svelte-kit/runtime/app/paths.js
Normal file
1
.svelte-kit/runtime/app/paths.js
Normal file
@@ -0,0 +1 @@
|
||||
export { assets, base } from '../paths.js';
|
||||
97
.svelte-kit/runtime/app/stores.js
Normal file
97
.svelte-kit/runtime/app/stores.js
Normal file
@@ -0,0 +1,97 @@
|
||||
import { getContext } from 'svelte';
|
||||
import { browser } from './env.js';
|
||||
import '../env.js';
|
||||
|
||||
// TODO remove this (for 1.0? after 1.0?)
|
||||
let warned = false;
|
||||
function stores() {
|
||||
if (!warned) {
|
||||
console.error('stores() is deprecated; use getStores() instead');
|
||||
warned = true;
|
||||
}
|
||||
return getStores();
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {import('$app/stores').getStores}
|
||||
*/
|
||||
const getStores = () => {
|
||||
const stores = getContext('__svelte__');
|
||||
|
||||
return {
|
||||
page: {
|
||||
subscribe: stores.page.subscribe
|
||||
},
|
||||
navigating: {
|
||||
subscribe: stores.navigating.subscribe
|
||||
},
|
||||
// TODO remove this (for 1.0? after 1.0?)
|
||||
// @ts-expect-error - deprecated, not part of type definitions, but still callable
|
||||
get preloading() {
|
||||
console.error('stores.preloading is deprecated; use stores.navigating instead');
|
||||
return {
|
||||
subscribe: stores.navigating.subscribe
|
||||
};
|
||||
},
|
||||
session: stores.session,
|
||||
updated: stores.updated
|
||||
};
|
||||
};
|
||||
|
||||
/** @type {typeof import('$app/stores').page} */
|
||||
const page = {
|
||||
/** @param {(value: any) => void} fn */
|
||||
subscribe(fn) {
|
||||
const store = getStores().page;
|
||||
return store.subscribe(fn);
|
||||
}
|
||||
};
|
||||
|
||||
/** @type {typeof import('$app/stores').navigating} */
|
||||
const navigating = {
|
||||
subscribe(fn) {
|
||||
const store = getStores().navigating;
|
||||
return store.subscribe(fn);
|
||||
}
|
||||
};
|
||||
|
||||
/** @param {string} verb */
|
||||
const throw_error = (verb) => {
|
||||
throw new Error(
|
||||
browser
|
||||
? `Cannot ${verb} session store before subscribing`
|
||||
: `Can only ${verb} session store in browser`
|
||||
);
|
||||
};
|
||||
|
||||
/** @type {typeof import('$app/stores').session} */
|
||||
const session = {
|
||||
subscribe(fn) {
|
||||
const store = getStores().session;
|
||||
|
||||
if (browser) {
|
||||
session.set = store.set;
|
||||
session.update = store.update;
|
||||
}
|
||||
|
||||
return store.subscribe(fn);
|
||||
},
|
||||
set: () => throw_error('set'),
|
||||
update: () => throw_error('update')
|
||||
};
|
||||
|
||||
/** @type {typeof import('$app/stores').updated} */
|
||||
const updated = {
|
||||
subscribe(fn) {
|
||||
const store = getStores().updated;
|
||||
|
||||
if (browser) {
|
||||
updated.check = store.check;
|
||||
}
|
||||
|
||||
return store.subscribe(fn);
|
||||
},
|
||||
check: () => throw_error('check')
|
||||
};
|
||||
|
||||
export { getStores, navigating, page, session, stores, updated };
|
||||
13
.svelte-kit/runtime/client/singletons.js
Normal file
13
.svelte-kit/runtime/client/singletons.js
Normal file
@@ -0,0 +1,13 @@
|
||||
/** @type {import('./types').Client} */
|
||||
let client;
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* client: import('./types').Client;
|
||||
* }} opts
|
||||
*/
|
||||
function init(opts) {
|
||||
client = opts.client;
|
||||
}
|
||||
|
||||
export { client, init };
|
||||
1650
.svelte-kit/runtime/client/start.js
Normal file
1650
.svelte-kit/runtime/client/start.js
Normal file
File diff suppressed because it is too large
Load Diff
29
.svelte-kit/runtime/components/error.svelte
Normal file
29
.svelte-kit/runtime/components/error.svelte
Normal file
@@ -0,0 +1,29 @@
|
||||
<script context="module">
|
||||
/** @type {import('@sveltejs/kit').ErrorLoad} */
|
||||
export function load({ error, status }) {
|
||||
return {
|
||||
props: { error, status }
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
/** @type {number} */
|
||||
export let status;
|
||||
|
||||
/** @type {Error & {frame?: string} & {loc?: object}} */
|
||||
export let error;
|
||||
</script>
|
||||
|
||||
<h1>{status}</h1>
|
||||
|
||||
<pre>{error.message}</pre>
|
||||
|
||||
<!-- TODO figure out what to do with frames/stacktraces in prod -->
|
||||
<!-- frame is populated by Svelte in its CompileError and is a Rollup/Vite convention -->
|
||||
{#if error.frame}
|
||||
<pre>{error.frame}</pre>
|
||||
{/if}
|
||||
{#if error.stack}
|
||||
<pre>{error.stack}</pre>
|
||||
{/if}
|
||||
1
.svelte-kit/runtime/components/layout.svelte
Normal file
1
.svelte-kit/runtime/components/layout.svelte
Normal file
@@ -0,0 +1 @@
|
||||
<slot></slot>
|
||||
8
.svelte-kit/runtime/env.js
Normal file
8
.svelte-kit/runtime/env.js
Normal file
@@ -0,0 +1,8 @@
|
||||
let prerendering = false;
|
||||
|
||||
/** @param {boolean} value */
|
||||
function set_prerendering(value) {
|
||||
prerendering = value;
|
||||
}
|
||||
|
||||
export { prerendering, set_prerendering };
|
||||
13
.svelte-kit/runtime/paths.js
Normal file
13
.svelte-kit/runtime/paths.js
Normal file
@@ -0,0 +1,13 @@
|
||||
/** @type {string} */
|
||||
let base = '';
|
||||
|
||||
/** @type {string} */
|
||||
let assets = '';
|
||||
|
||||
/** @param {{ base: string, assets: string }} paths */
|
||||
function set_paths(paths) {
|
||||
base = paths.base;
|
||||
assets = paths.assets || base;
|
||||
}
|
||||
|
||||
export { assets, base, set_paths };
|
||||
2845
.svelte-kit/runtime/server/index.js
Normal file
2845
.svelte-kit/runtime/server/index.js
Normal file
File diff suppressed because it is too large
Load Diff
43
.svelte-kit/tsconfig.json
Normal file
43
.svelte-kit/tsconfig.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"moduleResolution": "node",
|
||||
"module": "es2020",
|
||||
"lib": [
|
||||
"es2020",
|
||||
"DOM"
|
||||
],
|
||||
"target": "es2020",
|
||||
"importsNotUsedAsValues": "error",
|
||||
"preserveValueImports": true,
|
||||
"isolatedModules": true,
|
||||
"resolveJsonModule": true,
|
||||
"sourceMap": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"baseUrl": "..",
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"paths": {
|
||||
"$lib": [
|
||||
"src/lib"
|
||||
],
|
||||
"$lib/*": [
|
||||
"src/lib/*"
|
||||
]
|
||||
},
|
||||
"rootDirs": [
|
||||
"..",
|
||||
"./types"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"../src/**/*.js",
|
||||
"../src/**/*.ts",
|
||||
"../src/**/*.svelte"
|
||||
],
|
||||
"exclude": [
|
||||
"../node_modules/**",
|
||||
"./**"
|
||||
]
|
||||
}
|
||||
7
.svelte-kit/types/src/routes/__layout.d.ts
vendored
Normal file
7
.svelte-kit/types/src/routes/__layout.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
// this file is auto-generated
|
||||
import type { Load as GenericLoad } from '@sveltejs/kit';
|
||||
|
||||
export type Load<
|
||||
InputProps extends Record<string, any> = Record<string, any>,
|
||||
OutputProps extends Record<string, any> = InputProps
|
||||
> = GenericLoad<{}, InputProps, OutputProps>;
|
||||
7
.svelte-kit/types/src/routes/index.d.ts
vendored
Normal file
7
.svelte-kit/types/src/routes/index.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
// this file is auto-generated
|
||||
import type { Load as GenericLoad } from '@sveltejs/kit';
|
||||
|
||||
export type Load<
|
||||
InputProps extends Record<string, any> = Record<string, any>,
|
||||
OutputProps extends Record<string, any> = InputProps
|
||||
> = GenericLoad<{}, InputProps, OutputProps>;
|
||||
42
README.md
42
README.md
@@ -1,4 +1,40 @@
|
||||
# Nashboard: a Nostr network dashboard
|
||||
Firstly, I want to say thank you to relay operators. Without them, the Nostr network wouldn't run and this site wouldn't exist.
|
||||
# create-svelte
|
||||
|
||||
This small site displays basic statistics about the Nostr network - the events, the relays, the timestamps. You can think of it as the dashboard of the entire network. Visit: [nashboard.netlify.app](https://nashboard.netlify.app/).
|
||||
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).
|
||||
|
||||
## Creating a project
|
||||
|
||||
If you're seeing this, you've probably already done this step. Congrats!
|
||||
|
||||
```bash
|
||||
# create a new project in the current directory
|
||||
npm init svelte@next
|
||||
|
||||
# create a new project in my-app
|
||||
npm init svelte@next my-app
|
||||
```
|
||||
|
||||
> Note: the `@next` is temporary
|
||||
|
||||
## Developing
|
||||
|
||||
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
|
||||
# or start the server and open the app in a new browser tab
|
||||
npm run dev -- --open
|
||||
```
|
||||
|
||||
## Building
|
||||
|
||||
To create a production version of your app:
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
You can preview the production build with `npm run preview`.
|
||||
|
||||
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
|
||||
|
||||
3
jsconfig.json
Normal file
3
jsconfig.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "./.svelte-kit/tsconfig.json"
|
||||
}
|
||||
55
package.json
55
package.json
@@ -1,30 +1,29 @@
|
||||
{
|
||||
"name": "nashboard",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"watch": "postcss public/tailwind.css -o public/app.css -w",
|
||||
"build": "rollup -c",
|
||||
"dev": "rollup -c -w",
|
||||
"start": "sirv public --no-clear"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^17.0.0",
|
||||
"@rollup/plugin-node-resolve": "^11.0.0",
|
||||
"autoprefixer": "^10.4.2",
|
||||
"postcss-cli": "^9.1.0",
|
||||
"rollup": "^2.3.4",
|
||||
"rollup-plugin-css-only": "^3.1.0",
|
||||
"rollup-plugin-livereload": "^2.0.0",
|
||||
"rollup-plugin-svelte": "^7.0.0",
|
||||
"rollup-plugin-terser": "^7.0.0",
|
||||
"svelte": "^3.0.0",
|
||||
"tailwindcss": "^3.0.23"
|
||||
},
|
||||
"dependencies": {
|
||||
"sirv-cli": "^2.0.0",
|
||||
"svelte-chartjs": "^1.1.4",
|
||||
"timeago.js": "^4.0.2",
|
||||
"underscore": "^1.13.2"
|
||||
}
|
||||
"name": "nashboard-sveltekit",
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
"dev": "svelte-kit dev",
|
||||
"build": "svelte-kit build",
|
||||
"package": "svelte-kit package",
|
||||
"preview": "svelte-kit preview",
|
||||
"prepare": "svelte-kit sync",
|
||||
"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
|
||||
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/adapter-auto": "next",
|
||||
"@sveltejs/kit": "next",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-svelte3": "^3.2.1",
|
||||
"prettier": "^2.5.1",
|
||||
"prettier-plugin-svelte": "^2.5.0",
|
||||
"svelte": "^3.44.0",
|
||||
"postcss": "^8.4.5",
|
||||
"postcss-load-config": "^3.1.1",
|
||||
"svelte-preprocess": "^4.10.1",
|
||||
"autoprefixer": "^10.4.2",
|
||||
"tailwindcss": "^3.0.12"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
13
postcss.config.cjs
Normal file
13
postcss.config.cjs
Normal file
@@ -0,0 +1,13 @@
|
||||
const tailwindcss = require('tailwindcss');
|
||||
const autoprefixer = require('autoprefixer');
|
||||
|
||||
const config = {
|
||||
plugins: [
|
||||
//Some plugins, like tailwindcss/nesting, need to run before Tailwind,
|
||||
tailwindcss(),
|
||||
//But others, like autoprefixer, need to run after,
|
||||
autoprefixer
|
||||
]
|
||||
};
|
||||
|
||||
module.exports = config;
|
||||
@@ -1,6 +0,0 @@
|
||||
module.exports = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
}
|
||||
}
|
||||
583
public/app.css
583
public/app.css
@@ -1,583 +0,0 @@
|
||||
/*
|
||||
! tailwindcss v3.0.23 | MIT License | https://tailwindcss.com
|
||||
*//*
|
||||
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
|
||||
2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
|
||||
*/
|
||||
|
||||
*,
|
||||
::before,
|
||||
::after {
|
||||
box-sizing: border-box; /* 1 */
|
||||
border-width: 0; /* 2 */
|
||||
border-style: solid; /* 2 */
|
||||
border-color: #e5e7eb; /* 2 */
|
||||
}
|
||||
|
||||
::before,
|
||||
::after {
|
||||
--tw-content: '';
|
||||
}
|
||||
|
||||
/*
|
||||
1. Use a consistent sensible line-height in all browsers.
|
||||
2. Prevent adjustments of font size after orientation changes in iOS.
|
||||
3. Use a more readable tab size.
|
||||
4. Use the user's configured `sans` font-family by default.
|
||||
*/
|
||||
|
||||
html {
|
||||
line-height: 1.5; /* 1 */
|
||||
-webkit-text-size-adjust: 100%; /* 2 */
|
||||
-moz-tab-size: 4; /* 3 */
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4; /* 3 */
|
||||
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; /* 4 */
|
||||
}
|
||||
|
||||
/*
|
||||
1. Remove the margin in all browsers.
|
||||
2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.
|
||||
*/
|
||||
|
||||
body {
|
||||
margin: 0; /* 1 */
|
||||
line-height: inherit; /* 2 */
|
||||
}
|
||||
|
||||
/*
|
||||
1. Add the correct height in Firefox.
|
||||
2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
|
||||
3. Ensure horizontal rules are visible by default.
|
||||
*/
|
||||
|
||||
hr {
|
||||
height: 0; /* 1 */
|
||||
color: inherit; /* 2 */
|
||||
border-top-width: 1px; /* 3 */
|
||||
}
|
||||
|
||||
/*
|
||||
Add the correct text decoration in Chrome, Edge, and Safari.
|
||||
*/
|
||||
|
||||
abbr:where([title]) {
|
||||
-webkit-text-decoration: underline dotted;
|
||||
text-decoration: underline dotted;
|
||||
}
|
||||
|
||||
/*
|
||||
Remove the default font size and weight for headings.
|
||||
*/
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
font-size: inherit;
|
||||
font-weight: inherit;
|
||||
}
|
||||
|
||||
/*
|
||||
Reset links to optimize for opt-in styling instead of opt-out.
|
||||
*/
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: inherit;
|
||||
}
|
||||
|
||||
/*
|
||||
Add the correct font weight in Edge and Safari.
|
||||
*/
|
||||
|
||||
b,
|
||||
strong {
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
/*
|
||||
1. Use the user's configured `mono` font family by default.
|
||||
2. Correct the odd `em` font sizing in all browsers.
|
||||
*/
|
||||
|
||||
code,
|
||||
kbd,
|
||||
samp,
|
||||
pre {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; /* 1 */
|
||||
font-size: 1em; /* 2 */
|
||||
}
|
||||
|
||||
/*
|
||||
Add the correct font size in all browsers.
|
||||
*/
|
||||
|
||||
small {
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
/*
|
||||
Prevent `sub` and `sup` elements from affecting the line height in all browsers.
|
||||
*/
|
||||
|
||||
sub,
|
||||
sup {
|
||||
font-size: 75%;
|
||||
line-height: 0;
|
||||
position: relative;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
sub {
|
||||
bottom: -0.25em;
|
||||
}
|
||||
|
||||
sup {
|
||||
top: -0.5em;
|
||||
}
|
||||
|
||||
/*
|
||||
1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
|
||||
2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
|
||||
3. Remove gaps between table borders by default.
|
||||
*/
|
||||
|
||||
table {
|
||||
text-indent: 0; /* 1 */
|
||||
border-color: inherit; /* 2 */
|
||||
border-collapse: collapse; /* 3 */
|
||||
}
|
||||
|
||||
/*
|
||||
1. Change the font styles in all browsers.
|
||||
2. Remove the margin in Firefox and Safari.
|
||||
3. Remove default padding in all browsers.
|
||||
*/
|
||||
|
||||
button,
|
||||
input,
|
||||
optgroup,
|
||||
select,
|
||||
textarea {
|
||||
font-family: inherit; /* 1 */
|
||||
font-size: 100%; /* 1 */
|
||||
line-height: inherit; /* 1 */
|
||||
color: inherit; /* 1 */
|
||||
margin: 0; /* 2 */
|
||||
padding: 0; /* 3 */
|
||||
}
|
||||
|
||||
/*
|
||||
Remove the inheritance of text transform in Edge and Firefox.
|
||||
*/
|
||||
|
||||
button,
|
||||
select {
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
/*
|
||||
1. Correct the inability to style clickable types in iOS and Safari.
|
||||
2. Remove default button styles.
|
||||
*/
|
||||
|
||||
button,
|
||||
[type='button'],
|
||||
[type='reset'],
|
||||
[type='submit'] {
|
||||
-webkit-appearance: button; /* 1 */
|
||||
background-color: transparent; /* 2 */
|
||||
background-image: none; /* 2 */
|
||||
}
|
||||
|
||||
/*
|
||||
Use the modern Firefox focus style for all focusable elements.
|
||||
*/
|
||||
|
||||
:-moz-focusring {
|
||||
outline: auto;
|
||||
}
|
||||
|
||||
/*
|
||||
Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)
|
||||
*/
|
||||
|
||||
:-moz-ui-invalid {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
/*
|
||||
Add the correct vertical alignment in Chrome and Firefox.
|
||||
*/
|
||||
|
||||
progress {
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
/*
|
||||
Correct the cursor style of increment and decrement buttons in Safari.
|
||||
*/
|
||||
|
||||
::-webkit-inner-spin-button,
|
||||
::-webkit-outer-spin-button {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
/*
|
||||
1. Correct the odd appearance in Chrome and Safari.
|
||||
2. Correct the outline style in Safari.
|
||||
*/
|
||||
|
||||
[type='search'] {
|
||||
-webkit-appearance: textfield; /* 1 */
|
||||
outline-offset: -2px; /* 2 */
|
||||
}
|
||||
|
||||
/*
|
||||
Remove the inner padding in Chrome and Safari on macOS.
|
||||
*/
|
||||
|
||||
::-webkit-search-decoration {
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
|
||||
/*
|
||||
1. Correct the inability to style clickable types in iOS and Safari.
|
||||
2. Change font properties to `inherit` in Safari.
|
||||
*/
|
||||
|
||||
::-webkit-file-upload-button {
|
||||
-webkit-appearance: button; /* 1 */
|
||||
font: inherit; /* 2 */
|
||||
}
|
||||
|
||||
/*
|
||||
Add the correct display in Chrome and Safari.
|
||||
*/
|
||||
|
||||
summary {
|
||||
display: list-item;
|
||||
}
|
||||
|
||||
/*
|
||||
Removes the default spacing and border for appropriate elements.
|
||||
*/
|
||||
|
||||
blockquote,
|
||||
dl,
|
||||
dd,
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6,
|
||||
hr,
|
||||
figure,
|
||||
p,
|
||||
pre {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
fieldset {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
legend {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
ol,
|
||||
ul,
|
||||
menu {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Prevent resizing textareas horizontally by default.
|
||||
*/
|
||||
|
||||
textarea {
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
/*
|
||||
1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)
|
||||
2. Set the default placeholder color to the user's configured gray 400 color.
|
||||
*/
|
||||
|
||||
input::-moz-placeholder, textarea::-moz-placeholder {
|
||||
opacity: 1; /* 1 */
|
||||
color: #9ca3af; /* 2 */
|
||||
}
|
||||
|
||||
input:-ms-input-placeholder, textarea:-ms-input-placeholder {
|
||||
opacity: 1; /* 1 */
|
||||
color: #9ca3af; /* 2 */
|
||||
}
|
||||
|
||||
input::placeholder,
|
||||
textarea::placeholder {
|
||||
opacity: 1; /* 1 */
|
||||
color: #9ca3af; /* 2 */
|
||||
}
|
||||
|
||||
/*
|
||||
Set the default cursor for buttons.
|
||||
*/
|
||||
|
||||
button,
|
||||
[role="button"] {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/*
|
||||
Make sure disabled buttons don't get the pointer cursor.
|
||||
*/
|
||||
:disabled {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
/*
|
||||
1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)
|
||||
2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)
|
||||
This can trigger a poorly considered lint error in some tools but is included by design.
|
||||
*/
|
||||
|
||||
img,
|
||||
svg,
|
||||
video,
|
||||
canvas,
|
||||
audio,
|
||||
iframe,
|
||||
embed,
|
||||
object {
|
||||
display: block; /* 1 */
|
||||
vertical-align: middle; /* 2 */
|
||||
}
|
||||
|
||||
/*
|
||||
Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)
|
||||
*/
|
||||
|
||||
img,
|
||||
video {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
/*
|
||||
Ensure the default browser behavior of the `hidden` attribute.
|
||||
*/
|
||||
|
||||
[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
*, ::before, ::after {
|
||||
--tw-translate-x: 0;
|
||||
--tw-translate-y: 0;
|
||||
--tw-rotate: 0;
|
||||
--tw-skew-x: 0;
|
||||
--tw-skew-y: 0;
|
||||
--tw-scale-x: 1;
|
||||
--tw-scale-y: 1;
|
||||
--tw-pan-x: ;
|
||||
--tw-pan-y: ;
|
||||
--tw-pinch-zoom: ;
|
||||
--tw-scroll-snap-strictness: proximity;
|
||||
--tw-ordinal: ;
|
||||
--tw-slashed-zero: ;
|
||||
--tw-numeric-figure: ;
|
||||
--tw-numeric-spacing: ;
|
||||
--tw-numeric-fraction: ;
|
||||
--tw-ring-inset: ;
|
||||
--tw-ring-offset-width: 0px;
|
||||
--tw-ring-offset-color: #fff;
|
||||
--tw-ring-color: rgb(59 130 246 / 0.5);
|
||||
--tw-ring-offset-shadow: 0 0 #0000;
|
||||
--tw-ring-shadow: 0 0 #0000;
|
||||
--tw-shadow: 0 0 #0000;
|
||||
--tw-shadow-colored: 0 0 #0000;
|
||||
--tw-blur: ;
|
||||
--tw-brightness: ;
|
||||
--tw-contrast: ;
|
||||
--tw-grayscale: ;
|
||||
--tw-hue-rotate: ;
|
||||
--tw-invert: ;
|
||||
--tw-saturate: ;
|
||||
--tw-sepia: ;
|
||||
--tw-drop-shadow: ;
|
||||
--tw-backdrop-blur: ;
|
||||
--tw-backdrop-brightness: ;
|
||||
--tw-backdrop-contrast: ;
|
||||
--tw-backdrop-grayscale: ;
|
||||
--tw-backdrop-hue-rotate: ;
|
||||
--tw-backdrop-invert: ;
|
||||
--tw-backdrop-opacity: ;
|
||||
--tw-backdrop-saturate: ;
|
||||
--tw-backdrop-sepia: ;
|
||||
}
|
||||
.mx-auto {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
.my-5 {
|
||||
margin-top: 1.25rem;
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
.my-1 {
|
||||
margin-top: 0.25rem;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
.mr-3 {
|
||||
margin-right: 0.75rem;
|
||||
}
|
||||
.mb-2 {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
.block {
|
||||
display: block;
|
||||
}
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
.max-w-3xl {
|
||||
max-width: 48rem;
|
||||
}
|
||||
.flex-1 {
|
||||
flex: 1 1 0%;
|
||||
}
|
||||
.shrink {
|
||||
flex-shrink: 1;
|
||||
}
|
||||
.flex-col {
|
||||
flex-direction: column;
|
||||
}
|
||||
.justify-between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
.space-y-2 > :not([hidden]) ~ :not([hidden]) {
|
||||
--tw-space-y-reverse: 0;
|
||||
margin-top: calc(0.5rem * calc(1 - var(--tw-space-y-reverse)));
|
||||
margin-bottom: calc(0.5rem * var(--tw-space-y-reverse));
|
||||
}
|
||||
.self-start {
|
||||
align-self: flex-start;
|
||||
}
|
||||
.break-words {
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
.rounded-md {
|
||||
border-radius: 0.375rem;
|
||||
}
|
||||
.border-l-4 {
|
||||
border-left-width: 4px;
|
||||
}
|
||||
.border-slate-800 {
|
||||
--tw-border-opacity: 1;
|
||||
border-color: rgb(30 41 59 / var(--tw-border-opacity));
|
||||
}
|
||||
.bg-white {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(255 255 255 / var(--tw-bg-opacity));
|
||||
}
|
||||
.bg-gradient-to-r {
|
||||
background-image: linear-gradient(to right, var(--tw-gradient-stops));
|
||||
}
|
||||
.from-pink-100 {
|
||||
--tw-gradient-from: #fce7f3;
|
||||
--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to, rgb(252 231 243 / 0));
|
||||
}
|
||||
.to-orange-200 {
|
||||
--tw-gradient-to: #fed7aa;
|
||||
}
|
||||
.p-3 {
|
||||
padding: 0.75rem;
|
||||
}
|
||||
.p-2 {
|
||||
padding: 0.5rem;
|
||||
}
|
||||
.px-4 {
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
.pb-3 {
|
||||
padding-bottom: 0.75rem;
|
||||
}
|
||||
.pl-3 {
|
||||
padding-left: 0.75rem;
|
||||
}
|
||||
.text-center {
|
||||
text-align: center;
|
||||
}
|
||||
.font-mono {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
||||
}
|
||||
.text-sm {
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.25rem;
|
||||
}
|
||||
.text-2xl {
|
||||
font-size: 1.5rem;
|
||||
line-height: 2rem;
|
||||
}
|
||||
.text-neutral-400 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(163 163 163 / var(--tw-text-opacity));
|
||||
}
|
||||
.text-neutral-500 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(115 115 115 / var(--tw-text-opacity));
|
||||
}
|
||||
.text-orange-700 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(194 65 12 / var(--tw-text-opacity));
|
||||
}
|
||||
.text-neutral-600 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(82 82 82 / var(--tw-text-opacity));
|
||||
}
|
||||
.underline {
|
||||
-webkit-text-decoration-line: underline;
|
||||
text-decoration-line: underline;
|
||||
}
|
||||
.shadow {
|
||||
--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
|
||||
--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);
|
||||
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
|
||||
}
|
||||
@media (min-width: 640px) {
|
||||
|
||||
.sm\:flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.sm\:w-1\/2 {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.sm\:space-x-4 > :not([hidden]) ~ :not([hidden]) {
|
||||
--tw-space-x-reverse: 0;
|
||||
margin-right: calc(1rem * var(--tw-space-x-reverse));
|
||||
margin-left: calc(1rem * calc(1 - var(--tw-space-x-reverse)));
|
||||
}
|
||||
|
||||
.sm\:space-y-0 > :not([hidden]) ~ :not([hidden]) {
|
||||
--tw-space-y-reverse: 0;
|
||||
margin-top: calc(0px * calc(1 - var(--tw-space-y-reverse)));
|
||||
margin-bottom: calc(0px * var(--tw-space-y-reverse));
|
||||
}
|
||||
|
||||
.sm\:space-y-4 > :not([hidden]) ~ :not([hidden]) {
|
||||
--tw-space-y-reverse: 0;
|
||||
margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse)));
|
||||
margin-bottom: calc(1rem * var(--tw-space-y-reverse));
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<meta name='viewport' content='width=device-width,initial-scale=1'>
|
||||
|
||||
<title>Nashboard</title>
|
||||
|
||||
<link rel='icon' type='image/png' href='/favicon.png'>
|
||||
<link rel='stylesheet' href='/global.css'>
|
||||
<link rel='stylesheet' href='/app.css'>
|
||||
<link rel='stylesheet' href='/build/bundle.css'>
|
||||
|
||||
<script defer src='/build/bundle.js'></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,3 +0,0 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
@@ -1,76 +0,0 @@
|
||||
import svelte from 'rollup-plugin-svelte';
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import livereload from 'rollup-plugin-livereload';
|
||||
import { terser } from 'rollup-plugin-terser';
|
||||
import css from 'rollup-plugin-css-only';
|
||||
|
||||
const production = !process.env.ROLLUP_WATCH;
|
||||
|
||||
function serve() {
|
||||
let server;
|
||||
|
||||
function toExit() {
|
||||
if (server) server.kill(0);
|
||||
}
|
||||
|
||||
return {
|
||||
writeBundle() {
|
||||
if (server) return;
|
||||
server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
|
||||
stdio: ['ignore', 'inherit', 'inherit'],
|
||||
shell: true
|
||||
});
|
||||
|
||||
process.on('SIGTERM', toExit);
|
||||
process.on('exit', toExit);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default {
|
||||
input: 'src/main.js',
|
||||
output: {
|
||||
sourcemap: true,
|
||||
format: 'iife',
|
||||
name: 'app',
|
||||
file: 'public/build/bundle.js'
|
||||
},
|
||||
plugins: [
|
||||
svelte({
|
||||
compilerOptions: {
|
||||
// enable run-time checks when not in production
|
||||
dev: !production
|
||||
}
|
||||
}),
|
||||
// we'll extract any component CSS out into
|
||||
// a separate file - better for performance
|
||||
css({ output: 'bundle.css' }),
|
||||
|
||||
// If you have external dependencies installed from
|
||||
// npm, you'll most likely need these plugins. In
|
||||
// some cases you'll need additional configuration -
|
||||
// consult the documentation for details:
|
||||
// https://github.com/rollup/plugins/tree/master/packages/commonjs
|
||||
resolve({
|
||||
browser: true,
|
||||
dedupe: ['svelte']
|
||||
}),
|
||||
commonjs(),
|
||||
|
||||
// In dev mode, call `npm run start` once
|
||||
// the bundle has been generated
|
||||
!production && serve(),
|
||||
|
||||
// Watch the `public` directory and refresh the
|
||||
// browser on changes when not in production
|
||||
!production && livereload('public'),
|
||||
|
||||
// If we're building for production (npm run build
|
||||
// instead of npm run dev), minify
|
||||
production && terser()
|
||||
],
|
||||
watch: {
|
||||
clearScreen: false
|
||||
}
|
||||
};
|
||||
@@ -1,121 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
/** This script modifies the project to support TS code in .svelte files like:
|
||||
|
||||
<script lang="ts">
|
||||
export let name: string;
|
||||
</script>
|
||||
|
||||
As well as validating the code for CI.
|
||||
*/
|
||||
|
||||
/** To work on this script:
|
||||
rm -rf test-template template && git clone sveltejs/template test-template && node scripts/setupTypeScript.js test-template
|
||||
*/
|
||||
|
||||
const fs = require("fs")
|
||||
const path = require("path")
|
||||
const { argv } = require("process")
|
||||
|
||||
const projectRoot = argv[2] || path.join(__dirname, "..")
|
||||
|
||||
// Add deps to pkg.json
|
||||
const packageJSON = JSON.parse(fs.readFileSync(path.join(projectRoot, "package.json"), "utf8"))
|
||||
packageJSON.devDependencies = Object.assign(packageJSON.devDependencies, {
|
||||
"svelte-check": "^2.0.0",
|
||||
"svelte-preprocess": "^4.0.0",
|
||||
"@rollup/plugin-typescript": "^8.0.0",
|
||||
"typescript": "^4.0.0",
|
||||
"tslib": "^2.0.0",
|
||||
"@tsconfig/svelte": "^2.0.0"
|
||||
})
|
||||
|
||||
// Add script for checking
|
||||
packageJSON.scripts = Object.assign(packageJSON.scripts, {
|
||||
"check": "svelte-check --tsconfig ./tsconfig.json"
|
||||
})
|
||||
|
||||
// Write the package JSON
|
||||
fs.writeFileSync(path.join(projectRoot, "package.json"), JSON.stringify(packageJSON, null, " "))
|
||||
|
||||
// mv src/main.js to main.ts - note, we need to edit rollup.config.js for this too
|
||||
const beforeMainJSPath = path.join(projectRoot, "src", "main.js")
|
||||
const afterMainTSPath = path.join(projectRoot, "src", "main.ts")
|
||||
fs.renameSync(beforeMainJSPath, afterMainTSPath)
|
||||
|
||||
// Switch the app.svelte file to use TS
|
||||
const appSveltePath = path.join(projectRoot, "src", "App.svelte")
|
||||
let appFile = fs.readFileSync(appSveltePath, "utf8")
|
||||
appFile = appFile.replace("<script>", '<script lang="ts">')
|
||||
appFile = appFile.replace("export let name;", 'export let name: string;')
|
||||
fs.writeFileSync(appSveltePath, appFile)
|
||||
|
||||
// Edit rollup config
|
||||
const rollupConfigPath = path.join(projectRoot, "rollup.config.js")
|
||||
let rollupConfig = fs.readFileSync(rollupConfigPath, "utf8")
|
||||
|
||||
// Edit imports
|
||||
rollupConfig = rollupConfig.replace(`'rollup-plugin-terser';`, `'rollup-plugin-terser';
|
||||
import sveltePreprocess from 'svelte-preprocess';
|
||||
import typescript from '@rollup/plugin-typescript';`)
|
||||
|
||||
// Replace name of entry point
|
||||
rollupConfig = rollupConfig.replace(`'src/main.js'`, `'src/main.ts'`)
|
||||
|
||||
// Add preprocessor
|
||||
rollupConfig = rollupConfig.replace(
|
||||
'compilerOptions:',
|
||||
'preprocess: sveltePreprocess({ sourceMap: !production }),\n\t\t\tcompilerOptions:'
|
||||
);
|
||||
|
||||
// Add TypeScript
|
||||
rollupConfig = rollupConfig.replace(
|
||||
'commonjs(),',
|
||||
'commonjs(),\n\t\ttypescript({\n\t\t\tsourceMap: !production,\n\t\t\tinlineSources: !production\n\t\t}),'
|
||||
);
|
||||
fs.writeFileSync(rollupConfigPath, rollupConfig)
|
||||
|
||||
// Add TSConfig
|
||||
const tsconfig = `{
|
||||
"extends": "@tsconfig/svelte/tsconfig.json",
|
||||
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules/*", "__sapper__/*", "public/*"]
|
||||
}`
|
||||
const tsconfigPath = path.join(projectRoot, "tsconfig.json")
|
||||
fs.writeFileSync(tsconfigPath, tsconfig)
|
||||
|
||||
// Add global.d.ts
|
||||
const dtsPath = path.join(projectRoot, "src", "global.d.ts")
|
||||
fs.writeFileSync(dtsPath, `/// <reference types="svelte" />`)
|
||||
|
||||
// Delete this script, but not during testing
|
||||
if (!argv[2]) {
|
||||
// Remove the script
|
||||
fs.unlinkSync(path.join(__filename))
|
||||
|
||||
// Check for Mac's DS_store file, and if it's the only one left remove it
|
||||
const remainingFiles = fs.readdirSync(path.join(__dirname))
|
||||
if (remainingFiles.length === 1 && remainingFiles[0] === '.DS_store') {
|
||||
fs.unlinkSync(path.join(__dirname, '.DS_store'))
|
||||
}
|
||||
|
||||
// Check if the scripts folder is empty
|
||||
if (fs.readdirSync(path.join(__dirname)).length === 0) {
|
||||
// Remove the scripts folder
|
||||
fs.rmdirSync(path.join(__dirname))
|
||||
}
|
||||
}
|
||||
|
||||
// Adds the extension recommendation
|
||||
fs.mkdirSync(path.join(projectRoot, ".vscode"), { recursive: true })
|
||||
fs.writeFileSync(path.join(projectRoot, ".vscode", "extensions.json"), `{
|
||||
"recommendations": ["svelte.svelte-vscode"]
|
||||
}
|
||||
`)
|
||||
|
||||
console.log("Converted to TypeScript.")
|
||||
|
||||
if (fs.existsSync(path.join(projectRoot, "node_modules"))) {
|
||||
console.log("\nYou will need to re-run your dependency manager to get started.")
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
<script>
|
||||
export let networkActivity;
|
||||
let timeArrFirst = [];
|
||||
let timeArrSecond = [];
|
||||
|
||||
for (let i = 0; i < 12; i++) {
|
||||
const stringUtc = '000' + i;
|
||||
const hour = stringUtc.slice(-2);
|
||||
timeArrFirst.push(hour + ':00—');
|
||||
}
|
||||
|
||||
for (let i = 12; i < 24; i++) {
|
||||
const stringUtc = '000' + i;
|
||||
const hour = stringUtc.slice(-2);
|
||||
timeArrSecond.push(hour + ':00—');
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="rounded-md shadow p-3 bg-white">
|
||||
<span class="block text-center pb-3 text-sm text-neutral-400 font-mono"
|
||||
>NETWORK ACTIVITY (24H, UTC)</span
|
||||
>
|
||||
<div class="flex px-4">
|
||||
<div class="flex flex-col flex-1">
|
||||
{#each timeArrFirst as time, i}
|
||||
<div class="flex p-2">
|
||||
<span class="text-neutral-400">{time}</span>
|
||||
<span class="text-neutral-500 self-start">{networkActivity[i]} evt</span>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
<div class="flex flex-col flex-1">
|
||||
{#each timeArrSecond as time, i}
|
||||
<div class="flex p-2">
|
||||
<span class="text-neutral-400">{time}</span>
|
||||
<span class="text-neutral-500">{networkActivity[i + 12]} evt</span>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
160
src/App.svelte
160
src/App.svelte
@@ -1,160 +0,0 @@
|
||||
<script>
|
||||
import Count from "./Count.svelte";
|
||||
import Activity from "./Activity.svelte";
|
||||
import Relay from "./Relay.svelte";
|
||||
import Dots from "./Dots.svelte";
|
||||
import Tweet from "./Tweet.svelte";
|
||||
import Kind from "./Kind.svelte";
|
||||
|
||||
import _ from "underscore";
|
||||
import Pie from "svelte-chartjs/src/Pie.svelte";
|
||||
|
||||
// initial dummy event object
|
||||
let tweets = [];
|
||||
|
||||
let eventCount24h = 0;
|
||||
let eventCount1h = 0;
|
||||
let networkActivity = Array(24).fill(0); // array index is hour
|
||||
|
||||
// index of array represents "kind"
|
||||
// last index is kind "others"
|
||||
let kindArr = [0, 0, 0, 0, 0, 0];
|
||||
|
||||
let pieData = {
|
||||
labels: [
|
||||
"metadata",
|
||||
"tweet",
|
||||
"relay share",
|
||||
"contact list",
|
||||
"encrypted msg",
|
||||
"other",
|
||||
],
|
||||
datasets: [
|
||||
{
|
||||
label: "Event types",
|
||||
data: kindArr,
|
||||
backgroundColor: [
|
||||
"hsl(326, 85%, 90%)",
|
||||
"hsl(267, 85%, 90%)",
|
||||
"hsl(207, 85%, 90%)",
|
||||
"hsl(147, 85%, 90%)",
|
||||
"hsl(87, 85%, 90%)",
|
||||
"hsl(27, 85%, 90%)",
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const unixTime = Math.floor(Date.now() / 1000);
|
||||
const unixTimeMinus24h = unixTime - 60 * 60 * 24;
|
||||
const unixTimeMinus1h = unixTime - 60 * 60;
|
||||
|
||||
// taken from github.com/fiatjaf/nostr-relay-registry
|
||||
const relays = [
|
||||
"wss://nostr-pub.wellorder.net",
|
||||
"wss://relayer.fiatjaf.com",
|
||||
"wss://nostr.rocks",
|
||||
"wss://rsslay.fiatjaf.com",
|
||||
"wss://freedom-relay.herokuapp.com/ws",
|
||||
"wss://nostr-relay.freeberty.net",
|
||||
"wss://nostr.bitcoiner.social",
|
||||
"wss://nostr-relay.wlvs.space",
|
||||
"wss://nostr.onsats.org",
|
||||
"wss://nostr-relay.untethr.me",
|
||||
"wss://nostr-verified.wellorder.net",
|
||||
"wss://nostr.drss.io",
|
||||
"wss://nostr.unknown.place",
|
||||
];
|
||||
let relayActivity = Array(relays.length).fill(0);
|
||||
|
||||
relays.forEach((url, relayIndex) => {
|
||||
let socket = new WebSocket(url);
|
||||
|
||||
socket.onopen = function (event) {
|
||||
console.log(`Connected to ${url}`);
|
||||
|
||||
// pull all event 24h
|
||||
socket.send(
|
||||
JSON.stringify(["REQ", "foobar", { since: unixTimeMinus24h }])
|
||||
);
|
||||
};
|
||||
|
||||
// // take data and parse here
|
||||
socket.onmessage = function (incomingPayload) {
|
||||
// spits out lots of error when parsing
|
||||
// Uncaught SyntaxError: Unexpected token P in JSON at position 0
|
||||
const payload = JSON.parse(incomingPayload.data);
|
||||
const event = payload[2];
|
||||
const eventDate = new Date(event.created_at * 1000);
|
||||
|
||||
// count total event
|
||||
eventCount24h++;
|
||||
if (event.created_at > unixTimeMinus1h) eventCount1h++;
|
||||
|
||||
// count kinds
|
||||
if (event.kind == "0") kindArr[0]++;
|
||||
else if (event.kind == "1") kindArr[1]++;
|
||||
else if (event.kind == "2") kindArr[2]++;
|
||||
else if (event.kind == "3") kindArr[3]++;
|
||||
else if (event.kind == "4") kindArr[4]++;
|
||||
else kindArr[5]++;
|
||||
pieData = pieData; // super heavy operation...
|
||||
|
||||
// count peak event
|
||||
const eventHour = eventDate.getUTCHours();
|
||||
networkActivity[eventHour]++;
|
||||
|
||||
// count relay activity
|
||||
relayActivity[relayIndex]++;
|
||||
|
||||
// show tweets
|
||||
let tweet = {
|
||||
message: event.content,
|
||||
time: parseInt(event.created_at),
|
||||
id: event.id,
|
||||
pubkey: event.pubkey,
|
||||
};
|
||||
|
||||
tweets.push(tweet);
|
||||
const uniqueTweets = _.uniq(tweets, (tweet) => tweet.time);
|
||||
const sortedTweets = _.sortBy(uniqueTweets, "time");
|
||||
tweets = sortedTweets.reverse().slice(0, 20);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<section class="bg-gradient-to-r from-pink-100 to-orange-200">
|
||||
<div
|
||||
class="p-2 max-w-3xl mx-auto sm:flex sm:space-x-4 space-y-2 sm:space-y-0"
|
||||
>
|
||||
<div class="sm:w-1/2 space-y-2 sm:space-y-4">
|
||||
<Count {eventCount1h} {eventCount24h} />
|
||||
|
||||
<!-- pie kind component -->
|
||||
<div class="rounded-md shadow p-3 bg-white">
|
||||
<span class="block text-center pb-3 text-sm text-neutral-400 font-mono"
|
||||
>EVENT TYPES (24H)</span
|
||||
>
|
||||
<Pie data={pieData} />
|
||||
</div>
|
||||
|
||||
<Activity {networkActivity} />
|
||||
<Relay {relays} {relayActivity} />
|
||||
</div>
|
||||
|
||||
<div class="rounded-md shadow p-3 bg-white sm:w-1/2">
|
||||
<span class="block text-center pb-3 text-sm text-neutral-400 font-mono"
|
||||
>NOSTR NETWORK'S LATEST EVENTS</span
|
||||
>
|
||||
<div class="flex flex-col">
|
||||
{#each tweets as tweet}
|
||||
<Tweet
|
||||
time={tweet.time}
|
||||
pubkey={tweet.pubkey}
|
||||
message={tweet.message}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -1,20 +0,0 @@
|
||||
<script>
|
||||
export let eventCount1h;
|
||||
export let eventCount24h;
|
||||
</script>
|
||||
|
||||
<div class="rounded-md shadow p-3 bg-white">
|
||||
<span class="block text-center pb-3 text-sm text-neutral-400 font-mono"
|
||||
>NOSTR NETWORK'S EVENT COUNT</span
|
||||
>
|
||||
<div class="flex">
|
||||
<div class="flex-1 text-center">
|
||||
<span class="text-2xl">{eventCount1h}</span>
|
||||
<span class="text-neutral-400">last 1h</span>
|
||||
</div>
|
||||
<div class="flex-1 text-center">
|
||||
<span class="text-2xl">{eventCount24h}</span>
|
||||
<span class="text-neutral-400">last 24h</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,6 +0,0 @@
|
||||
<!-- separator of sections -->
|
||||
<div class="flex my-5">
|
||||
<div class="flex-1"></div>
|
||||
<div>· · ·</div>
|
||||
<div class="flex-1"></div>
|
||||
</div>
|
||||
@@ -1,37 +0,0 @@
|
||||
<script>
|
||||
import Pie from "svelte-chartjs/src/Pie.svelte";
|
||||
|
||||
export let kindArr;
|
||||
|
||||
let data = {
|
||||
labels: [
|
||||
"metadata",
|
||||
"tweet",
|
||||
"relay share",
|
||||
"contact list",
|
||||
"encrypted msg",
|
||||
"other",
|
||||
],
|
||||
datasets: [
|
||||
{
|
||||
label: "Event types",
|
||||
data: kindArr,
|
||||
backgroundColor: [
|
||||
"rgba(255, 99, 132, 0.2)",
|
||||
"rgba(54, 162, 235, 0.2)",
|
||||
"rgba(255, 206, 86, 0.2)",
|
||||
"rgba(75, 192, 192, 0.2)",
|
||||
"rgba(153, 102, 255, 0.2)",
|
||||
"rgba(255, 159, 64, 0.2)",
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="rounded-md shadow p-3 bg-white">
|
||||
<span class="block text-center pb-3 text-sm text-neutral-400 font-mono"
|
||||
>EVENT TYPES (24H)</span
|
||||
>
|
||||
<Pie {data} />
|
||||
</div>
|
||||
@@ -1,21 +0,0 @@
|
||||
<script>
|
||||
export let relays;
|
||||
export let relayActivity;
|
||||
</script>
|
||||
|
||||
<div class="rounded-md shadow p-3 bg-white">
|
||||
<span class="block text-center pb-3 text-sm text-neutral-400 font-mono"
|
||||
>EVENTS RECEIVED BY RELAY LAST 24H</span
|
||||
>
|
||||
<div class="flex flex-col">
|
||||
{#each relays as relay, i}
|
||||
<div class="flex p-2 break-words">
|
||||
<span class="flex-1 mr-3 text-neutral-500">{relay}</span>
|
||||
<span class="shrink text-neutral-400">{relayActivity[i]}</span>
|
||||
</div>
|
||||
{/each}
|
||||
<a href="https://github.com/vinliao/nashboard" class="p-2 text-center block text-orange-700 underline"
|
||||
>Add your relay?</a
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,24 +0,0 @@
|
||||
<script>
|
||||
import { format } from 'timeago.js';
|
||||
export let time;
|
||||
export let message;
|
||||
export let pubkey;
|
||||
export let replied; // a reply object, containing another tweet
|
||||
</script>
|
||||
|
||||
<div class="p-3 rounded-md">
|
||||
<div class="flex justify-between mb-2">
|
||||
<span>{pubkey.slice(0, 5) + '...' + pubkey.slice(-5)}</span>
|
||||
<span class="text-neutral-400">{format(time + '000', 'en_short')}</span>
|
||||
</div>
|
||||
{#if replied}
|
||||
<div class="my-1 pl-3 border-l-4 border-slate-800 rounded-md">
|
||||
<div class="flex justify-between">
|
||||
<span class="text-sm">{replied.pubkey}</span>
|
||||
<div />
|
||||
</div>
|
||||
<div class="text-neutral-400 text-sm break-words">{replied.message}</div>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="mb-2 break-words text-neutral-600">{message}</div>
|
||||
</div>
|
||||
4
src/app.css
Normal file
4
src/app.css
Normal file
@@ -0,0 +1,4 @@
|
||||
/* Write your global styles here, in PostCSS syntax */
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
10
src/app.d.ts
vendored
Normal file
10
src/app.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/// <reference types="@sveltejs/kit" />
|
||||
|
||||
// See https://kit.svelte.dev/docs/types#the-app-namespace
|
||||
// for information about these interfaces
|
||||
declare namespace App {
|
||||
// interface Locals {}
|
||||
// interface Platform {}
|
||||
// interface Session {}
|
||||
// interface Stuff {}
|
||||
}
|
||||
13
src/app.html
Normal file
13
src/app.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="description" content="" />
|
||||
<link rel="icon" href="%svelte.assets%/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
%svelte.head%
|
||||
</head>
|
||||
<body>
|
||||
<div>%svelte.body%</div>
|
||||
</body>
|
||||
</html>
|
||||
10
src/main.js
10
src/main.js
@@ -1,10 +0,0 @@
|
||||
import App from './App.svelte';
|
||||
|
||||
const app = new App({
|
||||
target: document.body,
|
||||
props: {
|
||||
name: 'world'
|
||||
}
|
||||
});
|
||||
|
||||
export default app;
|
||||
5
src/routes/__layout.svelte
Normal file
5
src/routes/__layout.svelte
Normal file
@@ -0,0 +1,5 @@
|
||||
<script>
|
||||
import '../app.css';
|
||||
</script>
|
||||
|
||||
<slot />
|
||||
4
src/routes/index.svelte
Normal file
4
src/routes/index.svelte
Normal file
@@ -0,0 +1,4 @@
|
||||
<h1>Welcome to SvelteKit</h1>
|
||||
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
|
||||
|
||||
<p class="underline">hello from branch</p>
|
||||
BIN
static/favicon.png
Normal file
BIN
static/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
17
svelte.config.js
Normal file
17
svelte.config.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import preprocess from 'svelte-preprocess';
|
||||
import adapter from '@sveltejs/adapter-auto';
|
||||
|
||||
/** @type {import('@sveltejs/kit').Config} */
|
||||
const config = {
|
||||
kit: {
|
||||
adapter: adapter()
|
||||
},
|
||||
|
||||
preprocess: [
|
||||
preprocess({
|
||||
postcss: true
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
export default config;
|
||||
11
tailwind.config.cjs
Normal file
11
tailwind.config.cjs
Normal file
@@ -0,0 +1,11 @@
|
||||
const config = {
|
||||
content: ['./src/**/*.{html,js,svelte,ts}'],
|
||||
|
||||
theme: {
|
||||
extend: {}
|
||||
},
|
||||
|
||||
plugins: []
|
||||
};
|
||||
|
||||
module.exports = config;
|
||||
@@ -1,7 +0,0 @@
|
||||
module.exports = {
|
||||
content: ['./src/**/*.svelte'],
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [],
|
||||
}
|
||||
Reference in New Issue
Block a user