@363045841yyt/klinechart-core 0.7.11 → 0.7.12

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.
Files changed (191) hide show
  1. package/dist/engine/indicators/indicator.worker.js +32 -4
  2. package/dist/engine/indicators/indicator.worker.js.map +1 -1
  3. package/dist/engine/indicators/indicatorDefinitionRegistry.d.ts +3 -2
  4. package/dist/engine/indicators/indicatorDefinitionRegistry.d.ts.map +1 -1
  5. package/dist/engine/indicators/indicatorDefinitionRegistry.js.map +1 -1
  6. package/dist/engine/indicators/indicatorMetadata.d.ts +27 -1
  7. package/dist/engine/indicators/indicatorMetadata.d.ts.map +1 -1
  8. package/dist/engine/indicators/indicatorMetadata.js.map +1 -1
  9. package/dist/engine/indicators/indicatorRuntime.d.ts +12 -117
  10. package/dist/engine/indicators/indicatorRuntime.d.ts.map +1 -1
  11. package/dist/engine/indicators/indicatorRuntime.js +123 -1308
  12. package/dist/engine/indicators/indicatorRuntime.js.map +1 -1
  13. package/dist/engine/indicators/scheduler.d.ts +3 -142
  14. package/dist/engine/indicators/scheduler.d.ts.map +1 -1
  15. package/dist/engine/indicators/scheduler.js +59 -431
  16. package/dist/engine/indicators/scheduler.js.map +1 -1
  17. package/dist/engine/indicators/stateComposer.d.ts.map +1 -1
  18. package/dist/engine/indicators/stateComposer.js +15 -47
  19. package/dist/engine/indicators/stateComposer.js.map +1 -1
  20. package/dist/engine/indicators/workerProtocol.d.ts +12 -36
  21. package/dist/engine/indicators/workerProtocol.d.ts.map +1 -1
  22. package/dist/engine/indicators/workerProtocol.js.map +1 -1
  23. package/dist/engine/renderers/Indicator/atr.d.ts.map +1 -1
  24. package/dist/engine/renderers/Indicator/atr.js +9 -3
  25. package/dist/engine/renderers/Indicator/atr.js.map +1 -1
  26. package/dist/engine/renderers/Indicator/boll.d.ts.map +1 -1
  27. package/dist/engine/renderers/Indicator/boll.js +4 -2
  28. package/dist/engine/renderers/Indicator/boll.js.map +1 -1
  29. package/dist/engine/renderers/Indicator/cci.d.ts.map +1 -1
  30. package/dist/engine/renderers/Indicator/cci.js +9 -3
  31. package/dist/engine/renderers/Indicator/cci.js.map +1 -1
  32. package/dist/engine/renderers/Indicator/chaikinVol.d.ts.map +1 -1
  33. package/dist/engine/renderers/Indicator/chaikinVol.js +8 -2
  34. package/dist/engine/renderers/Indicator/chaikinVol.js.map +1 -1
  35. package/dist/engine/renderers/Indicator/cmf.d.ts.map +1 -1
  36. package/dist/engine/renderers/Indicator/cmf.js +8 -2
  37. package/dist/engine/renderers/Indicator/cmf.js.map +1 -1
  38. package/dist/engine/renderers/Indicator/dema.d.ts.map +1 -1
  39. package/dist/engine/renderers/Indicator/dema.js +3 -2
  40. package/dist/engine/renderers/Indicator/dema.js.map +1 -1
  41. package/dist/engine/renderers/Indicator/donchian.d.ts.map +1 -1
  42. package/dist/engine/renderers/Indicator/donchian.js +3 -2
  43. package/dist/engine/renderers/Indicator/donchian.js.map +1 -1
  44. package/dist/engine/renderers/Indicator/ene.d.ts.map +1 -1
  45. package/dist/engine/renderers/Indicator/ene.js +5 -3
  46. package/dist/engine/renderers/Indicator/ene.js.map +1 -1
  47. package/dist/engine/renderers/Indicator/expma.d.ts.map +1 -1
  48. package/dist/engine/renderers/Indicator/expma.js +3 -1
  49. package/dist/engine/renderers/Indicator/expma.js.map +1 -1
  50. package/dist/engine/renderers/Indicator/fastk.d.ts.map +1 -1
  51. package/dist/engine/renderers/Indicator/fastk.js +9 -3
  52. package/dist/engine/renderers/Indicator/fastk.js.map +1 -1
  53. package/dist/engine/renderers/Indicator/fib.d.ts.map +1 -1
  54. package/dist/engine/renderers/Indicator/fib.js +3 -2
  55. package/dist/engine/renderers/Indicator/fib.js.map +1 -1
  56. package/dist/engine/renderers/Indicator/hma.d.ts.map +1 -1
  57. package/dist/engine/renderers/Indicator/hma.js +3 -2
  58. package/dist/engine/renderers/Indicator/hma.js.map +1 -1
  59. package/dist/engine/renderers/Indicator/hv.d.ts.map +1 -1
  60. package/dist/engine/renderers/Indicator/hv.js +3 -2
  61. package/dist/engine/renderers/Indicator/hv.js.map +1 -1
  62. package/dist/engine/renderers/Indicator/ichimoku.d.ts.map +1 -1
  63. package/dist/engine/renderers/Indicator/ichimoku.js +3 -2
  64. package/dist/engine/renderers/Indicator/ichimoku.js.map +1 -1
  65. package/dist/engine/renderers/Indicator/kama.d.ts.map +1 -1
  66. package/dist/engine/renderers/Indicator/kama.js +3 -2
  67. package/dist/engine/renderers/Indicator/kama.js.map +1 -1
  68. package/dist/engine/renderers/Indicator/keltner.d.ts.map +1 -1
  69. package/dist/engine/renderers/Indicator/keltner.js +3 -2
  70. package/dist/engine/renderers/Indicator/keltner.js.map +1 -1
  71. package/dist/engine/renderers/Indicator/kst.d.ts.map +1 -1
  72. package/dist/engine/renderers/Indicator/kst.js +4 -3
  73. package/dist/engine/renderers/Indicator/kst.js.map +1 -1
  74. package/dist/engine/renderers/Indicator/ma.d.ts.map +1 -1
  75. package/dist/engine/renderers/Indicator/ma.js +6 -1
  76. package/dist/engine/renderers/Indicator/ma.js.map +1 -1
  77. package/dist/engine/renderers/Indicator/macd.js +2 -2
  78. package/dist/engine/renderers/Indicator/macd.js.map +1 -1
  79. package/dist/engine/renderers/Indicator/mfi.d.ts.map +1 -1
  80. package/dist/engine/renderers/Indicator/mfi.js +8 -2
  81. package/dist/engine/renderers/Indicator/mfi.js.map +1 -1
  82. package/dist/engine/renderers/Indicator/mom.d.ts.map +1 -1
  83. package/dist/engine/renderers/Indicator/mom.js +9 -3
  84. package/dist/engine/renderers/Indicator/mom.js.map +1 -1
  85. package/dist/engine/renderers/Indicator/obv.d.ts.map +1 -1
  86. package/dist/engine/renderers/Indicator/obv.js +8 -2
  87. package/dist/engine/renderers/Indicator/obv.js.map +1 -1
  88. package/dist/engine/renderers/Indicator/parkinson.d.ts.map +1 -1
  89. package/dist/engine/renderers/Indicator/parkinson.js +3 -2
  90. package/dist/engine/renderers/Indicator/parkinson.js.map +1 -1
  91. package/dist/engine/renderers/Indicator/pivot.d.ts.map +1 -1
  92. package/dist/engine/renderers/Indicator/pivot.js +3 -2
  93. package/dist/engine/renderers/Indicator/pivot.js.map +1 -1
  94. package/dist/engine/renderers/Indicator/pvt.d.ts.map +1 -1
  95. package/dist/engine/renderers/Indicator/pvt.js +8 -2
  96. package/dist/engine/renderers/Indicator/pvt.js.map +1 -1
  97. package/dist/engine/renderers/Indicator/roc.d.ts.map +1 -1
  98. package/dist/engine/renderers/Indicator/roc.js +8 -2
  99. package/dist/engine/renderers/Indicator/roc.js.map +1 -1
  100. package/dist/engine/renderers/Indicator/rsi.d.ts.map +1 -1
  101. package/dist/engine/renderers/Indicator/rsi.js +7 -3
  102. package/dist/engine/renderers/Indicator/rsi.js.map +1 -1
  103. package/dist/engine/renderers/Indicator/sar.d.ts.map +1 -1
  104. package/dist/engine/renderers/Indicator/sar.js +3 -2
  105. package/dist/engine/renderers/Indicator/sar.js.map +1 -1
  106. package/dist/engine/renderers/Indicator/stoch.d.ts.map +1 -1
  107. package/dist/engine/renderers/Indicator/stoch.js +4 -3
  108. package/dist/engine/renderers/Indicator/stoch.js.map +1 -1
  109. package/dist/engine/renderers/Indicator/structure.d.ts.map +1 -1
  110. package/dist/engine/renderers/Indicator/structure.js +3 -2
  111. package/dist/engine/renderers/Indicator/structure.js.map +1 -1
  112. package/dist/engine/renderers/Indicator/supertrend.d.ts.map +1 -1
  113. package/dist/engine/renderers/Indicator/supertrend.js +3 -2
  114. package/dist/engine/renderers/Indicator/supertrend.js.map +1 -1
  115. package/dist/engine/renderers/Indicator/tema.d.ts.map +1 -1
  116. package/dist/engine/renderers/Indicator/tema.js +3 -2
  117. package/dist/engine/renderers/Indicator/tema.js.map +1 -1
  118. package/dist/engine/renderers/Indicator/trix.d.ts.map +1 -1
  119. package/dist/engine/renderers/Indicator/trix.js +3 -2
  120. package/dist/engine/renderers/Indicator/trix.js.map +1 -1
  121. package/dist/engine/renderers/Indicator/vma.d.ts.map +1 -1
  122. package/dist/engine/renderers/Indicator/vma.js +8 -2
  123. package/dist/engine/renderers/Indicator/vma.js.map +1 -1
  124. package/dist/engine/renderers/Indicator/volumeProfile.d.ts.map +1 -1
  125. package/dist/engine/renderers/Indicator/volumeProfile.js +3 -2
  126. package/dist/engine/renderers/Indicator/volumeProfile.js.map +1 -1
  127. package/dist/engine/renderers/Indicator/vwap.d.ts.map +1 -1
  128. package/dist/engine/renderers/Indicator/vwap.js +8 -2
  129. package/dist/engine/renderers/Indicator/vwap.js.map +1 -1
  130. package/dist/engine/renderers/Indicator/wma.d.ts.map +1 -1
  131. package/dist/engine/renderers/Indicator/wma.js +3 -2
  132. package/dist/engine/renderers/Indicator/wma.js.map +1 -1
  133. package/dist/engine/renderers/Indicator/wmsr.d.ts.map +1 -1
  134. package/dist/engine/renderers/Indicator/wmsr.js +9 -3
  135. package/dist/engine/renderers/Indicator/wmsr.js.map +1 -1
  136. package/dist/engine/renderers/Indicator/zones.d.ts.map +1 -1
  137. package/dist/engine/renderers/Indicator/zones.js +3 -2
  138. package/dist/engine/renderers/Indicator/zones.js.map +1 -1
  139. package/dist/version.d.ts +1 -1
  140. package/dist/version.js +1 -1
  141. package/package.json +6 -2
  142. package/src/engine/indicators/__tests__/registerBuiltins.test.ts +14 -22
  143. package/src/engine/indicators/__tests__/scheduler.test.ts +14 -14
  144. package/src/engine/indicators/__tests__/stateComposer.test.ts +7 -4
  145. package/src/engine/indicators/indicator.worker.ts +36 -4
  146. package/src/engine/indicators/indicatorDefinitionRegistry.ts +3 -1
  147. package/src/engine/indicators/indicatorMetadata.ts +29 -1
  148. package/src/engine/indicators/indicatorRuntime.ts +120 -1447
  149. package/src/engine/indicators/scheduler.ts +57 -485
  150. package/src/engine/indicators/stateComposer.ts +16 -60
  151. package/src/engine/indicators/workerProtocol.ts +14 -36
  152. package/src/engine/renderers/Indicator/atr.ts +9 -3
  153. package/src/engine/renderers/Indicator/boll.ts +4 -2
  154. package/src/engine/renderers/Indicator/cci.ts +9 -3
  155. package/src/engine/renderers/Indicator/chaikinVol.ts +8 -2
  156. package/src/engine/renderers/Indicator/cmf.ts +8 -2
  157. package/src/engine/renderers/Indicator/dema.ts +3 -2
  158. package/src/engine/renderers/Indicator/donchian.ts +3 -2
  159. package/src/engine/renderers/Indicator/ene.ts +5 -3
  160. package/src/engine/renderers/Indicator/expma.ts +3 -1
  161. package/src/engine/renderers/Indicator/fastk.ts +9 -3
  162. package/src/engine/renderers/Indicator/fib.ts +3 -2
  163. package/src/engine/renderers/Indicator/hma.ts +3 -2
  164. package/src/engine/renderers/Indicator/hv.ts +3 -2
  165. package/src/engine/renderers/Indicator/ichimoku.ts +3 -2
  166. package/src/engine/renderers/Indicator/kama.ts +3 -2
  167. package/src/engine/renderers/Indicator/keltner.ts +3 -2
  168. package/src/engine/renderers/Indicator/kst.ts +4 -3
  169. package/src/engine/renderers/Indicator/ma.ts +3 -2
  170. package/src/engine/renderers/Indicator/macd.ts +9 -9
  171. package/src/engine/renderers/Indicator/mfi.ts +8 -2
  172. package/src/engine/renderers/Indicator/mom.ts +9 -3
  173. package/src/engine/renderers/Indicator/obv.ts +8 -2
  174. package/src/engine/renderers/Indicator/parkinson.ts +3 -2
  175. package/src/engine/renderers/Indicator/pivot.ts +3 -2
  176. package/src/engine/renderers/Indicator/pvt.ts +8 -2
  177. package/src/engine/renderers/Indicator/roc.ts +8 -2
  178. package/src/engine/renderers/Indicator/rsi.ts +4 -3
  179. package/src/engine/renderers/Indicator/sar.ts +3 -2
  180. package/src/engine/renderers/Indicator/stoch.ts +4 -3
  181. package/src/engine/renderers/Indicator/structure.ts +3 -2
  182. package/src/engine/renderers/Indicator/supertrend.ts +3 -2
  183. package/src/engine/renderers/Indicator/tema.ts +3 -2
  184. package/src/engine/renderers/Indicator/trix.ts +3 -2
  185. package/src/engine/renderers/Indicator/vma.ts +8 -2
  186. package/src/engine/renderers/Indicator/volumeProfile.ts +3 -2
  187. package/src/engine/renderers/Indicator/vwap.ts +8 -2
  188. package/src/engine/renderers/Indicator/wma.ts +3 -2
  189. package/src/engine/renderers/Indicator/wmsr.ts +9 -3
  190. package/src/engine/renderers/Indicator/zones.ts +3 -2
  191. package/src/version.ts +1 -1
@@ -57,6 +57,7 @@ export class IndicatorScheduler {
57
57
  // 当前数据和配置快照
58
58
  currentData = [];
59
59
  configSnapshot = this.getDefaultConfig();
60
+ paneIdOverrides = new Map();
60
61
  // Worker 相关
61
62
  worker = null;
62
63
  workerReady = false;
@@ -87,6 +88,21 @@ export class IndicatorScheduler {
87
88
  console.warn(`[IndicatorScheduler] '${meta.name}' already registered, overwriting`);
88
89
  }
89
90
  this.registry.register(meta);
91
+ if (meta.runtime && this.inlineRuntime) {
92
+ this.inlineRuntime.addDescriptor(meta.runtime);
93
+ }
94
+ if (meta.runtime && this.useWorker && this.worker && this.workerReady) {
95
+ const rt = meta.runtime;
96
+ this.worker.postMessage({
97
+ type: 'addDescriptor',
98
+ descriptor: {
99
+ configKey: rt.configKey,
100
+ paneIdKey: rt.paneIdKey,
101
+ defaultConfig: typeof rt.defaultConfig === 'function' ? rt.defaultConfig() : rt.defaultConfig,
102
+ computeKey: rt.computeKey,
103
+ },
104
+ });
105
+ }
90
106
  this.configVersion++;
91
107
  this.triggerRecompute();
92
108
  console.log(`[IndicatorScheduler] Registered indicator '${meta.name}' (${meta.displayName})`);
@@ -279,41 +295,6 @@ export class IndicatorScheduler {
279
295
  showPOC: true,
280
296
  showValueArea: true,
281
297
  },
282
- rsiPaneId: 'sub_RSI',
283
- cciPaneId: 'sub_CCI',
284
- stochPaneId: 'sub_STOCH',
285
- momPaneId: 'sub_MOM',
286
- wmsrPaneId: 'sub_WMSR',
287
- kstPaneId: 'sub_KST',
288
- fastkPaneId: 'sub_FASTK',
289
- macdPaneId: 'sub_MACD',
290
- atrPaneId: 'sub_ATR',
291
- wmaPaneId: 'sub_WMA',
292
- demaPaneId: 'sub_DEMA',
293
- temaPaneId: 'sub_TEMA',
294
- hmaPaneId: 'sub_HMA',
295
- kamaPaneId: 'sub_KAMA',
296
- sarPaneId: 'sub_SAR',
297
- supertrendPaneId: 'sub_SuperTrend',
298
- keltnerPaneId: 'sub_Keltner',
299
- donchianPaneId: 'sub_Donchian',
300
- ichimokuPaneId: 'sub_Ichimoku',
301
- rocPaneId: 'sub_ROC',
302
- trixPaneId: 'sub_TRIX',
303
- hvPaneId: 'sub_HV',
304
- parkinsonPaneId: 'sub_Parkinson',
305
- chaikinVolPaneId: 'sub_ChaikinVol',
306
- vmaPaneId: 'sub_VMA',
307
- obvPaneId: 'sub_OBV',
308
- pvtPaneId: 'sub_PVT',
309
- vwapPaneId: 'sub_VWAP',
310
- cmfPaneId: 'sub_CMF',
311
- mfiPaneId: 'sub_MFI',
312
- pivotPaneId: 'sub_Pivot',
313
- fibPaneId: 'sub_Fib',
314
- structurePaneId: 'sub_Structure',
315
- zonesPaneId: 'sub_Zones',
316
- volumeProfilePaneId: 'sub_VolumeProfile',
317
298
  };
318
299
  }
319
300
  initBackend() {
@@ -330,8 +311,7 @@ export class IndicatorScheduler {
330
311
  return false;
331
312
  }
332
313
  try {
333
- // Vite 模块 Worker
334
- const workerUrl = new URL('./indicator.worker.ts', import.meta.url);
314
+ const workerUrl = new URL('./indicator.worker.js', import.meta.url);
335
315
  console.log('[IndicatorScheduler] Creating worker from:', workerUrl.href);
336
316
  this.worker = new Worker(workerUrl, { type: 'module' });
337
317
  console.log('[IndicatorScheduler] Worker created, waiting for ready...');
@@ -340,7 +320,6 @@ export class IndicatorScheduler {
340
320
  console.error('[IndicatorScheduler] Worker error:', err);
341
321
  this.fallbackToInline();
342
322
  };
343
- // 发送 init
344
323
  this.worker.postMessage({
345
324
  type: 'init',
346
325
  protocolVersion: PROTOCOL_VERSION,
@@ -354,7 +333,10 @@ export class IndicatorScheduler {
354
333
  }
355
334
  initInlineRuntime() {
356
335
  console.log('[IndicatorScheduler] Using INLINE runtime (fallback)');
357
- this.inlineRuntime = new IndicatorRuntime();
336
+ const runtimeDescs = this.registry.getAll()
337
+ .filter(m => m.runtime)
338
+ .map(m => m.runtime);
339
+ this.inlineRuntime = new IndicatorRuntime(runtimeDescs);
358
340
  this.useWorker = false;
359
341
  this.workerReady = true;
360
342
  }
@@ -388,7 +370,20 @@ export class IndicatorScheduler {
388
370
  this.workerReady = true;
389
371
  this.useWorker = true;
390
372
  console.log('[IndicatorScheduler] Worker READY - using Worker backend');
391
- // Worker 就绪后补算一次,但仅在有数据时(避免空数据产出 Infinity 极值)
373
+ for (const meta of this.registry.getAll()) {
374
+ if (!meta.runtime)
375
+ continue;
376
+ const rt = meta.runtime;
377
+ this.worker.postMessage({
378
+ type: 'addDescriptor',
379
+ descriptor: {
380
+ configKey: rt.configKey,
381
+ paneIdKey: rt.paneIdKey,
382
+ defaultConfig: typeof rt.defaultConfig === 'function' ? rt.defaultConfig() : rt.defaultConfig,
383
+ computeKey: rt.computeKey,
384
+ },
385
+ });
386
+ }
392
387
  if (this.currentData.length > 0) {
393
388
  this.triggerRecompute();
394
389
  }
@@ -455,9 +450,7 @@ export class IndicatorScheduler {
455
450
  if (!state)
456
451
  continue;
457
452
  this.checkVisibleExtremes(state, meta.displayName);
458
- const paneId = meta.paneIdField
459
- ? this.configSnapshot[meta.paneIdField]
460
- : meta.defaultPaneId;
453
+ const paneId = this.paneIdOverrides.get(meta.name) ?? meta.defaultPaneId;
461
454
  meta.applyResult(this.pluginHost, state, paneId);
462
455
  }
463
456
  }
@@ -475,9 +468,7 @@ export class IndicatorScheduler {
475
468
  continue;
476
469
  let state;
477
470
  if (meta.category === 'main') {
478
- const paneId = meta.paneIdField
479
- ? this.configSnapshot[meta.paneIdField]
480
- : meta.defaultPaneId;
471
+ const paneId = this.paneIdOverrides.get(meta.name) ?? meta.defaultPaneId;
481
472
  const current = this.pluginHost.getSharedState(resolveStateKey(meta.stateKey, paneId));
482
473
  const currentValid = current &&
483
474
  Number.isFinite(current.visibleMin) &&
@@ -494,9 +485,7 @@ export class IndicatorScheduler {
494
485
  if (state === undefined)
495
486
  continue;
496
487
  this.checkVisibleExtremes(state, meta.displayName);
497
- const paneId = meta.paneIdField
498
- ? this.configSnapshot[meta.paneIdField]
499
- : meta.defaultPaneId;
488
+ const paneId = this.paneIdOverrides.get(meta.name) ?? meta.defaultPaneId;
500
489
  meta.applyResult(this.pluginHost, state, paneId);
501
490
  if (meta.category === 'main') {
502
491
  mainStateUpdated = true;
@@ -509,9 +498,7 @@ export class IndicatorScheduler {
509
498
  const activeIds = this.getActiveSubPaneIds?.() ?? [];
510
499
  const mask = {};
511
500
  for (const meta of this.registry.getAll()) {
512
- if (!meta.paneIdField)
513
- continue;
514
- const paneId = this.configSnapshot[meta.paneIdField] ?? meta.defaultPaneId;
501
+ const paneId = this.paneIdOverrides.get(meta.name) ?? meta.defaultPaneId;
515
502
  mask[meta.name] = activeIds.includes(paneId) || !!(meta.allowMainPane && paneId === 'main');
516
503
  }
517
504
  return mask;
@@ -523,9 +510,7 @@ export class IndicatorScheduler {
523
510
  return { ...this.configSnapshot };
524
511
  const cfg = { ...this.configSnapshot };
525
512
  for (const meta of this.registry.getAll()) {
526
- if (!meta.paneIdField)
527
- continue;
528
- const paneId = cfg[meta.paneIdField];
513
+ const paneId = this.paneIdOverrides.get(meta.name) ?? meta.defaultPaneId;
529
514
  if (!activeIds.includes(paneId) && paneId !== 'main') {
530
515
  const subCfg = { ...cfg[meta.name] };
531
516
  for (const k of Object.keys(subCfg)) {
@@ -569,385 +554,25 @@ export class IndicatorScheduler {
569
554
  }
570
555
  }
571
556
  /**
572
- * MA 配置变更
573
- */
574
- updateMAConfig(config) {
575
- this.configSnapshot.ma = { ...config };
576
- this.configVersion++;
577
- this.triggerRecompute();
578
- }
579
- /**
580
- * BOLL 配置变更
581
- */
582
- updateBOLLConfig(config) {
583
- this.configSnapshot.boll = { ...this.configSnapshot.boll, ...config };
584
- this.configVersion++;
585
- this.triggerRecompute();
586
- }
587
- /**
588
- * EXPMA 配置变更
589
- */
590
- updateEXPMAConfig(config) {
591
- this.configSnapshot.expma = { ...this.configSnapshot.expma, ...config };
592
- this.configVersion++;
593
- this.triggerRecompute();
594
- }
595
- /**
596
- * ENE 配置变更
597
- */
598
- updateENEConfig(config) {
599
- this.configSnapshot.ene = { ...this.configSnapshot.ene, ...config };
600
- this.configVersion++;
601
- this.triggerRecompute();
602
- }
603
- /**
604
- * RSI 配置变更
605
- */
606
- updateRSIConfig(config, paneId) {
607
- if (paneId !== undefined) {
608
- this.configSnapshot.rsiPaneId = paneId;
609
- }
610
- this.configSnapshot.rsi = { ...this.configSnapshot.rsi, ...config };
611
- this.configVersion++;
612
- this.triggerRecompute();
613
- }
614
- /**
615
- * CCI 配置变更
616
- */
617
- updateCCIConfig(config, paneId) {
618
- if (paneId !== undefined) {
619
- this.configSnapshot.cciPaneId = paneId;
620
- }
621
- this.configSnapshot.cci = { ...this.configSnapshot.cci, ...config };
622
- this.configVersion++;
623
- this.triggerRecompute();
624
- }
625
- /**
626
- * STOCH 配置变更
627
- */
628
- updateSTOCHConfig(config, paneId) {
629
- if (paneId !== undefined) {
630
- this.configSnapshot.stochPaneId = paneId;
631
- }
632
- this.configSnapshot.stoch = { ...this.configSnapshot.stoch, ...config };
633
- this.configVersion++;
634
- this.triggerRecompute();
635
- }
636
- /**
637
- * MOM 配置变更
638
- */
639
- updateMOMConfig(config, paneId) {
640
- if (paneId !== undefined) {
641
- this.configSnapshot.momPaneId = paneId;
642
- }
643
- this.configSnapshot.mom = { ...this.configSnapshot.mom, ...config };
644
- this.configVersion++;
645
- this.triggerRecompute();
646
- }
647
- /**
648
- * WMSR 配置变更
649
- */
650
- updateWMSRConfig(config, paneId) {
651
- if (paneId !== undefined) {
652
- this.configSnapshot.wmsrPaneId = paneId;
653
- }
654
- this.configSnapshot.wmsr = { ...this.configSnapshot.wmsr, ...config };
655
- this.configVersion++;
656
- this.triggerRecompute();
657
- }
658
- /**
659
- * KST 配置变更
660
- */
661
- updateKSTConfig(config, paneId) {
662
- if (paneId !== undefined) {
663
- this.configSnapshot.kstPaneId = paneId;
664
- }
665
- this.configSnapshot.kst = { ...this.configSnapshot.kst, ...config };
666
- this.configVersion++;
667
- this.triggerRecompute();
668
- }
669
- /**
670
- * FASTK 配置变更
671
- */
672
- updateFASTKConfig(config, paneId) {
673
- if (paneId !== undefined) {
674
- this.configSnapshot.fastkPaneId = paneId;
675
- }
676
- this.configSnapshot.fastk = { ...this.configSnapshot.fastk, ...config };
677
- this.configVersion++;
678
- this.triggerRecompute();
679
- }
680
- /**
681
- * MACD 配置变更
682
- */
683
- updateMACDConfig(config, paneId) {
684
- if (paneId !== undefined) {
685
- this.configSnapshot.macdPaneId = paneId;
686
- }
687
- this.configSnapshot.macd = { ...this.configSnapshot.macd, ...config };
688
- this.configVersion++;
689
- this.triggerRecompute();
690
- }
691
- /**
692
- * ATR 配置变更
693
- */
694
- updateATRConfig(config, paneId) {
695
- if (paneId !== undefined) {
696
- this.configSnapshot.atrPaneId = paneId;
697
- }
698
- this.configSnapshot.atr = { ...this.configSnapshot.atr, ...config };
699
- this.configVersion++;
700
- this.triggerRecompute();
701
- }
702
- /**
703
- * WMA 配置变更
704
- */
705
- updateWMAConfig(config, paneId) {
706
- if (paneId !== undefined) {
707
- this.configSnapshot.wmaPaneId = paneId;
708
- }
709
- this.configSnapshot.wma = { ...this.configSnapshot.wma, ...config };
710
- this.configVersion++;
711
- this.triggerRecompute();
712
- }
713
- /**
714
- * DEMA 配置变更
715
- */
716
- updateDEMAConfig(config, paneId) {
717
- if (paneId !== undefined) {
718
- this.configSnapshot.demaPaneId = paneId;
719
- }
720
- this.configSnapshot.dema = { ...this.configSnapshot.dema, ...config };
721
- this.configVersion++;
722
- this.triggerRecompute();
723
- }
724
- /**
725
- * TEMA 配置变更
726
- */
727
- updateTEMAConfig(config, paneId) {
728
- if (paneId !== undefined) {
729
- this.configSnapshot.temaPaneId = paneId;
730
- }
731
- this.configSnapshot.tema = { ...this.configSnapshot.tema, ...config };
732
- this.configVersion++;
733
- this.triggerRecompute();
734
- }
735
- /**
736
- * HMA 配置变更
557
+ * 通用指标配置变更入口
737
558
  */
738
- updateHMAConfig(config, paneId) {
739
- if (paneId !== undefined) {
740
- this.configSnapshot.hmaPaneId = paneId;
559
+ updateIndicatorConfig(indicatorId, config, paneId) {
560
+ const meta = this.registry.get(indicatorId);
561
+ if (!meta?.runtime) {
562
+ console.warn(`[IndicatorScheduler] Unknown or unregistered indicator: ${indicatorId}`);
563
+ return;
741
564
  }
742
- this.configSnapshot.hma = { ...this.configSnapshot.hma, ...config };
743
- this.configVersion++;
744
- this.triggerRecompute();
745
- }
746
- /**
747
- * KAMA 配置变更
748
- */
749
- updateKAMAConfig(config, paneId) {
565
+ const rt = meta.runtime;
566
+ // Update paneId if provided
750
567
  if (paneId !== undefined) {
751
- this.configSnapshot.kamaPaneId = paneId;
568
+ this.paneIdOverrides.set(indicatorId, paneId);
752
569
  }
753
- this.configSnapshot.kama = { ...this.configSnapshot.kama, ...config };
754
- this.configVersion++;
755
- this.triggerRecompute();
756
- }
757
- /**
758
- * SAR 配置变更
759
- */
760
- updateSARConfig(config, paneId) {
761
- if (paneId !== undefined) {
762
- this.configSnapshot.sarPaneId = paneId;
763
- }
764
- this.configSnapshot.sar = { ...this.configSnapshot.sar, ...config };
765
- this.configVersion++;
766
- this.triggerRecompute();
767
- }
768
- /**
769
- * SuperTrend 配置变更
770
- */
771
- updateSuperTrendConfig(config, paneId) {
772
- if (paneId !== undefined)
773
- this.configSnapshot.supertrendPaneId = paneId;
774
- this.configSnapshot.supertrend = { ...this.configSnapshot.supertrend, ...config };
775
- this.configVersion++;
776
- this.triggerRecompute();
777
- }
778
- /**
779
- * Keltner 配置变更
780
- */
781
- updateKeltnerConfig(config, paneId) {
782
- if (paneId !== undefined)
783
- this.configSnapshot.keltnerPaneId = paneId;
784
- this.configSnapshot.keltner = { ...this.configSnapshot.keltner, ...config };
785
- this.configVersion++;
786
- this.triggerRecompute();
787
- }
788
- /**
789
- * Donchian 配置变更
790
- */
791
- updateDonchianConfig(config, paneId) {
792
- if (paneId !== undefined)
793
- this.configSnapshot.donchianPaneId = paneId;
794
- this.configSnapshot.donchian = { ...this.configSnapshot.donchian, ...config };
795
- this.configVersion++;
796
- this.triggerRecompute();
797
- }
798
- /**
799
- * Ichimoku 配置变更
800
- */
801
- updateIchimokuConfig(config, paneId) {
802
- if (paneId !== undefined)
803
- this.configSnapshot.ichimokuPaneId = paneId;
804
- this.configSnapshot.ichimoku = { ...this.configSnapshot.ichimoku, ...config };
805
- this.configVersion++;
806
- this.triggerRecompute();
807
- }
808
- /**
809
- * ROC 配置变更
810
- */
811
- updateROCConfig(config, paneId) {
812
- if (paneId !== undefined)
813
- this.configSnapshot.rocPaneId = paneId;
814
- this.configSnapshot.roc = { ...this.configSnapshot.roc, ...config };
815
- this.configVersion++;
816
- this.triggerRecompute();
817
- }
818
- /**
819
- * TRIX 配置变更
820
- */
821
- updateTRIXConfig(config, paneId) {
822
- if (paneId !== undefined)
823
- this.configSnapshot.trixPaneId = paneId;
824
- this.configSnapshot.trix = { ...this.configSnapshot.trix, ...config };
825
- this.configVersion++;
826
- this.triggerRecompute();
827
- }
828
- /**
829
- * HV 配置变更
830
- */
831
- updateHVConfig(config, paneId) {
832
- if (paneId !== undefined)
833
- this.configSnapshot.hvPaneId = paneId;
834
- this.configSnapshot.hv = { ...this.configSnapshot.hv, ...config };
835
- this.configVersion++;
836
- this.triggerRecompute();
837
- }
838
- /**
839
- * Parkinson 配置变更
840
- */
841
- updateParkinsonConfig(config, paneId) {
842
- if (paneId !== undefined)
843
- this.configSnapshot.parkinsonPaneId = paneId;
844
- this.configSnapshot.parkinson = { ...this.configSnapshot.parkinson, ...config };
845
- this.configVersion++;
846
- this.triggerRecompute();
847
- }
848
- /**
849
- * ChaikinVol 配置变更
850
- */
851
- updateChaikinVolConfig(config, paneId) {
852
- if (paneId !== undefined)
853
- this.configSnapshot.chaikinVolPaneId = paneId;
854
- this.configSnapshot.chaikinVol = { ...this.configSnapshot.chaikinVol, ...config };
855
- this.configVersion++;
856
- this.triggerRecompute();
857
- }
858
- /**
859
- * VMA 配置变更
860
- */
861
- updateVMAConfig(config, paneId) {
862
- if (paneId !== undefined)
863
- this.configSnapshot.vmaPaneId = paneId;
864
- this.configSnapshot.vma = { ...this.configSnapshot.vma, ...config };
865
- this.configVersion++;
866
- this.triggerRecompute();
867
- }
868
- /**
869
- * OBV 配置变更
870
- */
871
- updateOBVConfig(config, paneId) {
872
- if (paneId !== undefined)
873
- this.configSnapshot.obvPaneId = paneId;
874
- this.configSnapshot.obv = { ...this.configSnapshot.obv, ...config };
875
- this.configVersion++;
876
- this.triggerRecompute();
877
- }
878
- /**
879
- * PVT 配置变更
880
- */
881
- updatePVTConfig(config, paneId) {
882
- if (paneId !== undefined)
883
- this.configSnapshot.pvtPaneId = paneId;
884
- this.configSnapshot.pvt = { ...this.configSnapshot.pvt, ...config };
885
- this.configVersion++;
886
- this.triggerRecompute();
887
- }
888
- /**
889
- * VWAP 配置变更
890
- */
891
- updateVWAPConfig(config, paneId) {
892
- if (paneId !== undefined)
893
- this.configSnapshot.vwapPaneId = paneId;
894
- this.configSnapshot.vwap = { ...this.configSnapshot.vwap, ...config };
895
- this.configVersion++;
896
- this.triggerRecompute();
897
- }
898
- /** CMF 配置变更 */
899
- updateCMFConfig(config, paneId) {
900
- if (paneId !== undefined)
901
- this.configSnapshot.cmfPaneId = paneId;
902
- this.configSnapshot.cmf = { ...this.configSnapshot.cmf, ...config };
903
- this.configVersion++;
904
- this.triggerRecompute();
905
- }
906
- /** MFI 配置变更 */
907
- updateMFIConfig(config, paneId) {
908
- if (paneId !== undefined)
909
- this.configSnapshot.mfiPaneId = paneId;
910
- this.configSnapshot.mfi = { ...this.configSnapshot.mfi, ...config };
911
- this.configVersion++;
912
- this.triggerRecompute();
913
- }
914
- /** Pivot 配置变更 */
915
- updatePivotConfig(config, paneId) {
916
- if (paneId !== undefined)
917
- this.configSnapshot.pivotPaneId = paneId;
918
- this.configSnapshot.pivot = { ...this.configSnapshot.pivot, ...config };
919
- this.configVersion++;
920
- this.triggerRecompute();
921
- }
922
- /** Fib 配置变更 */
923
- updateFibConfig(config, paneId) {
924
- if (paneId !== undefined)
925
- this.configSnapshot.fibPaneId = paneId;
926
- this.configSnapshot.fib = { ...this.configSnapshot.fib, ...config };
927
- this.configVersion++;
928
- this.triggerRecompute();
929
- }
930
- /** Structure 配置变更 */
931
- updateStructureConfig(config, paneId) {
932
- if (paneId !== undefined)
933
- this.configSnapshot.structurePaneId = paneId;
934
- this.configSnapshot.structure = { ...this.configSnapshot.structure, ...config };
935
- this.configVersion++;
936
- this.triggerRecompute();
937
- }
938
- /** Zones 配置变更 */
939
- updateZonesConfig(config, paneId) {
940
- if (paneId !== undefined)
941
- this.configSnapshot.zonesPaneId = paneId;
942
- this.configSnapshot.zones = { ...this.configSnapshot.zones, ...config };
943
- this.configVersion++;
944
- this.triggerRecompute();
945
- }
946
- /** Volume Profile 配置变更 */
947
- updateVolumeProfileConfig(config, paneId) {
948
- if (paneId !== undefined)
949
- this.configSnapshot.volumeProfilePaneId = paneId;
950
- this.configSnapshot.volumeProfile = { ...this.configSnapshot.volumeProfile, ...config };
570
+ // Merge config
571
+ ;
572
+ this.configSnapshot[rt.configKey] = {
573
+ ...(this.configSnapshot[rt.configKey] ?? {}),
574
+ ...config,
575
+ };
951
576
  this.configVersion++;
952
577
  this.triggerRecompute();
953
578
  }
@@ -1024,7 +649,10 @@ export class IndicatorScheduler {
1024
649
  }
1025
650
  computeWithInline() {
1026
651
  if (!this.inlineRuntime) {
1027
- this.inlineRuntime = new IndicatorRuntime();
652
+ const runtimeDescs = this.registry.getAll()
653
+ .filter(m => m.runtime)
654
+ .map(m => m.runtime);
655
+ this.inlineRuntime = new IndicatorRuntime(runtimeDescs);
1028
656
  }
1029
657
  console.log(`[IndicatorScheduler] >> INLINE compute: dataV=${this.dataVersion} configV=${this.configVersion}`);
1030
658
  // 设置数据和配置(仅活跃副图)