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