mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 22:59:58 -07:00
web: fix index type imports
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* @import * as _ from "../packages/ufuzzy/v1.0.18/types"
|
||||
* @import { SerializedChartableIndex } from "./chart";
|
||||
* @import { Signal, Signals, Accessor } from "../packages/solid-signals/wrapper";
|
||||
* @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, P2PK33AddressIndex, P2PK65AddressIndex, P2PKHAddressIndex, P2SHAddressIndex, P2MSOutputIndex, P2AAddressIndex, P2TRAddressIndex, P2WPKHAddressIndex, P2WSHAddressIndex, TxIndex, InputIndex, OutputIndex, VecId, WeekIndex, YearIndex, VecIdToIndexes, QuarterIndex, EmptyOutputIndex, OpReturnIndex, UnknownOutputIndex } from "./vecid-to-indexes"
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -64,14 +64,14 @@ function initPackages() {
|
||||
const imports = {
|
||||
async signals() {
|
||||
return import("../packages/solid-signals/wrapper.js").then(
|
||||
(d) => d.default,
|
||||
(d) => d.default
|
||||
);
|
||||
},
|
||||
async lightweightCharts() {
|
||||
return window.document.fonts.ready.then(() =>
|
||||
import("../packages/lightweight-charts/wrapper.js").then(
|
||||
(d) => d.default,
|
||||
),
|
||||
(d) => d.default
|
||||
)
|
||||
);
|
||||
},
|
||||
async leanQr() {
|
||||
@@ -79,7 +79,7 @@ function initPackages() {
|
||||
},
|
||||
async ufuzzy() {
|
||||
return import("../packages/ufuzzy/v1.0.18/script.js").then(
|
||||
({ default: d }) => d,
|
||||
({ default: d }) => d
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -587,7 +587,7 @@ function createUtils() {
|
||||
window.history.pushState(
|
||||
null,
|
||||
"",
|
||||
`${pathname}?${urlParams.toString()}`,
|
||||
`${pathname}?${urlParams.toString()}`
|
||||
);
|
||||
} catch (_) {}
|
||||
},
|
||||
@@ -604,7 +604,7 @@ function createUtils() {
|
||||
window.history.replaceState(
|
||||
null,
|
||||
"",
|
||||
`${pathname}?${urlParams.toString()}`,
|
||||
`${pathname}?${urlParams.toString()}`
|
||||
);
|
||||
} catch (_) {}
|
||||
},
|
||||
@@ -1134,23 +1134,23 @@ function createUtils() {
|
||||
return "opreturnindex";
|
||||
case /** @satisfies {OutputIndex} */ (9):
|
||||
return "outputindex";
|
||||
case /** @satisfies {P2AIndex} */ (10):
|
||||
case /** @satisfies {P2AAddressIndex} */ (10):
|
||||
return "p2aaddressindex";
|
||||
case /** @satisfies {P2MSIndex} */ (11):
|
||||
case /** @satisfies {P2MSOutputIndex} */ (11):
|
||||
return "p2msoutputindex";
|
||||
case /** @satisfies {P2PK33Index} */ (12):
|
||||
case /** @satisfies {P2PK33AddressIndex} */ (12):
|
||||
return "p2pk33addressindex";
|
||||
case /** @satisfies {P2PK65Index} */ (13):
|
||||
case /** @satisfies {P2PK65AddressIndex} */ (13):
|
||||
return "p2pk65addressindex";
|
||||
case /** @satisfies {P2PKHIndex} */ (14):
|
||||
case /** @satisfies {P2PKHAddressIndex} */ (14):
|
||||
return "p2pkhaddressindex";
|
||||
case /** @satisfies {P2SHIndex} */ (15):
|
||||
case /** @satisfies {P2SHAddressIndex} */ (15):
|
||||
return "p2shaddressindex";
|
||||
case /** @satisfies {P2TRIndex} */ (16):
|
||||
case /** @satisfies {P2TRAddressIndex} */ (16):
|
||||
return "p2traddressindex";
|
||||
case /** @satisfies {P2WPKHIndex} */ (17):
|
||||
case /** @satisfies {P2WPKHAddressIndex} */ (17):
|
||||
return "p2wpkhaddressindex";
|
||||
case /** @satisfies {P2WSHIndex} */ (18):
|
||||
case /** @satisfies {P2WSHAddressIndex} */ (18):
|
||||
return "p2wshaddressindex";
|
||||
case /** @satisfies {QuarterIndex} */ (19):
|
||||
return "quarterindex";
|
||||
@@ -1248,8 +1248,8 @@ function createUtils() {
|
||||
today.getUTCDate(),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
),
|
||||
0
|
||||
)
|
||||
);
|
||||
},
|
||||
/**
|
||||
@@ -1336,7 +1336,7 @@ function createUtils() {
|
||||
*/
|
||||
function getNumberOfDaysBetweenTwoDates(oldest, youngest) {
|
||||
return Math.round(
|
||||
Math.abs((youngest.getTime() - oldest.getTime()) / date.ONE_DAY_IN_MS),
|
||||
Math.abs((youngest.getTime() - oldest.getTime()) / date.ONE_DAY_IN_MS)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1555,7 +1555,7 @@ function createVecsResources(signals, utils) {
|
||||
const fetchedRecord = signals.createSignal(
|
||||
/** @type {Map<string, {loading: boolean, at: Date | null, vec: Signal<T[] | null>}>} */ (
|
||||
new Map()
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
return {
|
||||
@@ -1605,7 +1605,7 @@ function createVecsResources(signals, utils) {
|
||||
index,
|
||||
id,
|
||||
from,
|
||||
to,
|
||||
to
|
||||
)
|
||||
);
|
||||
fetched.at = new Date();
|
||||
@@ -1866,7 +1866,7 @@ function initWebSockets(signals, utils) {
|
||||
|
||||
window.document.addEventListener(
|
||||
"visibilitychange",
|
||||
reinitWebSocketIfDocumentNotHidden,
|
||||
reinitWebSocketIfDocumentNotHidden
|
||||
);
|
||||
|
||||
window.document.addEventListener("online", reinitWebSocket);
|
||||
@@ -1875,7 +1875,7 @@ function initWebSockets(signals, utils) {
|
||||
ws?.close();
|
||||
window.document.removeEventListener(
|
||||
"visibilitychange",
|
||||
reinitWebSocketIfDocumentNotHidden,
|
||||
reinitWebSocketIfDocumentNotHidden
|
||||
);
|
||||
window.document.removeEventListener("online", reinitWebSocket);
|
||||
live.set(false);
|
||||
@@ -1901,7 +1901,7 @@ function initWebSockets(signals, utils) {
|
||||
symbol: ["BTC/USD"],
|
||||
interval: 1440,
|
||||
},
|
||||
}),
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1930,7 +1930,7 @@ function initWebSockets(signals, utils) {
|
||||
|
||||
/** @type {ReturnType<typeof createWebsocket<CandlestickData>>} */
|
||||
const kraken1dCandle = createWebsocket((callback) =>
|
||||
krakenCandleWebSocketCreator(callback),
|
||||
krakenCandleWebSocketCreator(callback)
|
||||
);
|
||||
|
||||
kraken1dCandle.open();
|
||||
@@ -1989,7 +1989,7 @@ function main() {
|
||||
}
|
||||
|
||||
const frame = window.document.getElementById(
|
||||
/** @type {string} */ (input.value),
|
||||
/** @type {string} */ (input.value)
|
||||
);
|
||||
|
||||
if (!frame) {
|
||||
@@ -2087,23 +2087,23 @@ function main() {
|
||||
|
||||
function initDark() {
|
||||
const preferredColorSchemeMatchMedia = window.matchMedia(
|
||||
"(prefers-color-scheme: dark)",
|
||||
"(prefers-color-scheme: dark)"
|
||||
);
|
||||
const dark = signals.createSignal(
|
||||
preferredColorSchemeMatchMedia.matches,
|
||||
preferredColorSchemeMatchMedia.matches
|
||||
);
|
||||
preferredColorSchemeMatchMedia.addEventListener(
|
||||
"change",
|
||||
({ matches }) => {
|
||||
dark.set(matches);
|
||||
},
|
||||
}
|
||||
);
|
||||
return dark;
|
||||
}
|
||||
const dark = initDark();
|
||||
|
||||
const qrcode = signals.createSignal(
|
||||
/** @type {string | null} */ (null),
|
||||
/** @type {string | null} */ (null)
|
||||
);
|
||||
|
||||
function createLastHeightResource() {
|
||||
@@ -2114,7 +2114,7 @@ function main() {
|
||||
lastHeight.set(h);
|
||||
},
|
||||
/** @satisfies {Height} */ (5),
|
||||
"height",
|
||||
"height"
|
||||
);
|
||||
}
|
||||
fetchLastHeight();
|
||||
@@ -2158,10 +2158,10 @@ function main() {
|
||||
const owner = signals.getOwner();
|
||||
|
||||
const chartOption = signals.createSignal(
|
||||
/** @type {ChartOption | null} */ (null),
|
||||
/** @type {ChartOption | null} */ (null)
|
||||
);
|
||||
const simOption = signals.createSignal(
|
||||
/** @type {SimulationOption | null} */ (null),
|
||||
/** @type {SimulationOption | null} */ (null)
|
||||
);
|
||||
|
||||
let previousElement = /** @type {HTMLElement | undefined} */ (
|
||||
@@ -2207,9 +2207,9 @@ function main() {
|
||||
webSockets,
|
||||
vecsResources,
|
||||
vecIdToIndexes,
|
||||
}),
|
||||
),
|
||||
),
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
firstTimeLoadingChart = false;
|
||||
@@ -2229,8 +2229,8 @@ function main() {
|
||||
vecsResources,
|
||||
option,
|
||||
vecIdToIndexes,
|
||||
}),
|
||||
),
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
firstTimeLoadingTable = false;
|
||||
@@ -2254,9 +2254,9 @@ function main() {
|
||||
signals,
|
||||
utils,
|
||||
vecsResources,
|
||||
}),
|
||||
),
|
||||
),
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
firstTimeLoadingSimulation = false;
|
||||
@@ -2285,7 +2285,7 @@ function main() {
|
||||
createMobileSwitchEffect();
|
||||
|
||||
utils.dom.onFirstIntersection(elements.aside, () =>
|
||||
signals.runWithOwner(owner, initSelectedFrame),
|
||||
signals.runWithOwner(owner, initSelectedFrame)
|
||||
);
|
||||
}
|
||||
initSelected();
|
||||
@@ -2365,7 +2365,7 @@ function main() {
|
||||
if (indexes?.length) {
|
||||
const maxIndex = Math.min(
|
||||
(order || indexes).length - 1,
|
||||
minIndex + RESULTS_PER_PAGE - 1,
|
||||
minIndex + RESULTS_PER_PAGE - 1
|
||||
);
|
||||
|
||||
list = Array(maxIndex - minIndex + 1);
|
||||
@@ -2441,7 +2441,7 @@ function main() {
|
||||
haystack,
|
||||
needle,
|
||||
undefined,
|
||||
infoThresh,
|
||||
infoThresh
|
||||
);
|
||||
|
||||
if (!result?.[0]?.length || !result?.[1]) {
|
||||
@@ -2449,7 +2449,7 @@ function main() {
|
||||
haystack,
|
||||
needle,
|
||||
outOfOrder,
|
||||
infoThresh,
|
||||
infoThresh
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2458,7 +2458,7 @@ function main() {
|
||||
haystack,
|
||||
needle,
|
||||
outOfOrder,
|
||||
infoThresh,
|
||||
infoThresh
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2467,7 +2467,7 @@ function main() {
|
||||
haystack,
|
||||
needle,
|
||||
outOfOrder,
|
||||
infoThresh,
|
||||
infoThresh
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2476,7 +2476,7 @@ function main() {
|
||||
haystack,
|
||||
needle,
|
||||
undefined,
|
||||
infoThresh,
|
||||
infoThresh
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2485,7 +2485,7 @@ function main() {
|
||||
haystack,
|
||||
needle,
|
||||
outOfOrder,
|
||||
infoThresh,
|
||||
infoThresh
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2568,7 +2568,7 @@ function main() {
|
||||
|
||||
shareDiv.hidden = false;
|
||||
});
|
||||
}),
|
||||
})
|
||||
);
|
||||
}
|
||||
initShare();
|
||||
@@ -2592,7 +2592,7 @@ function main() {
|
||||
utils.storage.write(barWidthLocalStorageKey, String(width));
|
||||
} else {
|
||||
elements.main.style.width = elements.style.getPropertyValue(
|
||||
"--default-main-width",
|
||||
"--default-main-width"
|
||||
);
|
||||
utils.storage.remove(barWidthLocalStorageKey);
|
||||
}
|
||||
@@ -2629,9 +2629,9 @@ function main() {
|
||||
window.addEventListener("mouseleave", setResizeFalse);
|
||||
}
|
||||
initDesktopResizeBar();
|
||||
}),
|
||||
),
|
||||
),
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
main();
|
||||
|
||||
@@ -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[]} */ ([])
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -322,11 +322,11 @@ function createTable({
|
||||
unit,
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return () => vecId;
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -393,7 +393,7 @@ export function init({
|
||||
},
|
||||
inside: span,
|
||||
title: "Click or tap to add a column to the table",
|
||||
}),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -459,23 +459,23 @@ function serializedIndexToIndex(serializedIndex) {
|
||||
case "outputindex":
|
||||
return /** @satisfies {OutputIndex} */ (9);
|
||||
case "p2pk33addressindex":
|
||||
return /** @satisfies {P2PK33Index} */ (12);
|
||||
return /** @satisfies {P2PK33AddressIndex} */ (12);
|
||||
case "p2pk65addressindex":
|
||||
return /** @satisfies {P2PK65Index} */ (13);
|
||||
return /** @satisfies {P2PK65AddressIndex} */ (13);
|
||||
case "p2pkhaddressindex":
|
||||
return /** @satisfies {P2PKHIndex} */ (14);
|
||||
return /** @satisfies {P2PKHAddressIndex} */ (14);
|
||||
case "p2shaddressindex":
|
||||
return /** @satisfies {P2SHIndex} */ (15);
|
||||
return /** @satisfies {P2SHAddressIndex} */ (15);
|
||||
case "p2traddressindex":
|
||||
return /** @satisfies {P2TRIndex} */ (16);
|
||||
return /** @satisfies {P2TRAddressIndex} */ (16);
|
||||
case "p2wpkhaddressindex":
|
||||
return /** @satisfies {P2WPKHIndex} */ (17);
|
||||
return /** @satisfies {P2WPKHAddressIndex} */ (17);
|
||||
case "p2wshaddressindex":
|
||||
return /** @satisfies {P2WSHIndex} */ (18);
|
||||
return /** @satisfies {P2WSHAddressIndex} */ (18);
|
||||
case "p2aaddressindex":
|
||||
return /** @satisfies {P2AIndex} */ (10);
|
||||
return /** @satisfies {P2AAddressIndex} */ (10);
|
||||
case "p2msoutputindex":
|
||||
return /** @satisfies {P2MSIndex} */ (11);
|
||||
return /** @satisfies {P2MSOutputIndex} */ (11);
|
||||
case "opreturnindex":
|
||||
return /** @satisfies {OpReturnIndex} */ (8);
|
||||
case "emptyoutputindex":
|
||||
@@ -498,7 +498,7 @@ function createIndexToVecIds(vecIdToIndexes) {
|
||||
});
|
||||
return arr;
|
||||
},
|
||||
/** @type {VecId[][]} */ (Array.from({ length: 24 })),
|
||||
/** @type {VecId[][]} */ (Array.from({ length: 24 }))
|
||||
);
|
||||
indexToVecIds.forEach((arr) => {
|
||||
arr.sort();
|
||||
|
||||
Reference in New Issue
Block a user