bitview: fix top unit + add back lib types

This commit is contained in:
nym21
2025-09-16 15:33:05 +02:00
parent d34f4bdd12
commit 6d194dbb71
36 changed files with 7090 additions and 2157 deletions

View File

@@ -174,12 +174,12 @@ export function init({
const { field: topUnitField, selected: topUnit } =
utils.dom.createHorizontalChoiceField({
defaultValue: "USD",
defaultValue: "usd",
keyPrefix,
key: "unit-0",
choices: /** @type {const} */ ([
/** @satisfies {Unit} */ ("USD"),
/** @satisfies {Unit} */ ("Sats"),
/** @satisfies {Unit} */ ("usd"),
/** @satisfies {Unit} */ ("sats"),
]),
signals,
sorted: true,
@@ -210,7 +210,7 @@ export function init({
const latest = { ..._latest };
if (unit === "Sats") {
if (unit === "sats") {
latest.open = Math.floor(ONE_BTC_IN_SATS / latest.open);
latest.high = Math.floor(ONE_BTC_IN_SATS / latest.high);
latest.low = Math.floor(ONE_BTC_IN_SATS / latest.low);
@@ -332,7 +332,7 @@ export function init({
console.log({ topUnit, topSeriesType });
switch (topUnit) {
case "USD": {
case "usd": {
switch (topSeriesType) {
case null:
case CANDLE: {
@@ -362,7 +362,7 @@ export function init({
}
break;
}
case "Sats": {
case "sats": {
switch (topSeriesType) {
case null:
case CANDLE: {

View File

@@ -691,7 +691,7 @@ export function init({
elements,
config: [
{
unit: "USD",
unit: "usd",
blueprints: [
{
title: "Bitcoin Value",
@@ -736,7 +736,7 @@ export function init({
utils,
config: [
{
unit: "BTC",
unit: "btc",
blueprints: [
{
title: "Bitcoin Stack",
@@ -761,7 +761,7 @@ export function init({
elements,
config: [
{
unit: "USD",
unit: "usd",
blueprints: [
{
title: "Bitcoin Price",
@@ -792,7 +792,7 @@ export function init({
elements,
config: [
{
unit: "USD",
unit: "usd",
blueprints: [
{
title: "Return Of Investment",

View File

@@ -141,7 +141,7 @@ function createTable({
list: serializedIndexes,
signal: serializedIndex,
}),
unit: "Index",
unit: "index",
});
let from = 0;
@@ -163,7 +163,7 @@ function createTable({
const th = window.document.createElement("th");
th.innerHTML = serializeValue({
value,
unit: "Index",
unit: "index",
});
th.scope = "row";
tr.append(th);
@@ -527,12 +527,12 @@ function serializeValue({ value, unit }) {
} else if (t !== "number") {
return JSON.stringify(value).replaceAll('"', "").slice(1, -1);
} else if (value !== 18446744073709552000) {
if (unit === "USD" || unit === "Difficulty" || unit === "sat/vB") {
if (unit === "usd" || unit === "difficulty" || unit === "sat/vb") {
return value.toLocaleString("en-us", {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
});
} else if (unit === "BTC") {
} else if (unit === "btc") {
return value.toLocaleString("en-us", {
minimumFractionDigits: 8,
maximumFractionDigits: 8,