mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-08 06:01:57 -07:00
global: snapshot
This commit is contained in:
+4
-1
@@ -15,14 +15,17 @@
|
||||
|
||||
## Website
|
||||
|
||||
- Added dashboards
|
||||
- Added a Home option
|
||||
- Added a library of PDFs viewable inside the app
|
||||
- Fixed service worker not passing 304 (not modified) response and instead serving cached responses
|
||||
- Fixed history not being properly registered
|
||||
- Fixed prices on charts not having a wide enough background due to the font not being fully loaded during the creation of the chart
|
||||
- Fixed window being moveable on iOS when in standalone mode when it shouldn't be
|
||||
|
||||
## Parser
|
||||
|
||||
- Added a `/datasets/last` json file with all the latest values
|
||||
- Added `--rpcconnect` parameter to the config
|
||||
|
||||
## Server
|
||||
|
||||
|
||||
@@ -119,6 +119,10 @@ For the first launch, the parser will need several information such as:
|
||||
- `--rpcuser`: the username of the RPC credentials to talk to the bitcoin server
|
||||
- `--rpcpassword`: the password of the RPC credentials
|
||||
|
||||
Optionally you can also specify:
|
||||
- `--rpcconnect`: if the bitcoin core server's IP is different than `localhost`
|
||||
- `--rpcport`: if the port is different than `8332`
|
||||
|
||||
Everything will be saved in a `config.toml` file, which will allow you to simply run `./run.sh` next time
|
||||
|
||||
Here's an example
|
||||
|
||||
+3
-2
@@ -1,10 +1,11 @@
|
||||
FROM rust:1.81
|
||||
|
||||
ENV rpcconnect=localhost
|
||||
ENV rpcport=8332
|
||||
ENV rpcuser=satoshi
|
||||
ENV rpcpassword=nakamoto
|
||||
ENV rpcport=8332
|
||||
|
||||
WORKDIR /container
|
||||
COPY . .
|
||||
|
||||
CMD ["sh", "-c", "bash cmd.sh ${rpcuser} ${rpcpassword} ${rpcport}"]
|
||||
CMD ["sh", "-c", "bash cmd.sh ${rpcconnect} ${rpcport} ${rpcuser} ${rpcpassword}"]
|
||||
|
||||
+5
-3
@@ -1,11 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cd kibo/parser
|
||||
|
||||
./run.sh \
|
||||
--datadir=/bitcoin \
|
||||
--rpcuser=$1 \
|
||||
--rpcpassword=$2 \
|
||||
--rpcport=$3
|
||||
--rpcconnect=$1 \
|
||||
--rpcport=$2 \
|
||||
--rpcuser=$3 \
|
||||
--rpcpassword=$4
|
||||
|
||||
# cd ../server
|
||||
# ./run.sh &
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
docker run \
|
||||
--env rpcuser=satoshi \
|
||||
--env rpcpassword=nakamoto \
|
||||
--env rpcport=localhost \
|
||||
--env rpcport=8332 \
|
||||
--volume /tmp/kibo/datasets:/container/kibo/datasets \
|
||||
--volume /tmp/kibo/price:/container/kibo/price \
|
||||
|
||||
@@ -10,6 +10,10 @@ pub struct Config {
|
||||
#[arg(long, value_name = "DIR")]
|
||||
pub datadir: Option<String>,
|
||||
|
||||
/// Bitcoin RPC ip, default: localhost, saved
|
||||
#[arg(long, value_name = "IP")]
|
||||
pub rpcconnect: Option<String>,
|
||||
|
||||
/// Bitcoin RPC port, default: 8332, saved
|
||||
#[arg(long, value_name = "PORT")]
|
||||
pub rpcport: Option<u16>,
|
||||
@@ -42,6 +46,12 @@ impl Config {
|
||||
config_saved.datadir = Some(datadir);
|
||||
}
|
||||
|
||||
if let Some(rpcconnect) = config_args.rpcconnect {
|
||||
config_saved.rpcconnect = Some(rpcconnect);
|
||||
} else {
|
||||
config_saved.rpcconnect = Some("localhost".to_string())
|
||||
}
|
||||
|
||||
if let Some(rpcport) = config_args.rpcport {
|
||||
config_saved.rpcport = Some(rpcport);
|
||||
} else {
|
||||
|
||||
@@ -4,7 +4,11 @@ use crate::Config;
|
||||
|
||||
pub fn create_rpc(config: &Config) -> color_eyre::Result<Client> {
|
||||
Ok(Client::new(
|
||||
&format!("http://localhost:{}", config.rpcport.unwrap()),
|
||||
&format!(
|
||||
"http://{}:{}",
|
||||
config.rpcconnect.as_ref().unwrap(),
|
||||
config.rpcport.unwrap()
|
||||
),
|
||||
Auth::UserPass(
|
||||
config.rpcuser.clone().unwrap(),
|
||||
config.rpcpassword.clone().unwrap(),
|
||||
|
||||
@@ -41,6 +41,7 @@ pub trait HeaderMapUtils {
|
||||
fn insert_content_type_application_javascript(&mut self);
|
||||
fn insert_content_type_application_json(&mut self);
|
||||
fn insert_content_type_application_manifest_json(&mut self);
|
||||
fn insert_content_type_application_pdf(&mut self);
|
||||
fn insert_content_type_text_css(&mut self);
|
||||
fn insert_content_type_text_html(&mut self);
|
||||
fn insert_content_type_text_plain(&mut self);
|
||||
@@ -148,6 +149,7 @@ impl HeaderMapUtils for HeaderMap {
|
||||
"html" => self.insert_content_type_text_html(),
|
||||
"css" => self.insert_content_type_text_css(),
|
||||
"txt" => self.insert_content_type_text_plain(),
|
||||
"pdf" => self.insert_content_type_application_pdf(),
|
||||
"woff2" => self.insert_content_type_font_woff2(),
|
||||
"ico" => self.insert_content_type_image_icon(),
|
||||
"jpg" | "jpeg" => self.insert_content_type_image_jpeg(),
|
||||
@@ -190,6 +192,10 @@ impl HeaderMapUtils for HeaderMap {
|
||||
);
|
||||
}
|
||||
|
||||
fn insert_content_type_application_pdf(&mut self) {
|
||||
self.insert(header::CONTENT_TYPE, "application/pdf".parse().unwrap());
|
||||
}
|
||||
|
||||
fn insert_content_type_text_css(&mut self) {
|
||||
self.insert(header::CONTENT_TYPE, "text/css".parse().unwrap());
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ use crate::header_map::HeaderMapUtils;
|
||||
|
||||
use super::minify_js;
|
||||
|
||||
const WEBSITE_PATH: &str = "../website";
|
||||
const WEBSITE_PATH: &str = "../website/";
|
||||
|
||||
pub async fn file_handler(headers: HeaderMap, path: extract::Path<String>) -> Response {
|
||||
let path = path.0.replace("..", "").replace("\\", "");
|
||||
@@ -46,6 +46,8 @@ pub async fn index_handler(headers: HeaderMap) -> Response {
|
||||
}
|
||||
|
||||
fn path_to_response(headers: HeaderMap, path: &Path) -> Response {
|
||||
log(&path.to_str().unwrap().replace(WEBSITE_PATH, ""));
|
||||
|
||||
let (date, response) = headers.check_if_modified_since(path).unwrap();
|
||||
|
||||
if let Some(response) = response {
|
||||
@@ -79,8 +81,14 @@ fn path_to_response(headers: HeaderMap, path: &Path) -> Response {
|
||||
let serialized_path = path.to_str().unwrap();
|
||||
|
||||
if serialized_path.contains("fonts/")
|
||||
|| serialized_path.contains("assets/pwa/")
|
||||
|| serialized_path.contains("assets/")
|
||||
|| serialized_path.contains("packages/")
|
||||
|| path.extension().is_some_and(|extension| {
|
||||
extension == "pdf"
|
||||
|| extension == "jpg"
|
||||
|| extension == "png"
|
||||
|| extension == "woff2"
|
||||
})
|
||||
{
|
||||
headers.insert_cache_control_immutable();
|
||||
} else {
|
||||
@@ -94,5 +102,5 @@ fn path_to_response(headers: HeaderMap, path: &Path) -> Response {
|
||||
}
|
||||
|
||||
fn str_to_path(path: &str) -> PathBuf {
|
||||
PathBuf::from(&format!("{WEBSITE_PATH}/{path}"))
|
||||
PathBuf::from(&format!("{WEBSITE_PATH}{path}"))
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+124
-12
@@ -291,7 +291,8 @@
|
||||
*/
|
||||
@font-face {
|
||||
font-family: "Satoshi";
|
||||
src: url("./fonts/satoshi/2024-09/font.var.woff2") format("woff2");
|
||||
src: url("./assets/fonts/satoshi/2024-09/font.var.woff2")
|
||||
format("woff2");
|
||||
font-weight: 100 900;
|
||||
font-display: block;
|
||||
font-style: normal;
|
||||
@@ -299,7 +300,8 @@
|
||||
|
||||
@font-face {
|
||||
font-family: "Satoshi Chart";
|
||||
src: url("./fonts/satoshi/2024-09/font.var.woff2") format("woff2");
|
||||
src: url("./assets/fonts/satoshi/2024-09/font.var.woff2")
|
||||
format("woff2");
|
||||
font-weight: 500 900;
|
||||
font-display: block;
|
||||
font-style: normal;
|
||||
@@ -478,6 +480,7 @@
|
||||
}
|
||||
|
||||
header {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
padding-top: 0.25rem /* 4px */;
|
||||
white-space: nowrap;
|
||||
@@ -755,6 +758,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
object {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
@@ -976,7 +983,6 @@
|
||||
#selected-frame {
|
||||
flex-direction: column;
|
||||
display: flex;
|
||||
opacity: 0;
|
||||
|
||||
> header {
|
||||
button {
|
||||
@@ -1002,6 +1008,71 @@
|
||||
}
|
||||
}
|
||||
|
||||
> #home {
|
||||
flex: 1;
|
||||
margin-top: 0 !important;
|
||||
font-size: var(--font-size-base);
|
||||
line-height: var(--line-height-base);
|
||||
text-wrap: pretty;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
> div {
|
||||
max-width: 32rem;
|
||||
}
|
||||
}
|
||||
|
||||
> #dashboards {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
z-index: 50;
|
||||
margin: -0.5px calc(-1.5rem - 1px);
|
||||
|
||||
> table {
|
||||
flex: 1;
|
||||
table-layout: auto;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0px 1px;
|
||||
border: 1px;
|
||||
border-top: 0;
|
||||
padding: 0.25rem 0;
|
||||
margin: -0.5px;
|
||||
font-size: var(--font-size-xs);
|
||||
line-height: var(--line-height-xs);
|
||||
|
||||
caption {
|
||||
border-bottom-style: dashed !important;
|
||||
border-width: 1px;
|
||||
padding: 0.375rem 0.625rem;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
tr {
|
||||
border: 1px;
|
||||
|
||||
&:hover,
|
||||
&:hover * {
|
||||
color: var(--orange) !important;
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 0.125rem 0.625rem;
|
||||
text-align: right;
|
||||
|
||||
&:first-child {
|
||||
text-align: left;
|
||||
color: var(--off-color);
|
||||
}
|
||||
|
||||
> i {
|
||||
color: var(--off-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
> #charts {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -1163,6 +1234,12 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
> object {
|
||||
margin: -1.5rem;
|
||||
flex: 1;
|
||||
z-index: 100;
|
||||
}
|
||||
}
|
||||
|
||||
#share-div {
|
||||
@@ -1722,9 +1799,9 @@
|
||||
// Prevent width jumping
|
||||
const savedWidth = localStorage.getItem("bar-width");
|
||||
if (savedWidth) {
|
||||
const mainFrames = window.document.getElementById("frames");
|
||||
if (!mainFrames) throw "Should exist";
|
||||
mainFrames.style.width = `${savedWidth}px`;
|
||||
const main = window.document.getElementById("main");
|
||||
if (!main) throw "Should exist";
|
||||
main.style.width = `${savedWidth}px`;
|
||||
}
|
||||
</script>
|
||||
<div class="shadow-top"></div>
|
||||
@@ -1827,7 +1904,7 @@
|
||||
<hr />
|
||||
<p id="search-no-input-text">
|
||||
If you can't think of anything, you might want to try to
|
||||
<button>open a random chart</button>
|
||||
<button id="search-no-input-text-button">open a random page</button>
|
||||
</p>
|
||||
<ul id="search-results" class="list" style="overflow-y: auto"></ul>
|
||||
<footer class="absolute">
|
||||
@@ -2027,7 +2104,7 @@
|
||||
<div class="shadow-right"></div>
|
||||
|
||||
<section id="selected-frame" hidden>
|
||||
<header>
|
||||
<header id="selected-header" hidden>
|
||||
<div>
|
||||
<div style="display: flex; align-items: center">
|
||||
<button id="button-share">
|
||||
@@ -2039,7 +2116,7 @@
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<h3 id="preset-title"></h3>
|
||||
<h1 id="selected-title"></h1>
|
||||
<button id="button-favorite">
|
||||
<svg viewBox="0 0 20 20">
|
||||
<path
|
||||
@@ -2050,11 +2127,45 @@
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<small id="preset-description"></small>
|
||||
<small id="selected-description"></small>
|
||||
</div>
|
||||
</header>
|
||||
<hr />
|
||||
<div id="charts">
|
||||
<hr id="selected-hr" hidden />
|
||||
<div id="home" hidden>
|
||||
<div>
|
||||
<svg
|
||||
style="height: 2.5rem; width: auto; margin: auto"
|
||||
viewBox="0 0 720 180"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<defs></defs>
|
||||
<g transform="matrix(7.5, 0, 0, 7.5, -2046.71228, -1592.744873)">
|
||||
<ellipse
|
||||
style="fill: var(--orange)"
|
||||
cx="284.895"
|
||||
cy="224.366"
|
||||
rx="12"
|
||||
ry="12"
|
||||
></ellipse>
|
||||
<path
|
||||
d="M 285.769 221.936 L 285.769 221.168 C 284.999 220.175 284.482 219 284.292 217.745 C 284.234 217.375 283.772 217.231 283.532 217.518 C 282.954 218.199 282.5 218.998 282.194 219.883 C 283.129 220.931 284.381 221.65 285.769 221.936 Z M 288.832 219.115 C 287.624 219.115 286.646 220.097 286.646 221.305 L 286.646 222.929 C 283.79 222.76 281.369 221.002 280.274 218.508 C 280.124 218.166 279.641 218.146 279.48 218.483 C 279.026 219.443 278.771 220.515 278.771 221.646 C 278.771 223.583 279.703 225.391 281.098 226.73 C 281.457 227.077 281.81 227.364 282.161 227.627 L 278.226 228.611 C 277.933 228.684 277.802 229.024 277.967 229.278 C 278.442 230.014 279.618 231.261 282.156 231.365 C 282.375 231.373 282.593 231.294 282.759 231.149 L 284.543 229.615 L 286.646 229.615 C 289.062 229.615 291.02 227.659 291.02 225.242 L 291.02 220.865 L 291.895 219.115 L 288.832 219.115 Z M 288.832 221.757 C 288.592 221.757 288.353 221.541 288.353 221.301 C 288.353 221.061 288.592 220.849 288.832 220.849 C 289.072 220.849 289.294 221.069 289.294 221.309 C 289.294 221.549 289.072 221.757 288.832 221.757 Z"
|
||||
style="fill: var(--white)"
|
||||
></path>
|
||||
</g>
|
||||
<g transform="matrix(1, 0, 0, 1, -30, 0)">
|
||||
<path
|
||||
d="M 278.049 146.789 L 278.049 127.527 L 287.141 117.972 L 304.4 146.789 L 331.83 146.789 L 303.784 100.251 L 332.755 69.739 L 303.013 69.739 L 278.049 97.477 L 278.049 30.598 L 254.318 30.598 L 254.318 146.789 L 278.049 146.789 Z M 354.169 57.719 C 361.565 57.719 367.575 51.709 367.575 44.158 C 367.575 36.608 361.565 30.752 354.169 30.752 C 346.618 30.752 340.608 36.608 340.608 44.158 C 340.608 51.709 346.618 57.719 354.169 57.719 Z M 342.457 146.789 L 366.188 146.789 L 366.188 69.739 L 342.457 69.739 L 342.457 146.789 Z M 406.407 146.789 L 407.64 136.927 C 411.801 144.015 421.047 148.792 431.834 148.792 C 453.716 148.792 468.972 132.92 468.972 109.035 C 468.972 83.916 455.257 67.119 433.683 67.119 C 422.588 67.119 412.417 71.742 407.794 78.677 L 407.794 30.598 L 384.063 30.598 L 384.063 146.789 L 406.407 146.789 Z M 407.948 107.802 C 407.948 96.244 415.653 88.539 426.749 88.539 C 437.998 88.539 445.087 96.398 445.087 107.802 C 445.087 119.205 437.998 127.064 426.749 127.064 C 415.653 127.064 407.948 119.359 407.948 107.802 Z M 498.713 56.332 L 543.402 56.332 L 543.402 40.306 L 498.713 40.306 L 498.713 56.332 Z M 478.526 108.11 C 478.526 132.458 496.402 148.638 521.058 148.638 C 545.56 148.638 563.435 132.458 563.435 108.11 C 563.435 83.762 545.56 67.428 521.058 67.428 C 496.402 67.428 478.526 83.762 478.526 108.11 Z M 502.412 107.956 C 502.412 96.398 509.963 88.693 521.058 88.693 C 531.999 88.693 539.55 96.398 539.55 107.956 C 539.55 119.667 531.999 127.372 521.058 127.372 C 509.963 127.372 502.412 119.667 502.412 107.956 Z"
|
||||
style="fill: var(--color)"
|
||||
></path>
|
||||
<path
|
||||
d="M 589.19 97.802 L 589.19 106.23 L 610.948 106.23 C 605.1 112.938 597.446 119.044 587.986 124.376 L 593.404 131.514 C 597.532 128.934 601.488 126.268 605.186 123.43 L 605.186 146.048 L 614.13 146.048 L 614.13 123.43 L 626.944 123.43 L 626.944 149.402 L 635.974 149.402 L 635.974 123.43 L 649.82 123.43 L 649.82 134.008 C 649.82 136.072 649.046 137.104 647.498 137.104 L 640.36 136.674 L 642.768 145.188 L 650.422 145.188 C 655.926 145.188 658.678 142.092 658.678 135.986 L 658.678 115.174 L 635.974 115.174 L 635.974 108.638 L 626.944 108.638 L 626.944 115.174 L 614.388 115.174 C 617.054 112.336 619.548 109.326 621.784 106.23 L 665.128 106.23 L 665.128 97.802 L 626.858 97.802 C 627.89 95.824 628.836 93.76 629.696 91.61 L 620.838 90.492 C 619.806 92.9 618.516 95.394 617.14 97.802 L 589.19 97.802 Z M 648.1 68.734 C 642.338 72.088 636.232 75.098 629.868 77.678 C 621.612 75.012 612.926 72.518 603.896 70.282 L 599.252 77.248 C 605.272 78.624 611.206 80.258 617.226 82.15 C 610.088 84.386 602.606 86.106 594.78 87.482 L 599.596 95.308 C 612.324 92.04 622.472 89.116 630.04 86.364 C 638.124 89.116 646.122 92.298 654.034 95.824 L 658.936 88.428 C 653.26 86.02 647.412 83.698 641.392 81.548 C 646.208 79.226 651.11 76.56 655.926 73.55 L 648.1 68.734 Z M 675.438 77.85 L 675.438 85.848 L 682.404 85.848 L 682.404 98.92 C 682.404 101.5 681.114 103.22 678.62 104.166 L 680.684 110.874 C 692.036 108.896 701.926 106.66 710.182 104.08 L 708.634 96.426 C 703.474 98.146 697.454 99.608 690.574 100.984 L 690.574 85.848 L 712.332 85.848 L 712.332 77.85 L 698.916 77.85 C 698.4 74.668 697.884 71.744 697.368 69.164 L 688.338 70.712 C 688.94 72.862 689.542 75.27 690.144 77.85 L 675.438 77.85 Z M 724.028 89.632 L 739.25 89.632 L 739.25 93.502 L 723.856 93.502 C 723.942 92.47 724.028 91.352 724.028 90.32 L 724.028 89.632 Z M 739.25 83.096 L 724.028 83.096 L 724.028 79.226 L 739.25 79.226 L 739.25 83.096 Z M 722.652 100.038 L 739.25 100.038 L 739.25 100.898 C 739.25 103.048 738.218 104.166 736.24 104.166 C 733.918 104.166 731.424 103.994 728.758 103.822 L 730.822 111.562 L 738.734 111.562 C 744.582 111.562 747.506 108.982 747.506 103.908 L 747.506 72.002 L 715.6 72.002 L 715.6 90.922 C 715.428 97.286 713.192 102.532 708.892 106.746 L 715.342 112.594 C 718.782 109.068 721.276 104.854 722.652 100.038 Z M 708.462 121.452 L 708.462 126.784 L 683.608 126.784 L 683.608 134.352 L 708.462 134.352 L 708.462 139.598 L 675.524 139.598 L 675.524 147.51 L 750 147.51 L 750 139.598 L 717.062 139.598 L 717.062 134.352 L 742.174 134.352 L 742.174 126.784 L 717.062 126.784 L 717.062 121.452 L 746.216 121.452 L 746.216 113.712 L 679.308 113.712 L 679.308 121.452 L 708.462 121.452 Z"
|
||||
style="fill: var(--off-color)"
|
||||
></path>
|
||||
</g>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
<div id="charts" hidden>
|
||||
<fieldset id="legend"></fieldset>
|
||||
<div id="chart-list">
|
||||
<div class="shadow-top"></div>
|
||||
@@ -2143,6 +2254,7 @@
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="dashboards" hidden></div>
|
||||
</section>
|
||||
</aside>
|
||||
<div id="share-div" hidden>
|
||||
|
||||
+2415
-1990
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,7 @@ self.addEventListener("install", (_event) => {
|
||||
"/packages/ufuzzy/v1.0.14/script.js",
|
||||
"/packages/lean-qr/v2.3.4/script.js",
|
||||
"/packages/lightweight-charts/v4.2.0/script.js",
|
||||
"/fonts/satoshi/2024-09/font.var.woff2",
|
||||
"/assets/fonts/satoshi/2024-09/font.var.woff2",
|
||||
]);
|
||||
})
|
||||
);
|
||||
|
||||
Vendored
+3
-3
File diff suppressed because one or more lines are too long
Vendored
+102
-38
@@ -16,20 +16,27 @@ import {
|
||||
IChartApi,
|
||||
ISeriesApi,
|
||||
} from "../packages/lightweight-charts/v4.2.0/types";
|
||||
import { DatePath, HeightPath } from "./paths";
|
||||
import { DatePath, HeightPath, LastPath } from "./paths";
|
||||
import { Owner } from "../packages/solid-signals/2024-04-17/types/owner";
|
||||
|
||||
type Scale = "date" | "height";
|
||||
type GrowToSize<T, N extends number, A extends T[]> = A["length"] extends N
|
||||
? A
|
||||
: GrowToSize<T, N, [...A, T]>;
|
||||
|
||||
type SettingsTheme = "system" | "dark" | "light";
|
||||
|
||||
type FoldersFilter = "all" | "favorites" | "new";
|
||||
type FixedArray<T, N extends number> = GrowToSize<T, N, []>;
|
||||
|
||||
type Signal<T> = Accessor<T> & { set: Setter<T> };
|
||||
|
||||
type SettingsTheme = "system" | "dark" | "light";
|
||||
type FoldersFilter = "all" | "favorites" | "new";
|
||||
|
||||
type TimeScale = "date" | "height";
|
||||
|
||||
type TimeRange = Range<Time | number>;
|
||||
|
||||
type DatasetPath<S extends Scale> = S extends "date" ? DatePath : HeightPath;
|
||||
type DatasetPath<Scale extends TimeScale> = Scale extends "date"
|
||||
? DatePath
|
||||
: HeightPath;
|
||||
|
||||
type AnyDatasetPath = import("./paths").DatePath | import("./paths").HeightPath;
|
||||
|
||||
@@ -86,48 +93,97 @@ type Unit =
|
||||
| "Dollars / (PetaHash / Second)"
|
||||
| "";
|
||||
|
||||
interface PresetBlueprint {
|
||||
interface PartialOption {
|
||||
icon: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
interface PartialHomeOption extends PartialOption {
|
||||
kind: "home";
|
||||
title: "Home";
|
||||
name: "Home";
|
||||
}
|
||||
|
||||
interface PartialDashboardOption extends PartialOption {
|
||||
title: string;
|
||||
description: string;
|
||||
groups: {
|
||||
name: string;
|
||||
unit?: Unit;
|
||||
values: {
|
||||
name: string;
|
||||
path?: LastPath;
|
||||
unit?: Unit;
|
||||
}[];
|
||||
}[];
|
||||
}
|
||||
|
||||
interface PartialChartOption extends PartialOption {
|
||||
scale: TimeScale;
|
||||
title: string;
|
||||
unit: Unit;
|
||||
description: string;
|
||||
top?: SeriesBlueprint[];
|
||||
bottom?: SeriesBlueprint[];
|
||||
}
|
||||
|
||||
interface PartialPreset extends PresetBlueprint {
|
||||
scale: Scale;
|
||||
icon: string;
|
||||
name: string;
|
||||
unit: Unit;
|
||||
title: string;
|
||||
description: string;
|
||||
interface PartialPdfOption extends PartialOption {
|
||||
file: string;
|
||||
}
|
||||
|
||||
interface PartialPresetFolder {
|
||||
interface PartialOptionsGroup {
|
||||
name: string;
|
||||
tree: PartialPresetTree;
|
||||
tree: PartialOptionsTree;
|
||||
}
|
||||
|
||||
type PartialPresetTree = (PartialPreset | PartialPresetFolder)[];
|
||||
type AnyPartialOption =
|
||||
| PartialHomeOption
|
||||
| PartialPdfOption
|
||||
| PartialDashboardOption
|
||||
| PartialChartOption;
|
||||
|
||||
interface Preset extends PartialPreset {
|
||||
type PartialOptionsTree = (AnyPartialOption | PartialOptionsGroup)[];
|
||||
|
||||
interface ProcessedOptionAddons {
|
||||
id: string;
|
||||
path: FilePath;
|
||||
path: OptionPath;
|
||||
serializedPath: string;
|
||||
isFavorite: Signal<boolean>;
|
||||
visited: Signal<boolean>;
|
||||
}
|
||||
|
||||
type PresetTree = (Preset | PresetFolder)[];
|
||||
|
||||
interface PresetFolder extends PartialPresetFolder {
|
||||
id: string;
|
||||
tree: PresetTree;
|
||||
}
|
||||
|
||||
type FilePath = {
|
||||
type OptionPath = {
|
||||
id: string;
|
||||
name: string;
|
||||
}[];
|
||||
|
||||
type SerializedPresetsHistory = [string, number][];
|
||||
type HomeOption = PartialHomeOption & ProcessedOptionAddons;
|
||||
|
||||
interface PdfOption extends PartialPdfOption, ProcessedOptionAddons {
|
||||
kind: "pdf";
|
||||
title: string;
|
||||
}
|
||||
|
||||
interface DashboardOption
|
||||
extends PartialDashboardOption,
|
||||
ProcessedOptionAddons {
|
||||
kind: "dashboard";
|
||||
}
|
||||
|
||||
interface ChartOption extends PartialChartOption, ProcessedOptionAddons {
|
||||
kind: "chart";
|
||||
}
|
||||
|
||||
type Option = HomeOption | PdfOption | DashboardOption | ChartOption;
|
||||
|
||||
type OptionsTree = (Option | OptionsGroup)[];
|
||||
|
||||
interface OptionsGroup extends PartialOptionsGroup {
|
||||
id: string;
|
||||
tree: OptionsTree;
|
||||
}
|
||||
|
||||
type SerializedHistory = [string, number][];
|
||||
|
||||
interface OHLC {
|
||||
open: number;
|
||||
@@ -137,20 +193,20 @@ interface OHLC {
|
||||
}
|
||||
|
||||
interface ResourceDataset<
|
||||
S extends Scale,
|
||||
Scale extends TimeScale,
|
||||
Type extends OHLC | number = number
|
||||
> {
|
||||
scale: S;
|
||||
scale: Scale;
|
||||
url: string;
|
||||
fetch: (id: number) => void;
|
||||
fetchedJSONs: FetchedResult<S, Type>[];
|
||||
fetchedJSONs: FetchedResult<Scale, Type>[];
|
||||
// drop: VoidFunction;
|
||||
}
|
||||
|
||||
type ValuedCandlestickData = CandlestickData & Valued;
|
||||
|
||||
interface FetchedResult<
|
||||
S extends Scale,
|
||||
Scale extends TimeScale,
|
||||
Type extends number | OHLC,
|
||||
Value extends DatasetValue<
|
||||
SingleValueData | ValuedCandlestickData
|
||||
@@ -159,7 +215,7 @@ interface FetchedResult<
|
||||
>
|
||||
> {
|
||||
at: Date | null;
|
||||
json: Signal<FetchedJSON<S, Type> | null>;
|
||||
json: Signal<FetchedJSON<Scale, Type> | null>;
|
||||
vec: Accessor<Value[] | null>;
|
||||
loading: boolean;
|
||||
}
|
||||
@@ -170,10 +226,10 @@ interface Valued {
|
||||
|
||||
type DatasetValue<T> = T & Valued;
|
||||
|
||||
interface FetchedJSON<S extends Scale, Type extends number | OHLC> {
|
||||
interface FetchedJSON<Scale extends TimeScale, Type extends number | OHLC> {
|
||||
source: FetchedSource;
|
||||
chunk: FetchedChunk;
|
||||
dataset: FetchedDataset<S, Type>;
|
||||
dataset: FetchedDataset<Scale, Type>;
|
||||
}
|
||||
|
||||
type FetchedSource = string;
|
||||
@@ -185,9 +241,11 @@ interface FetchedChunk {
|
||||
}
|
||||
|
||||
type FetchedDataset<
|
||||
S extends Scale,
|
||||
Scale extends TimeScale,
|
||||
Type extends number | OHLC
|
||||
> = S extends "date" ? FetchedDateDataset<Type> : FetchedHeightDataset<Type>;
|
||||
> = Scale extends "date"
|
||||
? FetchedDateDataset<Type>
|
||||
: FetchedHeightDataset<Type>;
|
||||
|
||||
interface Versioned {
|
||||
version: number;
|
||||
@@ -211,7 +269,7 @@ interface Series {
|
||||
disabled: Accessor<boolean>;
|
||||
active: Signal<boolean>;
|
||||
visible: Accessor<boolean>;
|
||||
dataset: ResourceDataset<Scale, number>;
|
||||
dataset: ResourceDataset<TimeScale, number>;
|
||||
}
|
||||
|
||||
interface Marker {
|
||||
@@ -226,3 +284,9 @@ interface Weighted {
|
||||
}
|
||||
|
||||
type DatasetCandlestickData = DatasetValue<CandlestickData> & { year: number };
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
MyNamespace: any;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user