@dshtrading/client-ui-strategies 0.6.3 → 0.7.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/lib/client.js CHANGED
@@ -8261,6 +8261,12 @@ window.__ModuleLoader__.load({
8261
8261
  }
8262
8262
  //#endregion
8263
8263
  //#region ../indicators/lib/validate.js
8264
+ /**
8265
+ * Worker 启动兜底(毫秒)。WebKit 上新建 Worker + 编译 blob 脚本是几十到上百毫秒,
8266
+ * 且这段属于环境开销而不是指标代码的耗时——试算超时只从 Worker 报到 start 之后算,
8267
+ * 这里给启动本身留足余量,同时不让它无限挂着。
8268
+ */
8269
+ const WORKER_STARTUP_TIMEOUT_MS = 1e4;
8264
8270
  /** 生成特征测试 K 线序列。 */
8265
8271
  function createSampleBars() {
8266
8272
  const baseTime = 17e11;
@@ -8358,6 +8364,9 @@ window.__ModuleLoader__.load({
8358
8364
  const WORKER_TRIAL_SCRIPT = `self.onmessage = (event) => {
8359
8365
  const { source, bars, params } = event.data
8360
8366
  try {
8367
+ // 先报一声"开始算了",主线程据此才起超时计时:Worker 的创建与脚本编译在 WebKit
8368
+ // 上是几十到上百毫秒,算作执行时间会把合法指标误判成死循环。
8369
+ self.postMessage({ phase: 'start' })
8361
8370
  const trimmed = String(source).trim()
8362
8371
  let fn
8363
8372
  if (/^(?:\\([a-zA-Z0-9_,\\s]*\\)|[a-zA-Z0-9_]+)\\s*=>/.test(trimmed) || /^function\\b/.test(trimmed)) {
@@ -8389,19 +8398,31 @@ window.__ModuleLoader__.load({
8389
8398
  const url = URL.createObjectURL(blob);
8390
8399
  const worker = new Worker(url);
8391
8400
  let settled = false;
8401
+ /** 当前生效的计时器:先是启动兜底,收到 Worker 的 start 后换成 compute 超时。 */
8402
+ let timer;
8403
+ const arm = (action, ms) => {
8404
+ if (timer !== void 0) clearTimeout(timer);
8405
+ timer = setTimeout(action, ms);
8406
+ };
8392
8407
  const finish = (action) => {
8393
8408
  if (settled) return;
8394
8409
  settled = true;
8395
- clearTimeout(timer);
8410
+ if (timer !== void 0) clearTimeout(timer);
8396
8411
  worker.terminate();
8397
8412
  URL.revokeObjectURL(url);
8398
8413
  action();
8399
8414
  };
8400
- const timer = setTimeout(() => {
8401
- finish(() => reject(/* @__PURE__ */ new Error(`compute 执行超时(超过 ${timeoutMs}ms),可能存在死循环(如 while/for 未退出)`)));
8402
- }, timeoutMs);
8415
+ arm(() => {
8416
+ finish(() => reject(/* @__PURE__ */ new Error("compute 试算环境没有起来(Worker 启动超时)")));
8417
+ }, WORKER_STARTUP_TIMEOUT_MS);
8403
8418
  worker.onmessage = (event) => {
8404
8419
  const data = event.data;
8420
+ if (data.phase === "start") {
8421
+ arm(() => {
8422
+ finish(() => reject(/* @__PURE__ */ new Error(`compute 执行超时(超过 ${timeoutMs}ms),可能存在死循环(如 while/for 未退出)`)));
8423
+ }, timeoutMs);
8424
+ return;
8425
+ }
8405
8426
  finish(() => {
8406
8427
  if (data.ok) resolve(data.result);
8407
8428
  else reject(new Error(data.message ?? "compute 执行失败"));
@@ -9984,30 +10005,30 @@ window.__ModuleLoader__.load({
9984
10005
  document.head.appendChild(tag);
9985
10006
  }
9986
10007
  var StrategyEditor_module_css_default = {
9987
- "panelHeader": "_9mrMhW_panelHeader",
9988
- "sourceArea": "_9mrMhW_sourceArea",
9989
- "secondaryBtn": "_9mrMhW_secondaryBtn",
9990
- "panel": "_9mrMhW_panel",
9991
- "noticeError": "_9mrMhW_noticeError",
10008
+ "paramTable": "_9mrMhW_paramTable",
10009
+ "fieldLabel": "_9mrMhW_fieldLabel",
10010
+ "actionSpacer": "_9mrMhW_actionSpacer",
10011
+ "paramRemove": "_9mrMhW_paramRemove",
10012
+ "overlay": "_9mrMhW_overlay",
9992
10013
  "noticeOk": "_9mrMhW_noticeOk",
9993
- "columnHeadRow": "_9mrMhW_columnHeadRow",
9994
- "columnRow": "_9mrMhW_columnRow",
9995
10014
  "field": "_9mrMhW_field",
10015
+ "noticeError": "_9mrMhW_noticeError",
10016
+ "actionBar": "_9mrMhW_actionBar",
9996
10017
  "paramCell": "_9mrMhW_paramCell",
10018
+ "paramRow": "_9mrMhW_paramRow",
10019
+ "secondaryBtn": "_9mrMhW_secondaryBtn",
10020
+ "panelTitle": "_9mrMhW_panelTitle",
10021
+ "columnRow": "_9mrMhW_columnRow",
9997
10022
  "addParamBtn": "_9mrMhW_addParamBtn",
9998
- "actionBar": "_9mrMhW_actionBar",
10023
+ "panel": "_9mrMhW_panel",
9999
10024
  "closeBtn": "_9mrMhW_closeBtn",
10000
- "overlay": "_9mrMhW_overlay",
10001
- "fieldLabel": "_9mrMhW_fieldLabel",
10025
+ "panelHeader": "_9mrMhW_panelHeader",
10026
+ "primaryBtn": "_9mrMhW_primaryBtn",
10002
10027
  "fieldInput": "_9mrMhW_fieldInput",
10003
- "paramRemove": "_9mrMhW_paramRemove",
10004
- "paramHeadRow": "_9mrMhW_paramHeadRow",
10005
- "paramRow": "_9mrMhW_paramRow",
10006
10028
  "formGrid": "_9mrMhW_formGrid",
10007
- "actionSpacer": "_9mrMhW_actionSpacer",
10008
- "panelTitle": "_9mrMhW_panelTitle",
10009
- "paramTable": "_9mrMhW_paramTable",
10010
- "primaryBtn": "_9mrMhW_primaryBtn"
10029
+ "paramHeadRow": "_9mrMhW_paramHeadRow",
10030
+ "sourceArea": "_9mrMhW_sourceArea",
10031
+ "columnHeadRow": "_9mrMhW_columnHeadRow"
10011
10032
  };
10012
10033
  //#endregion
10013
10034
  //#region src/client/ScreenerEditor.tsx
@@ -10460,47 +10481,47 @@ window.__ModuleLoader__.load({
10460
10481
  document.head.appendChild(tag);
10461
10482
  }
10462
10483
  var StrategyView_module_css_default = {
10484
+ "trendUp": "jg958W_trendUp",
10463
10485
  "configBar": "jg958W_configBar",
10486
+ "strategyCards": "jg958W_strategyCards",
10487
+ "tableSection": "jg958W_tableSection",
10488
+ "progressFill": "jg958W_progressFill",
10489
+ "progressWrap": "jg958W_progressWrap",
10490
+ "metricValue": "jg958W_metricValue",
10491
+ "chartWrapper": "jg958W_chartWrapper",
10492
+ "strategyCard": "jg958W_strategyCard",
10493
+ "mgmtRow": "jg958W_mgmtRow",
10494
+ "newStrategyBtn": "jg958W_newStrategyBtn",
10495
+ "root": "jg958W_root",
10496
+ "emptyIcon": "jg958W_emptyIcon",
10497
+ "horizonSelector": "jg958W_horizonSelector",
10464
10498
  "horizonBtn": "jg958W_horizonBtn",
10465
- "metricsGrid": "jg958W_metricsGrid",
10499
+ "paramInput": "jg958W_paramInput",
10466
10500
  "metricCard": "jg958W_metricCard",
10467
- "cardSummary": "jg958W_cardSummary",
10468
- "scanMeta": "jg958W_scanMeta",
10469
- "metricLabel": "jg958W_metricLabel",
10470
- "cardTitle": "jg958W_cardTitle",
10501
+ "chartContainer": "jg958W_chartContainer",
10471
10502
  "tableTitle": "jg958W_tableTitle",
10472
- "tradesTable": "jg958W_tradesTable",
10503
+ "cardBadge": "jg958W_cardBadge",
10473
10504
  "cardActions": "jg958W_cardActions",
10474
- "chartWrapper": "jg958W_chartWrapper",
10505
+ "trendDown": "jg958W_trendDown",
10506
+ "tradesTableWrapper": "jg958W_tradesTableWrapper",
10507
+ "tableEmptyCell": "jg958W_tableEmptyCell",
10508
+ "tradesTable": "jg958W_tradesTable",
10509
+ "cardTitleRow": "jg958W_cardTitleRow",
10475
10510
  "paramLabel": "jg958W_paramLabel",
10476
- "progressWrap": "jg958W_progressWrap",
10477
- "chartContainer": "jg958W_chartContainer",
10478
- "header": "jg958W_header",
10511
+ "runBtn": "jg958W_runBtn",
10512
+ "errorMessage": "jg958W_errorMessage",
10513
+ "scanMeta": "jg958W_scanMeta",
10514
+ "symbolValue": "jg958W_symbolValue",
10515
+ "cardTitle": "jg958W_cardTitle",
10479
10516
  "paramGroup": "jg958W_paramGroup",
10480
- "progressFill": "jg958W_progressFill",
10481
- "tableSection": "jg958W_tableSection",
10517
+ "cardSummary": "jg958W_cardSummary",
10518
+ "header": "jg958W_header",
10519
+ "cardActionBtn": "jg958W_cardActionBtn",
10520
+ "metricLabel": "jg958W_metricLabel",
10482
10521
  "reasonCell": "jg958W_reasonCell",
10483
- "trendUp": "jg958W_trendUp",
10484
- "mgmtRow": "jg958W_mgmtRow",
10485
- "paramInput": "jg958W_paramInput",
10486
- "symbolValue": "jg958W_symbolValue",
10487
- "tradesTableWrapper": "jg958W_tradesTableWrapper",
10488
- "horizonSelector": "jg958W_horizonSelector",
10489
10522
  "emptyState": "jg958W_emptyState",
10490
- "cardBadge": "jg958W_cardBadge",
10491
- "emptyIcon": "jg958W_emptyIcon",
10492
10523
  "nameCell": "jg958W_nameCell",
10493
- "metricValue": "jg958W_metricValue",
10494
- "trendDown": "jg958W_trendDown",
10495
- "cardActionBtn": "jg958W_cardActionBtn",
10496
- "root": "jg958W_root",
10497
- "errorMessage": "jg958W_errorMessage",
10498
- "newStrategyBtn": "jg958W_newStrategyBtn",
10499
- "strategyCard": "jg958W_strategyCard",
10500
- "strategyCards": "jg958W_strategyCards",
10501
- "tableEmptyCell": "jg958W_tableEmptyCell",
10502
- "runBtn": "jg958W_runBtn",
10503
- "cardTitleRow": "jg958W_cardTitleRow"
10524
+ "metricsGrid": "jg958W_metricsGrid"
10504
10525
  };
10505
10526
  //#endregion
10506
10527
  //#region src/client/ScreenerPane.tsx
@@ -12105,18 +12126,18 @@ window.__ModuleLoader__.load({
12105
12126
  document.head.appendChild(tag);
12106
12127
  }
12107
12128
  var toolview_module_css_default = {
12108
- "spark": "MbbyQa_spark",
12109
- "card": "MbbyQa_card",
12129
+ "metric": "MbbyQa_metric",
12110
12130
  "reason": "MbbyQa_reason",
12131
+ "head": "MbbyQa_head",
12111
12132
  "title": "MbbyQa_title",
12112
- "metric": "MbbyQa_metric",
12113
- "meta": "MbbyQa_meta",
12133
+ "metricValue": "MbbyQa_metricValue",
12114
12134
  "chip": "MbbyQa_chip",
12135
+ "card": "MbbyQa_card",
12136
+ "meta": "MbbyQa_meta",
12137
+ "spark": "MbbyQa_spark",
12138
+ "params": "MbbyQa_params",
12115
12139
  "metrics": "MbbyQa_metrics",
12116
- "metricLabel": "MbbyQa_metricLabel",
12117
- "head": "MbbyQa_head",
12118
- "metricValue": "MbbyQa_metricValue",
12119
- "params": "MbbyQa_params"
12140
+ "metricLabel": "MbbyQa_metricLabel"
12120
12141
  };
12121
12142
  //#endregion
12122
12143
  //#region src/client/toolview.tsx