server: add support for .json .csv and ?all=true

This commit is contained in:
k
2024-10-16 18:38:43 +02:00
parent 4cdc9ef9b3
commit 608ccafc70
66 changed files with 12150 additions and 11014 deletions
File diff suppressed because it is too large Load Diff
+309
View File
@@ -0,0 +1,309 @@
/**
* @import {Options} from './options';
*/
/**
* @param {Object} args
* @param {Flexmasonry} args.flexmasonry
* @param {Signal<Record<LastPath, number> | null>} args.lastValues
* @param {Options} args.options
* @param {Accessor<DashboardOption>} args.selected
* @param {Signals} args.signals
* @param {Elements} args.elements
* @param {Utilities} args.utils
*/
export function initDashboardElement({
elements,
flexmasonry,
lastValues,
options,
selected,
signals,
utils,
}) {
flexmasonry.destroyAll();
const element = elements.dashboard;
element.innerHTML = "";
/**
* @param {HTMLElement} parent
* @param {string} name
* @param {boolean} [defaultOpen]
*/
function createDetails(parent, name, defaultOpen) {
const details = window.document.createElement("details");
details.open = defaultOpen || false;
parent.append(details);
const summary = window.document.createElement("summary");
summary.innerHTML = name;
details.append(summary);
const div = window.document.createElement("div");
details.append(div);
return div;
}
/**
* @param {HTMLElement} parent
* @param {string} name
*/
function createTable(parent, name) {
const table = window.document.createElement("table");
parent.append(table);
const tbody = window.document.createElement("tbody");
table.append(tbody);
return tbody;
}
/**
* @param {Object} args
* @param {HTMLTableSectionElement} args.tbody
* @param {string} args.name
* @param {Unit} [args.unit]
* @param {string} args.path
* @param {boolean} [args.formatNumber]
*/
function createRow({ tbody, unit, name, path, formatNumber }) {
path = path.replace("date-to-", "").replace("height-to-", "");
const tr = window.document.createElement("tr");
tbody.append(tr);
const tdName = window.document.createElement("td");
tr.append(tdName);
const a = window.document.createElement("a");
a.href = path;
a.innerHTML = name;
tdName.append(a);
const tdValue = window.document.createElement("td");
const preSmall = window.document.createElement("small");
tdValue.append(preSmall);
const valueSpan = window.document.createElement("span");
tdValue.append(valueSpan);
const postSmall = window.document.createElement("small");
tdValue.append(postSmall);
signals.createEffect(() => {
const _lastValues = lastValues();
if (!_lastValues || !(path in _lastValues)) return;
const value = _lastValues[/** @type {LastPath} */ (path)] ?? 0;
tdValue.title = `${utils.locale.numberToUSFormat(value ?? 0)}`;
const formattedValue =
formatNumber ?? unit !== "Count"
? utils.locale.numberToShortUSFormat(value)
: utils.locale.numberToUSFormat(
value,
unit === "Count" ? 0 : undefined,
);
if (unit === "Date") {
valueSpan.innerHTML = String(value);
postSmall.innerHTML = ` UTC`;
return;
}
valueSpan.innerHTML = formattedValue;
switch (unit) {
case "US Dollars": {
preSmall.innerHTML = `$`;
break;
}
case "Bitcoin": {
preSmall.innerHTML = ``;
break;
}
case "Percentage": {
postSmall.innerHTML = `%`;
break;
}
case "Seconds": {
postSmall.innerHTML = ` sec`;
break;
}
case "Megabytes": {
postSmall.innerHTML = ` MB`;
break;
}
}
});
tr.append(tdValue);
}
// selected().groups.forEach(({ name, values, unit: groupUnit }) => {
// const tbody = createTable(name);
// values.forEach(({ name, path, unit: valueUnit, formatNumber }) => {
// const unit = groupUnit ?? valueUnit;
// createRow({
// name,
// tbody,
// path,
// unit,
// formatNumber,
// });
// });
// });
//
/** @type {HTMLTableSectionElement | null} */
let currentTbody = null;
const separator = " · ";
/**
* @param {Object} args
* @param {OptionsTree} args.tree
* @param {{group: OptionsGroup; element: HTMLElement} | null} args.parent
* @param {string[]} [args.namePre]
*/
function recursiveOptionConverter({ tree, parent, namePre }) {
tree.forEach((anyOption) => {
if ("tree" in anyOption) {
currentTbody = null;
const group = anyOption;
if (!group.tree.length || group.dashboard?.skip) return;
if (!parent || group.dashboard?.separate) {
recursiveOptionConverter({
tree: group.tree,
parent: {
group,
element: createDetails(
element,
group.name,
group.dashboard?.defaultOpen,
),
},
namePre,
});
} else {
const pre = group.dashboard?.flatten
? [...(namePre || []), group.name]
: [];
let element = parent.element;
if (!group.dashboard?.flatten) {
element = createDetails(
parent.element,
group.name,
group.dashboard?.defaultOpen,
);
}
recursiveOptionConverter({
tree: group.tree,
parent: {
group,
element,
},
namePre: pre,
});
}
} else if (anyOption.kind === "chart" && parent) {
currentTbody ||= createTable(
parent.element,
(namePre || []).join(separator),
);
if (!currentTbody) throw "Shouldn't be possible";
const tbody = currentTbody;
const option = anyOption;
if (option.dashboard?.skip) return;
const { top, bottom } = option;
const topLength = top?.length ?? 0;
const bottomLength = bottom?.length ?? 0;
/**
* @param {SeriesBlueprint[]} array
*/
function createRowFromBlueprint(array) {
const searchArray = array.filter(
(blueprint) =>
blueprint.options?.lastValueVisible !== false &&
/** @type {LineStyleOptions | undefined} */ (blueprint.options)
?.lineStyle === undefined,
);
const blueprint =
searchArray.length === 1
? searchArray[0]
: searchArray.find((blueprint) => blueprint.main);
if (!blueprint) return;
let name = namePre?.join(separator) || "";
if (!option.dashboard?.ignoreName) {
if (name) {
name += separator;
}
name += option.name;
}
createRow({
name,
tbody,
path: blueprint.datasetPath,
unit: option.unit,
formatNumber: blueprint.formatNumber,
});
}
if (!topLength && !bottomLength) {
createRow({
name: option.name,
tbody,
path: "close",
unit: option.unit,
formatNumber: false,
});
} else if (top && bottomLength === 0) {
createRowFromBlueprint(top);
} else if (bottom) {
createRowFromBlueprint(bottom);
}
} else if (parent && "unit" in anyOption) {
createRow({
name: anyOption.name,
tbody: currentTbody,
path: anyOption.path,
unit: anyOption.unit,
formatNumber: false,
});
}
});
currentTbody = null;
}
recursiveOptionConverter({
tree: /** @type {OptionsGroup} */ (
/** @type {OptionsGroup} */ (options.tree[1]).tree[0]
).tree,
parent: null,
});
flexmasonry.init([element]);
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,3 @@
URL + Version:
https://unpkg.com/browse/flexmasonry@latest/
@@ -0,0 +1,198 @@
const defaultOptions = {
/*
* If `responsive` is `true`, `breakpointCols` will be used to determine
* how many columns a grid should have at a given responsive breakpoint.
*/
responsive: true,
/*
* A list of how many columns should be shown at different responsive
* breakpoints, defined by media queries.
*/
breakpointCols: {
1500: 5,
1200: 4,
992: 3,
768: 2,
576: 1,
},
/*
* If `responsive` is `false`, this number of columns will always be shown,
* no matter the width of the screen.
*/
numCols: 4,
};
let _resizeId = null;
let _options = {};
let _targets = [];
function init(targets, options = {}) {
if (typeof targets === "string") {
_targets = document.querySelectorAll(targets);
} else {
_targets = targets;
}
_options = Object.assign(defaultOptions, options);
_targets.forEach(function (target) {
setUp(target);
// setHeight(target);
});
addEventListeners();
return this;
}
function setUp(target) {
target.classList.add("flexmasonry");
if (_options.responsive) {
target.classList.add("flexmasonry-responsive");
}
setColsClass(target);
Array.from(target.children).forEach(function (item) {
item.classList.add("flexmasonry-item");
});
addBreakElements(target);
}
// function onLoad() {
// _targets.forEach(function (target) {
// setHeight(target);
// });
// }
function onResize() {
if (_resizeId) {
window.cancelAnimationFrame(_resizeId);
}
_resizeId = window.requestAnimationFrame(function () {
refreshAll();
});
}
function addEventListeners() {
// window.addEventListener("load", onLoad);
window.addEventListener("resize", onResize);
}
function removeEventListeners() {
// window.removeEventListener("load", onLoad);
window.removeEventListener("resize", onResize);
}
// function setHeight(target) {
// if (getCurrentCols(target) < 2) {
// target.style.removeProperty("height");
// return;
// }
// let heights = [];
// Array.from(target.children).forEach(function (item) {
// if (item.classList.contains("flexmasonry-break")) {
// return;
// }
// const comp = window.getComputedStyle(item);
// const order = comp.getPropertyValue("order");
// const height = comp.getPropertyValue("height");
// if (!heights[order - 1]) {
// heights[order - 1] = 0;
// }
// heights[order - 1] += Math.ceil(parseFloat(height));
// });
// const maxHeight = Math.max(...heights);
// target.style.height = maxHeight + "px";
// }
function addBreakElements(target) {
const breakEls = target.querySelectorAll(".flexmasonry-break");
if (Array.from(breakEls).length === getCurrentCols(target) - 1) {
return;
}
for (let i = 1; i < getCurrentCols(target); i++) {
const breakDiv = document.createElement("div");
breakDiv.classList.add("flexmasonry-break");
breakDiv.classList.add("flexmasonry-break-" + i);
target.appendChild(breakDiv);
}
}
function removeBreakElements(target) {
const breakEls = target.querySelectorAll(".flexmasonry-break");
if (Array.from(breakEls).length === getCurrentCols(target) - 1) {
return;
}
Array.from(breakEls).forEach(function (breakEl) {
breakEl.parentNode.removeChild(breakEl);
});
}
function setColsClass(target) {
if (target.classList.contains("flexmasonry-cols-" + getCurrentCols(target))) {
return;
}
target.className = target.className.replace(/(flexmasonry-cols-\d+)/, "");
target.classList.add("flexmasonry-cols-" + getCurrentCols(target));
}
function getCurrentCols(target) {
if (!_options.responsive) {
return _options.numCols;
}
const descendingMinWidths = Object.keys(_options.breakpointCols)
.map((key) => Number(key))
.sort()
.reverse();
for (const minWidth of descendingMinWidths) {
if (target.clientWidth >= minWidth) {
return _options.breakpointCols[minWidth];
}
}
return 1;
}
function refresh(target, options = {}) {
_options = Object.assign(defaultOptions, options);
setColsClass(target);
removeBreakElements(target);
addBreakElements(target);
// setHeight(target);
return this;
}
function refreshAll(options = {}) {
_targets.forEach(function (target) {
refresh(target, options);
});
return this;
}
function destroyAll() {
removeEventListeners();
}
export default {
init,
refresh,
refreshAll,
destroyAll,
};
@@ -0,0 +1,170 @@
.flexmasonry {
display: flex;
flex-flow: column wrap;
align-content: space-between;
}
.flexmasonry-item {
width: 100%;
}
.flexmasonry-cols-2 .flexmasonry-item {
width: 50%;
}
.flexmasonry-cols-3 .flexmasonry-item {
width: 33.333%;
}
.flexmasonry-cols-4 .flexmasonry-item {
width: 25%;
}
.flexmasonry-cols-5 .flexmasonry-item {
width: 20%;
}
.flexmasonry-cols-6 .flexmasonry-item {
width: 16.666%;
}
.flexmasonry-cols-7 .flexmasonry-item {
width: 14.285%;
}
.flexmasonry-cols-8 .flexmasonry-item {
width: 12.5%;
}
.flexmasonry-cols-2 .flexmasonry-item:nth-child(2n + 1) {
order: 1;
}
.flexmasonry-cols-2 .flexmasonry-item:nth-child(2n) {
order: 2;
}
.flexmasonry-cols-3 .flexmasonry-item:nth-child(3n + 1) {
order: 1;
}
.flexmasonry-cols-3 .flexmasonry-item:nth-child(3n + 2) {
order: 2;
}
.flexmasonry-cols-3 .flexmasonry-item:nth-child(3n) {
order: 3;
}
.flexmasonry-cols-4 .flexmasonry-item:nth-child(4n + 1) {
order: 1;
}
.flexmasonry-cols-4 .flexmasonry-item:nth-child(4n + 2) {
order: 2;
}
.flexmasonry-cols-4 .flexmasonry-item:nth-child(4n + 3) {
order: 3;
}
.flexmasonry-cols-4 .flexmasonry-item:nth-child(4n) {
order: 4;
}
.flexmasonry-cols-5 .flexmasonry-item:nth-child(5n + 1) {
order: 1;
}
.flexmasonry-cols-5 .flexmasonry-item:nth-child(5n + 2) {
order: 2;
}
.flexmasonry-cols-5 .flexmasonry-item:nth-child(5n + 3) {
order: 3;
}
.flexmasonry-cols-5 .flexmasonry-item:nth-child(5n + 4) {
order: 4;
}
.flexmasonry-cols-5 .flexmasonry-item:nth-child(5n) {
order: 5;
}
.flexmasonry-cols-6 .flexmasonry-item:nth-child(6n + 1) {
order: 1;
}
.flexmasonry-cols-6 .flexmasonry-item:nth-child(6n + 2) {
order: 2;
}
.flexmasonry-cols-6 .flexmasonry-item:nth-child(6n + 3) {
order: 3;
}
.flexmasonry-cols-6 .flexmasonry-item:nth-child(6n + 4) {
order: 4;
}
.flexmasonry-cols-6 .flexmasonry-item:nth-child(6n + 5) {
order: 5;
}
.flexmasonry-cols-6 .flexmasonry-item:nth-child(6n) {
order: 6;
}
.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n + 1) {
order: 1;
}
.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n + 2) {
order: 2;
}
.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n + 3) {
order: 3;
}
.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n + 4) {
order: 4;
}
.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n + 5) {
order: 5;
}
.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n + 6) {
order: 6;
}
.flexmasonry-cols-7 .flexmasonry-item:nth-child(7n) {
order: 7;
}
.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n + 1) {
order: 1;
}
.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n + 2) {
order: 2;
}
.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n + 3) {
order: 3;
}
.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n + 4) {
order: 4;
}
.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n + 5) {
order: 5;
}
.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n + 6) {
order: 6;
}
.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n + 7) {
order: 7;
}
.flexmasonry-cols-8 .flexmasonry-item:nth-child(8n) {
order: 8;
}
.flexmasonry-break {
content: "";
flex-basis: 100%;
width: 0 !important;
margin: 0;
}
.flexmasonry-break-1 {
order: 1;
}
.flexmasonry-break-2 {
order: 2;
}
.flexmasonry-break-3 {
order: 3;
}
.flexmasonry-break-4 {
order: 4;
}
.flexmasonry-break-5 {
order: 5;
}
.flexmasonry-break-6 {
order: 6;
}
.flexmasonry-break-7 {
order: 7;
}
@@ -0,0 +1,3 @@
URL + Version:
https://unpkg.com/browse/lean-qr@latest/
File diff suppressed because one or more lines are too long
+241
View File
@@ -0,0 +1,241 @@
declare module "lean-qr" {
interface ImageDataLike {
readonly data: Uint8ClampedArray;
}
interface Context2DLike<DataT extends ImageDataLike> {
createImageData(width: number, height: number): DataT;
putImageData(data: DataT, x: number, y: number): void;
}
interface CanvasLike<DataT extends ImageDataLike> {
width: number;
height: number;
getContext(type: "2d"): Context2DLike<DataT> | null;
}
export type RGBA = readonly [number, number, number, number?];
export interface Bitmap1D {
push(value: number, bits: number): void;
}
export interface StringOptions {
on?: string;
off?: string;
lf?: string;
padX?: number;
padY?: number;
}
export interface ImageDataOptions {
on?: RGBA;
off?: RGBA;
padX?: number;
padY?: number;
}
export interface Bitmap2D {
readonly size: number;
get(x: number, y: number): boolean;
toString(options?: Readonly<StringOptions>): string;
toImageData<DataT extends ImageDataLike>(
context: Context2DLike<DataT>,
options?: Readonly<ImageDataOptions>,
): DataT;
toDataURL(
options?: Readonly<
ImageDataOptions & {
type?: `image/${string}`;
scale?: number;
}
>,
): string;
toCanvas(
canvas: CanvasLike<ImageDataLike>,
options?: Readonly<ImageDataOptions>,
): void;
}
export type Mask = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
export type Mode = (data: Bitmap1D, version: number) => void;
export interface ModeFactory {
(value: string): Mode;
test(string: string): boolean;
est(value: string, version: number): number;
eci?: number;
}
interface ModeAutoOptions {
modes?: ReadonlyArray<ModeFactory>;
}
export const mode: Readonly<{
auto(value: string, options?: Readonly<ModeAutoOptions>): Mode;
multi(...modes: ReadonlyArray<Mode>): Mode;
eci(id: number): Mode;
numeric: ModeFactory;
alphaNumeric: ModeFactory;
bytes(data: Uint8Array | ReadonlyArray<number>): Mode;
ascii: ModeFactory;
iso8859_1: ModeFactory;
shift_jis: ModeFactory;
utf8: ModeFactory;
}>;
type Correction = number & { readonly _: unique symbol };
export const correction: Readonly<{
min: Correction;
L: Correction;
M: Correction;
Q: Correction;
H: Correction;
max: Correction;
}>;
export interface GenerateOptions extends ModeAutoOptions {
minCorrectionLevel?: Correction;
maxCorrectionLevel?: Correction;
minVersion?: number;
maxVersion?: number;
mask?: null | Mask;
trailer?: number;
}
export type GenerateFn = (
data: Mode | string,
options?: Readonly<GenerateOptions>,
) => Bitmap2D;
interface Generate extends GenerateFn {
with(...modes: ReadonlyArray<ModeFactory>): GenerateFn;
}
export const generate: Generate;
}
declare module "lean-qr/extras/svg" {
import type { Bitmap2D } from "lean-qr";
export interface SVGOptions {
on?: string;
off?: string;
padX?: number;
padY?: number;
width?: number | null;
height?: number | null;
scale?: number;
}
export const toSvgPath: (code: Bitmap2D) => string;
export const toSvg: (
code: Bitmap2D,
target: Document | SVGElement,
options?: Readonly<SVGOptions>,
) => SVGElement;
export const toSvgSource: (
code: Bitmap2D,
options?: Readonly<SVGOptions & { xmlDeclaration?: boolean }>,
) => string;
export type toSvgDataURLFn = (
code: Bitmap2D,
options?: Readonly<SVGOptions>,
) => string;
export const toSvgDataURL: toSvgDataURLFn;
}
declare module "lean-qr/extras/node_export" {
import type { RGBA, Bitmap2D } from "lean-qr";
export interface PNGOptions {
on?: RGBA;
off?: RGBA;
padX?: number;
padY?: number;
scale?: number;
}
export const toPngBuffer: (
code: Bitmap2D,
options?: Readonly<PNGOptions>,
) => Uint8Array;
export const toPngDataURL: (
code: Bitmap2D,
options?: Readonly<PNGOptions>,
) => string;
}
declare module "lean-qr/extras/react" {
import type { ImageDataOptions, GenerateOptions, GenerateFn } from "lean-qr";
import type { SVGOptions, toSvgDataURLFn } from "lean-qr/extras/svg";
export interface AsyncFramework<T> {
createElement: (
type: "canvas",
props: {
ref: any;
style: { imageRendering: "pixelated" };
className: string;
},
) => T;
useRef<T>(initialValue: T | null): { readonly current: T | null };
useEffect(fn: () => void | (() => void), deps: unknown[]): void;
}
interface QRComponentProps {
content: string;
className?: string;
}
export interface AsyncQRComponentProps
extends ImageDataOptions,
GenerateOptions,
QRComponentProps {}
export type AsyncQRComponent<T> = (
props: Readonly<AsyncQRComponentProps>,
) => T;
export const makeAsyncComponent: <T>(
framework: Readonly<AsyncFramework<T>>,
generate: GenerateFn,
defaultProps?: Readonly<Partial<AsyncQRComponentProps>>,
) => AsyncQRComponent<T>;
export interface SyncFramework<T> {
createElement: (
type: "img",
props: {
src: string;
style: { imageRendering: "pixelated" };
className: string;
},
) => T;
useMemo<T>(fn: () => T, deps: unknown[]): T;
}
export interface SyncQRComponentProps
extends SVGOptions,
GenerateOptions,
QRComponentProps {}
export type SyncQRComponent<T> = (props: Readonly<SyncQRComponentProps>) => T;
export const makeSyncComponent: <T>(
framework: Readonly<SyncFramework<T>>,
generate: GenerateFn,
toSvgDataURL: toSvgDataURLFn,
defaultProps?: Readonly<Partial<SyncQRComponentProps>>,
) => SyncQRComponent<T>;
}
declare module "lean-qr/extras/errors" {
export const readError: (error: unknown) => string;
}
@@ -0,0 +1,2 @@
TradingView Lightweight Charts™
Copyright (с) 2023 TradingView, Inc. https://www.tradingview.com/
@@ -0,0 +1,3 @@
URL + Version:
https://unpkg.com/browse/lightweight-charts@latest/
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,10 @@
/**
* See https://dev.to/modderme123/super-charging-fine-grained-reactive-performance-47ph
* State clean corresponds to a node where all the sources are fully up to date
* State check corresponds to a node where some sources (including grandparents) may have changed
* State dirty corresponds to a node where the direct parents of a node has changed
*/
export declare const STATE_CLEAN = 0;
export declare const STATE_CHECK = 1;
export declare const STATE_DIRTY = 2;
export declare const STATE_DISPOSED = 3;
@@ -0,0 +1,143 @@
/**
* Nodes for constructing a graph of reactive values and reactive computations.
*
* - The graph is acyclic.
* - The user inputs new values into the graph by calling .write() on one more computation nodes.
* - The user retrieves computed results from the graph by calling .read() on one or more computation nodes.
* - The library is responsible for running any necessary computations so that .read() is up to date
* with all prior .write() calls anywhere in the graph.
* - We call the input nodes 'roots' and the output nodes 'leaves' of the graph here.
* - Changes flow from roots to leaves. It would be effective but inefficient to immediately
* propagate all changes from a root through the graph to descendant leaves. Instead, we defer
* change most change propagation computation until a leaf is accessed. This allows us to
* coalesce computations and skip altogether recalculating unused sections of the graph.
* - Each computation node tracks its sources and its observers (observers are other
* elements that have this node as a source). Source and observer links are updated automatically
* as observer computations re-evaluate and call get() on their sources.
* - Each node stores a cache state (clean/check/dirty) to support the change propagation algorithm:
*
* In general, execution proceeds in three passes:
*
* 1. write() propagates changes down the graph to the leaves
* direct children are marked as dirty and their deeper descendants marked as check
* (no computations are evaluated)
* 2. read() requests that parent nodes updateIfNecessary(), which proceeds recursively up the tree
* to decide whether the node is clean (parents unchanged) or dirty (parents changed)
* 3. updateIfNecessary() evaluates the computation if the node is dirty (the computations are
* executed in root to leaf order)
*/
import { type Flags } from './flags';
import { Owner } from './owner';
export interface SignalOptions<T> {
name?: string;
equals?: ((prev: T, next: T) => boolean) | false;
}
export interface MemoOptions<T> extends SignalOptions<T> {
initial?: T;
}
interface SourceType {
_observers: ObserverType[] | null;
_updateIfNecessary: () => void;
_stateFlags: Flags;
}
interface ObserverType {
_sources: SourceType[] | null;
_notify: (state: number) => void;
_handlerMask: Flags;
_notifyFlags: (mask: Flags, newFlags: Flags) => void;
}
/**
* Returns the current observer.
*/
export declare function getObserver(): ObserverType | null;
export declare const UNCHANGED: unique symbol;
export type UNCHANGED = typeof UNCHANGED;
export declare class Computation<T = any> extends Owner implements SourceType, ObserverType {
_sources: SourceType[] | null;
_observers: ObserverType[] | null;
_value: T | undefined;
_compute: null | (() => T);
_name: string | undefined;
_equals: false | ((a: T, b: T) => boolean);
/** Whether the computation is an error or has ancestors that are unresolved */
_stateFlags: number;
/** Which flags raised by sources are handled, vs. being passed through. */
_handlerMask: number;
_error: Computation<boolean> | null;
_loading: Computation<boolean> | null;
constructor(initialValue: T | undefined, compute: null | (() => T), options?: MemoOptions<T>);
_read(): T;
/**
* Return the current value of this computation
* Automatically re-executes the surrounding computation when the value changes
*/
read(): T;
/**
* Return the current value of this computation
* Automatically re-executes the surrounding computation when the value changes
*
* If the computation has any unresolved ancestors, this function waits for the value to resolve
* before continuing
*/
wait(): T;
/**
* Return true if the computation is the value is dependent on an unresolved promise
* Triggers re-execution of the computation when the loading state changes
*
* This is useful especially when effects want to re-execute when a computation's
* loading state changes
*/
loading(): boolean;
/**
* Return true if the computation is the computation threw an error
* Triggers re-execution of the computation when the error state changes
*/
error(): boolean;
/** Update the computation with a new value. */
write(value: T | ((currentValue: T) => T) | UNCHANGED, flags?: number, raw?: boolean): T;
/**
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
*/
_notify(state: number): void;
/**
* Notify the computation that one of its sources has changed flags.
*
* @param mask A bitmask for which flag(s) were changed.
* @param newFlags The source's new flags, masked to just the changed ones.
*/
_notifyFlags(mask: Flags, newFlags: Flags): void;
_setError(error: unknown): void;
/**
* This is the core part of the reactivity system, which makes sure that the values are updated
* before they are read. We've also adapted it to return the loading state of the computation,
* so that we can propagate that to the computation's observers.
*
* This function will ensure that the value and states we read from the computation are up to date
*/
_updateIfNecessary(): void;
/**
* Remove ourselves from the owner graph and the computation graph
*/
_disposeNode(): void;
}
/**
* Reruns a computation's _compute function, producing a new value and keeping track of dependencies.
*
* It handles the updating of sources and observers, disposal of previous executions,
* and error handling if the _compute function throws. It also sets the node as loading
* if it reads any parents that are currently loading.
*/
export declare function update<T>(node: Computation<T>): void;
export declare function isEqual<T>(a: T, b: T): boolean;
/**
* Returns the current value stored inside the given compute function without triggering any
* dependencies. Use `untrack` if you want to also disable owner tracking.
*/
export declare function untrack<T>(fn: () => T): T;
/**
* A convenient wrapper that calls `compute` with the `owner` and `observer` and is guaranteed
* to reset the global context after the computation is finished even if an error is thrown.
*/
export declare function compute<T>(owner: Owner | null, compute: (val: T) => T, observer: Computation<T>): T;
export declare function compute<T>(owner: Owner | null, compute: (val: undefined) => T, observer: null): T;
export {};
@@ -0,0 +1,25 @@
import { Computation, type MemoOptions } from './core';
/**
* By default, changes are batched on the microtask queue which is an async process. You can flush
* the queue synchronously to get the latest updates by calling `flushSync()`.
*/
export declare function flushSync(): void;
/**
* Effects are the leaf nodes of our reactive graph. When their sources change, they are
* automatically added to the queue of effects to re-execute, which will cause them to fetch their
* sources and recompute
*/
export declare class Effect<T = any> extends Computation<T> {
constructor(initialValue: T, compute: () => T, options?: MemoOptions<T>);
_notify(state: number): void;
write(value: T): T;
_setError(error: unknown): void;
}
export declare class RenderEffect<T = any> extends Computation<T> {
effect: (val: T) => void;
modified: boolean;
constructor(initialValue: T, compute: () => T, effect: (val: T) => void, options?: MemoOptions<T>);
_notify(state: number): void;
write(value: T): T;
_setError(error: unknown): void;
}
@@ -0,0 +1,11 @@
export declare class NotReadyError extends Error {
}
export declare class NoOwnerError extends Error {
constructor();
}
export declare class ContextNotFoundError extends Error {
constructor();
}
export interface ErrorHandler {
(error: unknown): void;
}
@@ -0,0 +1,8 @@
export type Flags = number;
export declare const ERROR_OFFSET = 0;
export declare const ERROR_BIT: number;
export declare const ERROR: unique symbol;
export declare const LOADING_OFFSET = 1;
export declare const LOADING_BIT: number;
export declare const LOADING: unique symbol;
export declare const DEFAULT_FLAGS: number;
@@ -0,0 +1,8 @@
export { ContextNotFoundError, NoOwnerError, NotReadyError, type ErrorHandler, } from './error';
export { Owner, createContext, getContext, setContext, hasContext, getOwner, setOwner, onCleanup, type Context, type ContextRecord, type Disposable, } from './owner';
export { Computation, compute, getObserver, isEqual, untrack, type MemoOptions, type SignalOptions, } from './core';
export { flushSync, Effect, RenderEffect } from './effect';
export { indexArray, mapArray, type Maybe } from './map';
export { createSelector, type SelectorOptions, type SelectorSignal, } from './selector';
export * from './signals';
export * from './store';
@@ -0,0 +1,26 @@
import type { Accessor } from './signals';
export type Maybe<T> = T | void | null | undefined | false;
/**
* Reactive map helper that caches each item by index to reduce unnecessary mapping on updates.
* It only runs the mapping function once per item and adds/removes as needed. In a non-keyed map
* like this the index is fixed but value can change (opposite of a keyed map).
*
* Prefer `mapArray` when referential checks are required.
*
* @see {@link https://github.com/solidjs/x-reactivity#indexarray}
*/
export declare function indexArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value: Accessor<Item>, index: number) => MappedItem, options?: {
name?: string;
}): Accessor<MappedItem[]>;
/**
* Reactive map helper that caches each list item by reference to reduce unnecessary mapping on
* updates. It only runs the mapping function once per item and then moves or removes it as needed.
* In a keyed map like this the value is fixed but the index changes (opposite of non-keyed map).
*
* Prefer `indexArray` when working with primitives to avoid unnecessary re-renders.
*
* @see {@link https://github.com/solidjs/x-reactivity#maparray}
*/
export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value: Item, index: Accessor<number>) => MappedItem, options?: {
name?: string;
}): Accessor<MappedItem[]>;
@@ -0,0 +1,88 @@
/**
* Owner tracking is used to enable nested tracking scopes with automatic cleanup.
* We also use owners to also keep track of which error handling context we are in.
*
* If you write the following
*
* const a = createOwner(() => {
* const b = createOwner(() => {});
*
* const c = createOwner(() => {
* const d = createOwner(() => {});
* });
*
* const e = createOwner(() => {});
* });
*
* The owner tree will look like this:
*
* a
* /|\
* b-c-e
* |
* d
*
* Following the _nextSibling pointers of each owner will first give you its children, and then its siblings (in reverse).
* a -> e -> c -> d -> b
*
* Note that the owner tree is largely orthogonal to the reactivity tree, and is much closer to the component tree.
*/
import { type ErrorHandler } from './error';
export type ContextRecord = Record<string | symbol, unknown>;
export interface Disposable {
(): void;
}
/**
* Returns the currently executing parent owner.
*/
export declare function getOwner(): Owner | null;
export declare function setOwner(owner: Owner | null): Owner | null;
export declare class Owner {
_parent: Owner | null;
_nextSibling: Owner | null;
_prevSibling: Owner | null;
_state: number;
_disposal: Disposable | Disposable[] | null;
_context: ContextRecord;
_handlers: ErrorHandler[] | null;
constructor(signal?: boolean);
append(child: Owner): void;
dispose(this: Owner, self?: boolean): void;
_disposeNode(): void;
emptyDisposal(): void;
handleError(error: unknown): void;
}
export interface Context<T> {
readonly id: symbol;
readonly defaultValue: T | undefined;
}
/**
* Context provides a form of dependency injection. It is used to save from needing to pass
* data as props through intermediate components. This function creates a new context object
* that can be used with `getContext` and `setContext`.
*
* A default value can be provided here which will be used when a specific value is not provided
* via a `setContext` call.
*/
export declare function createContext<T>(defaultValue?: T, description?: string): Context<T>;
/**
* Attempts to get a context value for the given key.
*
* @throws `NoOwnerError` if there's no owner at the time of call.
* @throws `ContextNotFoundError` if a context value has not been set yet.
*/
export declare function getContext<T>(context: Context<T>, owner?: Owner | null): T;
/**
* Attempts to set a context value on the parent scope with the given key.
*
* @throws `NoOwnerError` if there's no owner at the time of call.
*/
export declare function setContext<T>(context: Context<T>, value?: T, owner?: Owner | null): void;
/**
* Whether the given context is currently defined.
*/
export declare function hasContext(context: Context<any>, owner?: Owner | null): boolean;
/**
* Runs the given function when the parent owner computation is being disposed.
*/
export declare function onCleanup(disposable: Disposable): void;
@@ -0,0 +1,15 @@
import type { Accessor } from './signals';
export interface SelectorSignal<T> {
(key: T): Boolean;
}
export interface SelectorOptions<Key, Value> {
name?: string;
equals?: (key: Key, value: Value | undefined) => boolean;
}
/**
* Creates a signal that observes the given `source` and returns a new signal who only notifies
* observers when entering or exiting a specified key.
*
* @see {@link https://github.com/solidjs/x-reactivity#createselector}
*/
export declare function createSelector<Source, Key = Source>(source: Accessor<Source>, options?: SelectorOptions<Key, Source>): SelectorSignal<Key>;
@@ -0,0 +1,55 @@
import type { MemoOptions, SignalOptions } from './core';
import { Owner } from './owner';
export interface Accessor<T> {
(): T;
}
export interface Setter<T> {
(value: T | SetValue<T>): T;
}
export interface SetValue<T> {
(currentValue: T): T;
}
export type Signal<T> = [read: Accessor<T>, write: Setter<T>];
/**
* Wraps the given value into a signal. The signal will return the current value when invoked
* `fn()`, and provide a simple write API via `write()`. The value can now be observed
* when used inside other computations created with `computed` and `effect`.
*/
export declare function createSignal<T>(initialValue: T, options?: SignalOptions<T>): Signal<T>;
export declare function createAsync<T>(fn: () => Promise<T>, initial?: T, options?: SignalOptions<T>): Accessor<T>;
/**
* Creates a new computation whose value is computed and returned by the given function. The given
* compute function is _only_ re-run when one of it's dependencies are updated. Dependencies are
* are all signals that are read during execution.
*/
export declare function createMemo<T>(compute: () => T, initialValue?: T, options?: MemoOptions<T>): Accessor<T>;
/**
* Invokes the given function each time any of the signals that are read inside are updated
* (i.e., their value changes). The effect is immediately invoked on initialization.
*/
export declare function createEffect<T>(effect: () => T, initialValue?: T, options?: {
name?: string;
}): void;
/**
* Invokes the given function each time any of the signals that are read inside are updated
* (i.e., their value changes). The effect is immediately invoked on initialization.
*/
export declare function createRenderEffect<T>(compute: () => T, effect: (v: T) => T, initialValue?: T, options?: {
name?: string;
}): void;
/**
* Creates a computation root which is given a `dispose()` function to dispose of all inner
* computations.
*/
export declare function createRoot<T>(init: ((dispose: () => void) => T) | (() => T)): T;
/**
* Runs the given function in the given owner so that error handling and cleanups continue to work.
*
* Warning: Usually there are simpler ways of modeling a problem that avoid using this function
*/
export declare function runWithOwner<T>(owner: Owner | null, run: () => T): T | undefined;
/**
* Runs the given function when an error is thrown in a child owner. If the error is thrown again
* inside the error handler, it will trigger the next available parent owner handler.
*/
export declare function catchError<T>(fn: () => T, handler: (error: unknown) => void): void;
@@ -0,0 +1,22 @@
export type Store<T> = Readonly<T>;
export type StoreSetter<T> = (fn: (state: T) => void) => void;
export type StoreNode = Record<PropertyKey, any>;
export declare namespace SolidStore {
interface Unwrappable {
}
}
export type NotWrappable = string | number | bigint | symbol | boolean | Function | null | undefined | SolidStore.Unwrappable[keyof SolidStore.Unwrappable];
export declare function isWrappable<T>(obj: T | NotWrappable): obj is T;
/**
* Returns the underlying data in the store without a proxy.
* @param item store proxy object
* @example
* ```js
* const initial = {z...};
* const [state, setState] = createStore(initial);
* initial === state; // => false
* initial === unwrap(state); // => true
* ```
*/
export declare function unwrap<T>(item: T, set?: Set<unknown>): T;
export declare function createStore<T extends object = {}>(store: T | Store<T>): [get: Store<T>, set: StoreSetter<T>];
@@ -0,0 +1 @@
export declare function isUndefined(value: any): value is undefined;
@@ -0,0 +1,5 @@
Compiled version of: https://github.com/solidjs/signals/commits/main/
Head:
- SHA: 4d75d3f84ce22b560988f3b27a5065c0fd2e69a8
- Date: Apr 17, 2024
@@ -0,0 +1,8 @@
URL:
https://github.com/leeoniya/uFuzzy/commits/main/dist
Head:
- SHA: 6bb27a8d8c41e4be5458844afc5c89f6c2399512
- Date: Feb 21, 2024
- Version: v1.0.14
File diff suppressed because it is too large Load Diff
+196
View File
@@ -0,0 +1,196 @@
declare class uFuzzy {
constructor(opts?: uFuzzy.Options);
/** search API composed of filter/info/sort, with a info/ranking threshold (1e3) and fast outOfOrder impl */
search(
haystack: string[],
needle: string,
/** limit how many terms will be permuted, default = 0; 5 will result in up to 5! (120) search iterations. be careful with this! */
outOfOrder?: number,
/** default = 1e3 */
infoThresh?: number,
preFiltered?: uFuzzy.HaystackIdxs | null
): uFuzzy.SearchResult;
/** initial haystack filter, can accept idxs from previous prefix/typeahead match as optimization */
filter(
haystack: string[],
needle: string,
idxs?: uFuzzy.HaystackIdxs
): uFuzzy.HaystackIdxs | null;
/** collects stats about pre-filtered matches, does additional filtering based on term boundary settings, finds highlight ranges */
info(
idxs: uFuzzy.HaystackIdxs,
haystack: string[],
needle: string
): uFuzzy.Info;
/** performs final result sorting via Array.sort(), relying on Info */
sort(
info: uFuzzy.Info,
haystack: string[],
needle: string
): uFuzzy.InfoIdxOrder;
/** utility for splitting needle into terms following defined interSplit/intraSplit opts. useful for out-of-order permutes */
split(needle: string): uFuzzy.Terms;
/** util for creating out-of-order permutations of a needle terms array */
static permute(arr: unknown[]): unknown[][];
/** util for replacing common diacritics/accents */
static latinize<T extends string[] | string>(strings: T): T;
/** util for highlighting matched substr parts of a result */
static highlight<TAccum = string, TMarkedPart = string>(
match: string,
ranges: number[],
mark?: (part: string, matched: boolean) => TMarkedPart,
accum?: TAccum,
append?: (accum: TAccum, part: TMarkedPart) => TAccum | undefined
): TAccum;
}
export = uFuzzy;
declare namespace uFuzzy {
/** needle's terms */
export type Terms = string[];
/** subset of idxs of a haystack array */
export type HaystackIdxs = number[];
/** sorted order in which info facets should be iterated */
export type InfoIdxOrder = number[];
export type AbortedResult = [null, null, null];
export type FilteredResult = [uFuzzy.HaystackIdxs, null, null];
export type RankedResult = [
uFuzzy.HaystackIdxs,
uFuzzy.Info,
uFuzzy.InfoIdxOrder
];
export type SearchResult = FilteredResult | RankedResult | AbortedResult;
/** partial RegExp */
type PartialRegExp = string;
/** what should be considered acceptable term bounds */
export const enum BoundMode {
/** will match 'man' substr anywhere. e.g. tasmania */
Any = 0,
/** will match 'man' at whitespace, punct, case-change, and alpha-num boundaries. e.g. mantis, SuperMan, fooManBar, 0007man */
Loose = 1,
/** will match 'man' at whitespace, punct boundaries only. e.g. mega man, walk_man, man-made, foo.man.bar */
Strict = 2,
}
export const enum IntraMode {
/** allows any number of extra char insertions within a term, but all term chars must be present for a match */
MultiInsert = 0,
/** allows for a single-char substitution, transposition, insertion, or deletion within terms (excluding first and last chars) */
SingleError = 1,
}
export type IntraSliceIdxs = [from: number, to: number];
export interface Options {
// whether regexps use a /u unicode flag
unicode?: boolean; // false
/** @deprecated renamed to opts.alpha */
letters?: PartialRegExp | null; // a-z
// regexp character class [] of chars which should be treated as letters (case insensitive)
alpha?: PartialRegExp | null; // a-z
/** term segmentation & punct/whitespace merging */
interSplit?: PartialRegExp; // '[^A-Za-z\\d']+'
intraSplit?: PartialRegExp | null; // '[a-z][A-Z]'
/** inter bounds that will be used to increase lft2/rgt2 info counters */
interBound?: PartialRegExp | null; // '[^A-Za-z\\d]'
/** intra bounds that will be used to increase lft1/rgt1 info counters */
intraBound?: PartialRegExp | null; // '[A-Za-z][0-9]|[0-9][A-Za-z]|[a-z][A-Z]'
/** inter-term modes, during .info() can discard matches when bounds conditions are not met */
interLft?: BoundMode; // 0
interRgt?: BoundMode; // 0
/** allowance between terms */
interChars?: PartialRegExp; // '.'
interIns?: number; // Infinity
/** allowance between chars within terms */
intraChars?: PartialRegExp; // '[a-z\\d]'
intraIns?: number; // 0
/** contractions detection */
intraContr?: PartialRegExp; // "'[a-z]{1,2}\\b"
/** error tolerance mode within terms. will clamp intraIns to 1 when set to SingleError */
intraMode?: IntraMode; // 0
/** which part of each term should tolerate errors (when intraMode: 1) */
intraSlice?: IntraSliceIdxs; // [1, Infinity]
/** max substitutions (when intraMode: 1) */
intraSub?: 0 | 1; // 0
/** max transpositions (when intraMode: 1) */
intraTrn?: 0 | 1; // 0
/** max omissions/deletions (when intraMode: 1) */
intraDel?: 0 | 1; // 0
/** can dynamically adjust error tolerance rules per term in needle (when intraMode: 1) */
intraRules?: (term: string) => {
intraSlice?: IntraSliceIdxs;
intraIns: 0 | 1;
intraSub: 0 | 1;
intraTrn: 0 | 1;
intraDel: 0 | 1;
};
/** post-filters matches during .info() based on cmp of term in needle vs partial match */
intraFilt?: (term: string, match: string, index: number) => boolean; // should this also accept WIP info?
sort?: (info: Info, haystack: string[], needle: string) => InfoIdxOrder;
}
export interface Info {
/** matched idxs from haystack */
idx: HaystackIdxs;
/** match offsets */
start: number[];
/** number of left BoundMode.Strict term boundaries found */
interLft2: number[];
/** number of right BoundMode.Strict term boundaries found */
interRgt2: number[];
/** number of left BoundMode.Loose term boundaries found */
interLft1: number[];
/** number of right BoundMode.Loose term boundaries found */
interRgt1: number[];
/** total number of extra chars matched within all terms. higher = matched terms have more fuzz in them */
intraIns: number[];
/** total number of chars found in between matched terms. higher = terms are more sparse, have more fuzz in between them */
interIns: number[];
/** total number of matched contiguous chars (substrs but not necessarily full terms) */
chars: number[];
/** number of exactly-matched terms (intra = 0) where both lft and rgt landed on a BoundMode.Loose or BoundMode.Strict boundary */
terms: number[];
/** offset ranges within match for highlighting: [startIdx0, endIdx0, startIdx1, endIdx1,...] */
ranges: number[][];
}
}
export as namespace uFuzzy;
+90
View File
@@ -0,0 +1,90 @@
// @ts-check
const version = "v1";
self.addEventListener("install", (_event) => {
console.log("service-worker: install");
const event = /** @type {any} */ (_event);
event.waitUntil(
caches.open(version).then((cache) => {
return cache.addAll([
"/",
"/index.html",
"/assets/fonts/satoshi/2024-09/font.var.woff2",
"/scripts/main.js",
"/scripts/dashboard.js",
"/styles/dashboard.css",
"/scripts/chart.js",
"/styles/chart.css",
"/scripts/packages/flexmasonry/v0.2.3-modified/script.js",
"/scripts/packages/flexmasonry/v0.2.3-modified/style.css",
"/scripts/packages/lean-qr/v2.3.4/script.js",
"/scripts/packages/lightweight-charts/v4.2.0/script.js",
"/scripts/packages/solid-signals/2024-04-17/script.js",
"/scripts/packages/ufuzzy/v1.0.14/script.js",
]);
}),
);
// @ts-ignore
self.skipWaiting();
});
self.addEventListener("fetch", (_event) => {
const event = /** @type {any} */ (_event);
/** @type {Request} */
let request = event.request;
const method = request.method;
let url = request.url;
const { pathname, origin } = new URL(url);
const slashMatches = url.match(/\//g);
const dotMatches = pathname.split("/").at(-1)?.match(/./g);
const endsWithDotHtml = pathname.endsWith(".html");
const slashApiSlashMatches = url.match(/\/api\//g);
if (
slashMatches &&
slashMatches.length <= 3 &&
!slashApiSlashMatches &&
(!dotMatches || endsWithDotHtml)
) {
url = `${origin}/`;
}
request = new Request(url, request.mode !== "navigate" ? request : undefined);
console.log(`service-worker: fetching: ${url}`);
event.respondWith(
caches.match(request).then(async (cachedResponse) => {
return fetch(request)
.then((response) => {
const { status } = response;
if (method !== "GET" || slashApiSlashMatches) {
// API calls are cached in script.js
return response;
} else if (status === 200 || status === 304) {
if (status === 200) {
const clonedResponse = response.clone();
caches.open(version).then((cache) => {
cache.put(request, clonedResponse);
});
}
return response;
} else {
return cachedResponse || response;
}
})
.catch(() => {
console.log("service-worker: offline");
return cachedResponse;
});
}),
);
});
File diff suppressed because one or more lines are too long
+312
View File
@@ -0,0 +1,312 @@
import {
Accessor,
Setter,
} from "../packages/solid-signals/2024-04-17/types/signals";
import {
DeepPartial,
BaselineStyleOptions,
CandlestickStyleOptions,
LineStyleOptions,
SeriesOptionsCommon,
Range,
Time,
SingleValueData,
CandlestickData,
SeriesType,
IChartApi,
ISeriesApi,
} from "../packages/lightweight-charts/v4.2.0/types";
import { DatePath, HeightPath, LastPath } from "./paths";
import { Owner } from "../packages/solid-signals/2024-04-17/types/owner";
type GrowToSize<T, N extends number, A extends T[]> = A["length"] extends N
? A
: GrowToSize<T, N, [...A, T]>;
type FixedArray<T, N extends number> = GrowToSize<T, N, []>;
type Signal<T> = Accessor<T> & { set: Setter<T> };
type SettingsTheme = "system" | "dark" | "light";
type FoldersFilter = "all" | "favorites" | "new";
type TimeScale = "date" | "height";
type TimeRange = Range<Time | number>;
type DatasetPath<Scale extends TimeScale> = Scale extends "date"
? DatePath
: HeightPath;
type AnyDatasetPath = import("./paths").DatePath | import("./paths").HeightPath;
type AnyPath = AnyDatasetPath | LastPath;
type Color = () => string;
interface BaselineSpecificSeriesBlueprint {
type: "Baseline";
color?: Color;
options?: DeepPartial<BaselineStyleOptions & SeriesOptionsCommon>;
}
interface CandlestickSpecificSeriesBlueprint {
type: "Candlestick";
color?: undefined;
options?: DeepPartial<CandlestickStyleOptions & SeriesOptionsCommon>;
}
interface LineSpecificSeriesBlueprint {
type?: "Line";
color: Color;
options?: DeepPartial<LineStyleOptions & SeriesOptionsCommon>;
}
type AnySpecificSeriesBlueprint =
| BaselineSpecificSeriesBlueprint
| CandlestickSpecificSeriesBlueprint
| LineSpecificSeriesBlueprint;
type SpecificSeriesBlueprintWithChart<A extends AnySpecificSeriesBlueprint> = {
chart: IChartApi;
owner: Owner | null;
} & Omit<A, "type">;
type SeriesBlueprint = {
datasetPath: AnyDatasetPath;
title: string;
defaultActive?: boolean;
main?: boolean;
formatNumber?: false;
} & AnySpecificSeriesBlueprint;
type Unit =
| ""
| "Bitcoin"
| "Coinblocks"
| "Count"
| "Date"
| "Dollars / (PetaHash / Second)"
| "ExaHash / Second"
| "Height"
| "Megabytes"
| "Percentage"
| "Ratio"
| "Satoshis"
| "Seconds"
| "Transactions"
| "US Dollars"
| "Virtual Bytes"
| "Weight";
interface PartialOption {
icon: string;
name: string;
}
interface PartialHomeOption extends PartialOption {
kind: "home";
title: "Home";
name: "Home";
}
interface PartialDashboardOption extends PartialOption {
title: string;
description: string;
defaultOpen?: false;
groups: {
name: string;
unit?: Unit;
values: {
name: string;
path: LastPath;
unit?: Unit;
formatNumber?: false;
}[];
}[];
}
interface PartialChartOption extends PartialOption {
scale: TimeScale;
title: string;
shortTitle?: string;
unit: Unit;
description: string;
top?: SeriesBlueprint[];
bottom?: SeriesBlueprint[];
dashboard?: {
ignoreName?: boolean;
skip?: boolean;
};
}
interface PartialPdfOption extends PartialOption {
file: string;
}
interface PartialOptionsGroup {
name: string;
tree: PartialOptionsTree;
dashboard?: {
skip?: true;
flatten?: true;
hopOver?: true;
separate?: true;
defaultOpen?: true;
};
}
type AnyPartialOption =
| PartialHomeOption
| PartialPdfOption
| PartialDashboardOption
| PartialChartOption;
type PartialOptionsTree = (AnyPartialOption | PartialOptionsGroup)[];
interface ProcessedOptionAddons {
id: string;
path: OptionPath;
serializedPath: string;
isFavorite: Signal<boolean>;
visited: Signal<boolean>;
}
type OptionPath = {
id: string;
name: string;
}[];
type HomeOption = PartialHomeOption & ProcessedOptionAddons;
interface PdfOption extends PartialPdfOption, ProcessedOptionAddons {
kind: "pdf";
title: string;
}
interface DashboardOption
extends PartialDashboardOption,
ProcessedOptionAddons {
kind: "dashboard";
}
interface ChartOption extends PartialChartOption, ProcessedOptionAddons {
kind: "chart";
}
type Option = HomeOption | PdfOption | DashboardOption | ChartOption;
type OptionsTree = (Option | OptionsGroup)[];
interface OptionsGroup extends PartialOptionsGroup {
id: string;
tree: OptionsTree;
}
type SerializedHistory = [string, number][];
interface OHLC {
open: number;
high: number;
low: number;
close: number;
}
interface ResourceDataset<
Scale extends TimeScale,
Type extends OHLC | number = number,
> {
scale: Scale;
url: string;
fetch: (id: number) => void;
fetchedJSONs: FetchedResult<Scale, Type>[];
// drop: VoidFunction;
}
type ValuedCandlestickData = CandlestickData & Valued;
interface FetchedResult<
Scale extends TimeScale,
Type extends number | OHLC,
Value extends DatasetValue<
SingleValueData | ValuedCandlestickData
> = DatasetValue<
Type extends number ? SingleValueData : ValuedCandlestickData
>,
> {
at: Date | null;
json: Signal<FetchedJSON<Scale, Type> | null>;
vec: Accessor<Value[] | null>;
loading: boolean;
}
interface Valued {
value: number;
}
type DatasetValue<T> = T & Valued;
interface FetchedJSON<Scale extends TimeScale, Type extends number | OHLC> {
source: FetchedSource;
chunk: FetchedChunk;
dataset: FetchedDataset<Scale, Type>;
}
type FetchedSource = string;
interface FetchedChunk {
id: number;
previous: string | null;
next: string | null;
}
type FetchedDataset<
Scale extends TimeScale,
Type extends number | OHLC,
> = Scale extends "date"
? FetchedDateDataset<Type>
: FetchedHeightDataset<Type>;
interface Versioned {
version: number;
}
interface FetchedDateDataset<Type> extends Versioned {
map: Record<string, Type>;
}
interface FetchedHeightDataset<Type> extends Versioned {
map: Type[];
}
type PriceSeriesType = "Candlestick" | "Line";
interface Series {
id: string;
title: string;
chunks: Array<Accessor<ISeriesApi<SeriesType> | undefined>>;
color: Color | Color[];
disabled: Accessor<boolean>;
active: Signal<boolean>;
visible: Accessor<boolean>;
dataset: ResourceDataset<TimeScale, number>;
}
interface Marker {
weight: number;
time: Time;
value: number;
seriesChunk: ISeriesApi<any>;
}
interface Weighted {
weight: number;
}
type DatasetCandlestickData = DatasetValue<CandlestickData> & { year: number };
declare global {
interface Window {
MyNamespace: any;
}
}