@metamask-previews/advanced-chart-core 0.0.0-preview-c4789fdf4 → 0.0.0-preview-772d48ed6

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 (177) hide show
  1. package/dist/index.d.ts +7 -4
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +8 -26
  4. package/dist/index.js.map +1 -1
  5. package/package.json +5 -7
  6. package/dist/core/bootstrap.d.ts +0 -10
  7. package/dist/core/bootstrap.d.ts.map +0 -1
  8. package/dist/core/bootstrap.js +0 -183
  9. package/dist/core/bootstrap.js.map +0 -1
  10. package/dist/core/bridge.d.ts +0 -37
  11. package/dist/core/bridge.d.ts.map +0 -1
  12. package/dist/core/bridge.js +0 -92
  13. package/dist/core/bridge.js.map +0 -1
  14. package/dist/core/dataLifecycle.d.ts +0 -8
  15. package/dist/core/dataLifecycle.d.ts.map +0 -1
  16. package/dist/core/dataLifecycle.js +0 -46
  17. package/dist/core/dataLifecycle.js.map +0 -1
  18. package/dist/core/host.d.ts +0 -39
  19. package/dist/core/host.d.ts.map +0 -1
  20. package/dist/core/host.js +0 -39
  21. package/dist/core/host.js.map +0 -1
  22. package/dist/core/loadLibrary.d.ts +0 -16
  23. package/dist/core/loadLibrary.d.ts.map +0 -1
  24. package/dist/core/loadLibrary.js +0 -58
  25. package/dist/core/loadLibrary.js.map +0 -1
  26. package/dist/core/resolution.d.ts +0 -15
  27. package/dist/core/resolution.d.ts.map +0 -1
  28. package/dist/core/resolution.js +0 -54
  29. package/dist/core/resolution.js.map +0 -1
  30. package/dist/core/state.d.ts +0 -82
  31. package/dist/core/state.d.ts.map +0 -1
  32. package/dist/core/state.js +0 -309
  33. package/dist/core/state.js.map +0 -1
  34. package/dist/core/timeUtils.d.ts +0 -32
  35. package/dist/core/timeUtils.d.ts.map +0 -1
  36. package/dist/core/timeUtils.js +0 -66
  37. package/dist/core/timeUtils.js.map +0 -1
  38. package/dist/core/timezone.d.ts +0 -16
  39. package/dist/core/timezone.d.ts.map +0 -1
  40. package/dist/core/timezone.js +0 -131
  41. package/dist/core/timezone.js.map +0 -1
  42. package/dist/core/types.d.ts +0 -323
  43. package/dist/core/types.d.ts.map +0 -1
  44. package/dist/core/types.js +0 -17
  45. package/dist/core/types.js.map +0 -1
  46. package/dist/features/indicators/index.d.ts +0 -6
  47. package/dist/features/indicators/index.d.ts.map +0 -1
  48. package/dist/features/indicators/index.js +0 -177
  49. package/dist/features/indicators/index.js.map +0 -1
  50. package/dist/features/indicators/legend.d.ts +0 -40
  51. package/dist/features/indicators/legend.d.ts.map +0 -1
  52. package/dist/features/indicators/legend.js +0 -564
  53. package/dist/features/indicators/legend.js.map +0 -1
  54. package/dist/features/indicators/resize.d.ts +0 -2
  55. package/dist/features/indicators/resize.d.ts.map +0 -1
  56. package/dist/features/indicators/resize.js +0 -30
  57. package/dist/features/indicators/resize.js.map +0 -1
  58. package/dist/features/indicators/studies.d.ts +0 -36
  59. package/dist/features/indicators/studies.d.ts.map +0 -1
  60. package/dist/features/indicators/studies.js +0 -140
  61. package/dist/features/indicators/studies.js.map +0 -1
  62. package/dist/features/indicators/subPane.d.ts +0 -6
  63. package/dist/features/indicators/subPane.d.ts.map +0 -1
  64. package/dist/features/indicators/subPane.js +0 -72
  65. package/dist/features/indicators/subPane.js.map +0 -1
  66. package/dist/features/volume/index.d.ts +0 -4
  67. package/dist/features/volume/index.d.ts.map +0 -1
  68. package/dist/features/volume/index.js +0 -140
  69. package/dist/features/volume/index.js.map +0 -1
  70. package/dist/host-entry.d.ts +0 -5
  71. package/dist/host-entry.d.ts.map +0 -1
  72. package/dist/host-entry.js +0 -17
  73. package/dist/host-entry.js.map +0 -1
  74. package/dist/interaction/crosshair.d.ts +0 -21
  75. package/dist/interaction/crosshair.d.ts.map +0 -1
  76. package/dist/interaction/crosshair.js +0 -141
  77. package/dist/interaction/crosshair.js.map +0 -1
  78. package/dist/interaction/visibleRange.d.ts +0 -11
  79. package/dist/interaction/visibleRange.d.ts.map +0 -1
  80. package/dist/interaction/visibleRange.js +0 -97
  81. package/dist/interaction/visibleRange.js.map +0 -1
  82. package/dist/messages/contract.d.ts +0 -262
  83. package/dist/messages/contract.d.ts.map +0 -1
  84. package/dist/messages/contract.js +0 -26
  85. package/dist/messages/contract.js.map +0 -1
  86. package/dist/messages/handler.d.ts +0 -25
  87. package/dist/messages/handler.d.ts.map +0 -1
  88. package/dist/messages/handler.js +0 -48
  89. package/dist/messages/handler.js.map +0 -1
  90. package/dist/overlays/focusTime/index.d.ts +0 -6
  91. package/dist/overlays/focusTime/index.d.ts.map +0 -1
  92. package/dist/overlays/focusTime/index.js +0 -155
  93. package/dist/overlays/focusTime/index.js.map +0 -1
  94. package/dist/overlays/positionLines/index.d.ts +0 -4
  95. package/dist/overlays/positionLines/index.d.ts.map +0 -1
  96. package/dist/overlays/positionLines/index.js +0 -183
  97. package/dist/overlays/positionLines/index.js.map +0 -1
  98. package/dist/overlays/positionLines/state.d.ts +0 -8
  99. package/dist/overlays/positionLines/state.d.ts.map +0 -1
  100. package/dist/overlays/positionLines/state.js +0 -26
  101. package/dist/overlays/positionLines/state.js.map +0 -1
  102. package/dist/overlays/socialLeaderboard/index.d.ts +0 -48
  103. package/dist/overlays/socialLeaderboard/index.d.ts.map +0 -1
  104. package/dist/overlays/socialLeaderboard/index.js +0 -222
  105. package/dist/overlays/socialLeaderboard/index.js.map +0 -1
  106. package/dist/overlays/tradeMarkers/animation.d.ts +0 -5
  107. package/dist/overlays/tradeMarkers/animation.d.ts.map +0 -1
  108. package/dist/overlays/tradeMarkers/animation.js +0 -118
  109. package/dist/overlays/tradeMarkers/animation.js.map +0 -1
  110. package/dist/overlays/tradeMarkers/index.d.ts +0 -35
  111. package/dist/overlays/tradeMarkers/index.d.ts.map +0 -1
  112. package/dist/overlays/tradeMarkers/index.js +0 -324
  113. package/dist/overlays/tradeMarkers/index.js.map +0 -1
  114. package/dist/overlays/tradeMarkers/markerHitTest.d.ts +0 -15
  115. package/dist/overlays/tradeMarkers/markerHitTest.d.ts.map +0 -1
  116. package/dist/overlays/tradeMarkers/markerHitTest.js +0 -331
  117. package/dist/overlays/tradeMarkers/markerHitTest.js.map +0 -1
  118. package/dist/overlays/tradeMarkers/state.d.ts +0 -20
  119. package/dist/overlays/tradeMarkers/state.d.ts.map +0 -1
  120. package/dist/overlays/tradeMarkers/state.js +0 -60
  121. package/dist/overlays/tradeMarkers/state.js.map +0 -1
  122. package/dist/pagination/priceApi.d.ts +0 -43
  123. package/dist/pagination/priceApi.d.ts.map +0 -1
  124. package/dist/pagination/priceApi.js +0 -97
  125. package/dist/pagination/priceApi.js.map +0 -1
  126. package/dist/pagination/rnBacked.d.ts +0 -15
  127. package/dist/pagination/rnBacked.d.ts.map +0 -1
  128. package/dist/pagination/rnBacked.js +0 -100
  129. package/dist/pagination/rnBacked.js.map +0 -1
  130. package/dist/platform/iframeHost.d.ts +0 -35
  131. package/dist/platform/iframeHost.d.ts.map +0 -1
  132. package/dist/platform/iframeHost.js +0 -73
  133. package/dist/platform/iframeHost.js.map +0 -1
  134. package/dist/platform/reactNativeHost.d.ts +0 -8
  135. package/dist/platform/reactNativeHost.d.ts.map +0 -1
  136. package/dist/platform/reactNativeHost.js +0 -51
  137. package/dist/platform/reactNativeHost.js.map +0 -1
  138. package/dist/widget/chartType.d.ts +0 -4
  139. package/dist/widget/chartType.d.ts.map +0 -1
  140. package/dist/widget/chartType.js +0 -34
  141. package/dist/widget/chartType.js.map +0 -1
  142. package/dist/widget/datafeed.d.ts +0 -22
  143. package/dist/widget/datafeed.d.ts.map +0 -1
  144. package/dist/widget/datafeed.js +0 -223
  145. package/dist/widget/datafeed.js.map +0 -1
  146. package/dist/widget/externalLinkBridge.d.ts +0 -14
  147. package/dist/widget/externalLinkBridge.d.ts.map +0 -1
  148. package/dist/widget/externalLinkBridge.js +0 -127
  149. package/dist/widget/externalLinkBridge.js.map +0 -1
  150. package/dist/widget/initChart.d.ts +0 -53
  151. package/dist/widget/initChart.d.ts.map +0 -1
  152. package/dist/widget/initChart.js +0 -235
  153. package/dist/widget/initChart.js.map +0 -1
  154. package/dist/widget/ohlcvIngestion.d.ts +0 -16
  155. package/dist/widget/ohlcvIngestion.d.ts.map +0 -1
  156. package/dist/widget/ohlcvIngestion.js +0 -233
  157. package/dist/widget/ohlcvIngestion.js.map +0 -1
  158. package/dist/widget/priceFormatter.d.ts +0 -38
  159. package/dist/widget/priceFormatter.d.ts.map +0 -1
  160. package/dist/widget/priceFormatter.js +0 -135
  161. package/dist/widget/priceFormatter.js.map +0 -1
  162. package/dist/widget/scaleLayout.d.ts +0 -9
  163. package/dist/widget/scaleLayout.d.ts.map +0 -1
  164. package/dist/widget/scaleLayout.js +0 -85
  165. package/dist/widget/scaleLayout.js.map +0 -1
  166. package/dist/widget/theme.d.ts +0 -99
  167. package/dist/widget/theme.d.ts.map +0 -1
  168. package/dist/widget/theme.js +0 -270
  169. package/dist/widget/theme.js.map +0 -1
  170. package/dist/widget/tvDomHelpers.d.ts +0 -19
  171. package/dist/widget/tvDomHelpers.d.ts.map +0 -1
  172. package/dist/widget/tvDomHelpers.js +0 -60
  173. package/dist/widget/tvDomHelpers.js.map +0 -1
  174. package/dist/widget/visualOverrides.d.ts +0 -27
  175. package/dist/widget/visualOverrides.d.ts.map +0 -1
  176. package/dist/widget/visualOverrides.js +0 -58
  177. package/dist/widget/visualOverrides.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
- export { bootstrap } from './core/bootstrap.js';
2
- export { getHostTransport, setHostTransport, type ChartHostTransport, type InboundTransportListener, } from './core/host.js';
3
- export { createReactNativeHost } from './platform/reactNativeHost.js';
4
- export { createIframeHost, type IframeHostOptions, } from './platform/iframeHost.js';
1
+ /**
2
+ * Example function that returns a greeting for the given name.
3
+ *
4
+ * @param name - The name to greet.
5
+ * @returns The greeting.
6
+ */
7
+ export declare function greeter(name: string): string;
5
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,GAC9B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EACL,gBAAgB,EAChB,KAAK,iBAAiB,GACvB,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5C"}
package/dist/index.js CHANGED
@@ -1,28 +1,10 @@
1
- // AdvancedChart WebView IIFE entry point.
2
- //
3
- // Evaluated at runtime inside the WebView after AdvancedChartTemplate has
4
- // inlined window.CONFIG via a preceding <script> block. Calls bootstrap()
5
- // to seed state, wire the RN bridge, register Phase 1 handlers, and begin
6
- // loading the TradingView library.
7
- //
8
- // Future phases register their handlers / overlays / features inside their
9
- // own modules; this file stays a thin entry point.
10
- import { bootstrap } from './core/bootstrap.js';
11
- import { reportErrorToRN } from './core/bridge.js';
12
- import { setHostTransport } from './core/host.js';
13
- import { createReactNativeHost } from './platform/reactNativeHost.js';
14
- // Mobile RN WebView entry: select the React Native host transport before
15
- // booting. Other hosts (e.g. the extension iframe) import the exports below
16
- // and inject their own transport instead of evaluating this IIFE.
17
- setHostTransport(createReactNativeHost());
18
- try {
19
- bootstrap();
1
+ /**
2
+ * Example function that returns a greeting for the given name.
3
+ *
4
+ * @param name - The name to greet.
5
+ * @returns The greeting.
6
+ */
7
+ export function greeter(name) {
8
+ return `Hello, ${name}!`;
20
9
  }
21
- catch (error) {
22
- reportErrorToRN(error);
23
- }
24
- export { bootstrap } from './core/bootstrap.js';
25
- export { getHostTransport, setHostTransport, } from './core/host.js';
26
- export { createReactNativeHost } from './platform/reactNativeHost.js';
27
- export { createIframeHost, } from './platform/iframeHost.js';
28
10
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,EAAE;AACF,0EAA0E;AAC1E,0EAA0E;AAC1E,0EAA0E;AAC1E,mCAAmC;AACnC,EAAE;AACF,2EAA2E;AAC3E,mDAAmD;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,yEAAyE;AACzE,4EAA4E;AAC5E,kEAAkE;AAClE,gBAAgB,CAAC,qBAAqB,EAAE,CAAC,CAAC;AAE1C,IAAI,CAAC;IACH,SAAS,EAAE,CAAC;AACd,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,eAAe,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EACL,gBAAgB,EAChB,gBAAgB,GAGjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EACL,gBAAgB,GAEjB,MAAM,0BAA0B,CAAC","sourcesContent":["// AdvancedChart WebView IIFE entry point.\n//\n// Evaluated at runtime inside the WebView after AdvancedChartTemplate has\n// inlined window.CONFIG via a preceding <script> block. Calls bootstrap()\n// to seed state, wire the RN bridge, register Phase 1 handlers, and begin\n// loading the TradingView library.\n//\n// Future phases register their handlers / overlays / features inside their\n// own modules; this file stays a thin entry point.\n\nimport { bootstrap } from './core/bootstrap.js';\nimport { reportErrorToRN } from './core/bridge.js';\nimport { setHostTransport } from './core/host.js';\nimport { createReactNativeHost } from './platform/reactNativeHost.js';\n\n// Mobile RN WebView entry: select the React Native host transport before\n// booting. Other hosts (e.g. the extension iframe) import the exports below\n// and inject their own transport instead of evaluating this IIFE.\nsetHostTransport(createReactNativeHost());\n\ntry {\n bootstrap();\n} catch (error) {\n reportErrorToRN(error);\n}\n\nexport { bootstrap } from './core/bootstrap.js';\nexport {\n getHostTransport,\n setHostTransport,\n type ChartHostTransport,\n type InboundTransportListener,\n} from './core/host.js';\nexport { createReactNativeHost } from './platform/reactNativeHost.js';\nexport {\n createIframeHost,\n type IframeHostOptions,\n} from './platform/iframeHost.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,UAAU,IAAI,GAAG,CAAC;AAC3B,CAAC","sourcesContent":["/**\n * Example function that returns a greeting for the given name.\n *\n * @param name - The name to greet.\n * @returns The greeting.\n */\nexport function greeter(name: string): string {\n return `Hello, ${name}!`;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/advanced-chart-core",
3
- "version": "0.0.0-preview-c4789fdf4",
3
+ "version": "0.0.0-preview-772d48ed6",
4
4
  "description": "Platform-agnostic TradingView Advanced Charts WebView engine shared across MetaMask clients",
5
5
  "keywords": [
6
6
  "Ethereum",
@@ -25,10 +25,6 @@
25
25
  "types": "./dist/index.d.ts",
26
26
  "default": "./dist/index.js"
27
27
  },
28
- "./host": {
29
- "types": "./dist/host-entry.d.ts",
30
- "default": "./dist/host-entry.js"
31
- },
32
28
  "./package.json": "./package.json"
33
29
  },
34
30
  "publishConfig": {
@@ -45,6 +41,8 @@
45
41
  "changelog:validate": "../../scripts/validate-changelog.sh @metamask/advanced-chart-core",
46
42
  "lint:tsconfigs": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts",
47
43
  "lint:tsconfigs:fix": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts --fix",
44
+ "messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --check",
45
+ "messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --generate",
48
46
  "publish:preview": "yarn npm publish --tag preview",
49
47
  "since-latest-release": "../../scripts/since-latest-release.sh",
50
48
  "test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
@@ -58,11 +56,11 @@
58
56
  "@typescript/native": "npm:typescript@^7.0.2",
59
57
  "deepmerge": "^4.3.1",
60
58
  "jest": "^30.4.2",
61
- "jest-environment-jsdom": "^30.4.1",
62
59
  "rimraf": "^6.1.3",
63
- "ts-jest": "^29.4.12",
60
+ "ts-jest": "^29.4.14",
64
61
  "tsx": "^4.23.15",
65
62
  "typedoc": "^0.25.13",
63
+ "typedoc-plugin-missing-exports": "^2.0.0",
66
64
  "typescript": "npm:@typescript/typescript6@^6.0.2"
67
65
  },
68
66
  "engines": {
@@ -1,10 +0,0 @@
1
- import type { ChartConfig } from './types.js';
2
- /**
3
- * Phase 1 + 2 bootstrap. Returns the resolved CONFIG so callers (and tests)
4
- * can inspect what booted. Idempotent on its inbound subscription — the
5
- * WebView is not expected to bootstrap twice.
6
- *
7
- * @returns The resolved chart configuration read from `window.CONFIG`.
8
- */
9
- export declare function bootstrap(): ChartConfig;
10
- //# sourceMappingURL=bootstrap.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/core/bootstrap.ts"],"names":[],"mappings":"AA4EA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAuC9C;;;;;;GAMG;AACH,wBAAgB,SAAS,IAAI,WAAW,CA2GvC"}
@@ -1,183 +0,0 @@
1
- // Entry orchestration. Called once from src/index.ts when the IIFE evaluates
2
- // inside the WebView.
3
- //
4
- // Responsibilities (Phase 1 + 2):
5
- // 1. Read window.CONFIG (must be inlined by AdvancedChartTemplate before this
6
- // script runs).
7
- // 2. Seed core state with the symbol / resolution / theme from CONFIG.
8
- // 3. Wire the RN→WV bridge to the message dispatcher.
9
- // 4. Register Phase 1 + 2 message handlers:
10
- // SET_THEME_COLORS (Phase 1), SET_OHLCV_DATA, REALTIME_UPDATE,
11
- // SET_CHART_TYPE (Phase 2).
12
- // 5. Begin loading the TradingView library so it's ready when the first
13
- // SET_OHLCV_DATA arrives.
14
- // 6. On first SET_OHLCV_DATA: createChartWidget with the default datafeed,
15
- // apply visual overrides, attach crosshair + visible-range listeners.
16
- import { handleAddIndicator, handleRemoveIndicator, handleSetMAVisibility, } from '../features/indicators/index.js';
17
- import { attachLegendResizeListener, setupLegendOverlay, } from '../features/indicators/legend.js';
18
- import { handleSetSubPaneLayout } from '../features/indicators/subPane.js';
19
- import { handleToggleVolume, registerVolumeThemeSync, } from '../features/volume/index.js';
20
- import { attachCrosshairListener, attachTapDismiss, } from '../interaction/crosshair.js';
21
- import { attachVisibleRangeListeners } from '../interaction/visibleRange.js';
22
- import { dispatchInboundMessage, registerHandler, } from '../messages/handler.js';
23
- import { registerFocusTimeOverlay } from '../overlays/focusTime/index.js';
24
- import { registerPositionLinesOverlay } from '../overlays/positionLines/index.js';
25
- import { slbScheduleInitialCentering } from '../overlays/socialLeaderboard/index.js';
26
- import { registerTradeMarkerPulseHandler } from '../overlays/tradeMarkers/animation.js';
27
- import { registerTradeMarkerOverlay } from '../overlays/tradeMarkers/index.js';
28
- import { attachMarkerHitTest } from '../overlays/tradeMarkers/markerHitTest.js';
29
- import { registerRnBackedPaginationHandler } from '../pagination/rnBacked.js';
30
- import { handleSetChartType } from '../widget/chartType.js';
31
- import { customDatafeed } from '../widget/datafeed.js';
32
- import { createChartWidget, scheduleChartLayoutSettledNotify, } from '../widget/initChart.js';
33
- import { handleRealtimeUpdate, handleSetOHLCVData, onFirstOhlcvData, } from '../widget/ohlcvIngestion.js';
34
- import { advancedChartPriceFormatterFactory } from '../widget/priceFormatter.js';
35
- import { applyScaleLayout } from '../widget/scaleLayout.js';
36
- import { applyThemeColors, flushPendingTheme, initThemeFromConfig, } from '../widget/theme.js';
37
- import { applyVisualOverrides } from '../widget/visualOverrides.js';
38
- import { onFromRN, postToRN, reportErrorToRN } from './bridge.js';
39
- import { getHostTransport } from './host.js';
40
- import { loadTradingViewLibrary } from './loadLibrary.js';
41
- import { getOhlcvData, getVisibleFromMs, getVisibleToMs, setConfig, setSubPaneHeightRatio, } from './state.js';
42
- import { getApproxBarDurationSec } from './timeUtils.js';
43
- /**
44
- * When RN passes an explicit visible-range start (e.g. a specific period like
45
- * 1D/1W/1M), build a `{ type: 'time-range', from, to }` timeframe so the
46
- * initial view snaps to that window instead of defaulting to `Date.now()`.
47
- * Padded by 2 bar durations so the last bar isn't glued to the right edge.
48
- * Ported from chartLogic.js initChart's `tfOption` computation (~line 5284).
49
- *
50
- * @returns A `time-range` timeframe pinned to the requested window, or
51
- * `undefined` when RN did not pass an explicit visible-range start.
52
- */
53
- function buildInitialTimeframe() {
54
- const visibleFromMs = getVisibleFromMs();
55
- if (visibleFromMs === null) {
56
- return undefined;
57
- }
58
- const visibleToMs = getVisibleToMs() ?? Date.now();
59
- const initBarPadSec = getApproxBarDurationSec(getOhlcvData()) * 2;
60
- return {
61
- type: 'time-range',
62
- from: Math.floor(visibleFromMs / 1000),
63
- to: Math.ceil(visibleToMs / 1000) + initBarPadSec,
64
- };
65
- }
66
- function readConfig() {
67
- const config = getHostTransport().getConfig();
68
- if (!config) {
69
- throw new Error('window.CONFIG is missing — AdvancedChartTemplate must inline ' +
70
- 'CONFIG before chartLogic runs.');
71
- }
72
- return config;
73
- }
74
- /**
75
- * Phase 1 + 2 bootstrap. Returns the resolved CONFIG so callers (and tests)
76
- * can inspect what booted. Idempotent on its inbound subscription — the
77
- * WebView is not expected to bootstrap twice.
78
- *
79
- * @returns The resolved chart configuration read from `window.CONFIG`.
80
- */
81
- export function bootstrap() {
82
- const config = readConfig();
83
- setConfig(config);
84
- initThemeFromConfig(config.theme);
85
- if (typeof config.subPaneHeightRatio === 'number') {
86
- setSubPaneHeightRatio(config.subPaneHeightRatio);
87
- }
88
- registerHandler('SET_THEME_COLORS', (payload) => {
89
- applyThemeColors(payload);
90
- });
91
- registerHandler('SET_OHLCV_DATA', (payload) => {
92
- handleSetOHLCVData(payload);
93
- });
94
- registerHandler('REALTIME_UPDATE', (payload) => {
95
- handleRealtimeUpdate(payload);
96
- });
97
- registerHandler('SET_CHART_TYPE', (payload) => {
98
- handleSetChartType(payload);
99
- });
100
- registerHandler('ADD_INDICATOR', (payload) => {
101
- handleAddIndicator(payload, config);
102
- });
103
- registerHandler('REMOVE_INDICATOR', (payload) => {
104
- handleRemoveIndicator(payload);
105
- });
106
- registerHandler('SET_MA_VISIBILITY', (payload) => {
107
- handleSetMAVisibility(payload, config);
108
- });
109
- registerHandler('TOGGLE_VOLUME', (payload) => {
110
- handleToggleVolume(payload);
111
- });
112
- registerHandler('SET_SUB_PANE_LAYOUT', (payload) => {
113
- handleSetSubPaneLayout(payload);
114
- });
115
- registerTradeMarkerOverlay();
116
- registerTradeMarkerPulseHandler();
117
- registerFocusTimeOverlay();
118
- registerPositionLinesOverlay();
119
- registerRnBackedPaginationHandler();
120
- registerVolumeThemeSync();
121
- onFromRN((message) => {
122
- dispatchInboundMessage(message);
123
- });
124
- // Library load is fire-and-forget; the first-data handler awaits readiness
125
- // again before constructing the widget, so this is purely a head-start.
126
- loadTradingViewLibrary(config.libraryUrl).catch((error) => {
127
- reportErrorToRN(error);
128
- });
129
- onFirstOhlcvData(() => {
130
- loadTradingViewLibrary(config.libraryUrl)
131
- .then(() => {
132
- return createChartWidget(config, {
133
- datafeed: customDatafeed,
134
- customFormatters: {
135
- priceFormatterFactory: advancedChartPriceFormatterFactory,
136
- },
137
- timeframe: buildInitialTimeframe(),
138
- onReady: (widget) => {
139
- try {
140
- flushPendingTheme();
141
- applyScaleLayout();
142
- applyVisualOverrides(config.visualOverrides);
143
- setupLegendOverlay(config.legendOverlay);
144
- const chart = widget.activeChart();
145
- // Match legacy onChartReady: when no explicit visible range
146
- // was passed, pin a 2-bar gap on the right. TV's default is
147
- // wider, leaving the chart visibly offset left.
148
- if (getVisibleFromMs() === null) {
149
- try {
150
- chart.getTimeScale().setRightOffset(2);
151
- }
152
- catch (rightOffsetError) {
153
- reportErrorToRN(rightOffsetError);
154
- }
155
- }
156
- attachCrosshairListener(chart);
157
- attachTapDismiss(widget);
158
- attachMarkerHitTest(widget, chart);
159
- attachVisibleRangeListeners(chart);
160
- chart
161
- .selection()
162
- .onChanged()
163
- .subscribe(null, () => {
164
- chart.selection().clear();
165
- });
166
- attachLegendResizeListener(widget);
167
- slbScheduleInitialCentering();
168
- scheduleChartLayoutSettledNotify();
169
- }
170
- catch (error) {
171
- reportErrorToRN(error);
172
- }
173
- },
174
- });
175
- })
176
- .catch((error) => {
177
- reportErrorToRN(error);
178
- });
179
- });
180
- postToRN('DEBUG', { message: 'modular-bootstrap-ready' });
181
- return config;
182
- }
183
- //# sourceMappingURL=bootstrap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/core/bootstrap.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,sBAAsB;AACtB,EAAE;AACF,kCAAkC;AAClC,8EAA8E;AAC9E,mBAAmB;AACnB,uEAAuE;AACvE,sDAAsD;AACtD,4CAA4C;AAC5C,oEAAoE;AACpE,iCAAiC;AACjC,wEAAwE;AACxE,6BAA6B;AAC7B,2EAA2E;AAC3E,yEAAyE;AAEzE,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,M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AC;wBAC/B,gBAAgB,CAAC,MAAM,CAAC,CAAC;wBACzB,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;wBACnC,2BAA2B,CAAC,KAAK,CAAC,CAAC;wBACnC,KAAK;6BACF,SAAS,EAAE;6BACX,SAAS,EAAE;6BACX,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE;4BACpB,KAAK,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC;wBAC5B,CAAC,CAAC,CAAC;wBACL,0BAA0B,CAAC,MAAM,CAAC,CAAC;wBACnC,2BAA2B,EAAE,CAAC;wBAC9B,gCAAgC,EAAE,CAAC;oBACrC,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,eAAe,CAAC,KAAK,CAAC,CAAC;oBACzB,CAAC;gBACH,CAAC;aACF,CAAC,CAAC;QACL,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,eAAe,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,yBAAyB,EAAE,CAAC,CAAC;IAE1D,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Entry orchestration. Called once from src/index.ts when the IIFE evaluates\n// inside the WebView.\n//\n// Responsibilities (Phase 1 + 2):\n// 1. Read window.CONFIG (must be inlined by AdvancedChartTemplate before this\n// script runs).\n// 2. Seed core state with the symbol / resolution / theme from CONFIG.\n// 3. Wire the RN→WV bridge to the message dispatcher.\n// 4. Register Phase 1 + 2 message handlers:\n// SET_THEME_COLORS (Phase 1), SET_OHLCV_DATA, REALTIME_UPDATE,\n// SET_CHART_TYPE (Phase 2).\n// 5. Begin loading the TradingView library so it's ready when the first\n// SET_OHLCV_DATA arrives.\n// 6. On first SET_OHLCV_DATA: createChartWidget with the default datafeed,\n// apply visual overrides, attach crosshair + visible-range listeners.\n\nimport {\n handleAddIndicator,\n handleRemoveIndicator,\n handleSetMAVisibility,\n} from '../features/indicators/index.js';\nimport {\n attachLegendResizeListener,\n setupLegendOverlay,\n} from '../features/indicators/legend.js';\nimport { handleSetSubPaneLayout } from '../features/indicators/subPane.js';\nimport {\n handleToggleVolume,\n registerVolumeThemeSync,\n} from '../features/volume/index.js';\nimport {\n attachCrosshairListener,\n attachTapDismiss,\n} from '../interaction/crosshair.js';\nimport { attachVisibleRangeListeners } from '../interaction/visibleRange.js';\nimport {\n dispatchInboundMessage,\n registerHandler,\n} from '../messages/handler.js';\nimport { registerFocusTimeOverlay } from '../overlays/focusTime/index.js';\nimport { registerPositionLinesOverlay } from '../overlays/positionLines/index.js';\nimport { slbScheduleInitialCentering } from '../overlays/socialLeaderboard/index.js';\nimport { registerTradeMarkerPulseHandler } from '../overlays/tradeMarkers/animation.js';\nimport { registerTradeMarkerOverlay } from '../overlays/tradeMarkers/index.js';\nimport { attachMarkerHitTest } from '../overlays/tradeMarkers/markerHitTest.js';\nimport { registerRnBackedPaginationHandler } from '../pagination/rnBacked.js';\nimport { handleSetChartType } from '../widget/chartType.js';\nimport { customDatafeed } from '../widget/datafeed.js';\nimport {\n createChartWidget,\n scheduleChartLayoutSettledNotify,\n} from '../widget/initChart.js';\nimport {\n handleRealtimeUpdate,\n handleSetOHLCVData,\n onFirstOhlcvData,\n} from '../widget/ohlcvIngestion.js';\nimport { advancedChartPriceFormatterFactory } from '../widget/priceFormatter.js';\nimport { applyScaleLayout } from '../widget/scaleLayout.js';\nimport {\n applyThemeColors,\n flushPendingTheme,\n initThemeFromConfig,\n} from '../widget/theme.js';\nimport { applyVisualOverrides } from '../widget/visualOverrides.js';\nimport { onFromRN, postToRN, reportErrorToRN } from './bridge.js';\nimport { getHostTransport } from './host.js';\nimport { loadTradingViewLibrary } from './loadLibrary.js';\nimport {\n getOhlcvData,\n getVisibleFromMs,\n getVisibleToMs,\n setConfig,\n setSubPaneHeightRatio,\n} from './state.js';\nimport { getApproxBarDurationSec } from './timeUtils.js';\nimport type { ChartConfig } from './types.js';\n\n/**\n * When RN passes an explicit visible-range start (e.g. a specific period like\n * 1D/1W/1M), build a `{ type: 'time-range', from, to }` timeframe so the\n * initial view snaps to that window instead of defaulting to `Date.now()`.\n * Padded by 2 bar durations so the last bar isn't glued to the right edge.\n * Ported from chartLogic.js initChart's `tfOption` computation (~line 5284).\n *\n * @returns A `time-range` timeframe pinned to the requested window, or\n * `undefined` when RN did not pass an explicit visible-range start.\n */\nfunction buildInitialTimeframe():\n | { type: 'time-range'; from: number; to: number }\n | undefined {\n const visibleFromMs = getVisibleFromMs();\n if (visibleFromMs === null) {\n return undefined;\n }\n const visibleToMs = getVisibleToMs() ?? Date.now();\n const initBarPadSec = getApproxBarDurationSec(getOhlcvData()) * 2;\n return {\n type: 'time-range',\n from: Math.floor(visibleFromMs / 1000),\n to: Math.ceil(visibleToMs / 1000) + initBarPadSec,\n };\n}\n\nfunction readConfig(): ChartConfig {\n const config = getHostTransport().getConfig();\n if (!config) {\n throw new Error(\n 'window.CONFIG is missing — AdvancedChartTemplate must inline ' +\n 'CONFIG before chartLogic runs.',\n );\n }\n return config;\n}\n\n/**\n * Phase 1 + 2 bootstrap. Returns the resolved CONFIG so callers (and tests)\n * can inspect what booted. Idempotent on its inbound subscription — the\n * WebView is not expected to bootstrap twice.\n *\n * @returns The resolved chart configuration read from `window.CONFIG`.\n */\nexport function bootstrap(): ChartConfig {\n const config = readConfig();\n setConfig(config);\n\n initThemeFromConfig(config.theme);\n if (typeof config.subPaneHeightRatio === 'number') {\n setSubPaneHeightRatio(config.subPaneHeightRatio);\n }\n\n registerHandler('SET_THEME_COLORS', (payload) => {\n applyThemeColors(payload);\n });\n registerHandler('SET_OHLCV_DATA', (payload) => {\n handleSetOHLCVData(payload);\n });\n registerHandler('REALTIME_UPDATE', (payload) => {\n handleRealtimeUpdate(payload);\n });\n registerHandler('SET_CHART_TYPE', (payload) => {\n handleSetChartType(payload);\n });\n registerHandler('ADD_INDICATOR', (payload) => {\n handleAddIndicator(payload, config);\n });\n registerHandler('REMOVE_INDICATOR', (payload) => {\n handleRemoveIndicator(payload);\n });\n registerHandler('SET_MA_VISIBILITY', (payload) => {\n handleSetMAVisibility(payload, config);\n });\n registerHandler('TOGGLE_VOLUME', (payload) => {\n handleToggleVolume(payload);\n });\n registerHandler('SET_SUB_PANE_LAYOUT', (payload) => {\n handleSetSubPaneLayout(payload);\n });\n\n registerTradeMarkerOverlay();\n registerTradeMarkerPulseHandler();\n registerFocusTimeOverlay();\n registerPositionLinesOverlay();\n registerRnBackedPaginationHandler();\n registerVolumeThemeSync();\n\n onFromRN((message) => {\n dispatchInboundMessage(message);\n });\n\n // Library load is fire-and-forget; the first-data handler awaits readiness\n // again before constructing the widget, so this is purely a head-start.\n loadTradingViewLibrary(config.libraryUrl).catch((error) => {\n reportErrorToRN(error);\n });\n\n onFirstOhlcvData(() => {\n loadTradingViewLibrary(config.libraryUrl)\n .then(() => {\n return createChartWidget(config, {\n datafeed: customDatafeed,\n customFormatters: {\n priceFormatterFactory: advancedChartPriceFormatterFactory,\n },\n timeframe: buildInitialTimeframe(),\n onReady: (widget) => {\n try {\n flushPendingTheme();\n applyScaleLayout();\n applyVisualOverrides(config.visualOverrides);\n setupLegendOverlay(config.legendOverlay);\n const chart = widget.activeChart();\n // Match legacy onChartReady: when no explicit visible range\n // was passed, pin a 2-bar gap on the right. TV's default is\n // wider, leaving the chart visibly offset left.\n if (getVisibleFromMs() === null) {\n try {\n chart.getTimeScale().setRightOffset(2);\n } catch (rightOffsetError) {\n reportErrorToRN(rightOffsetError);\n }\n }\n attachCrosshairListener(chart);\n attachTapDismiss(widget);\n attachMarkerHitTest(widget, chart);\n attachVisibleRangeListeners(chart);\n chart\n .selection()\n .onChanged()\n .subscribe(null, () => {\n chart.selection().clear();\n });\n attachLegendResizeListener(widget);\n slbScheduleInitialCentering();\n scheduleChartLayoutSettledNotify();\n } catch (error) {\n reportErrorToRN(error);\n }\n },\n });\n })\n .catch((error) => {\n reportErrorToRN(error);\n });\n });\n\n postToRN('DEBUG', { message: 'modular-bootstrap-ready' });\n\n return config;\n}\n"]}
@@ -1,37 +0,0 @@
1
- import type { InboundMessage, OutboundMessageType, OutboundPayloads } from '../messages/contract.js';
2
- export declare function safeStringify(value: unknown): string;
3
- /**
4
- * Posts a typed message to the host via the active transport. Equivalent to
5
- * legacy `sendToReactNative(type, payload)` at chartLogic.js line ~98.
6
- * Silently no-ops when the host transport is unavailable (e.g. during unit
7
- * tests in a jsdom environment without the RN bridge stub).
8
- *
9
- * @param type - The outbound message type tag.
10
- * @param payload - The payload associated with the message type.
11
- */
12
- export declare function postToRN<Type extends OutboundMessageType>(type: Type, payload: OutboundPayloads[Type]): void;
13
- /**
14
- * Reports a runtime error to React Native via the ERROR channel. Matches the
15
- * legacy `sendToReactNative('ERROR', { message })` pattern used throughout
16
- * chartLogic.js.
17
- *
18
- * @param error - The error (or arbitrary thrown value) to report.
19
- */
20
- export declare function reportErrorToRN(error: unknown): void;
21
- export type InboundMessageHandler = (message: InboundMessage) => void;
22
- /**
23
- * Registers a single inbound listener. The host posts JSON strings; the
24
- * active transport delivers each raw payload (after any transport-level
25
- * origin filtering) and this function parses + validates it before forwarding
26
- * a well-formed message to the handler.
27
- *
28
- * The returned function unsubscribes — useful for tests; the real bundle
29
- * subscribes once at bootstrap and never unsubscribes.
30
- *
31
- * @param handler - Callback invoked with each well-formed inbound message.
32
- * @returns A function that removes the registered listeners.
33
- */
34
- export declare function onFromRN(handler: InboundMessageHandler): () => void;
35
- /** Re-export for callers that want the type tag union. */
36
- export type { InboundMessageType } from '../messages/contract.js';
37
- //# sourceMappingURL=bridge.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/core/bridge.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAGjC,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAMpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,IAAI,SAAS,mBAAmB,EACvD,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,gBAAgB,CAAC,IAAI,CAAC,GAC9B,IAAI,CAON;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAUpD;AAED,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;AAEtE;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,qBAAqB,GAAG,MAAM,IAAI,CAsBnE;AAED,0DAA0D;AAC1D,YAAY,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -1,92 +0,0 @@
1
- // Typed bridge between the WebView IIFE and its host.
2
- //
3
- // Owns the platform-agnostic parts of host communication — JSON framing,
4
- // inbound parsing, and message validation — and delegates the actual
5
- // transport (outbound delivery, inbound subscription, origin filtering) to
6
- // the injected host adapter (see core/host.ts). Preserves the same
7
- // window.ReactNativeWebView.postMessage(...) call shape via the default RN
8
- // adapter, so the RN-side parseWebViewMessage decodes messages unchanged.
9
- import { getHostTransport } from './host.js';
10
- export function safeStringify(value) {
11
- try {
12
- return JSON.stringify(value) ?? 'Unknown error';
13
- }
14
- catch {
15
- return String(value);
16
- }
17
- }
18
- /**
19
- * Posts a typed message to the host via the active transport. Equivalent to
20
- * legacy `sendToReactNative(type, payload)` at chartLogic.js line ~98.
21
- * Silently no-ops when the host transport is unavailable (e.g. during unit
22
- * tests in a jsdom environment without the RN bridge stub).
23
- *
24
- * @param type - The outbound message type tag.
25
- * @param payload - The payload associated with the message type.
26
- */
27
- export function postToRN(type, payload) {
28
- try {
29
- getHostTransport().postMessage(JSON.stringify({ type, payload }));
30
- }
31
- catch {
32
- // postMessage / JSON.stringify failure: nothing to do — the WebView
33
- // cannot inform the host of its own bridge failure.
34
- }
35
- }
36
- /**
37
- * Reports a runtime error to React Native via the ERROR channel. Matches the
38
- * legacy `sendToReactNative('ERROR', { message })` pattern used throughout
39
- * chartLogic.js.
40
- *
41
- * @param error - The error (or arbitrary thrown value) to report.
42
- */
43
- export function reportErrorToRN(error) {
44
- let message;
45
- if (error instanceof Error) {
46
- message = error.message;
47
- }
48
- else if (typeof error === 'string') {
49
- message = error;
50
- }
51
- else {
52
- message = safeStringify(error);
53
- }
54
- postToRN('ERROR', { message });
55
- }
56
- /**
57
- * Registers a single inbound listener. The host posts JSON strings; the
58
- * active transport delivers each raw payload (after any transport-level
59
- * origin filtering) and this function parses + validates it before forwarding
60
- * a well-formed message to the handler.
61
- *
62
- * The returned function unsubscribes — useful for tests; the real bundle
63
- * subscribes once at bootstrap and never unsubscribes.
64
- *
65
- * @param handler - Callback invoked with each well-formed inbound message.
66
- * @returns A function that removes the registered listeners.
67
- */
68
- export function onFromRN(handler) {
69
- return getHostTransport().subscribe((raw) => {
70
- let parsed;
71
- try {
72
- parsed = typeof raw === 'string' ? JSON.parse(raw) : raw;
73
- }
74
- catch (parseError) {
75
- reportErrorToRN(parseError);
76
- return;
77
- }
78
- if (!parsed || typeof parsed !== 'object') {
79
- return;
80
- }
81
- const candidate = parsed;
82
- if (typeof candidate.type !== 'string') {
83
- return;
84
- }
85
- // Trusting the type narrowing here is fine because messages/handler.ts
86
- // re-validates via a switch on candidate.type before dispatching to a
87
- // typed handler. Phase 1 only routes SET_THEME_COLORS, but the listener
88
- // forwards every well-formed message so the handler can decide.
89
- handler(parsed);
90
- });
91
- }
92
- //# sourceMappingURL=bridge.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../src/core/bridge.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,EAAE;AACF,yEAAyE;AACzE,qEAAqE;AACrE,2EAA2E;AAC3E,mEAAmE;AACnE,2EAA2E;AAC3E,0EAA0E;AAO1E,OAAO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G,CAAC;QAC3D,CAAC;QAAC,OAAO,UAAU,EAAE,CAAC;YACpB,eAAe,CAAC,UAAU,CAAC,CAAC;YAC5B,OAAO;QACT,CAAC;QACD,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC1C,OAAO;QACT,CAAC;QACD,MAAM,SAAS,GAAG,MAA4B,CAAC;QAC/C,IAAI,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACvC,OAAO;QACT,CAAC;QACD,uEAAuE;QACvE,sEAAsE;QACtE,wEAAwE;QACxE,gEAAgE;QAChE,OAAO,CAAC,MAAwB,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Typed bridge between the WebView IIFE and its host.\n//\n// Owns the platform-agnostic parts of host communication — JSON framing,\n// inbound parsing, and message validation — and delegates the actual\n// transport (outbound delivery, inbound subscription, origin filtering) to\n// the injected host adapter (see core/host.ts). Preserves the same\n// window.ReactNativeWebView.postMessage(...) call shape via the default RN\n// adapter, so the RN-side parseWebViewMessage decodes messages unchanged.\n\nimport type {\n InboundMessage,\n OutboundMessageType,\n OutboundPayloads,\n} from '../messages/contract.js';\nimport { getHostTransport } from './host.js';\n\nexport function safeStringify(value: unknown): string {\n try {\n return JSON.stringify(value) ?? 'Unknown error';\n } catch {\n return String(value);\n }\n}\n\n/**\n * Posts a typed message to the host via the active transport. Equivalent to\n * legacy `sendToReactNative(type, payload)` at chartLogic.js line ~98.\n * Silently no-ops when the host transport is unavailable (e.g. during unit\n * tests in a jsdom environment without the RN bridge stub).\n *\n * @param type - The outbound message type tag.\n * @param payload - The payload associated with the message type.\n */\nexport function postToRN<Type extends OutboundMessageType>(\n type: Type,\n payload: OutboundPayloads[Type],\n): void {\n try {\n getHostTransport().postMessage(JSON.stringify({ type, payload }));\n } catch {\n // postMessage / JSON.stringify failure: nothing to do — the WebView\n // cannot inform the host of its own bridge failure.\n }\n}\n\n/**\n * Reports a runtime error to React Native via the ERROR channel. Matches the\n * legacy `sendToReactNative('ERROR', { message })` pattern used throughout\n * chartLogic.js.\n *\n * @param error - The error (or arbitrary thrown value) to report.\n */\nexport function reportErrorToRN(error: unknown): void {\n let message: string;\n if (error instanceof Error) {\n message = error.message;\n } else if (typeof error === 'string') {\n message = error;\n } else {\n message = safeStringify(error);\n }\n postToRN('ERROR', { message });\n}\n\nexport type InboundMessageHandler = (message: InboundMessage) => void;\n\n/**\n * Registers a single inbound listener. The host posts JSON strings; the\n * active transport delivers each raw payload (after any transport-level\n * origin filtering) and this function parses + validates it before forwarding\n * a well-formed message to the handler.\n *\n * The returned function unsubscribes — useful for tests; the real bundle\n * subscribes once at bootstrap and never unsubscribes.\n *\n * @param handler - Callback invoked with each well-formed inbound message.\n * @returns A function that removes the registered listeners.\n */\nexport function onFromRN(handler: InboundMessageHandler): () => void {\n return getHostTransport().subscribe((raw: unknown): void => {\n let parsed: unknown;\n try {\n parsed = typeof raw === 'string' ? JSON.parse(raw) : raw;\n } catch (parseError) {\n reportErrorToRN(parseError);\n return;\n }\n if (!parsed || typeof parsed !== 'object') {\n return;\n }\n const candidate = parsed as { type?: unknown };\n if (typeof candidate.type !== 'string') {\n return;\n }\n // Trusting the type narrowing here is fine because messages/handler.ts\n // re-validates via a switch on candidate.type before dispatching to a\n // typed handler. Phase 1 only routes SET_THEME_COLORS, but the listener\n // forwards every well-formed message so the handler can decide.\n handler(parsed as InboundMessage);\n });\n}\n\n/** Re-export for callers that want the type tag union. */\nexport type { InboundMessageType } from '../messages/contract.js';\n"]}
@@ -1,8 +0,0 @@
1
- export type DataLifecycleEvent = 'ohlcvReset' | 'ohlcvPrepended' | 'visibleRangeChanged';
2
- type Listener = () => void;
3
- export declare function onDataLifecycle(event: DataLifecycleEvent, listener: Listener): () => void;
4
- export declare function notifyDataLifecycle(event: DataLifecycleEvent): void;
5
- /** Test-only: clear every listener across every event. */
6
- export declare function _resetDataLifecycleForTests(): void;
7
- export {};
8
- //# sourceMappingURL=dataLifecycle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dataLifecycle.d.ts","sourceRoot":"","sources":["../../src/core/dataLifecycle.ts"],"names":[],"mappings":"AAeA,MAAM,MAAM,kBAAkB,GAC1B,YAAY,GACZ,gBAAgB,GAChB,qBAAqB,CAAC;AAE1B,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC;AAQ3B,wBAAgB,eAAe,CAC7B,KAAK,EAAE,kBAAkB,EACzB,QAAQ,EAAE,QAAQ,GACjB,MAAM,IAAI,CASZ;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI,CASnE;AAED,0DAA0D;AAC1D,wBAAgB,2BAA2B,IAAI,IAAI,CAIlD"}
@@ -1,46 +0,0 @@
1
- // Lightweight event bus for data lifecycle events overlays need to react to.
2
- //
3
- // The widget modules (ohlcvIngestion, pagination, visibleRange) publish
4
- // events after they mutate the OHLCV series or the visible range;
5
- // overlay modules (tradeMarkers, positionLines) subscribe and re-place
6
- // their shapes. Keeps overlays decoupled from widget/* — overlays never
7
- // import from widget/*, matching the ESLint `no-restricted-paths`
8
- // direction described in the plan.
9
- //
10
- // The events are intentionally void — subscribers read whatever state
11
- // they need from core/state.ts. Errors inside a subscriber are logged
12
- // to RN so a broken overlay doesn't take the widget down with it.
13
- import { reportErrorToRN } from './bridge.js';
14
- const listeners = {
15
- ohlcvReset: [],
16
- ohlcvPrepended: [],
17
- visibleRangeChanged: [],
18
- };
19
- export function onDataLifecycle(event, listener) {
20
- listeners[event].push(listener);
21
- return () => {
22
- const bucket = listeners[event];
23
- const idx = bucket.indexOf(listener);
24
- if (idx !== -1) {
25
- bucket.splice(idx, 1);
26
- }
27
- };
28
- }
29
- export function notifyDataLifecycle(event) {
30
- const bucket = listeners[event];
31
- for (const listener of bucket) {
32
- try {
33
- listener();
34
- }
35
- catch (error) {
36
- reportErrorToRN(error);
37
- }
38
- }
39
- }
40
- /** Test-only: clear every listener across every event. */
41
- export function _resetDataLifecycleForTests() {
42
- listeners.ohlcvReset = [];
43
- listeners.ohlcvPrepended = [];
44
- listeners.visibleRangeChanged = [];
45
- }
46
- //# sourceMappingURL=dataLifecycle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dataLifecycle.js","sourceRoot":"","sources":["../../src/core/dataLifecycle.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,EAAE;AACF,wEAAwE;AACxE,kEAAkE;AAClE,uEAAuE;AACvE,wEAAwE;AACxE,kEAAkE;AAClE,mCAAmC;AACnC,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,kEAAkE;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAS9C,MAAM,SAAS,GAA2C;IACxD,UAAU,EAAE,EAAE;IACd,cAAc,EAAE,EAAE;IAClB,mBAAmB,EAAE,EAAE;CACxB,CAAC;AAEF,MAAM,UAAU,eAAe,CAC7B,KAAyB,EACzB,QAAkB;IAElB,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChC,OAAO,GAAG,EAAE;QACV,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;QAChC,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACrC,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;YACf,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAyB;IAC3D,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAChC,KAAK,MAAM,QAAQ,IAAI,MAAM,EAAE,CAAC;QAC9B,IAAI,CAAC;YACH,QAAQ,EAAE,CAAC;QACb,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,eAAe,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;AACH,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,2BAA2B;IACzC,SAAS,CAAC,UAAU,GAAG,EAAE,CAAC;IAC1B,SAAS,CAAC,cAAc,GAAG,EAAE,CAAC;IAC9B,SAAS,CAAC,mBAAmB,GAAG,EAAE,CAAC;AACrC,CAAC","sourcesContent":["// Lightweight event bus for data lifecycle events overlays need to react to.\n//\n// The widget modules (ohlcvIngestion, pagination, visibleRange) publish\n// events after they mutate the OHLCV series or the visible range;\n// overlay modules (tradeMarkers, positionLines) subscribe and re-place\n// their shapes. Keeps overlays decoupled from widget/* — overlays never\n// import from widget/*, matching the ESLint `no-restricted-paths`\n// direction described in the plan.\n//\n// The events are intentionally void — subscribers read whatever state\n// they need from core/state.ts. Errors inside a subscriber are logged\n// to RN so a broken overlay doesn't take the widget down with it.\n\nimport { reportErrorToRN } from './bridge.js';\n\nexport type DataLifecycleEvent =\n | 'ohlcvReset'\n | 'ohlcvPrepended'\n | 'visibleRangeChanged';\n\ntype Listener = () => void;\n\nconst listeners: Record<DataLifecycleEvent, Listener[]> = {\n ohlcvReset: [],\n ohlcvPrepended: [],\n visibleRangeChanged: [],\n};\n\nexport function onDataLifecycle(\n event: DataLifecycleEvent,\n listener: Listener,\n): () => void {\n listeners[event].push(listener);\n return () => {\n const bucket = listeners[event];\n const idx = bucket.indexOf(listener);\n if (idx !== -1) {\n bucket.splice(idx, 1);\n }\n };\n}\n\nexport function notifyDataLifecycle(event: DataLifecycleEvent): void {\n const bucket = listeners[event];\n for (const listener of bucket) {\n try {\n listener();\n } catch (error) {\n reportErrorToRN(error);\n }\n }\n}\n\n/** Test-only: clear every listener across every event. */\nexport function _resetDataLifecycleForTests(): void {\n listeners.ohlcvReset = [];\n listeners.ohlcvPrepended = [];\n listeners.visibleRangeChanged = [];\n}\n"]}
@@ -1,39 +0,0 @@
1
- import type { ChartConfig } from './types.js';
2
- /** Callback invoked with each raw inbound payload delivered by the host. */
3
- export type InboundTransportListener = (raw: unknown) => void;
4
- /**
5
- * The platform transport contract. An adapter owns the three things that
6
- * differ between hosts: how outbound messages are delivered, how inbound
7
- * messages are received (including any origin filtering), and where the
8
- * inlined chart CONFIG comes from.
9
- */
10
- export type ChartHostTransport = {
11
- /** Deliver a serialized outbound message to the host. */
12
- postMessage(serialized: string): void;
13
- /**
14
- * Subscribe to raw inbound messages from the host. The adapter is
15
- * responsible for any transport-level filtering (e.g. origin checks). The
16
- * returned function unsubscribes.
17
- */
18
- subscribe(onMessage: InboundTransportListener): () => void;
19
- /** Return the inlined chart configuration, or `undefined` when absent. */
20
- getConfig(): ChartConfig | undefined;
21
- };
22
- /**
23
- * Injects the host transport the engine should use. The mobile IIFE and the
24
- * extension entry call this before bootstrap; tests may call it to provide a
25
- * fake transport.
26
- *
27
- * @param host - The transport adapter to activate.
28
- */
29
- export declare function setHostTransport(host: ChartHostTransport): void;
30
- /**
31
- * Returns the active host transport, lazily defaulting to the React Native
32
- * adapter so untouched consumers keep their current behavior.
33
- *
34
- * @returns The active host transport.
35
- */
36
- export declare function getHostTransport(): ChartHostTransport;
37
- /** Test-only: clear the injected host so the next access re-defaults. */
38
- export declare function _resetHostTransportForTests(): void;
39
- //# sourceMappingURL=host.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/core/host.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,4EAA4E;AAC5E,MAAM,MAAM,wBAAwB,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,yDAAyD;IACzD,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC;;;;OAIG;IACH,SAAS,CAAC,SAAS,EAAE,wBAAwB,GAAG,MAAM,IAAI,CAAC;IAC3D,0EAA0E;IAC1E,SAAS,IAAI,WAAW,GAAG,SAAS,CAAC;CACtC,CAAC;AAIF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAE/D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,kBAAkB,CAGrD;AAED,yEAAyE;AACzE,wBAAgB,2BAA2B,IAAI,IAAI,CAElD"}