websites: default: snapshot

This commit is contained in:
nym21
2025-06-10 18:54:18 +02:00
parent dfd2969b3e
commit c7cf76d4a8
8 changed files with 83 additions and 59 deletions
+6 -7
View File
@@ -1,8 +1,7 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<!-- <title>kibo.money</title> -->
<meta
name="description"
content="An open source Bitcoin Core data extractor and visualizer"
@@ -1114,7 +1113,7 @@
// @ts-check
const preferredColorSchemeMatchMedia = window.matchMedia(
"(prefers-color-scheme: dark)"
"(prefers-color-scheme: dark)",
);
const themeColor = window.document.createElement("meta");
@@ -1123,10 +1122,10 @@
/** @param {boolean} dark */
function updateThemeColor(dark) {
const backgroundColor = getComputedStyle(
window.document.documentElement
const theme = getComputedStyle(
window.document.documentElement,
).getPropertyValue(dark ? "--black" : "--white");
themeColor.content = backgroundColor;
themeColor.content = theme;
}
updateThemeColor(preferredColorSchemeMatchMedia.matches);
@@ -1134,7 +1133,7 @@
"change",
({ matches }) => {
updateThemeColor(matches);
}
},
);
if ("standalone" in window.navigator && !!window.navigator.standalone) {
@@ -3,7 +3,7 @@
/**
* @import { SignalOptions } from "./v0.3.2-treeshaked/types/core/core"
* @import { getOwner as GetOwner, onCleanup as OnCleanup } from "./v0.3.2-treeshaked/types/core/owner"
* @import { createSignal as CreateSignal, createEffect as CreateEffect, createMemo as CreateMemo, createRoot as CreateRoot, runWithOwner as RunWithOwner } from "./v0.3.2-treeshaked/types/signals";
* @import { createSignal as CreateSignal, createEffect as CreateEffect, createMemo as CreateMemo, createRoot as CreateRoot, runWithOwner as RunWithOwner, Accessor } from "./v0.3.2-treeshaked/types/signals";
* @import { Signal } from "./types";
*/
@@ -40,13 +40,13 @@ const importSignals = import("./v0.3.2-treeshaked/script.js").then(
/**
* @template T
* @param {T} initialValue
* @param {SignalOptions<T> & {save?: {keyPrefix: string; key: string; serialize: (v: T) => string; deserialize: (v: string) => T; serializeParam?: boolean}}} [options]
* @param {SignalOptions<T> & {save?: {keyPrefix: string | Accessor<string>; key: string; serialize: (v: T) => string; deserialize: (v: string) => T; serializeParam?: boolean}}} [options]
* @returns {Signal<T>}
*/
createSignal(initialValue, options) {
const [get, set] = this.createSolidSignal(
/** @type {any} */ (initialValue),
options
options,
);
// @ts-ignore
@@ -59,27 +59,42 @@ const importSignals = import("./v0.3.2-treeshaked/script.js").then(
const save = options.save;
const paramKey = save.key;
const storageKey = `${save.keyPrefix}-${paramKey}`;
const storageKey = this.createMemo(
() =>
`${typeof save.keyPrefix === "string" ? save.keyPrefix : save.keyPrefix()}-${paramKey}`,
);
let serialized = /** @type {string | null} */ (null);
if (options.save.serializeParam !== false) {
serialized = new URLSearchParams(window.location.search).get(
paramKey
paramKey,
);
}
if (serialized === null) {
serialized = localStorage.getItem(storageKey());
}
if (serialized) {
set(() =>
serialized ? save.deserialize(serialized) : initialValue,
);
}
if (serialized === null) {
serialized = localStorage.getItem(storageKey);
}
if (serialized) {
set(() => save.deserialize(serialized));
}
let firstRun1 = true;
this.createEffect(storageKey, (storageKey) => {
if (!firstRun1) {
serialized = localStorage.getItem(storageKey);
set(() =>
serialized ? save.deserialize(serialized) : initialValue,
);
}
firstRun1 = false;
});
let firstEffect = true;
let firstRun2 = true;
this.createEffect(get, (value) => {
if (!save) return;
if (!firstEffect) {
if (!firstRun2) {
if (
value !== undefined &&
value !== null &&
@@ -87,9 +102,9 @@ const importSignals = import("./v0.3.2-treeshaked/script.js").then(
initialValue === null ||
save.serialize(value) !== save.serialize(initialValue))
) {
localStorage.setItem(storageKey, save.serialize(value));
localStorage.setItem(storageKey(), save.serialize(value));
} else {
localStorage.removeItem(storageKey);
localStorage.removeItem(storageKey());
}
}
@@ -105,7 +120,7 @@ const importSignals = import("./v0.3.2-treeshaked/script.js").then(
removeParam(paramKey);
}
firstEffect = false;
firstRun2 = false;
});
}
@@ -115,7 +130,7 @@ const importSignals = import("./v0.3.2-treeshaked/script.js").then(
};
return signals;
}
},
);
/**
@@ -135,7 +150,7 @@ function writeParam(key, value) {
window.history.replaceState(
null,
"",
`${window.location.pathname}?${urlParams.toString()}`
`${window.location.pathname}?${urlParams.toString()}`,
);
} catch (_) {}
}
+13 -8
View File
@@ -2,14 +2,14 @@
/**
* @import { Option, PartialChartOption, ChartOption, AnyPartialOption, ProcessedOptionAddons, OptionsTree, SimulationOption, AnySeriesBlueprint, ChartableIndex,CreatePriceLineOptions, CreatePriceLine } from "./options"
* @import {Valued, SingleValueData, CandlestickData, ChartData, OHLCTuple} from "../packages/lightweight-charts/wrapper"
* @import { Valued, SingleValueData, CandlestickData, ChartData, OHLCTuple, Series } from "../packages/lightweight-charts/wrapper"
* @import * as _ from "../packages/ufuzzy/v1.0.18/types"
* @import { createChart as CreateClassicChart, LineStyleOptions, DeepPartial, ChartOptions, IChartApi, IHorzScaleBehavior, WhitespaceData, ISeriesApi, Time, LineData, LogicalRange, BaselineStyleOptions, SeriesOptionsCommon, BaselineData, CandlestickStyleOptions } from "../packages/lightweight-charts/v5.0.7-treeshaked/types"
* @import { SignalOptions } from "../packages/solid-signals/v0.3.2-treeshaked/types/core/core"
* @import {Signal, Signals} from "../packages/solid-signals/types";
* @import { getOwner as GetOwner, onCleanup as OnCleanup, Owner } from "../packages/solid-signals/v0.3.2-treeshaked/types/core/owner"
* @import { createEffect as CreateEffect, Accessor, Setter, createMemo as CreateMemo } from "../packages/solid-signals/v0.3.2-treeshaked/types/signals";
* @import {DateIndex, DecadeIndex, DifficultyEpoch, Index, HalvingEpoch, Height, MonthIndex, P2PK33Index, P2PK65Index, P2PKHIndex, P2SHIndex, P2MSIndex, P2AIndex, P2TRIndex, P2WPKHIndex, P2WSHIndex, TxIndex, InputIndex, OutputIndex, VecId, WeekIndex, YearIndex, VecIdToIndexes, QuarterIndex, EmptyOutputIndex, OpReturnIndex, UnknownOutputIndex} from "./vecid-to-indexes"
* @import { DateIndex, DecadeIndex, DifficultyEpoch, Index, HalvingEpoch, Height, MonthIndex, P2PK33Index, P2PK65Index, P2PKHIndex, P2SHIndex, P2MSIndex, P2AIndex, P2TRIndex, P2WPKHIndex, P2WSHIndex, TxIndex, InputIndex, OutputIndex, VecId, WeekIndex, YearIndex, VecIdToIndexes, QuarterIndex, EmptyOutputIndex, OpReturnIndex, UnknownOutputIndex } from "./vecid-to-indexes"
*/
/**
@@ -378,7 +378,11 @@ function createUtils() {
sorted,
}) {
const choices = sorted
? /** @type {T} */ (/** @type {any} */ (unsortedChoices.toSorted()))
? /** @type {T} */ (
/** @type {any} */ (
unsortedChoices.toSorted((a, b) => a.localeCompare(b))
)
)
: unsortedChoices;
/** @type {Signal<T[number]>} */
@@ -389,7 +393,9 @@ function createUtils() {
key,
},
});
if (!choices.includes(selected())) {
console.log(choices, "don't include", selected());
selected.set(() => defaultValue);
}
@@ -424,15 +430,14 @@ function createUtils() {
return { field, selected };
},
/**
* @param {Object} args
* @param {1 | 2 | 3} [args.level]
* @param {string} [args.title]
* @param {string} [title]
* @param {1 | 2 | 3} [level]
*/
createHeader({ title, level = 1 }) {
createHeader(title = "", level = 1) {
const headerElement = window.document.createElement("header");
const headingElement = window.document.createElement(`h${level}`);
headingElement.innerHTML = title || "";
headingElement.innerHTML = title;
headerElement.append(headingElement);
headingElement.style.display = "block";
+12 -4
View File
@@ -391,9 +391,7 @@ export function init({
};
parametersElement.append(
utils.dom.createHeader({
title: "Save in Bitcoin",
}).headerElement,
utils.dom.createHeader("Save in Bitcoin").headerElement,
);
/**
@@ -698,7 +696,11 @@ export function init({
},
);
const index = () => /** @type {DateIndex} */ (0);
lightweightCharts.createChartElement({
index,
owner,
parent: resultsElement,
signals,
colors,
@@ -743,6 +745,8 @@ export function init({
});
lightweightCharts.createChartElement({
index,
owner,
parent: resultsElement,
signals,
colors,
@@ -767,6 +771,8 @@ export function init({
});
lightweightCharts.createChartElement({
index,
owner,
parent: resultsElement,
signals,
colors,
@@ -797,6 +803,8 @@ export function init({
});
lightweightCharts.createChartElement({
index,
owner,
parent: resultsElement,
signals,
colors,
@@ -805,7 +813,6 @@ export function init({
fitContentOnResize: true,
utils,
elements,
config: [
{
unit: "USD",
@@ -821,6 +828,7 @@ export function init({
});
lightweightCharts.createChartElement({
index,
parent: resultsElement,
signals,
colors,
+8 -10
View File
@@ -29,11 +29,11 @@ function createTable({
keyPrefix: "table",
key: "index",
},
}
},
)
);
const index = signals.createMemo(() =>
serializedIndexToIndex(serializedIndex())
serializedIndexToIndex(serializedIndex()),
);
const table = window.document.createElement("table");
@@ -73,7 +73,7 @@ function createTable({
table.append(tbody);
const rowElements = signals.createSignal(
/** @type {HTMLTableRowElement[]} */ ([])
/** @type {HTMLTableRowElement[]} */ ([]),
);
/**
@@ -197,7 +197,7 @@ function createTable({
});
signals.createEffect(vecIdOption, (vecIdOption) => {
select.style.width = `${30 + 8.5 * vecIdOption.name.length}px`;
select.style.width = `${21 + 7.25 * vecIdOption.name.length}px`;
});
if (_colIndex === columns().length) {
@@ -323,7 +323,7 @@ function createTable({
});
return () => vecId;
}
},
);
});
});
@@ -368,9 +368,7 @@ export function init({
vecIdToIndexes,
}) {
const parent = elements.table;
const { headerElement } = utils.dom.createHeader({
title: "Table",
});
const { headerElement } = utils.dom.createHeader("Table");
parent.append(headerElement);
const div = window.document.createElement("div");
@@ -394,7 +392,7 @@ export function init({
},
inside: span,
title: "Click or tap to add a column to the table",
})
}),
);
}
@@ -499,7 +497,7 @@ function createIndexToVecIds(vecIdToIndexes) {
});
return arr;
},
/** @type {VecId[][]} */ (new Array(24))
/** @type {VecId[][]} */ (new Array(24)),
);
indexToVecIds.forEach((arr) => {
arr.sort();
+1 -1
View File
@@ -2,7 +2,7 @@
// File auto-generated, any modifications will be overwritten
//
export const VERSION = "v0.0.47";
export const VERSION = "v0.0.48";
/** @typedef {0} DateIndex */
/** @typedef {1} DecadeIndex */
+5 -7
View File
@@ -16,11 +16,9 @@ sw.addEventListener("activate", (event) => {
.keys()
.then((keys) =>
Promise.all(
keys
.filter((key) => key !== CACHE_NAME && key !== "api")
.map((key) => caches.delete(key))
)
)
keys.filter((key) => key !== "api").map((key) => caches.delete(key)),
),
),
);
});
@@ -63,7 +61,7 @@ sw.addEventListener("fetch", (event) => {
throw new Error("Non-2xx on shell");
})
// On any failure, fall back to the cached shell
.catch(indexHTMLOrOffline)
.catch(indexHTMLOrOffline),
);
return;
}
@@ -86,6 +84,6 @@ sw.addEventListener("fetch", (event) => {
})
.catch(indexHTMLOrOffline);
})
.catch(indexHTMLOrOffline)
.catch(indexHTMLOrOffline),
);
});
+5 -4
View File
@@ -7,7 +7,9 @@
> div {
display: flex;
font-size: var(--font-size-sm);
font-size: var(--font-size-xs);
line--line-height: var(--line-height-xs);
font-weight: 450;
margin-left: var(--negative-main-padding);
margin-right: var(--negative-main-padding);
@@ -36,7 +38,7 @@
border-bottom: 1px;
border-color: var(--off-color);
border-style: dashed !important;
padding: 0.25rem 1rem;
padding: 0.25rem 0.75rem;
}
td {
@@ -84,7 +86,7 @@
> button {
padding: 0 0.25rem;
margin: 0 -0.25rem;
font-size: 1rem;
font-size: 0.75rem;
line-height: 0;
}
}
@@ -126,7 +128,6 @@
position: relative;
border-top-width: 1px;
width: 100%;
/* border-right-width: 1px; */
border-bottom-width: 1px;
border-style: dashed !important;