From 248187889283597c5dbb806292297453c25e97b8 Mon Sep 17 00:00:00 2001 From: k Date: Mon, 8 Jul 2024 19:57:30 +0200 Subject: [PATCH] release: v0.2.0 --- app/src/app/components/background.tsx | 3 + .../frames/chart/components/chart.tsx | 3 +- app/src/app/components/frames/settings.tsx | 6 +- app/src/app/index.tsx | 2 - app/src/env.ts | 10 +- app/src/scripts/lightweightCharts/markers.ts | 183 +++++++++--------- app/src/scripts/lightweightCharts/time.ts | 15 +- app/src/scripts/presets/apply.ts | 49 ++++- .../scripts/presets/market/averages/index.ts | 4 - app/src/scripts/ws/kraken.ts | 5 +- app/src/types/self.d.ts | 2 +- 11 files changed, 163 insertions(+), 119 deletions(-) diff --git a/app/src/app/components/background.tsx b/app/src/app/components/background.tsx index 263c854c9..355103987 100644 --- a/app/src/app/components/background.tsx +++ b/app/src/app/components/background.tsx @@ -5,6 +5,7 @@ const texts = [ "satonomics", "satonomics", "satonomics", + "satonomics", "stay humble, stack sats", "21 million", @@ -39,6 +40,8 @@ const texts = [ "low time preference", "absolute scarcity", "time is scarce", + "ride or die", + "cyberpunk", ]; export function Background({ diff --git a/app/src/app/components/frames/chart/components/chart.tsx b/app/src/app/components/frames/chart/components/chart.tsx index 84bee5390..1406e0ee1 100644 --- a/app/src/app/components/frames/chart/components/chart.tsx +++ b/app/src/app/components/frames/chart/components/chart.tsx @@ -1,3 +1,4 @@ +import { requestIdleCallbackPossible } from "/src/env"; import { createRWS } from "/src/solid/rws"; export function Chart({ @@ -19,7 +20,7 @@ export function Chart({ }) { const wasIdle = createRWS(false); - if ("requestIdleCallback" in window) { + if (requestIdleCallbackPossible) { const idleCallback = requestIdleCallback(() => { console.log("idle"); wasIdle.set(true); diff --git a/app/src/app/components/frames/settings.tsx b/app/src/app/components/frames/settings.tsx index 9282c4356..0846f4439 100644 --- a/app/src/app/components/frames/settings.tsx +++ b/app/src/app/components/frames/settings.tsx @@ -1,5 +1,5 @@ import { version } from "/src/../package.json"; -import { chrome, ipad, iphone, macOS, safari, standalone } from "/src/env"; +import { ipad, iphone, macOS, safariOnly, standalone } from "/src/env"; import { classPropToString } from "/src/solid/classes"; import { AnchorAPI } from "../strip/components/anchorAPI"; @@ -156,9 +156,7 @@ export function SettingsFrame({ - +
diff --git a/app/src/app/index.tsx b/app/src/app/index.tsx index 11e92b206..9e1afc7cb 100644 --- a/app/src/app/index.tsx +++ b/app/src/app/index.tsx @@ -225,8 +225,6 @@ export function App() { document.addEventListener("keydown", documentOnKeyDown); onCleanup(() => document.removeEventListener("keydown", documentOnKeyDown)); - const resizeInitialRange = createRWS(null); - const SearchFrame = lazy(() => import("./components/frames/search").then((d) => ({ default: d.SearchFrame, diff --git a/app/src/env.ts b/app/src/env.ts index 8ec1956cb..d2be3f7c5 100644 --- a/app/src/env.ts +++ b/app/src/env.ts @@ -6,6 +6,8 @@ export const touchScreen = navigator.maxTouchPoints > 0 || (navigator as any).msMaxTouchPoints > 0; +export const requestIdleCallbackPossible = "requestIdleCallback" in window; + console.log(navigator.userAgent); export const macOS = navigator.userAgent.toLowerCase().includes("mac os"); @@ -13,9 +15,15 @@ export const iphone = navigator.userAgent.toLowerCase().includes("iphone"); export const ipad = navigator.userAgent.toLowerCase().includes("ipad"); +export const chrome = navigator.userAgent.toLowerCase().includes("chrome"); + +export const firefox = navigator.userAgent.toLowerCase().includes("firefox"); + +export const gecko = navigator.userAgent.toLowerCase().includes("gecko"); + export const safari = navigator.userAgent.toLowerCase().includes("safari"); -export const chrome = navigator.userAgent.toLowerCase().includes("chrome"); +export const safariOnly = safari && !chrome; export const phone = /Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test( diff --git a/app/src/scripts/lightweightCharts/markers.ts b/app/src/scripts/lightweightCharts/markers.ts index 570abc407..be4a8fcdc 100644 --- a/app/src/scripts/lightweightCharts/markers.ts +++ b/app/src/scripts/lightweightCharts/markers.ts @@ -1,128 +1,135 @@ import { colors } from "/src/scripts/utils/colors"; import { chunkIdToIndex } from "../datasets/resource"; +import { valueToString } from "../utils/locale"; export function setMinMaxMarkers({ scale, visibleRange, legendList, activeIds, + dark, }: { scale: ResourceScale; visibleRange: TimeRange | undefined; legendList: SeriesLegend[]; activeIds: Accessor; + dark: Accessor; }) { - if (!visibleRange) return; + try { + if (!visibleRange) return; - const { from, to } = visibleRange; + const { from, to } = visibleRange; - const dateFrom = new Date(from as string); - const dateTo = new Date(to as string); + const dateFrom = new Date(from as string); + const dateTo = new Date(to as string); - let max = undefined as [number, Time, number, ISeriesApi] | undefined; - let min = undefined as [number, Time, number, ISeriesApi] | undefined; + let max = undefined as [number, Time, number, ISeriesApi] | undefined; + let min = undefined as [number, Time, number, ISeriesApi] | undefined; - legendList.forEach(({ seriesList, dataset }) => { - activeIds().forEach((id) => { - const seriesIndex = chunkIdToIndex(scale, id); + const ids = activeIds(); - const series = seriesList.at(seriesIndex)?.(); + for (let i = 0; i < legendList.length; i++) { + const { seriesList, dataset } = legendList[i]; - if (!series || !series?.options().visible) return; + for (let j = 0; j < ids.length; j++) { + const id = ids[j]; - series.setMarkers([]); + const seriesIndex = chunkIdToIndex(scale, id); - const isCandlestick = series.seriesType() === "Candlestick"; + const series = seriesList.at(seriesIndex)?.(); - const vec = dataset.fetchedJSONs.at(seriesIndex)?.vec(); + if (!series || !series?.options().visible) continue; - if (!vec) return; + series.setMarkers([]); - for (let i = 0; i < vec.length; i++) { - const data = vec[i]; + const isCandlestick = series.seriesType() === "Candlestick"; - let number; + const vec = dataset.fetchedJSONs.at(seriesIndex)?.vec(); - if (scale === "date") { - const date = new Date( - typeof data.time === "string" - ? data.time - : // @ts-ignore - `${data.time.year}-${data.time.month}-${data.time.day}`, - ); + if (!vec) return; - number = date.getTime(); + for (let k = 0; k < vec.length; k++) { + const data = vec[k]; - if (date <= dateFrom || date >= dateTo) { - continue; + let number; + + if (scale === "date") { + const date = + typeof data.time === "string" + ? new Date(data.time) + : // @ts-ignore + new Date(data.time.year, data.time.month, data.time.day); + + number = date.getTime(); + + if (date <= dateFrom || date >= dateTo) { + continue; + } + } else { + const height = data.time; + + number = height as number; + + if (height <= from || height >= to) { + continue; + } } - } else { - const height = data.time; - number = height as number; + // @ts-ignore + const high = isCandlestick ? data["high"] : data.value; + // @ts-ignore + const low = isCandlestick ? data["low"] : data.value; - if (height <= from || height >= to) { - continue; + if (!max || high > max[2]) { + max = [number, data.time, high, series]; + } + if (!min || low < min[2]) { + min = [number, data.time, low, series]; } - } - - // @ts-ignore - const high = isCandlestick ? data["high"] : data.value; - // @ts-ignore - const low = isCandlestick ? data["low"] : data.value; - - if (!max || high > max[2]) { - max = [number, data.time, high, series]; - } - if (!min || low < min[2]) { - min = [number, data.time, low, series]; } } - }); - }); - - let minMarker: (SeriesMarker