@mathieuc/tradingview 3.3.0 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mathieuc/tradingview",
3
- "version": "3.3.0",
3
+ "version": "3.3.1",
4
4
  "description": "Tradingview instant stocks API, indicator alerts, trading bot, and more !",
5
5
  "main": "main.js",
6
6
  "scripts": {
package/src/client.js CHANGED
@@ -215,6 +215,7 @@ module.exports = class Client {
215
215
  * @typedef {Object} ClientOptions
216
216
  * @prop {string} [token] User auth token (in 'sessionid' cookie)
217
217
  * @prop {boolean} [DEBUG] Enable debug mode
218
+ * @prop {'data' | 'prodata' | 'widgetdata'} [server] Server type
218
219
  */
219
220
 
220
221
  /** Client object
@@ -223,7 +224,8 @@ module.exports = class Client {
223
224
  constructor(clientOptions = {}) {
224
225
  if (clientOptions.DEBUG) global.TW_DEBUG = clientOptions.DEBUG;
225
226
 
226
- this.#ws = new WebSocket('wss://data.tradingview.com/socket.io/websocket', {
227
+ const server = clientOptions.server || 'data';
228
+ this.#ws = new WebSocket(`wss://${server}.tradingview.com/socket.io/websocket`, {
227
229
  origin: 'https://s.tradingview.com',
228
230
  });
229
231
 
@@ -275,10 +275,12 @@ module.exports = {
275
275
  data.result.metaInfo.inputs.forEach((input) => {
276
276
  if (['text', 'pineId', 'pineVersion'].includes(input.id)) return;
277
277
 
278
+ const inlineName = input.name.replace(/ /g, '_').replace(/[^a-zA-Z0-9_]/g, '');
279
+
278
280
  inputs[input.id] = {
279
281
  name: input.name,
280
- inline: input.inline || input.name.replace(/ /g, '_').replace(/[^a-zA-Z0-9_]/g, ''),
281
- internalID: input.internalID,
282
+ inline: input.inline || inlineName,
283
+ internalID: input.internalID || inlineName,
282
284
  tooltip: input.tooltip,
283
285
 
284
286
  type: input.type,