@backtest-kit/ui 6.8.1 → 6.9.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/build/index.cjs CHANGED
@@ -22,7 +22,7 @@ const CC_WWWROOT_HOST = process.env.CC_WWWROOT_HOST || "0.0.0.0";
22
22
  const CC_WWWROOT_PORT = parseInt(process.env.CC_WWWROOT_PORT) || 60050;
23
23
  const CC_ENABLE_MOCK = !!parseInt(process.env.CC_ENABLE_MOCK) || false;
24
24
 
25
- const serveSubject = new functoolsKit.Subject();
25
+ const serveSubject = new functoolsKit.BehaviorSubject();
26
26
 
27
27
  const router$b = Router({
28
28
  params: true,
@@ -1672,9 +1672,9 @@ const symbol_list = [
1672
1672
  ];
1673
1673
 
1674
1674
  const require$3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
1675
- const getSymbolList = functoolsKit.singleshot(() => {
1675
+ const getSymbolList = functoolsKit.singleshot((cwd) => {
1676
1676
  try {
1677
- const modulePath = require$3.resolve(path.join(process.cwd(), `./config/symbol.config.cjs`));
1677
+ const modulePath = require$3.resolve(path.join(cwd, `./config/symbol.config.cjs`));
1678
1678
  console.log(`Using ${modulePath} implementation as symbol.config.cjs`);
1679
1679
  return require$3(modulePath);
1680
1680
  }
@@ -1688,7 +1688,10 @@ class SymbolConnectionService {
1688
1688
  this.loggerService = inject(TYPES.loggerService);
1689
1689
  this.getSymbolList = functoolsKit.singleshot(async () => {
1690
1690
  this.loggerService.log("symbolConnectionService getSymbolList");
1691
- const symbolListRaw = await getSymbolList();
1691
+ if (!serveSubject.data) {
1692
+ throw new Error("Make sure to call serve() before getSymbolList().");
1693
+ }
1694
+ const symbolListRaw = await getSymbolList(serveSubject.data);
1692
1695
  const uniqueSymbols = new Set();
1693
1696
  const symbolList = symbolListRaw
1694
1697
  .filter((item) => {
@@ -4147,12 +4150,12 @@ const serveInternal = functoolsKit.singleshot((host = CC_WWWROOT_HOST, port = CC
4147
4150
  serveInternal.clear();
4148
4151
  };
4149
4152
  });
4150
- function serve(host, port) {
4153
+ function serve(host, port, cwd = process.cwd()) {
4151
4154
  ioc.loggerService.log(METHOD_NAME_SERVE, {
4152
4155
  host,
4153
4156
  port,
4154
4157
  });
4155
- serveSubject.next();
4158
+ serveSubject.next(cwd);
4156
4159
  return serveInternal(host, port);
4157
4160
  }
4158
4161
  function getRouter() {
package/build/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import http from 'http';
2
- import { Subject, isObject, singleshot, pickDocuments, str, memoize, errorData, getErrorMessage } from 'functools-kit';
2
+ import { BehaviorSubject, isObject, singleshot, pickDocuments, str, memoize, errorData, getErrorMessage } from 'functools-kit';
3
3
  import micro from 'micro';
4
4
  import Router from 'router';
5
5
  import finalhandler from 'finalhandler';
@@ -19,7 +19,7 @@ const CC_WWWROOT_HOST = process.env.CC_WWWROOT_HOST || "0.0.0.0";
19
19
  const CC_WWWROOT_PORT = parseInt(process.env.CC_WWWROOT_PORT) || 60050;
20
20
  const CC_ENABLE_MOCK = !!parseInt(process.env.CC_ENABLE_MOCK) || false;
21
21
 
22
- const serveSubject = new Subject();
22
+ const serveSubject = new BehaviorSubject();
23
23
 
24
24
  const router$b = Router({
25
25
  params: true,
@@ -1669,9 +1669,9 @@ const symbol_list = [
1669
1669
  ];
1670
1670
 
1671
1671
  const require$2 = createRequire(import.meta.url);
1672
- const getSymbolList = singleshot(() => {
1672
+ const getSymbolList = singleshot((cwd) => {
1673
1673
  try {
1674
- const modulePath = require$2.resolve(path.join(process.cwd(), `./config/symbol.config.cjs`));
1674
+ const modulePath = require$2.resolve(path.join(cwd, `./config/symbol.config.cjs`));
1675
1675
  console.log(`Using ${modulePath} implementation as symbol.config.cjs`);
1676
1676
  return require$2(modulePath);
1677
1677
  }
@@ -1685,7 +1685,10 @@ class SymbolConnectionService {
1685
1685
  this.loggerService = inject(TYPES.loggerService);
1686
1686
  this.getSymbolList = singleshot(async () => {
1687
1687
  this.loggerService.log("symbolConnectionService getSymbolList");
1688
- const symbolListRaw = await getSymbolList();
1688
+ if (!serveSubject.data) {
1689
+ throw new Error("Make sure to call serve() before getSymbolList().");
1690
+ }
1691
+ const symbolListRaw = await getSymbolList(serveSubject.data);
1689
1692
  const uniqueSymbols = new Set();
1690
1693
  const symbolList = symbolListRaw
1691
1694
  .filter((item) => {
@@ -4144,12 +4147,12 @@ const serveInternal = singleshot((host = CC_WWWROOT_HOST, port = CC_WWWROOT_PORT
4144
4147
  serveInternal.clear();
4145
4148
  };
4146
4149
  });
4147
- function serve(host, port) {
4150
+ function serve(host, port, cwd = process.cwd()) {
4148
4151
  ioc.loggerService.log(METHOD_NAME_SERVE, {
4149
4152
  host,
4150
4153
  port,
4151
4154
  });
4152
- serveSubject.next();
4155
+ serveSubject.next(cwd);
4153
4156
  return serveInternal(host, port);
4154
4157
  }
4155
4158
  function getRouter() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backtest-kit/ui",
3
- "version": "6.8.1",
3
+ "version": "6.9.0",
4
4
  "description": "Full-stack UI framework for visualizing cryptocurrency trading signals, backtests, and real-time market data. React dashboard with candlestick charts, signal tracking, and risk analysis.",
5
5
  "author": {
6
6
  "name": "Petr Tripolsky",
@@ -92,11 +92,11 @@
92
92
  "ccxt": "4.5.24",
93
93
  "touch": "3.1.1",
94
94
  "worker-testbed": "1.0.12",
95
- "backtest-kit": "6.8.1",
95
+ "backtest-kit": "6.9.0",
96
96
  "markdown-it": "14.1.0"
97
97
  },
98
98
  "peerDependencies": {
99
- "backtest-kit": "^6.8.1",
99
+ "backtest-kit": "^6.9.0",
100
100
  "markdown-it": "^14.1.0",
101
101
  "ccxt": "^4.5.24",
102
102
  "typescript": "^5.0.0"
package/types.d.ts CHANGED
@@ -3,7 +3,7 @@ import * as backtest_kit from 'backtest-kit';
3
3
  import { CandleInterval, NotificationModel, IStorageSignalRow, ILogEntry, IPublicSignalRow } from 'backtest-kit';
4
4
  import * as functools_kit from 'functools-kit';
5
5
 
6
- declare function serve(host?: string, port?: number): () => void;
6
+ declare function serve(host?: string, port?: number, cwd?: string): () => void;
7
7
  declare function getRouter(): http.RequestListener;
8
8
 
9
9
  interface ILogger {