@metamask-previews/advanced-chart-core 0.0.0-preview-238cb7063 → 0.0.0-preview-c4789fdf4
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/CHANGELOG.md +5 -0
- package/dist/core/{bootstrap.d.mts → bootstrap.d.ts} +2 -2
- package/dist/core/bootstrap.d.ts.map +1 -0
- package/dist/core/{bootstrap.mjs → bootstrap.js} +30 -28
- package/dist/core/bootstrap.js.map +1 -0
- package/dist/core/{bridge.d.cts → bridge.d.ts} +11 -11
- package/dist/core/bridge.d.ts.map +1 -0
- package/dist/core/{bridge.mjs → bridge.js} +22 -38
- package/dist/core/bridge.js.map +1 -0
- package/dist/core/{dataLifecycle.d.cts → dataLifecycle.d.ts} +1 -1
- package/dist/core/dataLifecycle.d.ts.map +1 -0
- package/dist/core/{dataLifecycle.mjs → dataLifecycle.js} +2 -2
- package/dist/core/dataLifecycle.js.map +1 -0
- package/dist/core/host.d.ts +39 -0
- package/dist/core/host.d.ts.map +1 -0
- package/dist/core/host.js +39 -0
- package/dist/core/host.js.map +1 -0
- package/dist/core/{loadLibrary.d.cts → loadLibrary.d.ts} +1 -1
- package/dist/core/loadLibrary.d.ts.map +1 -0
- package/dist/core/{loadLibrary.mjs → loadLibrary.js} +3 -3
- package/dist/core/loadLibrary.js.map +1 -0
- package/dist/core/{resolution.d.cts → resolution.d.ts} +2 -2
- package/dist/core/resolution.d.ts.map +1 -0
- package/dist/core/{resolution.mjs → resolution.js} +15 -15
- package/dist/core/resolution.js.map +1 -0
- package/dist/core/{state.d.cts → state.d.ts} +17 -2
- package/dist/core/state.d.ts.map +1 -0
- package/dist/core/{state.mjs → state.js} +27 -1
- package/dist/core/state.js.map +1 -0
- package/dist/core/{timeUtils.d.cts → timeUtils.d.ts} +1 -1
- package/dist/core/timeUtils.d.ts.map +1 -0
- package/dist/core/{timeUtils.mjs → timeUtils.js} +1 -1
- package/dist/core/timeUtils.js.map +1 -0
- package/dist/core/{timezone.d.cts → timezone.d.ts} +1 -1
- package/dist/core/timezone.d.ts.map +1 -0
- package/dist/core/{timezone.mjs → timezone.js} +1 -1
- package/dist/core/timezone.js.map +1 -0
- package/dist/core/{types.d.mts → types.d.ts} +1 -1
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/{types.mjs → types.js} +1 -1
- package/dist/core/types.js.map +1 -0
- package/dist/features/indicators/{index.d.cts → index.d.ts} +3 -3
- package/dist/features/indicators/index.d.ts.map +1 -0
- package/dist/features/indicators/{index.mjs → index.js} +7 -7
- package/dist/features/indicators/index.js.map +1 -0
- package/dist/features/indicators/{legend.d.cts → legend.d.ts} +2 -2
- package/dist/features/indicators/legend.d.ts.map +1 -0
- package/dist/features/indicators/{legend.mjs → legend.js} +4 -4
- package/dist/features/indicators/legend.js.map +1 -0
- package/dist/features/indicators/{resize.d.cts → resize.d.ts} +1 -1
- package/dist/features/indicators/resize.d.ts.map +1 -0
- package/dist/features/indicators/{resize.mjs → resize.js} +2 -2
- package/dist/features/indicators/resize.js.map +1 -0
- package/dist/features/indicators/{studies.d.cts → studies.d.ts} +2 -2
- package/dist/features/indicators/studies.d.ts.map +1 -0
- package/dist/features/indicators/{studies.mjs → studies.js} +1 -1
- package/dist/features/indicators/studies.js.map +1 -0
- package/dist/features/indicators/{subPane.d.cts → subPane.d.ts} +3 -3
- package/dist/features/indicators/subPane.d.ts.map +1 -0
- package/dist/features/indicators/{subPane.mjs → subPane.js} +3 -3
- package/dist/features/indicators/subPane.js.map +1 -0
- package/dist/features/volume/{index.d.cts → index.d.ts} +2 -2
- package/dist/features/volume/index.d.ts.map +1 -0
- package/dist/features/volume/{index.mjs → index.js} +5 -5
- package/dist/features/volume/index.js.map +1 -0
- package/dist/host-entry.d.ts +5 -0
- package/dist/host-entry.d.ts.map +1 -0
- package/dist/host-entry.js +17 -0
- package/dist/host-entry.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/interaction/{crosshair.d.cts → crosshair.d.ts} +2 -2
- package/dist/interaction/crosshair.d.ts.map +1 -0
- package/dist/interaction/{crosshair.mjs → crosshair.js} +3 -3
- package/dist/interaction/crosshair.js.map +1 -0
- package/dist/interaction/{visibleRange.d.cts → visibleRange.d.ts} +2 -2
- package/dist/interaction/visibleRange.d.ts.map +1 -0
- package/dist/interaction/{visibleRange.mjs → visibleRange.js} +4 -4
- package/dist/interaction/visibleRange.js.map +1 -0
- package/dist/messages/{contract.d.mts → contract.d.ts} +4 -4
- package/dist/messages/contract.d.ts.map +1 -0
- package/dist/messages/{contract.mjs → contract.js} +1 -1
- package/dist/messages/contract.js.map +1 -0
- package/dist/messages/{handler.d.cts → handler.d.ts} +2 -2
- package/dist/messages/handler.d.ts.map +1 -0
- package/dist/messages/{handler.mjs → handler.js} +2 -2
- package/dist/messages/handler.js.map +1 -0
- package/dist/overlays/focusTime/{index.d.cts → index.d.ts} +2 -2
- package/dist/overlays/focusTime/index.d.ts.map +1 -0
- package/dist/overlays/focusTime/{index.mjs → index.js} +5 -5
- package/dist/overlays/focusTime/index.js.map +1 -0
- package/dist/overlays/positionLines/{index.d.cts → index.d.ts} +2 -2
- package/dist/overlays/positionLines/index.d.ts.map +1 -0
- package/dist/overlays/positionLines/{index.mjs → index.js} +6 -6
- package/dist/overlays/positionLines/index.js.map +1 -0
- package/dist/overlays/positionLines/{state.d.cts → state.d.ts} +2 -2
- package/dist/overlays/positionLines/state.d.ts.map +1 -0
- package/dist/overlays/positionLines/{state.mjs → state.js} +1 -1
- package/dist/overlays/positionLines/state.js.map +1 -0
- package/dist/overlays/socialLeaderboard/{index.d.cts → index.d.ts} +2 -2
- package/dist/overlays/socialLeaderboard/index.d.ts.map +1 -0
- package/dist/overlays/socialLeaderboard/{index.mjs → index.js} +4 -4
- package/dist/overlays/socialLeaderboard/index.js.map +1 -0
- package/dist/overlays/tradeMarkers/{animation.d.cts → animation.d.ts} +2 -2
- package/dist/overlays/tradeMarkers/animation.d.ts.map +1 -0
- package/dist/overlays/tradeMarkers/{animation.mjs → animation.js} +6 -6
- package/dist/overlays/tradeMarkers/animation.js.map +1 -0
- package/dist/overlays/tradeMarkers/{index.d.cts → index.d.ts} +3 -3
- package/dist/overlays/tradeMarkers/index.d.ts.map +1 -0
- package/dist/overlays/tradeMarkers/{index.mjs → index.js} +6 -6
- package/dist/overlays/tradeMarkers/index.js.map +1 -0
- package/dist/overlays/tradeMarkers/{markerHitTest.d.cts → markerHitTest.d.ts} +2 -2
- package/dist/overlays/tradeMarkers/markerHitTest.d.ts.map +1 -0
- package/dist/overlays/tradeMarkers/{markerHitTest.mjs → markerHitTest.js} +6 -6
- package/dist/overlays/tradeMarkers/markerHitTest.js.map +1 -0
- package/dist/overlays/tradeMarkers/{state.d.mts → state.d.ts} +3 -3
- package/dist/overlays/tradeMarkers/state.d.ts.map +1 -0
- package/dist/overlays/tradeMarkers/{state.mjs → state.js} +1 -1
- package/dist/overlays/tradeMarkers/state.js.map +1 -0
- package/dist/pagination/{priceApi.d.cts → priceApi.d.ts} +2 -2
- package/dist/pagination/priceApi.d.ts.map +1 -0
- package/dist/pagination/{priceApi.mjs → priceApi.js} +4 -4
- package/dist/pagination/priceApi.js.map +1 -0
- package/dist/pagination/{rnBacked.d.cts → rnBacked.d.ts} +3 -3
- package/dist/pagination/rnBacked.d.ts.map +1 -0
- package/dist/pagination/{rnBacked.mjs → rnBacked.js} +4 -4
- package/dist/pagination/rnBacked.js.map +1 -0
- package/dist/platform/iframeHost.d.ts +35 -0
- package/dist/platform/iframeHost.d.ts.map +1 -0
- package/dist/platform/iframeHost.js +73 -0
- package/dist/platform/iframeHost.js.map +1 -0
- package/dist/platform/reactNativeHost.d.ts +8 -0
- package/dist/platform/reactNativeHost.d.ts.map +1 -0
- package/dist/platform/reactNativeHost.js +51 -0
- package/dist/platform/reactNativeHost.js.map +1 -0
- package/dist/widget/chartType.d.ts +4 -0
- package/dist/widget/chartType.d.ts.map +1 -0
- package/dist/widget/{chartType.mjs → chartType.js} +5 -5
- package/dist/widget/chartType.js.map +1 -0
- package/dist/widget/{datafeed.d.cts → datafeed.d.ts} +2 -2
- package/dist/widget/datafeed.d.ts.map +1 -0
- package/dist/widget/{datafeed.mjs → datafeed.js} +7 -7
- package/dist/widget/datafeed.js.map +1 -0
- package/dist/widget/{externalLinkBridge.d.cts → externalLinkBridge.d.ts} +1 -1
- package/dist/widget/externalLinkBridge.d.ts.map +1 -0
- package/dist/widget/{externalLinkBridge.mjs → externalLinkBridge.js} +3 -3
- package/dist/widget/externalLinkBridge.js.map +1 -0
- package/dist/widget/{initChart.d.cts → initChart.d.ts} +2 -2
- package/dist/widget/initChart.d.ts.map +1 -0
- package/dist/widget/{initChart.mjs → initChart.js} +9 -9
- package/dist/widget/initChart.js.map +1 -0
- package/dist/widget/{ohlcvIngestion.d.cts → ohlcvIngestion.d.ts} +2 -2
- package/dist/widget/ohlcvIngestion.d.ts.map +1 -0
- package/dist/widget/{ohlcvIngestion.mjs → ohlcvIngestion.js} +9 -9
- package/dist/widget/ohlcvIngestion.js.map +1 -0
- package/dist/widget/{priceFormatter.d.cts → priceFormatter.d.ts} +1 -1
- package/dist/widget/priceFormatter.d.ts.map +1 -0
- package/dist/widget/{priceFormatter.mjs → priceFormatter.js} +6 -5
- package/dist/widget/priceFormatter.js.map +1 -0
- package/dist/widget/{scaleLayout.d.cts → scaleLayout.d.ts} +2 -2
- package/dist/widget/scaleLayout.d.ts.map +1 -0
- package/dist/widget/{scaleLayout.mjs → scaleLayout.js} +5 -5
- package/dist/widget/scaleLayout.js.map +1 -0
- package/dist/widget/{theme.d.cts → theme.d.ts} +3 -3
- package/dist/widget/theme.d.ts.map +1 -0
- package/dist/widget/{theme.mjs → theme.js} +3 -3
- package/dist/widget/theme.js.map +1 -0
- package/dist/widget/{tvDomHelpers.d.cts → tvDomHelpers.d.ts} +1 -1
- package/dist/widget/tvDomHelpers.d.ts.map +1 -0
- package/dist/widget/{tvDomHelpers.mjs → tvDomHelpers.js} +1 -1
- package/dist/widget/tvDomHelpers.js.map +1 -0
- package/dist/widget/{visualOverrides.d.cts → visualOverrides.d.ts} +1 -1
- package/dist/widget/visualOverrides.d.ts.map +1 -0
- package/dist/widget/{visualOverrides.mjs → visualOverrides.js} +3 -3
- package/dist/widget/visualOverrides.js.map +1 -0
- package/package.json +20 -20
- package/dist/core/bootstrap.cjs +0 -185
- package/dist/core/bootstrap.cjs.map +0 -1
- package/dist/core/bootstrap.d.cts +0 -10
- package/dist/core/bootstrap.d.cts.map +0 -1
- package/dist/core/bootstrap.d.mts.map +0 -1
- package/dist/core/bootstrap.mjs.map +0 -1
- package/dist/core/bridge.cjs +0 -115
- package/dist/core/bridge.cjs.map +0 -1
- package/dist/core/bridge.d.cts.map +0 -1
- package/dist/core/bridge.d.mts +0 -37
- package/dist/core/bridge.d.mts.map +0 -1
- package/dist/core/bridge.mjs.map +0 -1
- package/dist/core/dataLifecycle.cjs +0 -52
- package/dist/core/dataLifecycle.cjs.map +0 -1
- package/dist/core/dataLifecycle.d.cts.map +0 -1
- package/dist/core/dataLifecycle.d.mts +0 -8
- package/dist/core/dataLifecycle.d.mts.map +0 -1
- package/dist/core/dataLifecycle.mjs.map +0 -1
- package/dist/core/loadLibrary.cjs +0 -63
- package/dist/core/loadLibrary.cjs.map +0 -1
- package/dist/core/loadLibrary.d.cts.map +0 -1
- package/dist/core/loadLibrary.d.mts +0 -16
- package/dist/core/loadLibrary.d.mts.map +0 -1
- package/dist/core/loadLibrary.mjs.map +0 -1
- package/dist/core/resolution.cjs +0 -58
- package/dist/core/resolution.cjs.map +0 -1
- package/dist/core/resolution.d.cts.map +0 -1
- package/dist/core/resolution.d.mts +0 -15
- package/dist/core/resolution.d.mts.map +0 -1
- package/dist/core/resolution.mjs.map +0 -1
- package/dist/core/state.cjs +0 -343
- package/dist/core/state.cjs.map +0 -1
- package/dist/core/state.d.cts.map +0 -1
- package/dist/core/state.d.mts +0 -67
- package/dist/core/state.d.mts.map +0 -1
- package/dist/core/state.mjs.map +0 -1
- package/dist/core/timeUtils.cjs +0 -72
- package/dist/core/timeUtils.cjs.map +0 -1
- package/dist/core/timeUtils.d.cts.map +0 -1
- package/dist/core/timeUtils.d.mts +0 -32
- package/dist/core/timeUtils.d.mts.map +0 -1
- package/dist/core/timeUtils.mjs.map +0 -1
- package/dist/core/timezone.cjs +0 -135
- package/dist/core/timezone.cjs.map +0 -1
- package/dist/core/timezone.d.cts.map +0 -1
- package/dist/core/timezone.d.mts +0 -16
- package/dist/core/timezone.d.mts.map +0 -1
- package/dist/core/timezone.mjs.map +0 -1
- package/dist/core/types.cjs +0 -20
- package/dist/core/types.cjs.map +0 -1
- package/dist/core/types.d.cts +0 -323
- package/dist/core/types.d.cts.map +0 -1
- package/dist/core/types.d.mts.map +0 -1
- package/dist/core/types.mjs.map +0 -1
- package/dist/features/indicators/index.cjs +0 -183
- package/dist/features/indicators/index.cjs.map +0 -1
- package/dist/features/indicators/index.d.cts.map +0 -1
- package/dist/features/indicators/index.d.mts +0 -6
- package/dist/features/indicators/index.d.mts.map +0 -1
- package/dist/features/indicators/index.mjs.map +0 -1
- package/dist/features/indicators/legend.cjs +0 -575
- package/dist/features/indicators/legend.cjs.map +0 -1
- package/dist/features/indicators/legend.d.cts.map +0 -1
- package/dist/features/indicators/legend.d.mts +0 -40
- package/dist/features/indicators/legend.d.mts.map +0 -1
- package/dist/features/indicators/legend.mjs.map +0 -1
- package/dist/features/indicators/resize.cjs +0 -34
- package/dist/features/indicators/resize.cjs.map +0 -1
- package/dist/features/indicators/resize.d.cts.map +0 -1
- package/dist/features/indicators/resize.d.mts +0 -2
- package/dist/features/indicators/resize.d.mts.map +0 -1
- package/dist/features/indicators/resize.mjs.map +0 -1
- package/dist/features/indicators/studies.cjs +0 -147
- package/dist/features/indicators/studies.cjs.map +0 -1
- package/dist/features/indicators/studies.d.cts.map +0 -1
- package/dist/features/indicators/studies.d.mts +0 -36
- package/dist/features/indicators/studies.d.mts.map +0 -1
- package/dist/features/indicators/studies.mjs.map +0 -1
- package/dist/features/indicators/subPane.cjs +0 -78
- package/dist/features/indicators/subPane.cjs.map +0 -1
- package/dist/features/indicators/subPane.d.cts.map +0 -1
- package/dist/features/indicators/subPane.d.mts +0 -6
- package/dist/features/indicators/subPane.d.mts.map +0 -1
- package/dist/features/indicators/subPane.mjs.map +0 -1
- package/dist/features/volume/index.cjs +0 -145
- package/dist/features/volume/index.cjs.map +0 -1
- package/dist/features/volume/index.d.cts.map +0 -1
- package/dist/features/volume/index.d.mts +0 -4
- package/dist/features/volume/index.d.mts.map +0 -1
- package/dist/features/volume/index.mjs.map +0 -1
- package/dist/index.cjs +0 -20
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -2
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts +0 -2
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -18
- package/dist/index.mjs.map +0 -1
- package/dist/interaction/crosshair.cjs +0 -147
- package/dist/interaction/crosshair.cjs.map +0 -1
- package/dist/interaction/crosshair.d.cts.map +0 -1
- package/dist/interaction/crosshair.d.mts +0 -21
- package/dist/interaction/crosshair.d.mts.map +0 -1
- package/dist/interaction/crosshair.mjs.map +0 -1
- package/dist/interaction/visibleRange.cjs +0 -102
- package/dist/interaction/visibleRange.cjs.map +0 -1
- package/dist/interaction/visibleRange.d.cts.map +0 -1
- package/dist/interaction/visibleRange.d.mts +0 -11
- package/dist/interaction/visibleRange.d.mts.map +0 -1
- package/dist/interaction/visibleRange.mjs.map +0 -1
- package/dist/messages/contract.cjs +0 -27
- package/dist/messages/contract.cjs.map +0 -1
- package/dist/messages/contract.d.cts +0 -262
- package/dist/messages/contract.d.cts.map +0 -1
- package/dist/messages/contract.d.mts.map +0 -1
- package/dist/messages/contract.mjs.map +0 -1
- package/dist/messages/handler.cjs +0 -54
- package/dist/messages/handler.cjs.map +0 -1
- package/dist/messages/handler.d.cts.map +0 -1
- package/dist/messages/handler.d.mts +0 -25
- package/dist/messages/handler.d.mts.map +0 -1
- package/dist/messages/handler.mjs.map +0 -1
- package/dist/overlays/focusTime/index.cjs +0 -161
- package/dist/overlays/focusTime/index.cjs.map +0 -1
- package/dist/overlays/focusTime/index.d.cts.map +0 -1
- package/dist/overlays/focusTime/index.d.mts +0 -6
- package/dist/overlays/focusTime/index.d.mts.map +0 -1
- package/dist/overlays/focusTime/index.mjs.map +0 -1
- package/dist/overlays/positionLines/index.cjs +0 -188
- package/dist/overlays/positionLines/index.cjs.map +0 -1
- package/dist/overlays/positionLines/index.d.cts.map +0 -1
- package/dist/overlays/positionLines/index.d.mts +0 -4
- package/dist/overlays/positionLines/index.d.mts.map +0 -1
- package/dist/overlays/positionLines/index.mjs.map +0 -1
- package/dist/overlays/positionLines/state.cjs +0 -35
- package/dist/overlays/positionLines/state.cjs.map +0 -1
- package/dist/overlays/positionLines/state.d.cts.map +0 -1
- package/dist/overlays/positionLines/state.d.mts +0 -8
- package/dist/overlays/positionLines/state.d.mts.map +0 -1
- package/dist/overlays/positionLines/state.mjs.map +0 -1
- package/dist/overlays/socialLeaderboard/index.cjs +0 -229
- package/dist/overlays/socialLeaderboard/index.cjs.map +0 -1
- package/dist/overlays/socialLeaderboard/index.d.cts.map +0 -1
- package/dist/overlays/socialLeaderboard/index.d.mts +0 -48
- package/dist/overlays/socialLeaderboard/index.d.mts.map +0 -1
- package/dist/overlays/socialLeaderboard/index.mjs.map +0 -1
- package/dist/overlays/tradeMarkers/animation.cjs +0 -123
- package/dist/overlays/tradeMarkers/animation.cjs.map +0 -1
- package/dist/overlays/tradeMarkers/animation.d.cts.map +0 -1
- package/dist/overlays/tradeMarkers/animation.d.mts +0 -5
- package/dist/overlays/tradeMarkers/animation.d.mts.map +0 -1
- package/dist/overlays/tradeMarkers/animation.mjs.map +0 -1
- package/dist/overlays/tradeMarkers/index.cjs +0 -334
- package/dist/overlays/tradeMarkers/index.cjs.map +0 -1
- package/dist/overlays/tradeMarkers/index.d.cts.map +0 -1
- package/dist/overlays/tradeMarkers/index.d.mts +0 -35
- package/dist/overlays/tradeMarkers/index.d.mts.map +0 -1
- package/dist/overlays/tradeMarkers/index.mjs.map +0 -1
- package/dist/overlays/tradeMarkers/markerHitTest.cjs +0 -337
- package/dist/overlays/tradeMarkers/markerHitTest.cjs.map +0 -1
- package/dist/overlays/tradeMarkers/markerHitTest.d.cts.map +0 -1
- package/dist/overlays/tradeMarkers/markerHitTest.d.mts +0 -15
- package/dist/overlays/tradeMarkers/markerHitTest.d.mts.map +0 -1
- package/dist/overlays/tradeMarkers/markerHitTest.mjs.map +0 -1
- package/dist/overlays/tradeMarkers/state.cjs +0 -75
- package/dist/overlays/tradeMarkers/state.cjs.map +0 -1
- package/dist/overlays/tradeMarkers/state.d.cts +0 -20
- package/dist/overlays/tradeMarkers/state.d.cts.map +0 -1
- package/dist/overlays/tradeMarkers/state.d.mts.map +0 -1
- package/dist/overlays/tradeMarkers/state.mjs.map +0 -1
- package/dist/pagination/priceApi.cjs +0 -102
- package/dist/pagination/priceApi.cjs.map +0 -1
- package/dist/pagination/priceApi.d.cts.map +0 -1
- package/dist/pagination/priceApi.d.mts +0 -43
- package/dist/pagination/priceApi.d.mts.map +0 -1
- package/dist/pagination/priceApi.mjs.map +0 -1
- package/dist/pagination/rnBacked.cjs +0 -108
- package/dist/pagination/rnBacked.cjs.map +0 -1
- package/dist/pagination/rnBacked.d.cts.map +0 -1
- package/dist/pagination/rnBacked.d.mts +0 -15
- package/dist/pagination/rnBacked.d.mts.map +0 -1
- package/dist/pagination/rnBacked.mjs.map +0 -1
- package/dist/widget/chartType.cjs +0 -39
- package/dist/widget/chartType.cjs.map +0 -1
- package/dist/widget/chartType.d.cts +0 -4
- package/dist/widget/chartType.d.cts.map +0 -1
- package/dist/widget/chartType.d.mts +0 -4
- package/dist/widget/chartType.d.mts.map +0 -1
- package/dist/widget/chartType.mjs.map +0 -1
- package/dist/widget/datafeed.cjs +0 -228
- package/dist/widget/datafeed.cjs.map +0 -1
- package/dist/widget/datafeed.d.cts.map +0 -1
- package/dist/widget/datafeed.d.mts +0 -22
- package/dist/widget/datafeed.d.mts.map +0 -1
- package/dist/widget/datafeed.mjs.map +0 -1
- package/dist/widget/externalLinkBridge.cjs +0 -134
- package/dist/widget/externalLinkBridge.cjs.map +0 -1
- package/dist/widget/externalLinkBridge.d.cts.map +0 -1
- package/dist/widget/externalLinkBridge.d.mts +0 -14
- package/dist/widget/externalLinkBridge.d.mts.map +0 -1
- package/dist/widget/externalLinkBridge.mjs.map +0 -1
- package/dist/widget/initChart.cjs +0 -242
- package/dist/widget/initChart.cjs.map +0 -1
- package/dist/widget/initChart.d.cts.map +0 -1
- package/dist/widget/initChart.d.mts +0 -53
- package/dist/widget/initChart.d.mts.map +0 -1
- package/dist/widget/initChart.mjs.map +0 -1
- package/dist/widget/ohlcvIngestion.cjs +0 -240
- package/dist/widget/ohlcvIngestion.cjs.map +0 -1
- package/dist/widget/ohlcvIngestion.d.cts.map +0 -1
- package/dist/widget/ohlcvIngestion.d.mts +0 -16
- package/dist/widget/ohlcvIngestion.d.mts.map +0 -1
- package/dist/widget/ohlcvIngestion.mjs.map +0 -1
- package/dist/widget/priceFormatter.cjs +0 -142
- package/dist/widget/priceFormatter.cjs.map +0 -1
- package/dist/widget/priceFormatter.d.cts.map +0 -1
- package/dist/widget/priceFormatter.d.mts +0 -38
- package/dist/widget/priceFormatter.d.mts.map +0 -1
- package/dist/widget/priceFormatter.mjs.map +0 -1
- package/dist/widget/scaleLayout.cjs +0 -89
- package/dist/widget/scaleLayout.cjs.map +0 -1
- package/dist/widget/scaleLayout.d.cts.map +0 -1
- package/dist/widget/scaleLayout.d.mts +0 -9
- package/dist/widget/scaleLayout.d.mts.map +0 -1
- package/dist/widget/scaleLayout.mjs.map +0 -1
- package/dist/widget/theme.cjs +0 -286
- package/dist/widget/theme.cjs.map +0 -1
- package/dist/widget/theme.d.cts.map +0 -1
- package/dist/widget/theme.d.mts +0 -99
- package/dist/widget/theme.d.mts.map +0 -1
- package/dist/widget/theme.mjs.map +0 -1
- package/dist/widget/tvDomHelpers.cjs +0 -65
- package/dist/widget/tvDomHelpers.cjs.map +0 -1
- package/dist/widget/tvDomHelpers.d.cts.map +0 -1
- package/dist/widget/tvDomHelpers.d.mts +0 -19
- package/dist/widget/tvDomHelpers.d.mts.map +0 -1
- package/dist/widget/tvDomHelpers.mjs.map +0 -1
- package/dist/widget/visualOverrides.cjs +0 -63
- package/dist/widget/visualOverrides.cjs.map +0 -1
- package/dist/widget/visualOverrides.d.cts.map +0 -1
- package/dist/widget/visualOverrides.d.mts +0 -27
- package/dist/widget/visualOverrides.d.mts.map +0 -1
- package/dist/widget/visualOverrides.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
13
13
|
|
|
14
14
|
### Changed
|
|
15
15
|
|
|
16
|
+
- Introduce an injectable platform host transport layer so the engine's host communication and config ingestion are no longer hardwired to the React Native WebView
|
|
17
|
+
- Adds a `ChartHostTransport` interface with `createReactNativeHost()` (default, preserves existing behavior) and `createIframeHost()` (for browser/extension iframe hosts), plus `setHostTransport`/`getHostTransport` and a `bootstrap` export for programmatic hosts.
|
|
18
|
+
- `createIframeHost()` accepts an `allowedOrigins` array and resolves `targetOrigin` from `document.referrer` automatically, replacing the legacy RN-bridge shim the hosted page previously needed.
|
|
19
|
+
- `core/bridge.ts` now handles only JSON framing/parsing/validation and delegates transport to the active host; `window.CONFIG` reads route through `getConfig()`.
|
|
20
|
+
- A new `@metamask/advanced-chart-core/host` subpath export provides a side-effect-free entry point (no auto-boot) for non-mobile hosts that choose their own transport and boot timing.
|
|
16
21
|
- Conform the vendored WebView engine to the `core` monorepo lint conventions without altering its runtime behavior ([#9762](https://github.com/MetaMask/core/pull/9762))
|
|
17
22
|
- Applies core naming, JSDoc, and code-quality rules in source, with narrowly-scoped rule allowances only for browser globals and external contract identifiers.
|
|
18
23
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChartConfig } from
|
|
1
|
+
import type { ChartConfig } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Phase 1 + 2 bootstrap. Returns the resolved CONFIG so callers (and tests)
|
|
4
4
|
* can inspect what booted. Idempotent on its inbound subscription — the
|
|
@@ -7,4 +7,4 @@ import type { ChartConfig } from "./types.mjs";
|
|
|
7
7
|
* @returns The resolved chart configuration read from `window.CONFIG`.
|
|
8
8
|
*/
|
|
9
9
|
export declare function bootstrap(): ChartConfig;
|
|
10
|
-
//# sourceMappingURL=bootstrap.d.
|
|
10
|
+
//# sourceMappingURL=bootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -13,32 +13,33 @@
|
|
|
13
13
|
// SET_OHLCV_DATA arrives.
|
|
14
14
|
// 6. On first SET_OHLCV_DATA: createChartWidget with the default datafeed,
|
|
15
15
|
// apply visual overrides, attach crosshair + visible-range listeners.
|
|
16
|
-
import { handleAddIndicator, handleRemoveIndicator, handleSetMAVisibility } from
|
|
17
|
-
import { attachLegendResizeListener, setupLegendOverlay } from
|
|
18
|
-
import { handleSetSubPaneLayout } from
|
|
19
|
-
import { handleToggleVolume, registerVolumeThemeSync } from
|
|
20
|
-
import { attachCrosshairListener, attachTapDismiss } from
|
|
21
|
-
import { attachVisibleRangeListeners } from
|
|
22
|
-
import { dispatchInboundMessage, registerHandler } from
|
|
23
|
-
import { registerFocusTimeOverlay } from
|
|
24
|
-
import { registerPositionLinesOverlay } from
|
|
25
|
-
import { slbScheduleInitialCentering } from
|
|
26
|
-
import { registerTradeMarkerPulseHandler } from
|
|
27
|
-
import { registerTradeMarkerOverlay } from
|
|
28
|
-
import { attachMarkerHitTest } from
|
|
29
|
-
import { registerRnBackedPaginationHandler } from
|
|
30
|
-
import { handleSetChartType } from
|
|
31
|
-
import { customDatafeed } from
|
|
32
|
-
import { createChartWidget, scheduleChartLayoutSettledNotify } from
|
|
33
|
-
import { handleRealtimeUpdate, handleSetOHLCVData, onFirstOhlcvData } from
|
|
34
|
-
import { advancedChartPriceFormatterFactory } from
|
|
35
|
-
import { applyScaleLayout } from
|
|
36
|
-
import { applyThemeColors, flushPendingTheme, initThemeFromConfig } from
|
|
37
|
-
import { applyVisualOverrides } from
|
|
38
|
-
import { onFromRN, postToRN, reportErrorToRN } from
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
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';
|
|
42
43
|
/**
|
|
43
44
|
* When RN passes an explicit visible-range start (e.g. a specific period like
|
|
44
45
|
* 1D/1W/1M), build a `{ type: 'time-range', from, to }` timeframe so the
|
|
@@ -63,7 +64,7 @@ function buildInitialTimeframe() {
|
|
|
63
64
|
};
|
|
64
65
|
}
|
|
65
66
|
function readConfig() {
|
|
66
|
-
const config =
|
|
67
|
+
const config = getHostTransport().getConfig();
|
|
67
68
|
if (!config) {
|
|
68
69
|
throw new Error('window.CONFIG is missing — AdvancedChartTemplate must inline ' +
|
|
69
70
|
'CONFIG before chartLogic runs.');
|
|
@@ -79,6 +80,7 @@ function readConfig() {
|
|
|
79
80
|
*/
|
|
80
81
|
export function bootstrap() {
|
|
81
82
|
const config = readConfig();
|
|
83
|
+
setConfig(config);
|
|
82
84
|
initThemeFromConfig(config.theme);
|
|
83
85
|
if (typeof config.subPaneHeightRatio === 'number') {
|
|
84
86
|
setSubPaneHeightRatio(config.subPaneHeightRatio);
|
|
@@ -178,4 +180,4 @@ export function bootstrap() {
|
|
|
178
180
|
postToRN('DEBUG', { message: 'modular-bootstrap-ready' });
|
|
179
181
|
return config;
|
|
180
182
|
}
|
|
181
|
-
//# sourceMappingURL=bootstrap.
|
|
183
|
+
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EACL,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EACL,sBAAsB,EACtB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AACrF,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,C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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,10 +1,10 @@
|
|
|
1
|
-
import type { InboundMessage, OutboundMessageType, OutboundPayloads } from
|
|
1
|
+
import type { InboundMessage, OutboundMessageType, OutboundPayloads } from '../messages/contract.js';
|
|
2
2
|
export declare function safeStringify(value: unknown): string;
|
|
3
3
|
/**
|
|
4
|
-
* Posts a typed message to
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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
8
|
*
|
|
9
9
|
* @param type - The outbound message type tag.
|
|
10
10
|
* @param payload - The payload associated with the message type.
|
|
@@ -20,10 +20,10 @@ export declare function postToRN<Type extends OutboundMessageType>(type: Type, p
|
|
|
20
20
|
export declare function reportErrorToRN(error: unknown): void;
|
|
21
21
|
export type InboundMessageHandler = (message: InboundMessage) => void;
|
|
22
22
|
/**
|
|
23
|
-
* Registers a single inbound listener.
|
|
24
|
-
*
|
|
25
|
-
* and
|
|
26
|
-
*
|
|
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
27
|
*
|
|
28
28
|
* The returned function unsubscribes — useful for tests; the real bundle
|
|
29
29
|
* subscribes once at bootstrap and never unsubscribes.
|
|
@@ -33,5 +33,5 @@ export type InboundMessageHandler = (message: InboundMessage) => void;
|
|
|
33
33
|
*/
|
|
34
34
|
export declare function onFromRN(handler: InboundMessageHandler): () => void;
|
|
35
35
|
/** Re-export for callers that want the type tag union. */
|
|
36
|
-
export type { InboundMessageType } from
|
|
37
|
-
//# sourceMappingURL=bridge.d.
|
|
36
|
+
export type { InboundMessageType } from '../messages/contract.js';
|
|
37
|
+
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,9 +1,12 @@
|
|
|
1
|
-
// Typed bridge between the WebView IIFE and
|
|
1
|
+
// Typed bridge between the WebView IIFE and its host.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
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';
|
|
7
10
|
export function safeStringify(value) {
|
|
8
11
|
try {
|
|
9
12
|
return JSON.stringify(value) ?? 'Unknown error';
|
|
@@ -13,25 +16,21 @@ export function safeStringify(value) {
|
|
|
13
16
|
}
|
|
14
17
|
}
|
|
15
18
|
/**
|
|
16
|
-
* Posts a typed message to
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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).
|
|
20
23
|
*
|
|
21
24
|
* @param type - The outbound message type tag.
|
|
22
25
|
* @param payload - The payload associated with the message type.
|
|
23
26
|
*/
|
|
24
27
|
export function postToRN(type, payload) {
|
|
25
|
-
const bridge = window.ReactNativeWebView;
|
|
26
|
-
if (!bridge) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
28
|
try {
|
|
30
|
-
|
|
29
|
+
getHostTransport().postMessage(JSON.stringify({ type, payload }));
|
|
31
30
|
}
|
|
32
31
|
catch {
|
|
33
32
|
// postMessage / JSON.stringify failure: nothing to do — the WebView
|
|
34
|
-
// cannot inform
|
|
33
|
+
// cannot inform the host of its own bridge failure.
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
36
|
/**
|
|
@@ -55,10 +54,10 @@ export function reportErrorToRN(error) {
|
|
|
55
54
|
postToRN('ERROR', { message });
|
|
56
55
|
}
|
|
57
56
|
/**
|
|
58
|
-
* Registers a single inbound listener.
|
|
59
|
-
*
|
|
60
|
-
* and
|
|
61
|
-
*
|
|
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.
|
|
62
61
|
*
|
|
63
62
|
* The returned function unsubscribes — useful for tests; the real bundle
|
|
64
63
|
* subscribes once at bootstrap and never unsubscribes.
|
|
@@ -67,17 +66,10 @@ export function reportErrorToRN(error) {
|
|
|
67
66
|
* @returns A function that removes the registered listeners.
|
|
68
67
|
*/
|
|
69
68
|
export function onFromRN(handler) {
|
|
70
|
-
|
|
71
|
-
// RN WebView inline HTML: native bridge messages arrive with an empty
|
|
72
|
-
// or "null" origin. Reject messages from real web origins.
|
|
73
|
-
const { origin } = event;
|
|
74
|
-
if (origin && origin !== 'null' && !origin.startsWith('file:')) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
69
|
+
return getHostTransport().subscribe((raw) => {
|
|
77
70
|
let parsed;
|
|
78
71
|
try {
|
|
79
|
-
parsed =
|
|
80
|
-
typeof event.data === 'string' ? JSON.parse(event.data) : event.data;
|
|
72
|
+
parsed = typeof raw === 'string' ? JSON.parse(raw) : raw;
|
|
81
73
|
}
|
|
82
74
|
catch (parseError) {
|
|
83
75
|
reportErrorToRN(parseError);
|
|
@@ -95,14 +87,6 @@ export function onFromRN(handler) {
|
|
|
95
87
|
// typed handler. Phase 1 only routes SET_THEME_COLORS, but the listener
|
|
96
88
|
// forwards every well-formed message so the handler can decide.
|
|
97
89
|
handler(parsed);
|
|
98
|
-
};
|
|
99
|
-
// iOS posts arrive on window; Android posts arrive on document. Subscribe
|
|
100
|
-
// to both to match legacy chartLogic.js handleMessage wiring.
|
|
101
|
-
window.addEventListener('message', dispatch);
|
|
102
|
-
document.addEventListener('message', dispatch);
|
|
103
|
-
return () => {
|
|
104
|
-
window.removeEventListener('message', dispatch);
|
|
105
|
-
document.removeEventListener('message', dispatch);
|
|
106
|
-
};
|
|
90
|
+
});
|
|
107
91
|
}
|
|
108
|
-
//# sourceMappingURL=bridge.
|
|
92
|
+
//# sourceMappingURL=bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,eAAe,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UA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,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"]}
|
|
@@ -5,4 +5,4 @@ export declare function notifyDataLifecycle(event: DataLifecycleEvent): void;
|
|
|
5
5
|
/** Test-only: clear every listener across every event. */
|
|
6
6
|
export declare function _resetDataLifecycleForTests(): void;
|
|
7
7
|
export {};
|
|
8
|
-
//# sourceMappingURL=dataLifecycle.d.
|
|
8
|
+
//# sourceMappingURL=dataLifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// The events are intentionally void — subscribers read whatever state
|
|
11
11
|
// they need from core/state.ts. Errors inside a subscriber are logged
|
|
12
12
|
// to RN so a broken overlay doesn't take the widget down with it.
|
|
13
|
-
import { reportErrorToRN } from
|
|
13
|
+
import { reportErrorToRN } from './bridge.js';
|
|
14
14
|
const listeners = {
|
|
15
15
|
ohlcvReset: [],
|
|
16
16
|
ohlcvPrepended: [],
|
|
@@ -43,4 +43,4 @@ export function _resetDataLifecycleForTests() {
|
|
|
43
43
|
listeners.ohlcvPrepended = [];
|
|
44
44
|
listeners.visibleRangeChanged = [];
|
|
45
45
|
}
|
|
46
|
-
//# sourceMappingURL=dataLifecycle.
|
|
46
|
+
//# sourceMappingURL=dataLifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Platform host transport layer.
|
|
2
|
+
//
|
|
3
|
+
// Abstracts the *platform-specific* transport (how the WebView talks to its
|
|
4
|
+
// host and where it reads its inlined CONFIG) behind a single injectable
|
|
5
|
+
// interface. The engine's message bridge (core/bridge.ts) and config accessor
|
|
6
|
+
// (core/state.ts getConfig) depend on this interface instead of naming a
|
|
7
|
+
// concrete global, so the same engine can run inside a React Native WebView
|
|
8
|
+
// or a browser extension iframe.
|
|
9
|
+
//
|
|
10
|
+
// Adapters live in src/platform/*. The React Native adapter is the default so
|
|
11
|
+
// that existing consumers (and the mobile IIFE) keep their exact behavior
|
|
12
|
+
// without any wiring.
|
|
13
|
+
import { createReactNativeHost } from '../platform/reactNativeHost.js';
|
|
14
|
+
let activeHost = null;
|
|
15
|
+
/**
|
|
16
|
+
* Injects the host transport the engine should use. The mobile IIFE and the
|
|
17
|
+
* extension entry call this before bootstrap; tests may call it to provide a
|
|
18
|
+
* fake transport.
|
|
19
|
+
*
|
|
20
|
+
* @param host - The transport adapter to activate.
|
|
21
|
+
*/
|
|
22
|
+
export function setHostTransport(host) {
|
|
23
|
+
activeHost = host;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns the active host transport, lazily defaulting to the React Native
|
|
27
|
+
* adapter so untouched consumers keep their current behavior.
|
|
28
|
+
*
|
|
29
|
+
* @returns The active host transport.
|
|
30
|
+
*/
|
|
31
|
+
export function getHostTransport() {
|
|
32
|
+
activeHost ??= createReactNativeHost();
|
|
33
|
+
return activeHost;
|
|
34
|
+
}
|
|
35
|
+
/** Test-only: clear the injected host so the next access re-defaults. */
|
|
36
|
+
export function _resetHostTransportForTests() {
|
|
37
|
+
activeHost = null;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/core/host.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,EAAE;AACF,4EAA4E;AAC5E,yEAAyE;AACzE,8EAA8E;AAC9E,yEAAyE;AACzE,4EAA4E;AAC5E,iCAAiC;AACjC,EAAE;AACF,8EAA8E;AAC9E,0EAA0E;AAC1E,sBAAsB;AAEtB,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAyBvE,IAAI,UAAU,GAA8B,IAAI,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAwB;IACvD,UAAU,GAAG,IAAI,CAAC;AACpB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB;IAC9B,UAAU,KAAK,qBAAqB,EAAE,CAAC;IACvC,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,2BAA2B;IACzC,UAAU,GAAG,IAAI,CAAC;AACpB,CAAC","sourcesContent":["// Platform host transport layer.\n//\n// Abstracts the *platform-specific* transport (how the WebView talks to its\n// host and where it reads its inlined CONFIG) behind a single injectable\n// interface. The engine's message bridge (core/bridge.ts) and config accessor\n// (core/state.ts getConfig) depend on this interface instead of naming a\n// concrete global, so the same engine can run inside a React Native WebView\n// or a browser extension iframe.\n//\n// Adapters live in src/platform/*. The React Native adapter is the default so\n// that existing consumers (and the mobile IIFE) keep their exact behavior\n// without any wiring.\n\nimport { createReactNativeHost } from '../platform/reactNativeHost.js';\nimport type { ChartConfig } from './types.js';\n\n/** Callback invoked with each raw inbound payload delivered by the host. */\nexport type InboundTransportListener = (raw: unknown) => void;\n\n/**\n * The platform transport contract. An adapter owns the three things that\n * differ between hosts: how outbound messages are delivered, how inbound\n * messages are received (including any origin filtering), and where the\n * inlined chart CONFIG comes from.\n */\nexport type ChartHostTransport = {\n /** Deliver a serialized outbound message to the host. */\n postMessage(serialized: string): void;\n /**\n * Subscribe to raw inbound messages from the host. The adapter is\n * responsible for any transport-level filtering (e.g. origin checks). The\n * returned function unsubscribes.\n */\n subscribe(onMessage: InboundTransportListener): () => void;\n /** Return the inlined chart configuration, or `undefined` when absent. */\n getConfig(): ChartConfig | undefined;\n};\n\nlet activeHost: ChartHostTransport | null = null;\n\n/**\n * Injects the host transport the engine should use. The mobile IIFE and the\n * extension entry call this before bootstrap; tests may call it to provide a\n * fake transport.\n *\n * @param host - The transport adapter to activate.\n */\nexport function setHostTransport(host: ChartHostTransport): void {\n activeHost = host;\n}\n\n/**\n * Returns the active host transport, lazily defaulting to the React Native\n * adapter so untouched consumers keep their current behavior.\n *\n * @returns The active host transport.\n */\nexport function getHostTransport(): ChartHostTransport {\n activeHost ??= createReactNativeHost();\n return activeHost;\n}\n\n/** Test-only: clear the injected host so the next access re-defaults. */\nexport function _resetHostTransportForTests(): void {\n activeHost = null;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadLibrary.d.ts","sourceRoot":"","sources":["../../src/core/loadLibrary.ts"],"names":[],"mappings":"AAkBA;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCxE;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,CAEhD"}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
//
|
|
4
4
|
// Mirrors legacy chartLogic.js `loadLibrary()` (lines ~5211-5237) but returns
|
|
5
5
|
// a Promise so callers can `await` library readiness in bootstrap.ts.
|
|
6
|
-
import { reportErrorToRN } from
|
|
7
|
-
import { setLibraryLoaded, setLibraryError, isLibraryLoaded, getLibraryError } from
|
|
6
|
+
import { reportErrorToRN } from './bridge.js';
|
|
7
|
+
import { setLibraryLoaded, setLibraryError, isLibraryLoaded, getLibraryError, } from './state.js';
|
|
8
8
|
const CHARTING_LIBRARY_FILE = 'charting_library.js';
|
|
9
9
|
let inflightPromise = null;
|
|
10
10
|
/**
|
|
@@ -55,4 +55,4 @@ export function loadTradingViewLibrary(libraryUrl) {
|
|
|
55
55
|
export function _resetLoadLibraryForTests() {
|
|
56
56
|
inflightPromise = null;
|
|
57
57
|
}
|
|
58
|
-
//# sourceMappingURL=loadLibrary.
|
|
58
|
+
//# sourceMapping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,OAAO,GAAG,GAAS,EAAE;YAC1B,MAAM,OAAO,GAAG,4CAA4C,SAAS,EAAE,CAAC;YACxE,eAAe,CAAC,OAAO,CAAC,CAAC;YACzB,eAAe,GAAG,IAAI,CAAC;YACvB,eAAe,CAAC,OAAO,CAAC,CAAC;YACzB,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7B,CAAC,CAAC;QACF,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IACH,OAAO,eAAe,CAAC;AACzB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB;IACvC,eAAe,GAAG,IAAI,CAAC;AACzB,CAAC","sourcesContent":["// Loads the TradingView Advanced Charts library from window.CONFIG.libraryUrl\n// by injecting a <script> tag into the document head.\n//\n// Mirrors legacy chartLogic.js `loadLibrary()` (lines ~5211-5237) but returns\n// a Promise so callers can `await` library readiness in bootstrap.ts.\n\nimport { reportErrorToRN } from './bridge.js';\nimport {\n setLibraryLoaded,\n setLibraryError,\n isLibraryLoaded,\n getLibraryError,\n} from './state.js';\n\nconst CHARTING_LIBRARY_FILE = 'charting_library.js';\n\nlet inflightPromise: Promise<void> | null = null;\n\n/**\n * Loads the TradingView library script. Subsequent calls resolve immediately\n * if the library is already loaded; rejected if a previous load failed.\n * Concurrent calls while the script is still loading share the same promise.\n *\n * @param libraryUrl - Base URL that the `charting_library.js` file is appended to.\n * @returns A promise that resolves once the library script has loaded.\n */\nexport function loadTradingViewLibrary(libraryUrl: string): Promise<void> {\n if (isLibraryLoaded()) {\n return Promise.resolve();\n }\n const existingError = getLibraryError();\n if (existingError) {\n return Promise.reject(new Error(existingError));\n }\n if (inflightPromise) {\n return inflightPromise;\n }\n\n inflightPromise = new Promise<void>((resolve, reject) => {\n const scriptUrl = libraryUrl + CHARTING_LIBRARY_FILE;\n const script = document.createElement('script');\n script.type = 'text/javascript';\n script.src = scriptUrl;\n script.onload = (): void => {\n setLibraryLoaded(true);\n inflightPromise = null;\n resolve();\n };\n script.onerror = (): void => {\n const message = `Failed to load TradingView library. URL: ${scriptUrl}`;\n setLibraryError(message);\n inflightPromise = null;\n reportErrorToRN(message);\n reject(new Error(message));\n };\n document.head.appendChild(script);\n });\n return inflightPromise;\n}\n\n/**\n * Resets the cached in-flight library-load promise.\n *\n * @internal\n */\nexport function _resetLoadLibraryForTests(): void {\n inflightPromise = null;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TVResolution } from
|
|
1
|
+
import type { TVResolution } from './types.js';
|
|
2
2
|
/** OHLCV bar interval in milliseconds → TradingView resolution code. */
|
|
3
3
|
export declare const INTERVAL_MS_TO_TV: Readonly<Record<number, TVResolution>>;
|
|
4
4
|
/**
|
|
@@ -12,4 +12,4 @@ export declare const INTERVAL_MS_TO_TV: Readonly<Record<number, TVResolution>>;
|
|
|
12
12
|
export declare function detectResolution(data: {
|
|
13
13
|
time: number;
|
|
14
14
|
}[]): TVResolution;
|
|
15
|
-
//# sourceMappingURL=resolution.d.
|
|
15
|
+
//# sourceMappingURL=resolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolution.d.ts","sourceRoot":"","sources":["../../src/core/resolution.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wEAAwE;AACxE,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAepE,CAAC;AAIF;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,GAAG,YAAY,CAuBvE"}
|
|
@@ -4,20 +4,20 @@
|
|
|
4
4
|
// (lines ~463-505). Phase 2 consumes this from widget/ohlcvIngestion.ts.
|
|
5
5
|
/** OHLCV bar interval in milliseconds → TradingView resolution code. */
|
|
6
6
|
export const INTERVAL_MS_TO_TV = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
60_000: '1',
|
|
8
|
+
180_000: '3',
|
|
9
|
+
300_000: '5',
|
|
10
|
+
900_000: '15',
|
|
11
|
+
1_800_000: '30',
|
|
12
|
+
3_600_000: '60',
|
|
13
|
+
7_200_000: '120',
|
|
14
|
+
14_400_000: '240',
|
|
15
|
+
28_800_000: '480',
|
|
16
|
+
43_200_000: '720',
|
|
17
|
+
86_400_000: '1D',
|
|
18
|
+
259_200_000: '3D',
|
|
19
|
+
604_800_000: '1W',
|
|
20
|
+
2_592_000_000: '1M',
|
|
21
21
|
};
|
|
22
22
|
const DEFAULT_RESOLUTION = '5';
|
|
23
23
|
/**
|
|
@@ -51,4 +51,4 @@ export function detectResolution(data) {
|
|
|
51
51
|
}
|
|
52
52
|
return best;
|
|
53
53
|
}
|
|
54
|
-
//# sourceMappingURL=resolution.
|
|
54
|
+
//# sourceMappingURL=resolution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolution.js","sourceRoot":"","sources":["../../src/core/resolution.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,EAAE;AACF,0EAA0E;AAC1E,yEAAyE;AAIzE,wEAAwE;AACxE,MAAM,CAAC,MAAM,iBAAiB,GAA2C;IACvE,MAAM,EAAE,GAAG;IACX,OAAO,EAAE,GAAG;IACZ,OAAO,EAAE,GAAG;IACZ,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,KAAK;IAChB,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE,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,CAAC;YACpB,IAAI,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["// Maps OHLCV bar intervals (milliseconds) to TradingView resolution strings.\n//\n// Ported verbatim from chartLogic.js INTERVAL_MS_TO_TV + detectResolution\n// (lines ~463-505). Phase 2 consumes this from widget/ohlcvIngestion.ts.\n\nimport type { TVResolution } from './types.js';\n\n/** OHLCV bar interval in milliseconds → TradingView resolution code. */\nexport const INTERVAL_MS_TO_TV: Readonly<Record<number, TVResolution>> = {\n 60_000: '1',\n 180_000: '3',\n 300_000: '5',\n 900_000: '15',\n 1_800_000: '30',\n 3_600_000: '60',\n 7_200_000: '120',\n 14_400_000: '240',\n 28_800_000: '480',\n 43_200_000: '720',\n 86_400_000: '1D',\n 259_200_000: '3D',\n 604_800_000: '1W',\n 2_592_000_000: '1M',\n};\n\nconst DEFAULT_RESOLUTION: TVResolution = '5';\n\n/**\n * Picks the closest matching TV resolution for an OHLCV bar series.\n * Uses the median diff over the first few bars so a single gap doesn't skew\n * the result (matches legacy chartLogic.js detectResolution semantics).\n *\n * @param data - The OHLCV bar series (each bar carries a `time` in ms).\n * @returns The closest matching TradingView resolution.\n */\nexport function detectResolution(data: { time: number }[]): TVResolution {\n if (data.length < 2) {\n return DEFAULT_RESOLUTION;\n }\n const sampleCount = Math.min(data.length - 1, 10);\n const diffs: number[] = [];\n for (let i = 0; i < sampleCount; i++) {\n diffs.push(data[i + 1].time - data[i].time);\n }\n diffs.sort((a, b) => a - b);\n const median = diffs[Math.floor(diffs.length / 2)];\n\n let best = DEFAULT_RESOLUTION;\n let bestDist = Infinity;\n for (const key of Object.keys(INTERVAL_MS_TO_TV)) {\n const intervalMs = Number(key);\n const distance = Math.abs(intervalMs - median);\n if (distance < bestDist) {\n bestDist = distance;\n best = INTERVAL_MS_TO_TV[intervalMs];\n }\n }\n return best;\n}\n"]}
|
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
import type { ChartTheme, ChartType, OHLCVBar, OHLCVPaginationConfig, RealtimeTickCallback, StudyId, TVChartingLibraryWidget } from
|
|
1
|
+
import type { ChartConfig, ChartTheme, ChartType, OHLCVBar, OHLCVPaginationConfig, RealtimeTickCallback, StudyId, TVChartingLibraryWidget } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Seeds the resolved chart config. Called once by bootstrap after reading it
|
|
4
|
+
* from the host transport.
|
|
5
|
+
*
|
|
6
|
+
* @param config - The resolved chart configuration.
|
|
7
|
+
*/
|
|
8
|
+
export declare function setConfig(config: ChartConfig): void;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the resolved chart config. Prefers the value seeded at bootstrap and
|
|
11
|
+
* falls back to the host transport (e.g. before bootstrap, or in unit tests
|
|
12
|
+
* that stub the config directly).
|
|
13
|
+
*
|
|
14
|
+
* @returns The chart config, or `undefined` when none is available.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getConfig(): ChartConfig | undefined;
|
|
2
17
|
export declare function getWidget(): TVChartingLibraryWidget | null;
|
|
3
18
|
export declare function setWidget(widget: TVChartingLibraryWidget | null): void;
|
|
4
19
|
export declare function isChartReady(): boolean;
|
|
@@ -64,4 +79,4 @@ export declare function setHasExplicitCurrentPriceLine(has: boolean): void;
|
|
|
64
79
|
* the theme or feature flags change).
|
|
65
80
|
*/
|
|
66
81
|
export declare function _resetStateForTests(): void;
|
|
67
|
-
//# sourceMappingURL=state.d.
|
|
82
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/core/state.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,EACR,qBAAqB,EACrB,oBAAoB,EACpB,OAAO,EACP,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAgGpB;;;;;GAKG;AACH,wBAAgB,SAAS,CA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