@xyo-network/react-price-forecast-plugin 2.61.0-rc.4 → 2.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/Plugin.cjs +270 -0
- package/dist/browser/Plugin.cjs.map +1 -0
- package/dist/browser/Plugin.d.cts +3 -0
- package/dist/browser/Plugin.d.cts.map +1 -0
- package/dist/browser/components/DetailsBox.cjs +254 -0
- package/dist/browser/components/DetailsBox.cjs.map +1 -0
- package/dist/browser/components/DetailsBox.d.cts +9 -0
- package/dist/browser/components/DetailsBox.d.cts.map +1 -0
- package/dist/browser/components/index.cjs +256 -0
- package/dist/browser/components/index.cjs.map +1 -0
- package/dist/browser/components/index.d.cts +2 -0
- package/dist/browser/components/index.d.cts.map +1 -0
- package/dist/browser/index.cjs +271 -0
- package/dist/browser/index.cjs.map +1 -0
- package/dist/browser/index.d.cts +3 -0
- package/dist/browser/index.d.cts.map +1 -0
- package/dist/browser/lib/DataLineStyles.cjs +31 -0
- package/dist/{node/lib/DataLineStyles.mjs.map → browser/lib/DataLineStyles.cjs.map} +1 -1
- package/dist/browser/lib/DataLineStyles.d.cts +5 -0
- package/dist/browser/lib/DataLineStyles.d.cts.map +1 -0
- package/dist/browser/lib/DataPointStyles.cjs +33 -0
- package/dist/{node/lib/DataPointStyles.mjs.map → browser/lib/DataPointStyles.cjs.map} +1 -1
- package/dist/browser/lib/DataPointStyles.d.cts +8 -0
- package/dist/browser/lib/DataPointStyles.d.cts.map +1 -0
- package/dist/browser/lib/ForecastLineChartConfigBuilder.cjs +225 -0
- package/dist/browser/lib/ForecastLineChartConfigBuilder.cjs.map +1 -0
- package/dist/browser/lib/ForecastLineChartConfigBuilder.d.cts +47 -0
- package/dist/browser/lib/ForecastLineChartConfigBuilder.d.cts.map +1 -0
- package/dist/browser/lib/MockSourcePayloads.cjs +45 -0
- package/dist/{node/lib/MockSourcePayloads.mjs.map → browser/lib/MockSourcePayloads.cjs.map} +1 -1
- package/dist/browser/lib/MockSourcePayloads.d.cts +18 -0
- package/dist/browser/lib/MockSourcePayloads.d.cts.map +1 -0
- package/dist/browser/lib/SourcePayloads.cjs +85 -0
- package/dist/browser/lib/SourcePayloads.cjs.map +1 -0
- package/dist/browser/lib/SourcePayloads.d.cts +30 -0
- package/dist/browser/lib/SourcePayloads.d.cts.map +1 -0
- package/dist/browser/lib/index.cjs +227 -0
- package/dist/browser/lib/index.cjs.map +1 -0
- package/dist/browser/lib/index.d.cts +4 -0
- package/dist/browser/lib/index.d.cts.map +1 -0
- package/dist/docs.json +23326 -0
- package/dist/node/Plugin.cjs +278 -0
- package/dist/node/Plugin.cjs.map +1 -0
- package/dist/node/Plugin.d.cts +3 -0
- package/dist/node/Plugin.d.cts.map +1 -0
- package/dist/node/Plugin.js +249 -27
- package/dist/node/Plugin.js.map +1 -1
- package/dist/node/components/DetailsBox.cjs +262 -0
- package/dist/node/components/DetailsBox.cjs.map +1 -0
- package/dist/node/components/DetailsBox.d.cts +9 -0
- package/dist/node/components/DetailsBox.d.cts.map +1 -0
- package/dist/node/components/DetailsBox.js +230 -39
- package/dist/node/components/DetailsBox.js.map +1 -1
- package/dist/node/components/index.cjs +264 -0
- package/dist/node/components/index.cjs.map +1 -0
- package/dist/node/components/index.d.cts +2 -0
- package/dist/node/components/index.d.cts.map +1 -0
- package/dist/node/components/index.js +244 -20
- package/dist/node/components/index.js.map +1 -1
- package/dist/node/index.cjs +280 -0
- package/dist/node/index.cjs.map +1 -0
- package/dist/node/index.d.cts +3 -0
- package/dist/node/index.d.cts.map +1 -0
- package/dist/node/index.js +259 -22
- package/dist/node/index.js.map +1 -1
- package/dist/node/lib/DataLineStyles.cjs +35 -0
- package/dist/node/lib/DataLineStyles.cjs.map +1 -0
- package/dist/node/lib/DataLineStyles.d.cts +5 -0
- package/dist/node/lib/DataLineStyles.d.cts.map +1 -0
- package/dist/node/lib/DataLineStyles.js +6 -29
- package/dist/node/lib/DataLineStyles.js.map +1 -1
- package/dist/node/lib/DataPointStyles.cjs +37 -0
- package/dist/node/lib/DataPointStyles.cjs.map +1 -0
- package/dist/node/lib/DataPointStyles.d.cts +8 -0
- package/dist/node/lib/DataPointStyles.d.cts.map +1 -0
- package/dist/node/lib/DataPointStyles.js +4 -27
- package/dist/node/lib/DataPointStyles.js.map +1 -1
- package/dist/node/lib/ForecastLineChartConfigBuilder.cjs +233 -0
- package/dist/node/lib/ForecastLineChartConfigBuilder.cjs.map +1 -0
- package/dist/node/lib/ForecastLineChartConfigBuilder.d.cts +47 -0
- package/dist/node/lib/ForecastLineChartConfigBuilder.d.cts.map +1 -0
- package/dist/node/lib/ForecastLineChartConfigBuilder.js +92 -39
- package/dist/node/lib/ForecastLineChartConfigBuilder.js.map +1 -1
- package/dist/node/lib/MockSourcePayloads.cjs +49 -0
- package/dist/node/lib/MockSourcePayloads.cjs.map +1 -0
- package/dist/node/lib/MockSourcePayloads.d.cts +18 -0
- package/dist/node/lib/MockSourcePayloads.d.cts.map +1 -0
- package/dist/node/lib/MockSourcePayloads.js +4 -27
- package/dist/node/lib/MockSourcePayloads.js.map +1 -1
- package/dist/node/lib/SourcePayloads.cjs +89 -0
- package/dist/node/lib/SourcePayloads.cjs.map +1 -0
- package/dist/node/lib/SourcePayloads.d.cts +30 -0
- package/dist/node/lib/SourcePayloads.d.cts.map +1 -0
- package/dist/node/lib/SourcePayloads.js +26 -29
- package/dist/node/lib/SourcePayloads.js.map +1 -1
- package/dist/node/lib/index.cjs +237 -0
- package/dist/node/lib/index.cjs.map +1 -0
- package/dist/node/lib/index.d.cts +4 -0
- package/dist/node/lib/index.d.cts.map +1 -0
- package/dist/node/lib/index.js +205 -24
- package/dist/node/lib/index.js.map +1 -1
- package/package.json +18 -18
- package/dist/browser/components/DetailsBox.stories.js +0 -64
- package/dist/browser/components/DetailsBox.stories.js.map +0 -1
- package/dist/node/Plugin.mjs +0 -17
- package/dist/node/Plugin.mjs.map +0 -1
- package/dist/node/components/DetailsBox.mjs +0 -42
- package/dist/node/components/DetailsBox.mjs.map +0 -1
- package/dist/node/components/DetailsBox.stories.js +0 -89
- package/dist/node/components/DetailsBox.stories.js.map +0 -1
- package/dist/node/components/DetailsBox.stories.mjs +0 -64
- package/dist/node/components/DetailsBox.stories.mjs.map +0 -1
- package/dist/node/components/index.mjs +0 -2
- package/dist/node/components/index.mjs.map +0 -1
- package/dist/node/index.mjs +0 -3
- package/dist/node/index.mjs.map +0 -1
- package/dist/node/lib/DataLineStyles.mjs +0 -9
- package/dist/node/lib/DataPointStyles.mjs +0 -11
- package/dist/node/lib/ForecastLineChartConfigBuilder.mjs +0 -129
- package/dist/node/lib/ForecastLineChartConfigBuilder.mjs.map +0 -1
- package/dist/node/lib/MockSourcePayloads.mjs +0 -23
- package/dist/node/lib/SourcePayloads.mjs +0 -41
- package/dist/node/lib/SourcePayloads.mjs.map +0 -1
- package/dist/node/lib/index.mjs +0 -4
- package/dist/node/lib/index.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/DetailsBox.stories.tsx"],"sourcesContent":["import { Button, ButtonGroup, Typography } from '@mui/material'\nimport { Meta, StoryFn } from '@storybook/react'\nimport { FlexCol } from '@xylabs/react-flexbox'\nimport { ForecastPayloadSchema } from '@xyo-network/diviner-forecasting-model'\nimport { RefObject, useRef, useState } from 'react'\n\nimport { MockSourcePayloads } from '../lib'\nimport { PriceForecastDetailsBox } from './DetailsBox'\n\nconst tenMin = 600000\n\nconst ForecastingDivinerPayload = {\n schema: ForecastPayloadSchema,\n values: [1, 2, 3, 4, 5, 6, 7, 8].map((item) => ({\n error: 0,\n timestamp: Date.now() + tenMin * item,\n value: 100 * item,\n })),\n}\n\nconst StorybookEntry = {\n argTypes: {},\n component: PriceForecastDetailsBox,\n parameters: {\n docs: {\n page: null,\n },\n },\n title: 'plugin/price-forecast/DetailsBox',\n} as Meta<typeof PriceForecastDetailsBox>\n\nconst Template: StoryFn<typeof PriceForecastDetailsBox> = (args) => {\n const [showPayloads, setShowPayloads] = useState(false)\n const forecastPayloadRef = useRef<HTMLParagraphElement>(null)\n const sourcePayloadsRef = useRef<HTMLParagraphElement>(null)\n const handleClick = (ref: RefObject<HTMLParagraphElement>) => {\n setShowPayloads(!showPayloads)\n if (ref.current) ref.current.scrollIntoView({ behavior: 'smooth', block: 'start' })\n }\n return (\n <>\n <PriceForecastDetailsBox mb={3} {...args} />\n <FlexCol>\n <ButtonGroup>\n <Button variant=\"contained\" onClick={() => handleClick(forecastPayloadRef)}>\n Forecast Payload\n </Button>\n <Button variant=\"contained\" onClick={() => handleClick(sourcePayloadsRef)}>\n Source Payloads\n </Button>\n </ButtonGroup>\n </FlexCol>\n <pre>\n <Typography ref={forecastPayloadRef}>\n ForecastPayload: <code>{JSON.stringify(args.payload, null, 2)}</code>\n </Typography>\n </pre>\n <pre>\n <Typography ref={sourcePayloadsRef}>\n SourcePayloads: <pre>{JSON.stringify(MockSourcePayloads(), null, 2)}</pre>\n </Typography>\n </pre>\n </>\n )\n}\n\nconst Default = Template.bind({})\nDefault.args = {}\n\nconst WithData = Template.bind({})\nWithData.args = {\n payload: ForecastingDivinerPayload,\n}\n\nexport { Default, WithData }\n\n// eslint-disable-next-line import/no-default-export\nexport default StorybookEntry\n"],"mappings":"AAwCI,mBACE,KAEE,YAHJ;AAxCJ,SAAS,QAAQ,aAAa,kBAAkB;AAEhD,SAAS,eAAe;AACxB,SAAS,6BAA6B;AACtC,SAAoB,QAAQ,gBAAgB;AAE5C,SAAS,0BAA0B;AACnC,SAAS,+BAA+B;AAExC,MAAM,SAAS;AAEf,MAAM,4BAA4B;AAAA,EAChC,QAAQ;AAAA,EACR,QAAQ,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,EAAE,IAAI,CAAC,UAAU;AAAA,IAC9C,OAAO;AAAA,IACP,WAAW,KAAK,IAAI,IAAI,SAAS;AAAA,IACjC,OAAO,MAAM;AAAA,EACf,EAAE;AACJ;AAEA,MA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1,17 +0,0 @@
|
|
|
1
|
-
import { createPayloadRenderPlugin } from "@xyo-network/react-payload-plugin";
|
|
2
|
-
import { PriceForecastDetailsBox } from "./components";
|
|
3
|
-
const PriceForecastRenderPlugin = {
|
|
4
|
-
...createPayloadRenderPlugin({
|
|
5
|
-
canRender: () => true,
|
|
6
|
-
components: {
|
|
7
|
-
box: {
|
|
8
|
-
detailsBox: PriceForecastDetailsBox
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
name: "PriceForecast"
|
|
12
|
-
})
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
PriceForecastRenderPlugin
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=Plugin.mjs.map
|
package/dist/node/Plugin.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Plugin.ts"],"sourcesContent":["import { createPayloadRenderPlugin, PayloadRenderPlugin } from '@xyo-network/react-payload-plugin'\n\nimport { PriceForecastDetailsBox } from './components'\n\nexport const PriceForecastRenderPlugin: PayloadRenderPlugin = {\n ...createPayloadRenderPlugin({\n canRender: () => true,\n components: {\n box: {\n detailsBox: PriceForecastDetailsBox,\n },\n },\n name: 'PriceForecast',\n }),\n}\n"],"mappings":"AAAA,SAAS,iCAAsD;AAE/D,SAAS,+BAA+B;AAEjC,MAAM,4BAAiD;AAAA,EAC5D,GAAG,0BAA0B;AAAA,IAC3B,WAAW,MAAM;AAAA,IACjB,YAAY;AAAA,MACV,KAAK;AAAA,QACH,YAAY;AAAA,MACd;AAAA,IACF;AAAA,IACA,MAAM;AAAA,EACR,CAAC;AACH;","names":[]}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import "chartjs-adapter-luxon";
|
|
3
|
-
import { useTheme } from "@mui/material";
|
|
4
|
-
import { useAsyncEffect } from "@xylabs/react-async-effect";
|
|
5
|
-
import { FlexCol } from "@xylabs/react-flexbox";
|
|
6
|
-
import {
|
|
7
|
-
CategoryScale,
|
|
8
|
-
Chart as ChartJS,
|
|
9
|
-
Legend,
|
|
10
|
-
LinearScale,
|
|
11
|
-
LineElement,
|
|
12
|
-
PointElement,
|
|
13
|
-
TimeScale,
|
|
14
|
-
Title,
|
|
15
|
-
Tooltip
|
|
16
|
-
} from "chart.js";
|
|
17
|
-
import { useState } from "react";
|
|
18
|
-
import { Line } from "react-chartjs-2";
|
|
19
|
-
import { ForecastLineChartConfigBuilder } from "../lib";
|
|
20
|
-
ChartJS.register(CategoryScale, TimeScale, PointElement, LineElement, LinearScale, Title, Tooltip, Legend);
|
|
21
|
-
const PriceForecastDetailsBox = ({ payload, ...props }) => {
|
|
22
|
-
const priceForecastPayload = payload;
|
|
23
|
-
const theme = useTheme();
|
|
24
|
-
const [data, setData] = useState({ datasets: [] });
|
|
25
|
-
const [options, setOptions] = useState({});
|
|
26
|
-
useAsyncEffect(
|
|
27
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
|
-
async (mounted) => {
|
|
29
|
-
const { data: data2, options: options2 } = await ForecastLineChartConfigBuilder.create(theme, priceForecastPayload, { fetch: true });
|
|
30
|
-
if (mounted()) {
|
|
31
|
-
setData(data2);
|
|
32
|
-
setOptions(options2);
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
[priceForecastPayload, theme]
|
|
36
|
-
);
|
|
37
|
-
return /* @__PURE__ */ jsx(FlexCol, { ...props, busy: priceForecastPayload === void 0, minHeight: "25vh", children: priceForecastPayload ? /* @__PURE__ */ jsx(Line, { options, data }) : null });
|
|
38
|
-
};
|
|
39
|
-
export {
|
|
40
|
-
PriceForecastDetailsBox
|
|
41
|
-
};
|
|
42
|
-
//# sourceMappingURL=DetailsBox.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/DetailsBox.tsx"],"sourcesContent":["import 'chartjs-adapter-luxon'\n\nimport { useTheme } from '@mui/material'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { FlexBoxProps, FlexCol } from '@xylabs/react-flexbox'\nimport { ForecastPayload } from '@xyo-network/diviner-forecasting-model'\nimport { Payload } from '@xyo-network/payload-model'\nimport {\n CategoryScale,\n Chart as ChartJS,\n ChartData,\n ChartOptions,\n Legend,\n LinearScale,\n LineElement,\n PointElement,\n TimeScale,\n Title,\n Tooltip,\n} from 'chart.js'\nimport { useState } from 'react'\nimport { Line } from 'react-chartjs-2'\n\nimport { ForecastLineChartConfigBuilder } from '../lib'\n\nChartJS.register(CategoryScale, TimeScale, PointElement, LineElement, LinearScale, Title, Tooltip, Legend)\n\nexport interface PriceForecastDetailsBoxProps extends FlexBoxProps {\n payload?: Payload\n}\n\nexport const PriceForecastDetailsBox: React.FC<PriceForecastDetailsBoxProps> = ({ payload, ...props }) => {\n const priceForecastPayload = payload as ForecastPayload | undefined\n const theme = useTheme()\n const [data, setData] = useState<ChartData<'line'>>({ datasets: [] })\n const [options, setOptions] = useState<ChartOptions<'line'>>({})\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n const { data, options } = await ForecastLineChartConfigBuilder.create(theme, priceForecastPayload, { fetch: true })\n if (mounted()) {\n setData(data)\n setOptions(options)\n }\n },\n [priceForecastPayload, theme],\n )\n\n return (\n <FlexCol {...props} busy={priceForecastPayload === undefined} minHeight=\"25vh\">\n {priceForecastPayload ? <Line options={options} data={data} /> : null}\n </FlexCol>\n )\n}\n"],"mappings":"AAmD8B;AAnD9B,OAAO;AAEP,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAC/B,SAAuB,eAAe;AAGtC;AAAA,EACE;AAAA,EACA,SAAS;AAAA,EAGT;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB;AACzB,SAAS,YAAY;AAErB,SAAS,sCAAsC;AAE/C,QAAQ,SAAS,eAAe,WAAW,cAAc,aAAa,aAAa,OAAO,SAAS,MAAM;AAMlG,MAAM,0BAAkE,CAAC,EAAE,SAAS,GAAG,MAAM,MAAM;AACxG,QAAM,uBAAuB;AAC7B,QAAM,QAAQ,SAAS;AACvB,QAAM,CAAC,MAAM,OAAO,IAAI,SAA4B,EAAE,UAAU,CAAC,EAAE,CAAC;AACpE,QAAM,CAAC,SAAS,UAAU,IAAI,SAA+B,CAAC,CAAC;AAE/D;AAAA;AAAA,IAEE,OAAO,YAAY;AACjB,YAAM,EAAE,MAAAA,OAAM,SAAAC,SAAQ,IAAI,MAAM,+BAA+B,OAAO,OAAO,sBAAsB,EAAE,OAAO,KAAK,CAAC;AAClH,UAAI,QAAQ,GAAG;AACb,gBAAQD,KAAI;AACZ,mBAAWC,QAAO;AAAA,MACpB;AAAA,IACF;AAAA,IACA,CAAC,sBAAsB,KAAK;AAAA,EAC9B;AAEA,SACE,oBAAC,WAAS,GAAG,OAAO,MAAM,yBAAyB,QAAW,WAAU,QACrE,iCAAuB,oBAAC,QAAK,SAAkB,MAAY,IAAK,MACnE;AAEJ;","names":["data","options"]}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var DetailsBox_stories_exports = {};
|
|
20
|
-
__export(DetailsBox_stories_exports, {
|
|
21
|
-
Default: () => Default,
|
|
22
|
-
WithData: () => WithData,
|
|
23
|
-
default: () => DetailsBox_stories_default
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(DetailsBox_stories_exports);
|
|
26
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
27
|
-
var import_material = require("@mui/material");
|
|
28
|
-
var import_react_flexbox = require("@xylabs/react-flexbox");
|
|
29
|
-
var import_diviner_forecasting_model = require("@xyo-network/diviner-forecasting-model");
|
|
30
|
-
var import_react2 = require("react");
|
|
31
|
-
var import_lib = require("../lib");
|
|
32
|
-
var import_DetailsBox = require("./DetailsBox");
|
|
33
|
-
const tenMin = 6e5;
|
|
34
|
-
const ForecastingDivinerPayload = {
|
|
35
|
-
schema: import_diviner_forecasting_model.ForecastPayloadSchema,
|
|
36
|
-
values: [1, 2, 3, 4, 5, 6, 7, 8].map((item) => ({
|
|
37
|
-
error: 0,
|
|
38
|
-
timestamp: Date.now() + tenMin * item,
|
|
39
|
-
value: 100 * item
|
|
40
|
-
}))
|
|
41
|
-
};
|
|
42
|
-
const StorybookEntry = {
|
|
43
|
-
argTypes: {},
|
|
44
|
-
component: import_DetailsBox.PriceForecastDetailsBox,
|
|
45
|
-
parameters: {
|
|
46
|
-
docs: {
|
|
47
|
-
page: null
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
title: "plugin/price-forecast/DetailsBox"
|
|
51
|
-
};
|
|
52
|
-
const Template = (args) => {
|
|
53
|
-
const [showPayloads, setShowPayloads] = (0, import_react2.useState)(false);
|
|
54
|
-
const forecastPayloadRef = (0, import_react2.useRef)(null);
|
|
55
|
-
const sourcePayloadsRef = (0, import_react2.useRef)(null);
|
|
56
|
-
const handleClick = (ref) => {
|
|
57
|
-
setShowPayloads(!showPayloads);
|
|
58
|
-
if (ref.current)
|
|
59
|
-
ref.current.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
60
|
-
};
|
|
61
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
62
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DetailsBox.PriceForecastDetailsBox, { mb: 3, ...args }),
|
|
63
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_flexbox.FlexCol, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_material.ButtonGroup, { children: [
|
|
64
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Button, { variant: "contained", onClick: () => handleClick(forecastPayloadRef), children: "Forecast Payload" }),
|
|
65
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Button, { variant: "contained", onClick: () => handleClick(sourcePayloadsRef), children: "Source Payloads" })
|
|
66
|
-
] }) }),
|
|
67
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_material.Typography, { ref: forecastPayloadRef, children: [
|
|
68
|
-
"ForecastPayload: ",
|
|
69
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: JSON.stringify(args.payload, null, 2) })
|
|
70
|
-
] }) }),
|
|
71
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_material.Typography, { ref: sourcePayloadsRef, children: [
|
|
72
|
-
"SourcePayloads: ",
|
|
73
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { children: JSON.stringify((0, import_lib.MockSourcePayloads)(), null, 2) })
|
|
74
|
-
] }) })
|
|
75
|
-
] });
|
|
76
|
-
};
|
|
77
|
-
const Default = Template.bind({});
|
|
78
|
-
Default.args = {};
|
|
79
|
-
const WithData = Template.bind({});
|
|
80
|
-
WithData.args = {
|
|
81
|
-
payload: ForecastingDivinerPayload
|
|
82
|
-
};
|
|
83
|
-
var DetailsBox_stories_default = StorybookEntry;
|
|
84
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
-
0 && (module.exports = {
|
|
86
|
-
Default,
|
|
87
|
-
WithData
|
|
88
|
-
});
|
|
89
|
-
//# sourceMappingURL=DetailsBox.stories.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/DetailsBox.stories.tsx"],"sourcesContent":["import { Button, ButtonGroup, Typography } from '@mui/material'\nimport { Meta, StoryFn } from '@storybook/react'\nimport { FlexCol } from '@xylabs/react-flexbox'\nimport { ForecastPayloadSchema } from '@xyo-network/diviner-forecasting-model'\nimport { RefObject, useRef, useState } from 'react'\n\nimport { MockSourcePayloads } from '../lib'\nimport { PriceForecastDetailsBox } from './DetailsBox'\n\nconst tenMin = 600000\n\nconst ForecastingDivinerPayload = {\n schema: ForecastPayloadSchema,\n values: [1, 2, 3, 4, 5, 6, 7, 8].map((item) => ({\n error: 0,\n timestamp: Date.now() + tenMin * item,\n value: 100 * item,\n })),\n}\n\nconst StorybookEntry = {\n argTypes: {},\n component: PriceForecastDetailsBox,\n parameters: {\n docs: {\n page: null,\n },\n },\n title: 'plugin/price-forecast/DetailsBox',\n} as Meta<typeof PriceForecastDetailsBox>\n\nconst Template: StoryFn<typeof PriceForecastDetailsBox> = (args) => {\n const [showPayloads, setShowPayloads] = useState(false)\n const forecastPayloadRef = useRef<HTMLParagraphElement>(null)\n const sourcePayloadsRef = useRef<HTMLParagraphElement>(null)\n const handleClick = (ref: RefObject<HTMLParagraphElement>) => {\n setShowPayloads(!showPayloads)\n if (ref.current) ref.current.scrollIntoView({ behavior: 'smooth', block: 'start' })\n }\n return (\n <>\n <PriceForecastDetailsBox mb={3} {...args} />\n <FlexCol>\n <ButtonGroup>\n <Button variant=\"contained\" onClick={() => handleClick(forecastPayloadRef)}>\n Forecast Payload\n </Button>\n <Button variant=\"contained\" onClick={() => handleClick(sourcePayloadsRef)}>\n Source Payloads\n </Button>\n </ButtonGroup>\n </FlexCol>\n <pre>\n <Typography ref={forecastPayloadRef}>\n ForecastPayload: <code>{JSON.stringify(args.payload, null, 2)}</code>\n </Typography>\n </pre>\n <pre>\n <Typography ref={sourcePayloadsRef}>\n SourcePayloads: <pre>{JSON.stringify(MockSourcePayloads(), null, 2)}</pre>\n </Typography>\n </pre>\n </>\n )\n}\n\nconst Default = Template.bind({})\nDefault.args = {}\n\nconst WithData = Template.bind({})\nWithData.args = {\n payload: ForecastingDivinerPayload,\n}\n\nexport { Default, WithData }\n\n// eslint-disable-next-line import/no-default-export\nexport default StorybookEntry\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwCI;AAxCJ,sBAAgD;AAEhD,2BAAwB;AACxB,uCAAsC;AACtC,IAAAA,gBAA4C;AAE5C,iBAAmC;AACnC,wBAAwC;AAExC,MAAM,SAAS;AAEf,MAAM,4BAA4B;AAAA,EAChC,QAAQ;AAAA,EACR,QAAQ,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,EAAE,IAAI,CAAC,UAAU;AAAA,IAC9C,OAAO;AAAA,IACP,WAAW,KAAK,IAAI,IAAI,SAAS;AAAA,IACjC,OAAO,MAAM;AAAA,EACf,EAAE;AACJ;AAEA,MAAM,iBAAiB;AAAA,EACrB,UAAU,CAAC;AAAA,EACX,WAAW;AAAA,EACX,YAAY;AAAA,IACV,MAAM;AAAA,MACJ,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA,OAAO;AACT;AAEA,MAAM,WAAoD,CAAC,SAAS;AAClE,QAAM,CAAC,cAAc,eAAe,QAAI,wBAAS,KAAK;AACtD,QAAM,yBAAqB,sBAA6B,IAAI;AAC5D,QAAM,wBAAoB,sBAA6B,IAAI;AAC3D,QAAM,cAAc,CAAC,QAAyC;AAC5D,oBAAgB,CAAC,YAAY;AAC7B,QAAI,IAAI;AAAS,UAAI,QAAQ,eAAe,EAAE,UAAU,UAAU,OAAO,QAAQ,CAAC;AAAA,EACpF;AACA,SACE,4EACE;AAAA,gDAAC,6CAAwB,IAAI,GAAI,GAAG,MAAM;AAAA,IAC1C,4CAAC,gCACC,uDAAC,+BACC;AAAA,kDAAC,0BAAO,SAAQ,aAAY,SAAS,MAAM,YAAY,kBAAkB,GAAG,8BAE5E;AAAA,MACA,4CAAC,0BAAO,SAAQ,aAAY,SAAS,MAAM,YAAY,iBAAiB,GAAG,6BAE3E;AAAA,OACF,GACF;AAAA,IACA,4CAAC,SACC,uDAAC,8BAAW,KAAK,oBAAoB;AAAA;AAAA,MAClB,4CAAC,UAAM,eAAK,UAAU,KAAK,SAAS,MAAM,CAAC,GAAE;AAAA,OAChE,GACF;AAAA,IACA,4CAAC,SACC,uDAAC,8BAAW,KAAK,mBAAmB;AAAA;AAAA,MAClB,4CAAC,SAAK,eAAK,cAAU,+BAAmB,GAAG,MAAM,CAAC,GAAE;AAAA,OACtE,GACF;AAAA,KACF;AAEJ;AAEA,MAAM,UAAU,SAAS,KAAK,CAAC,CAAC;AAChC,QAAQ,OAAO,CAAC;AAEhB,MAAM,WAAW,SAAS,KAAK,CAAC,CAAC;AACjC,SAAS,OAAO;AAAA,EACd,SAAS;AACX;AAKA,IAAO,6BAAQ;","names":["import_react"]}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button, ButtonGroup, Typography } from "@mui/material";
|
|
3
|
-
import { FlexCol } from "@xylabs/react-flexbox";
|
|
4
|
-
import { ForecastPayloadSchema } from "@xyo-network/diviner-forecasting-model";
|
|
5
|
-
import { useRef, useState } from "react";
|
|
6
|
-
import { MockSourcePayloads } from "../lib";
|
|
7
|
-
import { PriceForecastDetailsBox } from "./DetailsBox";
|
|
8
|
-
const tenMin = 6e5;
|
|
9
|
-
const ForecastingDivinerPayload = {
|
|
10
|
-
schema: ForecastPayloadSchema,
|
|
11
|
-
values: [1, 2, 3, 4, 5, 6, 7, 8].map((item) => ({
|
|
12
|
-
error: 0,
|
|
13
|
-
timestamp: Date.now() + tenMin * item,
|
|
14
|
-
value: 100 * item
|
|
15
|
-
}))
|
|
16
|
-
};
|
|
17
|
-
const StorybookEntry = {
|
|
18
|
-
argTypes: {},
|
|
19
|
-
component: PriceForecastDetailsBox,
|
|
20
|
-
parameters: {
|
|
21
|
-
docs: {
|
|
22
|
-
page: null
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
title: "plugin/price-forecast/DetailsBox"
|
|
26
|
-
};
|
|
27
|
-
const Template = (args) => {
|
|
28
|
-
const [showPayloads, setShowPayloads] = useState(false);
|
|
29
|
-
const forecastPayloadRef = useRef(null);
|
|
30
|
-
const sourcePayloadsRef = useRef(null);
|
|
31
|
-
const handleClick = (ref) => {
|
|
32
|
-
setShowPayloads(!showPayloads);
|
|
33
|
-
if (ref.current)
|
|
34
|
-
ref.current.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
35
|
-
};
|
|
36
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
37
|
-
/* @__PURE__ */ jsx(PriceForecastDetailsBox, { mb: 3, ...args }),
|
|
38
|
-
/* @__PURE__ */ jsx(FlexCol, { children: /* @__PURE__ */ jsxs(ButtonGroup, { children: [
|
|
39
|
-
/* @__PURE__ */ jsx(Button, { variant: "contained", onClick: () => handleClick(forecastPayloadRef), children: "Forecast Payload" }),
|
|
40
|
-
/* @__PURE__ */ jsx(Button, { variant: "contained", onClick: () => handleClick(sourcePayloadsRef), children: "Source Payloads" })
|
|
41
|
-
] }) }),
|
|
42
|
-
/* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsxs(Typography, { ref: forecastPayloadRef, children: [
|
|
43
|
-
"ForecastPayload: ",
|
|
44
|
-
/* @__PURE__ */ jsx("code", { children: JSON.stringify(args.payload, null, 2) })
|
|
45
|
-
] }) }),
|
|
46
|
-
/* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsxs(Typography, { ref: sourcePayloadsRef, children: [
|
|
47
|
-
"SourcePayloads: ",
|
|
48
|
-
/* @__PURE__ */ jsx("pre", { children: JSON.stringify(MockSourcePayloads(), null, 2) })
|
|
49
|
-
] }) })
|
|
50
|
-
] });
|
|
51
|
-
};
|
|
52
|
-
const Default = Template.bind({});
|
|
53
|
-
Default.args = {};
|
|
54
|
-
const WithData = Template.bind({});
|
|
55
|
-
WithData.args = {
|
|
56
|
-
payload: ForecastingDivinerPayload
|
|
57
|
-
};
|
|
58
|
-
var DetailsBox_stories_default = StorybookEntry;
|
|
59
|
-
export {
|
|
60
|
-
Default,
|
|
61
|
-
WithData,
|
|
62
|
-
DetailsBox_stories_default as default
|
|
63
|
-
};
|
|
64
|
-
//# sourceMappingURL=DetailsBox.stories.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/DetailsBox.stories.tsx"],"sourcesContent":["import { Button, ButtonGroup, Typography } from '@mui/material'\nimport { Meta, StoryFn } from '@storybook/react'\nimport { FlexCol } from '@xylabs/react-flexbox'\nimport { ForecastPayloadSchema } from '@xyo-network/diviner-forecasting-model'\nimport { RefObject, useRef, useState } from 'react'\n\nimport { MockSourcePayloads } from '../lib'\nimport { PriceForecastDetailsBox } from './DetailsBox'\n\nconst tenMin = 600000\n\nconst ForecastingDivinerPayload = {\n schema: ForecastPayloadSchema,\n values: [1, 2, 3, 4, 5, 6, 7, 8].map((item) => ({\n error: 0,\n timestamp: Date.now() + tenMin * item,\n value: 100 * item,\n })),\n}\n\nconst StorybookEntry = {\n argTypes: {},\n component: PriceForecastDetailsBox,\n parameters: {\n docs: {\n page: null,\n },\n },\n title: 'plugin/price-forecast/DetailsBox',\n} as Meta<typeof PriceForecastDetailsBox>\n\nconst Template: StoryFn<typeof PriceForecastDetailsBox> = (args) => {\n const [showPayloads, setShowPayloads] = useState(false)\n const forecastPayloadRef = useRef<HTMLParagraphElement>(null)\n const sourcePayloadsRef = useRef<HTMLParagraphElement>(null)\n const handleClick = (ref: RefObject<HTMLParagraphElement>) => {\n setShowPayloads(!showPayloads)\n if (ref.current) ref.current.scrollIntoView({ behavior: 'smooth', block: 'start' })\n }\n return (\n <>\n <PriceForecastDetailsBox mb={3} {...args} />\n <FlexCol>\n <ButtonGroup>\n <Button variant=\"contained\" onClick={() => handleClick(forecastPayloadRef)}>\n Forecast Payload\n </Button>\n <Button variant=\"contained\" onClick={() => handleClick(sourcePayloadsRef)}>\n Source Payloads\n </Button>\n </ButtonGroup>\n </FlexCol>\n <pre>\n <Typography ref={forecastPayloadRef}>\n ForecastPayload: <code>{JSON.stringify(args.payload, null, 2)}</code>\n </Typography>\n </pre>\n <pre>\n <Typography ref={sourcePayloadsRef}>\n SourcePayloads: <pre>{JSON.stringify(MockSourcePayloads(), null, 2)}</pre>\n </Typography>\n </pre>\n </>\n )\n}\n\nconst Default = Template.bind({})\nDefault.args = {}\n\nconst WithData = Template.bind({})\nWithData.args = {\n payload: ForecastingDivinerPayload,\n}\n\nexport { Default, WithData }\n\n// eslint-disable-next-line import/no-default-export\nexport default StorybookEntry\n"],"mappings":"AAwCI,mBACE,KAEE,YAHJ;AAxCJ,SAAS,QAAQ,aAAa,kBAAkB;AAEhD,SAAS,eAAe;AACxB,SAAS,6BAA6B;AACtC,SAAoB,QAAQ,gBAAgB;AAE5C,SAAS,0BAA0B;AACnC,SAAS,+BAA+B;AAExC,MAAM,SAAS;AAEf,MAAM,4BAA4B;AAAA,EAChC,QAAQ;AAAA,EACR,QAAQ,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,EAAE,IAAI,CAAC,UAAU;AAAA,IAC9C,OAAO;AAAA,IACP,WAAW,KAAK,IAAI,IAAI,SAAS;AAAA,IACjC,OAAO,MAAM;AAAA,EACf,E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0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/index.ts"],"sourcesContent":["export * from './DetailsBox'\n"],"mappings":"AAAA,cAAc;","names":[]}
|
package/dist/node/index.mjs
DELETED
package/dist/node/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './components'\nexport * from './Plugin'\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const DataPointStyles = (pointHoverBackgroundColor) => ({
|
|
2
|
-
pointHitRadius: 20,
|
|
3
|
-
pointHoverBackgroundColor,
|
|
4
|
-
pointHoverRadius: 10,
|
|
5
|
-
pointRadius: 5,
|
|
6
|
-
pointStyle: "circle"
|
|
7
|
-
});
|
|
8
|
-
export {
|
|
9
|
-
DataPointStyles
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=DataPointStyles.mjs.map
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { DataLineStyles } from "./DataLineStyles";
|
|
2
|
-
import { DataPointStyles } from "./DataPointStyles";
|
|
3
|
-
import { SourcePayloads } from "./SourcePayloads";
|
|
4
|
-
const defaultOptions = () => ({
|
|
5
|
-
plugins: {
|
|
6
|
-
legend: {
|
|
7
|
-
position: "top"
|
|
8
|
-
}
|
|
9
|
-
},
|
|
10
|
-
responsive: true
|
|
11
|
-
});
|
|
12
|
-
class ForecastLineChartConfigBuilder {
|
|
13
|
-
constructor(theme, payload) {
|
|
14
|
-
this.payload = payload;
|
|
15
|
-
this.themeColors = this.parseTheme(theme);
|
|
16
|
-
}
|
|
17
|
-
data = {
|
|
18
|
-
datasets: []
|
|
19
|
-
};
|
|
20
|
-
options = defaultOptions();
|
|
21
|
-
themeColors;
|
|
22
|
-
get forecastPayload() {
|
|
23
|
-
if (this.payload) {
|
|
24
|
-
return this.payload;
|
|
25
|
-
} else {
|
|
26
|
-
throw Error("ForecastPayload was not defined");
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
static async create(theme, payload, sourcePayloadConfig) {
|
|
30
|
-
const instance = new ForecastLineChartConfigBuilder(theme, payload);
|
|
31
|
-
await instance.build(sourcePayloadConfig?.fetch);
|
|
32
|
-
instance.refreshValues();
|
|
33
|
-
return instance;
|
|
34
|
-
}
|
|
35
|
-
async build(includeSources) {
|
|
36
|
-
this.buildOptions();
|
|
37
|
-
await this.buildData(includeSources);
|
|
38
|
-
return this;
|
|
39
|
-
}
|
|
40
|
-
async buildData(includeSources) {
|
|
41
|
-
const forecastData = this.generateDataSetForecastData();
|
|
42
|
-
const datasets = [forecastData];
|
|
43
|
-
if (includeSources) {
|
|
44
|
-
const sourceData = await this.generateDataSetSourcePayloads();
|
|
45
|
-
datasets.unshift(sourceData);
|
|
46
|
-
const lastSourceDataItem = sourceData.data.at(-1);
|
|
47
|
-
forecastData.data.unshift(lastSourceDataItem);
|
|
48
|
-
}
|
|
49
|
-
this.data = {
|
|
50
|
-
datasets
|
|
51
|
-
};
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
buildOptions() {
|
|
55
|
-
if (this.options.plugins) {
|
|
56
|
-
this.options.plugins.title = this.generateTitle();
|
|
57
|
-
this.options.plugins.legend = this.generateLegend();
|
|
58
|
-
}
|
|
59
|
-
this.options.scales = this.generateScales();
|
|
60
|
-
return this;
|
|
61
|
-
}
|
|
62
|
-
refreshValues() {
|
|
63
|
-
this.data = { ...this.data };
|
|
64
|
-
this.options = { ...this.options };
|
|
65
|
-
}
|
|
66
|
-
generateLegend() {
|
|
67
|
-
return {
|
|
68
|
-
labels: {
|
|
69
|
-
pointStyle: "circle",
|
|
70
|
-
usePointStyle: true
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
generateScales() {
|
|
75
|
-
return {
|
|
76
|
-
x: {
|
|
77
|
-
grid: {
|
|
78
|
-
color: this.themeColors?.gridColor
|
|
79
|
-
},
|
|
80
|
-
time: {
|
|
81
|
-
unit: "minute"
|
|
82
|
-
},
|
|
83
|
-
type: "time"
|
|
84
|
-
},
|
|
85
|
-
y: {
|
|
86
|
-
grid: {
|
|
87
|
-
color: this.themeColors?.gridColor
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
generateTitle() {
|
|
93
|
-
return {
|
|
94
|
-
display: true,
|
|
95
|
-
text: `Gas Price Forecaster (GWEI over time from ${this.forecastPayload?.values[0].timestamp ? new Date(this.forecastPayload.values[0].timestamp).toLocaleDateString() : ""})`
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
parseTheme(theme) {
|
|
99
|
-
const dark = theme.palette.mode === "dark";
|
|
100
|
-
return {
|
|
101
|
-
dataSetColorPrimary: theme.palette.primary.light,
|
|
102
|
-
dataSetColorSecondary: theme.palette.secondary.light,
|
|
103
|
-
gridColor: dark ? theme.palette.grey[800] : theme.palette.grey[300]
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
generateDataSetForecastData() {
|
|
107
|
-
return {
|
|
108
|
-
borderDash: [5],
|
|
109
|
-
borderDashOffset: 0.5,
|
|
110
|
-
data: this.forecastPayload.values.map((price) => ({ x: price.timestamp ?? 0, y: price.value })),
|
|
111
|
-
label: "Forecast Price",
|
|
112
|
-
...DataPointStyles(this.themeColors?.dataSetColorPrimary),
|
|
113
|
-
...DataLineStyles(this.themeColors?.dataSetColorPrimary)
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
async generateDataSetSourcePayloads() {
|
|
117
|
-
const { sourcePrices } = await SourcePayloads.build("feePerGas.medium");
|
|
118
|
-
return {
|
|
119
|
-
data: sourcePrices,
|
|
120
|
-
label: "Source Prices",
|
|
121
|
-
...DataLineStyles(this.themeColors?.dataSetColorSecondary),
|
|
122
|
-
...DataPointStyles(this.themeColors?.dataSetColorSecondary)
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
export {
|
|
127
|
-
ForecastLineChartConfigBuilder
|
|
128
|
-
};
|
|
129
|
-
//# sourceMappingURL=ForecastLineChartConfigBuilder.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/ForecastLineChartConfigBuilder.ts"],"sourcesContent":["import { Theme } from '@mui/material'\nimport { ForecastPayload } from '@xyo-network/diviner-forecasting-model'\nimport { ChartData, ChartDataset, ChartOptions, LegendOptions, Point, ScaleChartOptions } from 'chart.js'\n// eslint-disable-next-line import/no-unresolved\nimport { _DeepPartialObject } from 'chart.js/dist/types/utils'\n\nimport { DataLineStyles } from './DataLineStyles'\nimport { DataPointStyles } from './DataPointStyles'\nimport { SourcePayloads } from './SourcePayloads'\n\ninterface SourcePayloadConfig {\n fetch: boolean\n sampleSize?: number\n}\n\ninterface ThemeColors {\n dataSetColorPrimary: string\n dataSetColorSecondary: string\n gridColor: string\n}\n\nconst defaultOptions: () => ChartOptions<'line'> = () => ({\n plugins: {\n legend: {\n position: 'top' as const,\n },\n },\n responsive: true,\n})\n\nexport class ForecastLineChartConfigBuilder {\n data: ChartData<'line'> = {\n datasets: [],\n }\n options: ChartOptions<'line'> = defaultOptions()\n themeColors: ThemeColors | undefined\n\n constructor(\n theme: Theme,\n private payload?: ForecastPayload,\n ) {\n this.themeColors = this.parseTheme(theme)\n }\n\n get forecastPayload() {\n if (this.payload) {\n return this.payload\n } else {\n throw Error('ForecastPayload was not defined')\n }\n }\n\n static async create(theme: Theme, payload?: ForecastPayload, sourcePayloadConfig?: SourcePayloadConfig) {\n const instance = new ForecastLineChartConfigBuilder(theme, payload)\n\n await instance.build(sourcePayloadConfig?.fetch)\n\n instance.refreshValues()\n\n return instance\n }\n\n async build(includeSources?: boolean) {\n this.buildOptions()\n await this.buildData(includeSources)\n return this\n }\n\n async buildData(includeSources?: boolean) {\n const forecastData = this.generateDataSetForecastData()\n\n const datasets: ChartDataset<'line'>[] = [forecastData]\n\n if (includeSources) {\n // build data from sources in forecastPayload\n const sourceData = await this.generateDataSetSourcePayloads()\n datasets.unshift(sourceData)\n\n // add last source point as first item in prediction to connect the lines\n const lastSourceDataItem = sourceData.data.at(-1) as Point\n forecastData.data.unshift(lastSourceDataItem)\n }\n\n this.data = {\n datasets,\n }\n\n return this\n }\n\n buildOptions() {\n if (this.options.plugins) {\n this.options.plugins.title = this.generateTitle()\n this.options.plugins.legend = this.generateLegend()\n }\n this.options.scales = this.generateScales()\n\n return this\n }\n\n refreshValues() {\n this.data = { ...this.data }\n this.options = { ...this.options }\n }\n\n protected generateLegend(): _DeepPartialObject<LegendOptions<'line'>> {\n return {\n labels: {\n pointStyle: 'circle',\n usePointStyle: true,\n },\n }\n }\n\n protected generateScales(): _DeepPartialObject<ScaleChartOptions<'line'>['scales']> {\n return {\n x: {\n grid: {\n color: this.themeColors?.gridColor,\n },\n time: {\n unit: 'minute',\n },\n type: 'time',\n },\n y: {\n grid: {\n color: this.themeColors?.gridColor,\n },\n },\n }\n }\n\n protected generateTitle() {\n return {\n display: true,\n text: `Gas Price Forecaster (GWEI over time from ${\n this.forecastPayload?.values[0].timestamp ? new Date(this.forecastPayload.values[0].timestamp).toLocaleDateString() : ''\n })`,\n }\n }\n\n protected parseTheme(theme: Theme) {\n const dark = theme.palette.mode === 'dark'\n return {\n dataSetColorPrimary: theme.palette.primary.light,\n dataSetColorSecondary: theme.palette.secondary.light,\n gridColor: dark ? theme.palette.grey[800] : theme.palette.grey[300],\n }\n }\n\n private generateDataSetForecastData(): ChartDataset<'line'> {\n return {\n borderDash: [5],\n borderDashOffset: 0.5,\n data: this.forecastPayload.values.map((price) => ({ x: price.timestamp ?? 0, y: price.value })),\n label: 'Forecast Price',\n ...DataPointStyles(this.themeColors?.dataSetColorPrimary),\n ...DataLineStyles(this.themeColors?.dataSetColorPrimary),\n }\n }\n\n private async generateDataSetSourcePayloads(): Promise<ChartDataset<'line'>> {\n const { sourcePrices } = await SourcePayloads.build('feePerGas.medium')\n return {\n data: sourcePrices,\n label: 'Source Prices',\n ...DataLineStyles(this.themeColors?.dataSetColorSecondary),\n ...DataPointStyles(this.themeColors?.dataSetColorSecondary),\n }\n }\n}\n"],"mappings":"AAMA,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAa/B,MAAM,iBAA6C,OAAO;AAAA,EACxD,SAAS;AAAA,IACP,QAAQ;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,EACF;AAAA,EACA,YAAY;AACd;AAEO,MAAM,+BAA+B;AAAA,EAO1C,YACE,OACQ,SACR;AADQ;AAER,SAAK,cAAc,KAAK,WAAW,KAAK;AAAA,EAC1C;AAAA,EAXA,OAA0B;AAAA,IACxB,UAAU,CAAC;AAAA,EACb;AAAA,EACA,UAAgC,eAAe;AAAA,EAC/C;AAAA,EASA,IAAI,kBAAkB;AACpB,QAAI,KAAK,SAAS;AAChB,aAAO,KAAK;AAAA,IACd,OAAO;AACL,YAAM,MAAM,iCAAiC;AAAA,IAC/C;AAAA,EACF;AAAA,EAEA,aAAa,OAAO,OAAc,SAA2B,qBAA2C;AACtG,UAAM,WAAW,IAAI,+BAA+B,OAAO,OAAO;AAElE,UAAM,SAAS,MAAM,qBAAqB,KAAK;AAE/C,aAAS,cAAc;AAEvB,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,MAAM,gBAA0B;AACpC,SAAK,aAAa;AAClB,UAAM,KAAK,UAAU,cAAc;AACnC,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,UAAU,gBAA0B;AACxC,UAAM,eAAe,KAAK,4BAA4B;AAEtD,UAAM,WAAmC,CAAC,YAAY;AAEtD,QAAI,gBAAgB;AAElB,YAAM,aAAa,MAAM,KAAK,8BAA8B;AAC5D,eAAS,QAAQ,UAAU;AAG3B,YAAM,qBAAqB,WAAW,KAAK,GAAG,EAAE;AAChD,mBAAa,KAAK,QAAQ,kBAAkB;AAAA,IAC9C;AAEA,SAAK,OAAO;AAAA,MACV;AAAA,IACF;AAEA,WAAO;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,8BAAoD;AAC1D,WAAO;AAAA,MACL,YAAY,CAAC,CAAC;AAAA,MACd,kBAAkB;AAAA,MAClB,MAAM,KAAK,gBAAgB,OAAO,IAAI,CAAC,WAAW,EAAE,GAAG,MAAM,aAAa,GAAG,GAAG,MAAM,MAAM,EAAE;AAAA,MAC9F,OAAO;AAAA,MACP,GAAG,gBAAgB,KAAK,aAAa,mBAAmB;AAAA,MACxD,GAAG,eAAe,KAAK,aAAa,mBAAmB;AAAA,IACzD;AAAA,EACF;AAAA,EAEA,MAAc,gCAA+D;AAC3E,UAAM,EAAE,aAAa,IAAI,MAAM,eAAe,MAAM,kBAAkB;AACtE,WAAO;AAAA,MACL,MAAM;AAAA,MACN,OAAO;AAAA,MACP,GAAG,eAAe,KAAK,aAAa,qBAAqB;AAAA,MACzD,GAAG,gBAAgB,KAAK,aAAa,qBAAqB;AAAA,IAC5D;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const MockSourcePayloads = () => {
|
|
2
|
-
const tenMin = 6e5;
|
|
3
|
-
return [
|
|
4
|
-
{
|
|
5
|
-
baseFee: 38.90155387825,
|
|
6
|
-
feePerGas: { high: 47.9945864396, low: 39.006868093, medium: 39.306868093, veryHigh: 44.45384380525 },
|
|
7
|
-
priorityFeePerGas: { high: 1.0266666666666666, low: -0.41000000000000003, medium: 0.38, veryHigh: 1.3900000000000001 },
|
|
8
|
-
schema: "network.xyo.blockchain.ethereum.gas",
|
|
9
|
-
timestamp: Date.now() - tenMin
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
baseFee: 38.90155387825,
|
|
13
|
-
feePerGas: { high: 47.9945864396, low: 39.006868093, medium: 100, veryHigh: 44.45384380525 },
|
|
14
|
-
priorityFeePerGas: { high: 1.0266666666666666, low: -0.41000000000000003, medium: 0.38, veryHigh: 1.3900000000000001 },
|
|
15
|
-
schema: "network.xyo.blockchain.ethereum.gas",
|
|
16
|
-
timestamp: Date.now()
|
|
17
|
-
}
|
|
18
|
-
];
|
|
19
|
-
};
|
|
20
|
-
export {
|
|
21
|
-
MockSourcePayloads
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=MockSourcePayloads.mjs.map
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { MockSourcePayloads } from "./MockSourcePayloads";
|
|
2
|
-
class SourcePayloads {
|
|
3
|
-
constructor(sourcePayloads) {
|
|
4
|
-
this.sourcePayloads = sourcePayloads;
|
|
5
|
-
}
|
|
6
|
-
sourcePrices = [];
|
|
7
|
-
get payloads() {
|
|
8
|
-
return this.sourcePayloads;
|
|
9
|
-
}
|
|
10
|
-
static async build(jsonPath) {
|
|
11
|
-
const sourcePayloads = await this.fetchSourcePayloads();
|
|
12
|
-
const instance = new this(sourcePayloads);
|
|
13
|
-
const paths = jsonPath.split(".");
|
|
14
|
-
instance.sourcePrices = sourcePayloads.map((payload) => {
|
|
15
|
-
return { x: payload.timestamp, y: instance.jsonPathTraverser(payload, paths) };
|
|
16
|
-
});
|
|
17
|
-
return instance;
|
|
18
|
-
}
|
|
19
|
-
// TODO - fetch from archivist
|
|
20
|
-
static async fetchSourcePayloads() {
|
|
21
|
-
const payloads = await Promise.resolve(MockSourcePayloads());
|
|
22
|
-
return payloads;
|
|
23
|
-
}
|
|
24
|
-
jsonPathTraverser(obj, path) {
|
|
25
|
-
let result = obj;
|
|
26
|
-
for (const key of path) {
|
|
27
|
-
if (key in result) {
|
|
28
|
-
const foundKey = key;
|
|
29
|
-
result = result[foundKey];
|
|
30
|
-
} else {
|
|
31
|
-
result = void 0;
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return result;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
export {
|
|
39
|
-
SourcePayloads
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=SourcePayloads.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/SourcePayloads.ts"],"sourcesContent":["import { Payload } from '@xyo-network/payload-model'\nimport { Point } from 'chart.js'\n\nimport { MockSourcePayloads } from './MockSourcePayloads'\n\nexport class SourcePayloads {\n sourcePrices: Point[] = []\n\n constructor(public sourcePayloads: Payload[]) {}\n\n get payloads() {\n return this.sourcePayloads\n }\n\n static async build(jsonPath: string) {\n const sourcePayloads = await this.fetchSourcePayloads()\n const instance = new this(sourcePayloads)\n\n const paths = jsonPath.split('.')\n instance.sourcePrices = sourcePayloads.map((payload) => {\n return { x: payload.timestamp, y: instance.jsonPathTraverser(payload, paths) }\n })\n return instance\n }\n\n // TODO - fetch from archivist\n static async fetchSourcePayloads() {\n const payloads = await Promise.resolve(MockSourcePayloads())\n return payloads\n }\n\n jsonPathTraverser(obj: Payload, path: string[]) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let result: any = obj\n for (const key of path) {\n if (key in result) {\n const foundKey = key as keyof typeof result\n result = result[foundKey]\n } else {\n result = undefined\n break\n }\n }\n\n return result\n }\n}\n"],"mappings":"AAGA,SAAS,0BAA0B;AAE5B,MAAM,eAAe;AAAA,EAG1B,YAAmB,gBAA2B;AAA3B;AAAA,EAA4B;AAAA,EAF/C,eAAwB,CAAC;AAAA,EAIzB,IAAI,WAAW;AACb,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,aAAa,MAAM,UAAkB;AACnC,UAAM,iBAAiB,MAAM,KAAK,oBAAoB;AACtD,UAAM,WAAW,IAAI,KAAK,cAAc;AAExC,UAAM,QAAQ,SAAS,MAAM,GAAG;AAChC,aAAS,eAAe,eAAe,IAAI,CAAC,YAAY;AACtD,aAAO,EAAE,GAAG,QAAQ,WAAW,GAAG,SAAS,kBAAkB,SAAS,KAAK,EAAE;AAAA,IAC/E,CAAC;AACD,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,aAAa,sBAAsB;AACjC,UAAM,WAAW,MAAM,QAAQ,QAAQ,mBAAmB,CAAC;AAC3D,WAAO;AAAA,EACT;AAAA,EAEA,kBAAkB,KAAc,MAAgB;AAE9C,QAAI,SAAc;AAClB,eAAW,OAAO,MAAM;AACtB,UAAI,OAAO,QAAQ;AACjB,cAAM,WAAW;AACjB,iBAAS,OAAO,QAAQ;AAAA,MAC1B,OAAO;AACL,iBAAS;AACT;AAAA,MACF;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/dist/node/lib/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/index.ts"],"sourcesContent":["export * from './ForecastLineChartConfigBuilder'\nexport * from './MockSourcePayloads'\nexport * from './SourcePayloads'\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|