mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-26 17:54:44 -07:00
bitview: reorg part 5
This commit is contained in:
69
Cargo.lock
generated
69
Cargo.lock
generated
@@ -182,9 +182,9 @@ checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
|
||||
|
||||
[[package]]
|
||||
name = "async-compression"
|
||||
version = "0.4.30"
|
||||
version = "0.4.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "977eb15ea9efd848bb8a4a1a2500347ed7f0bf794edf0dc3ddcf439f43d36b23"
|
||||
checksum = "9611ec0b6acea03372540509035db2f7f1e9f04da5d27728436fa994033c00a0"
|
||||
dependencies = [
|
||||
"compression-codecs",
|
||||
"compression-core",
|
||||
@@ -656,6 +656,7 @@ dependencies = [
|
||||
"brk_interface",
|
||||
"brk_rmcp",
|
||||
"log",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -674,9 +675,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "brk_rmcp"
|
||||
version = "0.6.0"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5788307976c7fbc3b549b56c70fd6b1893d609e08e82d470d6938b748742cf54"
|
||||
checksum = "ac54fb0335b049bce158a31900681dd6b328d5cd3640e76c478c1067eb50fc79"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"brk_rmcp-macros",
|
||||
@@ -704,9 +705,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "brk_rmcp-macros"
|
||||
version = "0.6.0"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b49ac541e14b18e43696144176faeabc547ce198cb10d575c13fcc6245d337c"
|
||||
checksum = "241b6c6ee464ae951e152122567e4fd5e4443ee1ed484bd575530de3afb72f99"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
@@ -1560,12 +1561,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "deranged"
|
||||
version = "0.5.3"
|
||||
version = "0.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d630bccd429a5bb5a64b5e94f693bfc48c9f8566418fda4c494cc94f911f87cc"
|
||||
checksum = "a41953f86f8a05768a6cda24def994fd2f424b04ec5c719cf89989779f199071"
|
||||
dependencies = [
|
||||
"powerfmt",
|
||||
"serde",
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2475,14 +2476,23 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.80"
|
||||
version = "0.3.81"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "852f13bec5eba4ba9afbeb93fd7c13fe56147f055939ae21c43a29a0ecb2702e"
|
||||
checksum = "ec48937a97411dcb524a265206ccd4c90bb711fca92b2792c407f268825b9305"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "json-escape-simd"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a1f7d5786a4cb0f4e0f862b562a0e085b5bfa23a4f0dc05e7b823ed4e4d791f"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "json-strip-comments"
|
||||
version = "3.0.1"
|
||||
@@ -2532,9 +2542,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.175"
|
||||
version = "0.2.176"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543"
|
||||
checksum = "58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174"
|
||||
|
||||
[[package]]
|
||||
name = "libredox"
|
||||
@@ -3193,9 +3203,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "oxc_resolver"
|
||||
version = "11.8.2"
|
||||
version = "11.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49c4a4d746f42bac28538163952aa66da2f0ea781a0708772d8ad3f6fc066963"
|
||||
checksum = "c553f3d6a88eb57513b4bb6b8387ab71c7701721ecd242b673ffeb3dc99cfd08"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"indexmap 2.11.4",
|
||||
@@ -3238,11 +3248,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "oxc_sourcemap"
|
||||
version = "4.1.2"
|
||||
version = "4.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87a91923e9269b32c91cd956596f9c3bd24b60a89df5c815abb2812a0ffa8b7b"
|
||||
checksum = "f6194c58467a15d9dcb5cb852fcad312af57fd46fabd419fae87fcf801f83702"
|
||||
dependencies = [
|
||||
"base64-simd",
|
||||
"json-escape-simd",
|
||||
"rustc-hash",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -4502,9 +4513,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.22.0"
|
||||
version = "3.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84fa4d11fadde498443cca10fd3ac23c951f0dc59e080e9f4b93d4df4e4eea53"
|
||||
checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16"
|
||||
dependencies = [
|
||||
"fastrand",
|
||||
"getrandom 0.3.3",
|
||||
@@ -5131,9 +5142,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.103"
|
||||
version = "0.2.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab10a69fbd0a177f5f649ad4d8d3305499c42bab9aef2f7ff592d0ec8f833819"
|
||||
checksum = "c1da10c01ae9f1ae40cbfac0bac3b1e724b320abfcf52229f80b547c0d250e2d"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
@@ -5144,9 +5155,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.103"
|
||||
version = "0.2.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0bb702423545a6007bbc368fde243ba47ca275e549c8a28617f56f6ba53b1d1c"
|
||||
checksum = "671c9a5a66f49d8a47345ab942e2cb93c7d1d0339065d4f8139c486121b43b19"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"log",
|
||||
@@ -5158,9 +5169,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.103"
|
||||
version = "0.2.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc65f4f411d91494355917b605e1480033152658d71f722a90647f56a70c88a0"
|
||||
checksum = "7ca60477e4c59f5f2986c50191cd972e3a50d8a95603bc9434501cf156a9a119"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
@@ -5168,9 +5179,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.103"
|
||||
version = "0.2.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffc003a991398a8ee604a401e194b6b3a39677b3173d6e74495eb51b82e99a32"
|
||||
checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -5181,9 +5192,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.103"
|
||||
version = "0.2.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "293c37f4efa430ca14db3721dfbe48d8c33308096bd44d80ebaa775ab71ba1cf"
|
||||
checksum = "bad67dc8b2a1a6e5448428adec4c3e84c43e561d8c9ee8a9e5aabeb193ec41d1"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
@@ -29,7 +29,7 @@ impl Bridge for Interface<'static> {
|
||||
|
||||
fs::create_dir_all(&path)?;
|
||||
|
||||
generate_vecs_file(self, &path)?;
|
||||
generate_metrics_file(self, &path)?;
|
||||
generate_pools_file(&path)
|
||||
}
|
||||
}
|
||||
@@ -70,8 +70,8 @@ return /** @type {const} */ ({
|
||||
fs::write(path, contents)
|
||||
}
|
||||
|
||||
fn generate_vecs_file(interface: &Interface<'static>, parent: &Path) -> io::Result<()> {
|
||||
let path = parent.join(Path::new("vecs.js"));
|
||||
fn generate_metrics_file(interface: &Interface<'static>, parent: &Path) -> io::Result<()> {
|
||||
let path = parent.join(Path::new("metrics.js"));
|
||||
|
||||
let indexes = Index::all();
|
||||
|
||||
|
||||
@@ -12,8 +12,9 @@ build = "build.rs"
|
||||
[dependencies]
|
||||
axum = { workspace = true }
|
||||
brk_interface = { workspace = true }
|
||||
log = { workspace = true }
|
||||
brk_rmcp = { version = "0.6.0", features = [
|
||||
brk_rmcp = { version = "0.7.1", features = [
|
||||
"transport-worker",
|
||||
"transport-streamable-http-server",
|
||||
] }
|
||||
log = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use brk_interface::{IdParam, Interface, PaginatedIndexParam, PaginationParam, Params};
|
||||
use brk_rmcp::{
|
||||
ErrorData as McpError, RoleServer, ServerHandler,
|
||||
handler::server::{router::tool::ToolRouter, tool::Parameters},
|
||||
handler::server::{router::tool::ToolRouter, wrapper::Parameters},
|
||||
model::*,
|
||||
service::RequestContext,
|
||||
tool, tool_handler, tool_router,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/** @import { IChartApi, ISeriesApi as _ISeriesApi, SeriesDefinition, SingleValueData as _SingleValueData, CandlestickData as _CandlestickData, BaselineData as _BaselineData, HistogramData as _HistogramData, SeriesType, IPaneApi, LineSeriesPartialOptions as _LineSeriesPartialOptions, HistogramSeriesPartialOptions as _HistogramSeriesPartialOptions, BaselineSeriesPartialOptions as _BaselineSeriesPartialOptions, CandlestickSeriesPartialOptions as _CandlestickSeriesPartialOptions, WhitespaceData, DeepPartial, ChartOptions, Time, LineData as _LineData } from '../packages/lightweight-charts/5.0.8/dist/typings' */
|
||||
/** @import { IChartApi, ISeriesApi as _ISeriesApi, SeriesDefinition, SingleValueData as _SingleValueData, CandlestickData as _CandlestickData, BaselineData as _BaselineData, HistogramData as _HistogramData, SeriesType, IPaneApi, LineSeriesPartialOptions as _LineSeriesPartialOptions, HistogramSeriesPartialOptions as _HistogramSeriesPartialOptions, BaselineSeriesPartialOptions as _BaselineSeriesPartialOptions, CandlestickSeriesPartialOptions as _CandlestickSeriesPartialOptions, WhitespaceData, DeepPartial, ChartOptions, Time, LineData as _LineData } from '../../packages/lightweight-charts/5.0.8/dist/typings' */
|
||||
|
||||
import {
|
||||
createChart,
|
||||
@@ -7,20 +7,18 @@ import {
|
||||
LineSeries,
|
||||
BaselineSeries,
|
||||
// } from "../packages/lightweight-charts/5.0.8/dist/lightweight-charts.standalone.development.mjs";
|
||||
} from "../packages/lightweight-charts/5.0.8/dist/lightweight-charts.standalone.production.mjs";
|
||||
} from "../../packages/lightweight-charts/5.0.8/dist/lightweight-charts.standalone.production.mjs";
|
||||
|
||||
import {
|
||||
createHorizontalChoiceField,
|
||||
createLabeledInput,
|
||||
createSpanName,
|
||||
} from "./dom";
|
||||
import { createOklchToRGBA } from "./colors";
|
||||
import { throttle } from "./timing";
|
||||
import { serdeBool } from "./serde";
|
||||
} from "../dom";
|
||||
import { createOklchToRGBA } from "./oklch";
|
||||
import { throttle } from "../timing";
|
||||
import { serdeBool } from "../serde";
|
||||
|
||||
/**
|
||||
* @typedef {[number, number, number, number]} OHLCTuple
|
||||
*
|
||||
* @typedef {Object} Valued
|
||||
* @property {number} value
|
||||
*
|
||||
@@ -1003,7 +1001,7 @@ function numberToShortUSFormat(value, digits) {
|
||||
return numberToUSFormat(value, Math.min(1, digits || 10));
|
||||
} else if (absoluteValue < 1_000_000) {
|
||||
return numberToUSFormat(value, 0);
|
||||
} else if (absoluteValue >= 900_000_000_000_000_000_000_000) {
|
||||
} else if (absoluteValue >= 1_000_000_000_000_000_000_000) {
|
||||
return "Inf.";
|
||||
}
|
||||
|
||||
@@ -1015,11 +1013,6 @@ function numberToShortUSFormat(value, digits) {
|
||||
|
||||
const modulused = log % 3;
|
||||
|
||||
// return `${numberToUSFormat(
|
||||
// value / (1_000_000 * 1_000 ** letterIndex),
|
||||
// 3,
|
||||
// )}${letter}`;
|
||||
|
||||
if (modulused === 0) {
|
||||
return `${numberToUSFormat(
|
||||
value / (1_000_000 * 1_000 ** letterIndex),
|
||||
100
websites/bitview/scripts/core/chart/oklch.js
Normal file
100
websites/bitview/scripts/core/chart/oklch.js
Normal file
@@ -0,0 +1,100 @@
|
||||
export function createOklchToRGBA() {
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @param {readonly [number, number, number, number, number, number, number, number, number]} A
|
||||
* @param {readonly [number, number, number]} B
|
||||
* @returns
|
||||
*/
|
||||
function multiplyMatrices(A, B) {
|
||||
return /** @type {const} */ ([
|
||||
A[0] * B[0] + A[1] * B[1] + A[2] * B[2],
|
||||
A[3] * B[0] + A[4] * B[1] + A[5] * B[2],
|
||||
A[6] * B[0] + A[7] * B[1] + A[8] * B[2],
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* @param {readonly [number, number, number]} param0
|
||||
*/
|
||||
function oklch2oklab([l, c, h]) {
|
||||
return /** @type {const} */ ([
|
||||
l,
|
||||
isNaN(h) ? 0 : c * Math.cos((h * Math.PI) / 180),
|
||||
isNaN(h) ? 0 : c * Math.sin((h * Math.PI) / 180),
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* @param {readonly [number, number, number]} rgb
|
||||
*/
|
||||
function srgbLinear2rgb(rgb) {
|
||||
return rgb.map((c) =>
|
||||
Math.abs(c) > 0.0031308
|
||||
? (c < 0 ? -1 : 1) * (1.055 * Math.abs(c) ** (1 / 2.4) - 0.055)
|
||||
: 12.92 * c,
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @param {readonly [number, number, number]} lab
|
||||
*/
|
||||
function oklab2xyz(lab) {
|
||||
const LMSg = multiplyMatrices(
|
||||
/** @type {const} */ ([
|
||||
1, 0.3963377773761749, 0.2158037573099136, 1, -0.1055613458156586,
|
||||
-0.0638541728258133, 1, -0.0894841775298119, -1.2914855480194092,
|
||||
]),
|
||||
lab,
|
||||
);
|
||||
const LMS = /** @type {[number, number, number]} */ (
|
||||
LMSg.map((val) => val ** 3)
|
||||
);
|
||||
return multiplyMatrices(
|
||||
/** @type {const} */ ([
|
||||
1.2268798758459243, -0.5578149944602171, 0.2813910456659647,
|
||||
-0.0405757452148008, 1.112286803280317, -0.0717110580655164,
|
||||
-0.0763729366746601, -0.4214933324022432, 1.5869240198367816,
|
||||
]),
|
||||
LMS,
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @param {readonly [number, number, number]} xyz
|
||||
*/
|
||||
function xyz2rgbLinear(xyz) {
|
||||
return multiplyMatrices(
|
||||
[
|
||||
3.2409699419045226, -1.537383177570094, -0.4986107602930034,
|
||||
-0.9692436362808796, 1.8759675015077202, 0.04155505740717559,
|
||||
0.05563007969699366, -0.20397695888897652, 1.0569715142428786,
|
||||
],
|
||||
xyz,
|
||||
);
|
||||
}
|
||||
|
||||
/** @param {string} oklch */
|
||||
return function (oklch) {
|
||||
oklch = oklch.replace("oklch(", "");
|
||||
oklch = oklch.replace(")", "");
|
||||
let splitOklch = oklch.split(" / ");
|
||||
let alpha = 1;
|
||||
if (splitOklch.length === 2) {
|
||||
alpha = Number(splitOklch.pop()?.replace("%", "")) / 100;
|
||||
}
|
||||
splitOklch = oklch.split(" ");
|
||||
const lch = splitOklch.map((v, i) => {
|
||||
if (!i && v.includes("%")) {
|
||||
return Number(v.replace("%", "")) / 100;
|
||||
} else {
|
||||
return Number(v);
|
||||
}
|
||||
});
|
||||
const rgb = srgbLinear2rgb(
|
||||
xyz2rgbLinear(
|
||||
oklab2xyz(oklch2oklab(/** @type {[number, number, number]} */ (lch))),
|
||||
),
|
||||
).map((v) => {
|
||||
return Math.max(Math.min(Math.round(v * 255), 255), 0);
|
||||
});
|
||||
return [...rgb, alpha];
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -114,104 +114,3 @@ export function createColors(dark) {
|
||||
* @typedef {Colors["orange"]} Color
|
||||
* @typedef {keyof Colors} ColorName
|
||||
*/
|
||||
|
||||
export function createOklchToRGBA() {
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @param {readonly [number, number, number, number, number, number, number, number, number]} A
|
||||
* @param {readonly [number, number, number]} B
|
||||
* @returns
|
||||
*/
|
||||
function multiplyMatrices(A, B) {
|
||||
return /** @type {const} */ ([
|
||||
A[0] * B[0] + A[1] * B[1] + A[2] * B[2],
|
||||
A[3] * B[0] + A[4] * B[1] + A[5] * B[2],
|
||||
A[6] * B[0] + A[7] * B[1] + A[8] * B[2],
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* @param {readonly [number, number, number]} param0
|
||||
*/
|
||||
function oklch2oklab([l, c, h]) {
|
||||
return /** @type {const} */ ([
|
||||
l,
|
||||
isNaN(h) ? 0 : c * Math.cos((h * Math.PI) / 180),
|
||||
isNaN(h) ? 0 : c * Math.sin((h * Math.PI) / 180),
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* @param {readonly [number, number, number]} rgb
|
||||
*/
|
||||
function srgbLinear2rgb(rgb) {
|
||||
return rgb.map((c) =>
|
||||
Math.abs(c) > 0.0031308
|
||||
? (c < 0 ? -1 : 1) * (1.055 * Math.abs(c) ** (1 / 2.4) - 0.055)
|
||||
: 12.92 * c,
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @param {readonly [number, number, number]} lab
|
||||
*/
|
||||
function oklab2xyz(lab) {
|
||||
const LMSg = multiplyMatrices(
|
||||
/** @type {const} */ ([
|
||||
1, 0.3963377773761749, 0.2158037573099136, 1, -0.1055613458156586,
|
||||
-0.0638541728258133, 1, -0.0894841775298119, -1.2914855480194092,
|
||||
]),
|
||||
lab,
|
||||
);
|
||||
const LMS = /** @type {[number, number, number]} */ (
|
||||
LMSg.map((val) => val ** 3)
|
||||
);
|
||||
return multiplyMatrices(
|
||||
/** @type {const} */ ([
|
||||
1.2268798758459243, -0.5578149944602171, 0.2813910456659647,
|
||||
-0.0405757452148008, 1.112286803280317, -0.0717110580655164,
|
||||
-0.0763729366746601, -0.4214933324022432, 1.5869240198367816,
|
||||
]),
|
||||
LMS,
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @param {readonly [number, number, number]} xyz
|
||||
*/
|
||||
function xyz2rgbLinear(xyz) {
|
||||
return multiplyMatrices(
|
||||
[
|
||||
3.2409699419045226, -1.537383177570094, -0.4986107602930034,
|
||||
-0.9692436362808796, 1.8759675015077202, 0.04155505740717559,
|
||||
0.05563007969699366, -0.20397695888897652, 1.0569715142428786,
|
||||
],
|
||||
xyz,
|
||||
);
|
||||
}
|
||||
|
||||
/** @param {string} oklch */
|
||||
return function (oklch) {
|
||||
oklch = oklch.replace("oklch(", "");
|
||||
oklch = oklch.replace(")", "");
|
||||
let splitOklch = oklch.split(" / ");
|
||||
let alpha = 1;
|
||||
if (splitOklch.length === 2) {
|
||||
alpha = Number(splitOklch.pop()?.replace("%", "")) / 100;
|
||||
}
|
||||
splitOklch = oklch.split(" ");
|
||||
const lch = splitOklch.map((v, i) => {
|
||||
if (!i && v.includes("%")) {
|
||||
return Number(v.replace("%", "")) / 100;
|
||||
} else {
|
||||
return Number(v);
|
||||
}
|
||||
});
|
||||
const rgb = srgbLinear2rgb(
|
||||
xyz2rgbLinear(
|
||||
oklab2xyz(oklch2oklab(/** @type {[number, number, number]} */ (lch))),
|
||||
),
|
||||
).map((v) => {
|
||||
return Math.max(Math.min(Math.round(v * 255), 255), 0);
|
||||
});
|
||||
return [...rgb, alpha];
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -101,9 +101,9 @@ export const serdeBool = {
|
||||
* @param {string} v
|
||||
*/
|
||||
deserialize(v) {
|
||||
if (v === "true") {
|
||||
if (v === "true" || v === "1") {
|
||||
return true;
|
||||
} else if (v === "false") {
|
||||
} else if (v === "false" || v === "0") {
|
||||
return false;
|
||||
} else {
|
||||
throw "deser bool err";
|
||||
@@ -111,70 +111,6 @@ export const serdeBool = {
|
||||
},
|
||||
};
|
||||
|
||||
export const serdeIndex = {
|
||||
/**
|
||||
* @param {Index} v
|
||||
*/
|
||||
serialize(v) {
|
||||
switch (v) {
|
||||
case /** @satisfies {DateIndex} */ (0):
|
||||
return "dateindex";
|
||||
case /** @satisfies {DecadeIndex} */ (1):
|
||||
return "decadeindex";
|
||||
case /** @satisfies {DifficultyEpoch} */ (2):
|
||||
return "difficultyepoch";
|
||||
case /** @satisfies {EmptyOutputIndex} */ (3):
|
||||
return "emptyoutputindex";
|
||||
case /** @satisfies {HalvingEpoch} */ (4):
|
||||
return "halvingepoch";
|
||||
case /** @satisfies {Height} */ (5):
|
||||
return "height";
|
||||
case /** @satisfies {InputIndex} */ (6):
|
||||
return "inputindex";
|
||||
case /** @satisfies {MonthIndex} */ (7):
|
||||
return "monthindex";
|
||||
case /** @satisfies {OpReturnIndex} */ (8):
|
||||
return "opreturnindex";
|
||||
case /** @satisfies {OutputIndex} */ (9):
|
||||
return "outputindex";
|
||||
case /** @satisfies {P2AAddressIndex} */ (10):
|
||||
return "p2aaddressindex";
|
||||
case /** @satisfies {P2MSOutputIndex} */ (11):
|
||||
return "p2msoutputindex";
|
||||
case /** @satisfies {P2PK33AddressIndex} */ (12):
|
||||
return "p2pk33addressindex";
|
||||
case /** @satisfies {P2PK65AddressIndex} */ (13):
|
||||
return "p2pk65addressindex";
|
||||
case /** @satisfies {P2PKHAddressIndex} */ (14):
|
||||
return "p2pkhaddressindex";
|
||||
case /** @satisfies {P2SHAddressIndex} */ (15):
|
||||
return "p2shaddressindex";
|
||||
case /** @satisfies {P2TRAddressIndex} */ (16):
|
||||
return "p2traddressindex";
|
||||
case /** @satisfies {P2WPKHAddressIndex} */ (17):
|
||||
return "p2wpkhaddressindex";
|
||||
case /** @satisfies {P2WSHAddressIndex} */ (18):
|
||||
return "p2wshaddressindex";
|
||||
case /** @satisfies {QuarterIndex} */ (19):
|
||||
return "quarterindex";
|
||||
case /** @satisfies {SemesterIndex} */ (20):
|
||||
return "semesterindex";
|
||||
case /** @satisfies {TxIndex} */ (21):
|
||||
return "txindex";
|
||||
case /** @satisfies {UnknownOutputIndex} */ (22):
|
||||
return "unknownoutputindex";
|
||||
case /** @satisfies {WeekIndex} */ (23):
|
||||
return "weekindex";
|
||||
case /** @satisfies {YearIndex} */ (24):
|
||||
return "yearindex";
|
||||
case /** @satisfies {LoadedAddressIndex} */ (25):
|
||||
return "loadedaddressindex";
|
||||
case /** @satisfies {EmptyAddressIndex} */ (26):
|
||||
return "emptyaddressindex";
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const serdeChartableIndex = {
|
||||
/**
|
||||
* @param {number} v
|
||||
|
||||
@@ -36,15 +36,3 @@ export function throttle(callback, wait = 1000) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {VoidFunction} callback
|
||||
* @param {number} [timeout = 1]
|
||||
*/
|
||||
export function runWhenIdle(callback, timeout = 1) {
|
||||
if ("requestIdleCallback" in window) {
|
||||
requestIdleCallback(callback);
|
||||
} else {
|
||||
setTimeout(callback, timeout);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
*
|
||||
* @import { Valued, SingleValueData, CandlestickData, OHLCTuple, Series, ISeries, HistogramData, LineData, BaselineData, LineSeriesPartialOptions, BaselineSeriesPartialOptions, HistogramSeriesPartialOptions, CandlestickSeriesPartialOptions, CreateChartElement, Chart } from "./core/chart"
|
||||
* @import { Valued, SingleValueData, CandlestickData, Series, ISeries, HistogramData, LineData, BaselineData, LineSeriesPartialOptions, BaselineSeriesPartialOptions, HistogramSeriesPartialOptions, CandlestickSeriesPartialOptions, CreateChartElement, Chart } from "./core/chart/index"
|
||||
*
|
||||
* @import * as _ from "./packages/leeoniya-ufuzzy/1.0.19/dist/uFuzzy.d.ts"
|
||||
*
|
||||
@@ -26,7 +26,6 @@
|
||||
* @typedef {typeof import("./core/utils")} Utilities
|
||||
* @typedef {typeof import("./core/env")["default"]} Env
|
||||
* @typedef {typeof import("./core/elements")["default"]} Elements
|
||||
* @typedef {string} Metric
|
||||
*/
|
||||
|
||||
// DO NOT CHANGE, Exact format is expected in `brk_bundler`
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
const imports = {
|
||||
async signals() {
|
||||
return import("./packages/solidjs-signals/wrapper.js").then(
|
||||
(d) => d.default,
|
||||
);
|
||||
return import("./packages/solidjs-signals/index.js").then((d) => d.default);
|
||||
},
|
||||
async chart() {
|
||||
return window.document.fonts.ready.then(() =>
|
||||
import("./core/chart.js").then((d) => d.default),
|
||||
import("./core/chart/index.js").then((d) => d.default),
|
||||
);
|
||||
},
|
||||
async leanQr() {
|
||||
@@ -18,18 +16,15 @@ const imports = {
|
||||
);
|
||||
},
|
||||
async modernScreenshot() {
|
||||
return import("./packages/modern-screenshot/wrapper.js").then((d) => d);
|
||||
return import("./packages/modern-screenshot/index.js").then((d) => d);
|
||||
},
|
||||
async brk() {
|
||||
return import("./packages/brk/index.js").then((d) => d);
|
||||
},
|
||||
|
||||
async options() {
|
||||
return import("./core/options/full.js").then((d) => d);
|
||||
},
|
||||
async vecs() {
|
||||
return import("./bridge/vecs.js").then((d) => d);
|
||||
},
|
||||
async pools() {
|
||||
return import("./bridge/pools.js").then((d) => d);
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -91,25 +91,13 @@ function initFrameSelectors() {
|
||||
}
|
||||
initFrameSelectors();
|
||||
|
||||
Promise.all([
|
||||
packages.signals(),
|
||||
packages.vecs(),
|
||||
packages.pools(),
|
||||
packages.options(),
|
||||
]).then(
|
||||
([
|
||||
signals,
|
||||
{ createMetricToIndexes, VERSION },
|
||||
{ createPools },
|
||||
{ initOptions },
|
||||
]) =>
|
||||
Promise.all([packages.signals(), packages.brk(), packages.options()]).then(
|
||||
([signals, { initOptions }]) =>
|
||||
signals.createRoot(() => {
|
||||
const owner = signals.getOwner();
|
||||
|
||||
console.log(`VERSION = ${VERSION}`);
|
||||
|
||||
const metricToIndexes = createMetricToIndexes();
|
||||
|
||||
if (env.localhost) {
|
||||
Object.keys(metricToIndexes).forEach((metric) => {
|
||||
serdeUnit.deserialize(metric);
|
||||
@@ -135,22 +123,22 @@ Promise.all([
|
||||
|
||||
const qrcode = signals.createSignal(/** @type {string | null} */ (null));
|
||||
|
||||
function createLastHeightResource() {
|
||||
const lastHeight = signals.createSignal(0);
|
||||
function fetchLastHeight() {
|
||||
utils.api.fetchLast(
|
||||
(h) => {
|
||||
lastHeight.set(h);
|
||||
},
|
||||
/** @satisfies {Height} */ (5),
|
||||
"height",
|
||||
);
|
||||
}
|
||||
fetchLastHeight();
|
||||
setInterval(fetchLastHeight, 10_000);
|
||||
return lastHeight;
|
||||
}
|
||||
const lastHeight = createLastHeightResource();
|
||||
// function createLastHeightResource() {
|
||||
// const lastHeight = signals.createSignal(0);
|
||||
// function fetchLastHeight() {
|
||||
// utils.api.fetchLast(
|
||||
// (h) => {
|
||||
// lastHeight.set(h);
|
||||
// },
|
||||
// /** @satisfies {Height} */ (5),
|
||||
// "height",
|
||||
// );
|
||||
// }
|
||||
// fetchLastHeight();
|
||||
// setInterval(fetchLastHeight, 10_000);
|
||||
// return lastHeight;
|
||||
// }
|
||||
// const lastHeight = createLastHeightResource();
|
||||
|
||||
const webSockets = createWebSockets(signals);
|
||||
|
||||
|
||||
2
websites/packages/brk/.gitignore
vendored
Normal file
2
websites/packages/brk/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
pools.js
|
||||
metrics.js
|
||||
11
websites/packages/brk/idle.js
Normal file
11
websites/packages/brk/idle.js
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @param {VoidFunction} callback
|
||||
* @param {number} [timeout = 1]
|
||||
*/
|
||||
export function runWhenIdle(callback, timeout = 1) {
|
||||
if ("requestIdleCallback" in window) {
|
||||
requestIdleCallback(callback);
|
||||
} else {
|
||||
setTimeout(callback, timeout);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,19 @@
|
||||
import { serdeIndex } from "./serde";
|
||||
import { runWhenIdle } from "./timing";
|
||||
import { runWhenIdle } from "./idle";
|
||||
import { createPools } from "./pools";
|
||||
import { createMetricToIndexes } from "./metrics";
|
||||
|
||||
const localhost = window.location.hostname === "localhost";
|
||||
|
||||
/**
|
||||
* @param {Signals} signals
|
||||
* @param {Utilities} utils
|
||||
* @param {Env} env
|
||||
* @param {MetricToIndexes} metricToIndexes
|
||||
*/
|
||||
export function createVecsResources(signals, utils, env, metricToIndexes) {
|
||||
export default function (signals) {
|
||||
const owner = signals.getOwner();
|
||||
|
||||
const pools = createPools();
|
||||
const metricToIndexes = createMetricToIndexes();
|
||||
|
||||
const defaultFrom = -10_000;
|
||||
const defaultTo = undefined;
|
||||
|
||||
@@ -30,17 +34,15 @@ export function createVecsResources(signals, utils, env, metricToIndexes) {
|
||||
|
||||
/**
|
||||
* @template {number | OHLCTuple} [T=number]
|
||||
* @param {Index} index
|
||||
* @param {Metric} metric
|
||||
* @param {Index} index
|
||||
*/
|
||||
function createVecResource(index, metric) {
|
||||
if (env.localhost && !(metric in metricToIndexes)) {
|
||||
function createMetricResource(metric, index) {
|
||||
if (localhost && !(metric in metricToIndexes)) {
|
||||
throw Error(`${metric} not recognized`);
|
||||
}
|
||||
|
||||
return signals.runWithOwner(owner, () => {
|
||||
/** @typedef {T extends number ? SingleValueData : CandlestickData} Value */
|
||||
|
||||
const fetchedRecord = signals.createSignal(
|
||||
/** @type {Map<string, {loading: boolean, at: Date | null, vec: Signal<T[] | null>}>} */ (
|
||||
new Map()
|
||||
@@ -85,7 +87,7 @@ export function createVecsResources(signals, utils, env, metricToIndexes) {
|
||||
}
|
||||
fetched.loading = true;
|
||||
const res = /** @type {T[] | null} */ (
|
||||
await api.fetchVec(
|
||||
await fetchVec(
|
||||
(values) => {
|
||||
if (values.length || !fetched.vec()) {
|
||||
fetched.vec.set(values);
|
||||
@@ -105,23 +107,23 @@ export function createVecsResources(signals, utils, env, metricToIndexes) {
|
||||
});
|
||||
}
|
||||
|
||||
/** @type {Map<string, NonNullable<ReturnType<typeof createVecResource>>>} */
|
||||
/** @type {Map<string, NonNullable<ReturnType<typeof createMetricResource>>>} */
|
||||
const map = new Map();
|
||||
|
||||
const vecs = {
|
||||
const metrics = {
|
||||
/**
|
||||
* @template {number | OHLCTuple} [T=number]
|
||||
* @param {Index} index
|
||||
* @param {Metric} metric
|
||||
* @param {Index} index
|
||||
*/
|
||||
getOrCreate(index, metric) {
|
||||
const key = `${index},${metric}`;
|
||||
getOrCreate(metric, index) {
|
||||
const key = `${metric}/${index}`;
|
||||
const found = map.get(key);
|
||||
if (found) {
|
||||
return found;
|
||||
}
|
||||
|
||||
const vec = createVecResource(index, metric);
|
||||
const vec = createMetricResource(index, metric);
|
||||
if (!vec) throw Error("vec is undefined");
|
||||
map.set(key, /** @type {any} */ (vec));
|
||||
return vec;
|
||||
@@ -130,10 +132,10 @@ export function createVecsResources(signals, utils, env, metricToIndexes) {
|
||||
defaultFetchedKey,
|
||||
};
|
||||
|
||||
return vecs;
|
||||
return { metrics, pools };
|
||||
}
|
||||
/** @typedef {ReturnType<typeof createVecsResources>} VecsResources */
|
||||
/** @typedef {ReturnType<VecsResources["getOrCreate"]>} VecResource */
|
||||
// /** @typedef {ReturnType<typeof createVecsResources>} VecsResources */
|
||||
// /** @typedef {ReturnType<VecsResources["getOrCreate"]>} VecResource */
|
||||
|
||||
const CACHE_NAME = "api";
|
||||
const API_VECS_PREFIX = "/api/vecs";
|
||||
@@ -142,9 +144,8 @@ const API_VECS_PREFIX = "/api/vecs";
|
||||
* @template T
|
||||
* @param {(value: T) => void} callback
|
||||
* @param {string} path
|
||||
* @param {boolean} [mustBeArray]
|
||||
*/
|
||||
async function fetchApi(callback, path, mustBeArray) {
|
||||
async function fetchApi(callback, path) {
|
||||
const url = `${API_VECS_PREFIX}${path}`;
|
||||
|
||||
/** @type {T | null} */
|
||||
@@ -184,9 +185,7 @@ async function fetchApi(callback, path, mustBeArray) {
|
||||
let fetchedJson = /** @type {T | null} */ (null);
|
||||
try {
|
||||
const f = await fetchedResponse.json();
|
||||
fetchedJson = /** @type {T} */ (
|
||||
mustBeArray && !Array.isArray(f) ? [f] : f
|
||||
);
|
||||
fetchedJson = /** @type {T} */ (f);
|
||||
} catch (_) {
|
||||
return cachedJson;
|
||||
}
|
||||
@@ -249,33 +248,23 @@ function genPath(index, metric, from, to) {
|
||||
return path;
|
||||
}
|
||||
|
||||
export const api = {
|
||||
/**
|
||||
* @param {Index} index
|
||||
* @param {Metric} metric
|
||||
* @param {number} from
|
||||
*/
|
||||
genUrl(index, metric, from) {
|
||||
return `${API_VECS_PREFIX}${genPath(index, metric, from)}`;
|
||||
},
|
||||
/**
|
||||
* @template {number | OHLCTuple} [T=number]
|
||||
* @param {(v: T[]) => void} callback
|
||||
* @param {Index} index
|
||||
* @param {Metric} metric
|
||||
* @param {number} [from]
|
||||
* @param {number} [to]
|
||||
*/
|
||||
fetchVec(callback, index, metric, from, to) {
|
||||
return fetchApi(callback, genPath(index, metric, from, to), true);
|
||||
},
|
||||
/**
|
||||
* @template {number | OHLCTuple} [T=number]
|
||||
* @param {(v: T) => void} callback
|
||||
* @param {Index} index
|
||||
* @param {Metric} metric
|
||||
*/
|
||||
fetchLast(callback, index, metric) {
|
||||
return fetchApi(callback, genPath(index, metric, -1));
|
||||
},
|
||||
};
|
||||
// /**
|
||||
// * @template {number | OHLCTuple} [T=number]
|
||||
// * @param {(v: T[]) => void} callback
|
||||
// * @param {Index} index
|
||||
// * @param {Metric} metric
|
||||
// * @param {number} [from]
|
||||
// * @param {number} [to]
|
||||
// */
|
||||
// function fetchMetric(callback, index, metric, from, to) {
|
||||
// return fetchApi(callback, genPath(index, metric, from, to));
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * @param {Index} index
|
||||
// * @param {Metric} metric
|
||||
// * @param {number} from
|
||||
// */
|
||||
// function genUrl(index, metric, from) {
|
||||
// return `${API_VECS_PREFIX}${genPath(index, metric, from)}`;
|
||||
// }
|
||||
64
websites/packages/brk/serde.js
Normal file
64
websites/packages/brk/serde.js
Normal file
@@ -0,0 +1,64 @@
|
||||
// Should be generated by server
|
||||
export const serdeIndex = {
|
||||
/**
|
||||
* @param {Index} v
|
||||
*/
|
||||
serialize(v) {
|
||||
switch (v) {
|
||||
case /** @satisfies {DateIndex} */ (0):
|
||||
return "dateindex";
|
||||
case /** @satisfies {DecadeIndex} */ (1):
|
||||
return "decadeindex";
|
||||
case /** @satisfies {DifficultyEpoch} */ (2):
|
||||
return "difficultyepoch";
|
||||
case /** @satisfies {EmptyOutputIndex} */ (3):
|
||||
return "emptyoutputindex";
|
||||
case /** @satisfies {HalvingEpoch} */ (4):
|
||||
return "halvingepoch";
|
||||
case /** @satisfies {Height} */ (5):
|
||||
return "height";
|
||||
case /** @satisfies {InputIndex} */ (6):
|
||||
return "inputindex";
|
||||
case /** @satisfies {MonthIndex} */ (7):
|
||||
return "monthindex";
|
||||
case /** @satisfies {OpReturnIndex} */ (8):
|
||||
return "opreturnindex";
|
||||
case /** @satisfies {OutputIndex} */ (9):
|
||||
return "outputindex";
|
||||
case /** @satisfies {P2AAddressIndex} */ (10):
|
||||
return "p2aaddressindex";
|
||||
case /** @satisfies {P2MSOutputIndex} */ (11):
|
||||
return "p2msoutputindex";
|
||||
case /** @satisfies {P2PK33AddressIndex} */ (12):
|
||||
return "p2pk33addressindex";
|
||||
case /** @satisfies {P2PK65AddressIndex} */ (13):
|
||||
return "p2pk65addressindex";
|
||||
case /** @satisfies {P2PKHAddressIndex} */ (14):
|
||||
return "p2pkhaddressindex";
|
||||
case /** @satisfies {P2SHAddressIndex} */ (15):
|
||||
return "p2shaddressindex";
|
||||
case /** @satisfies {P2TRAddressIndex} */ (16):
|
||||
return "p2traddressindex";
|
||||
case /** @satisfies {P2WPKHAddressIndex} */ (17):
|
||||
return "p2wpkhaddressindex";
|
||||
case /** @satisfies {P2WSHAddressIndex} */ (18):
|
||||
return "p2wshaddressindex";
|
||||
case /** @satisfies {QuarterIndex} */ (19):
|
||||
return "quarterindex";
|
||||
case /** @satisfies {SemesterIndex} */ (20):
|
||||
return "semesterindex";
|
||||
case /** @satisfies {TxIndex} */ (21):
|
||||
return "txindex";
|
||||
case /** @satisfies {UnknownOutputIndex} */ (22):
|
||||
return "unknownoutputindex";
|
||||
case /** @satisfies {WeekIndex} */ (23):
|
||||
return "weekindex";
|
||||
case /** @satisfies {YearIndex} */ (24):
|
||||
return "yearindex";
|
||||
case /** @satisfies {LoadedAddressIndex} */ (25):
|
||||
return "loadedaddressindex";
|
||||
case /** @satisfies {EmptyAddressIndex} */ (26):
|
||||
return "emptyaddressindex";
|
||||
}
|
||||
},
|
||||
};
|
||||
4
websites/packages/brk/standalone.js
Normal file
4
websites/packages/brk/standalone.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import signals from "../solidjs-signals/index";
|
||||
import brk from "./index";
|
||||
|
||||
export default () => brk(signals);
|
||||
9
websites/packages/brk/types.js
Normal file
9
websites/packages/brk/types.js
Normal file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* @import { Signal, Signals, Accessor } from "../solidjs-signals/index";
|
||||
*
|
||||
* @import { DateIndex, DecadeIndex, DifficultyEpoch, Index, HalvingEpoch, Height, MonthIndex, P2PK33AddressIndex, P2PK65AddressIndex, P2PKHAddressIndex, P2SHAddressIndex, P2MSOutputIndex, P2AAddressIndex, P2TRAddressIndex, P2WPKHAddressIndex, P2WSHAddressIndex, TxIndex, InputIndex, OutputIndex, WeekIndex, SemesterIndex, YearIndex, MetricToIndexes, QuarterIndex, EmptyOutputIndex, OpReturnIndex, UnknownOutputIndex, EmptyAddressIndex, LoadedAddressIndex } from "./metrics"
|
||||
*
|
||||
* @typedef {[number, number, number, number]} OHLCTuple
|
||||
*
|
||||
* @typedef {any} Metric
|
||||
*/
|
||||
@@ -5,8 +5,6 @@ const iphone = userAgent.includes("iphone");
|
||||
const ipad = userAgent.includes("ipad");
|
||||
const ios = iphone || ipad;
|
||||
|
||||
console.log({ ios });
|
||||
|
||||
/**
|
||||
* @param {Object} args
|
||||
* @param {Element} args.element
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/**
|
||||
* @import { SignalOptions } from "./0.4.11/dist/types/core/core"
|
||||
* @import { getOwner as GetOwner, onCleanup as OnCleanup } from "./0.4.11/dist/types/core/owner"
|
||||
Reference in New Issue
Block a user