cdp-client-ts
TypeScript icon, indicating that this package has built-in type declarations

0.3.5 • Public • Published

CDP Studio Client - Isomorphic - TypeScript

CDP Studio Client for Browser and Node.js

Install using npm install cdp-client-ts

Example Use:

import { Client, ClientOptions, CDPNodeType } from "cdp-client-ts";

/* Using isomorphic-ws, works in Browser and Node.js environments */
async function main() {

  /* Default options can be changed on Client Init */
  const options: ClientOptions = {
    protocol: "ws://",  // ws:// or wss://
    maxRetry: 0,        // maxRetry == 0 => Infinity
    retryTimeout: 3e4   // waiting time before retrying connection
  }
  
  /* Can initiate Client with or without options */
  const client = new Client("127.0.0.1:7694", options);
  
  
  /* Iterate Over Children */
  const component: StructureNode = await client.find("SomeComponent.SomeSubComponent")
  component.forEachChild((child) => {
    if (child.nodeType == CDPNodeType.CDP_OBJECT) {
      console.log(child.route, child.id, child.lastValue)
    }
  })
  
  
  /* Get Value Async or Subscribe with callback */
  const node: StructureNode  = await client.find("SomeComponent.SomeSubComponent.SomeNode")
  const nodeValue = await node.getValue()
  node.subscribeToValue((value) => console.log(value))
  
}

Missing Features

  • Structure Change in Studio Tree
  • Authentication on init and ReAuth events

Inspiration: CDP Client (JavaScript)

Package Sidebar

Install

npm i cdp-client-ts

Weekly Downloads

1

Version

0.3.5

License

ISC

Unpacked Size

370 kB

Total Files

22

Last publish

Collaborators

  • einar.aglen