@dshtrading/client-ui-strategies 0.6.3 → 0.7.1

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 执行失败"));
@@ -9985,29 +10006,29 @@ window.__ModuleLoader__.load({
9985
10006
  }
9986
10007
  var StrategyEditor_module_css_default = {
9987
10008
  "panelHeader": "_9mrMhW_panelHeader",
9988
- "sourceArea": "_9mrMhW_sourceArea",
9989
- "secondaryBtn": "_9mrMhW_secondaryBtn",
9990
- "panel": "_9mrMhW_panel",
9991
- "noticeError": "_9mrMhW_noticeError",
10009
+ "fieldLabel": "_9mrMhW_fieldLabel",
10010
+ "panelTitle": "_9mrMhW_panelTitle",
10011
+ "paramHeadRow": "_9mrMhW_paramHeadRow",
9992
10012
  "noticeOk": "_9mrMhW_noticeOk",
9993
10013
  "columnHeadRow": "_9mrMhW_columnHeadRow",
9994
- "columnRow": "_9mrMhW_columnRow",
9995
10014
  "field": "_9mrMhW_field",
9996
- "paramCell": "_9mrMhW_paramCell",
9997
10015
  "addParamBtn": "_9mrMhW_addParamBtn",
9998
- "actionBar": "_9mrMhW_actionBar",
9999
- "closeBtn": "_9mrMhW_closeBtn",
10000
10016
  "overlay": "_9mrMhW_overlay",
10001
- "fieldLabel": "_9mrMhW_fieldLabel",
10017
+ "actionBar": "_9mrMhW_actionBar",
10018
+ "secondaryBtn": "_9mrMhW_secondaryBtn",
10019
+ "paramRow": "_9mrMhW_paramRow",
10020
+ "noticeError": "_9mrMhW_noticeError",
10002
10021
  "fieldInput": "_9mrMhW_fieldInput",
10022
+ "actionSpacer": "_9mrMhW_actionSpacer",
10023
+ "sourceArea": "_9mrMhW_sourceArea",
10024
+ "primaryBtn": "_9mrMhW_primaryBtn",
10003
10025
  "paramRemove": "_9mrMhW_paramRemove",
10004
- "paramHeadRow": "_9mrMhW_paramHeadRow",
10005
- "paramRow": "_9mrMhW_paramRow",
10026
+ "closeBtn": "_9mrMhW_closeBtn",
10027
+ "paramCell": "_9mrMhW_paramCell",
10028
+ "panel": "_9mrMhW_panel",
10006
10029
  "formGrid": "_9mrMhW_formGrid",
10007
- "actionSpacer": "_9mrMhW_actionSpacer",
10008
- "panelTitle": "_9mrMhW_panelTitle",
10009
10030
  "paramTable": "_9mrMhW_paramTable",
10010
- "primaryBtn": "_9mrMhW_primaryBtn"
10031
+ "columnRow": "_9mrMhW_columnRow"
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 = {
10463
- "configBar": "jg958W_configBar",
10464
- "horizonBtn": "jg958W_horizonBtn",
10465
- "metricsGrid": "jg958W_metricsGrid",
10466
10484
  "metricCard": "jg958W_metricCard",
10467
- "cardSummary": "jg958W_cardSummary",
10468
- "scanMeta": "jg958W_scanMeta",
10469
- "metricLabel": "jg958W_metricLabel",
10485
+ "paramLabel": "jg958W_paramLabel",
10486
+ "metricValue": "jg958W_metricValue",
10470
10487
  "cardTitle": "jg958W_cardTitle",
10488
+ "cardBadge": "jg958W_cardBadge",
10489
+ "symbolValue": "jg958W_symbolValue",
10471
10490
  "tableTitle": "jg958W_tableTitle",
10472
- "tradesTable": "jg958W_tradesTable",
10473
- "cardActions": "jg958W_cardActions",
10474
- "chartWrapper": "jg958W_chartWrapper",
10475
- "paramLabel": "jg958W_paramLabel",
10476
- "progressWrap": "jg958W_progressWrap",
10477
- "chartContainer": "jg958W_chartContainer",
10478
- "header": "jg958W_header",
10479
- "paramGroup": "jg958W_paramGroup",
10480
- "progressFill": "jg958W_progressFill",
10481
- "tableSection": "jg958W_tableSection",
10482
- "reasonCell": "jg958W_reasonCell",
10491
+ "strategyCard": "jg958W_strategyCard",
10483
10492
  "trendUp": "jg958W_trendUp",
10493
+ "tableEmptyCell": "jg958W_tableEmptyCell",
10494
+ "runBtn": "jg958W_runBtn",
10484
10495
  "mgmtRow": "jg958W_mgmtRow",
10496
+ "newStrategyBtn": "jg958W_newStrategyBtn",
10497
+ "metricLabel": "jg958W_metricLabel",
10498
+ "configBar": "jg958W_configBar",
10485
10499
  "paramInput": "jg958W_paramInput",
10486
- "symbolValue": "jg958W_symbolValue",
10487
- "tradesTableWrapper": "jg958W_tradesTableWrapper",
10488
- "horizonSelector": "jg958W_horizonSelector",
10489
- "emptyState": "jg958W_emptyState",
10490
- "cardBadge": "jg958W_cardBadge",
10491
- "emptyIcon": "jg958W_emptyIcon",
10500
+ "tableSection": "jg958W_tableSection",
10501
+ "progressWrap": "jg958W_progressWrap",
10492
10502
  "nameCell": "jg958W_nameCell",
10493
- "metricValue": "jg958W_metricValue",
10494
- "trendDown": "jg958W_trendDown",
10495
- "cardActionBtn": "jg958W_cardActionBtn",
10503
+ "emptyIcon": "jg958W_emptyIcon",
10504
+ "strategyCards": "jg958W_strategyCards",
10505
+ "progressFill": "jg958W_progressFill",
10496
10506
  "root": "jg958W_root",
10507
+ "horizonSelector": "jg958W_horizonSelector",
10508
+ "scanMeta": "jg958W_scanMeta",
10509
+ "chartWrapper": "jg958W_chartWrapper",
10510
+ "horizonBtn": "jg958W_horizonBtn",
10511
+ "chartContainer": "jg958W_chartContainer",
10512
+ "metricsGrid": "jg958W_metricsGrid",
10513
+ "emptyState": "jg958W_emptyState",
10514
+ "cardActions": "jg958W_cardActions",
10515
+ "reasonCell": "jg958W_reasonCell",
10516
+ "cardSummary": "jg958W_cardSummary",
10497
10517
  "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"
10518
+ "paramGroup": "jg958W_paramGroup",
10519
+ "trendDown": "jg958W_trendDown",
10520
+ "header": "jg958W_header",
10521
+ "tradesTable": "jg958W_tradesTable",
10522
+ "tradesTableWrapper": "jg958W_tradesTableWrapper",
10523
+ "cardTitleRow": "jg958W_cardTitleRow",
10524
+ "cardActionBtn": "jg958W_cardActionBtn"
10504
10525
  };
10505
10526
  //#endregion
10506
10527
  //#region src/client/ScreenerPane.tsx
@@ -12106,17 +12127,17 @@ window.__ModuleLoader__.load({
12106
12127
  }
12107
12128
  var toolview_module_css_default = {
12108
12129
  "spark": "MbbyQa_spark",
12109
- "card": "MbbyQa_card",
12110
- "reason": "MbbyQa_reason",
12111
- "title": "MbbyQa_title",
12112
- "metric": "MbbyQa_metric",
12113
- "meta": "MbbyQa_meta",
12114
- "chip": "MbbyQa_chip",
12115
- "metrics": "MbbyQa_metrics",
12116
- "metricLabel": "MbbyQa_metricLabel",
12117
12130
  "head": "MbbyQa_head",
12131
+ "metricLabel": "MbbyQa_metricLabel",
12118
12132
  "metricValue": "MbbyQa_metricValue",
12119
- "params": "MbbyQa_params"
12133
+ "params": "MbbyQa_params",
12134
+ "chip": "MbbyQa_chip",
12135
+ "metric": "MbbyQa_metric",
12136
+ "reason": "MbbyQa_reason",
12137
+ "card": "MbbyQa_card",
12138
+ "metrics": "MbbyQa_metrics",
12139
+ "meta": "MbbyQa_meta",
12140
+ "title": "MbbyQa_title"
12120
12141
  };
12121
12142
  //#endregion
12122
12143
  //#region src/client/toolview.tsx