Registry / messaging / mcs-lite-connect

mcs-lite-connect

JSON →
library0.3.41jsnpmunverified

A React higher-order component library (v0.3.41) that connects components to MCS (Media Cloud Service) via WebSocket, built on recompose and W3CWebSocket. It handles WebSocket lifecycle (connect, reconnect, send, receive) declaratively. Stable but low activity; last release July 2019. Differentiator: opinionated HOC pattern vs. raw WebSocket or hooks. Not actively maintained; known footgun: requires specific prop structure from parent.

npm install mcs-lite-connect
INSTALL
IMPORT
SIG · MCS-LITE-CONNECT
M
mcs-lite-connect
messagingjavascriptv0.3.41
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

connectSocket
import { connectSocket } from 'mcs-lite-connect'
import connectSocket from 'mcs-lite-connect'
Default export is not available; only named export.
withLifecycle
import { withLifecycle } from 'mcs-lite-connect'
const withLifecycle = require('mcs-lite-connect').withLifecycle
CommonJS require also works but ESM preferred.
withWebSocket
import { withWebSocket } from 'mcs-lite-connect'
import { WithWebSocket } from 'mcs-lite-connect'
Default export is not available; only named export.

Shows how to use connectSocket HOC to connect a React component to MCS via WebSocket with send, reconnect, and close detection.

import { connectSocket } from 'mcs-lite-connect'; const MyComponent = ({ send, isWebSocketClose, reconnect }) => ( <div> <button onClick={() => send('Hello')} disabled={isWebSocketClose}> Send </button> <button onClick={reconnect}>Reconnect</button> </div> ); const EnhancedComponent = connectSocket( props => 'ws://localhost:8000/deviceId/' + props.deviceId + '/deviceKey/' + props.deviceKey, props => datapoint => console.log('Received:', datapoint), ({ readyState, send, createWebSocket }) => ({ send, isWebSocketClose: readyState.sender === 3, reconnect: createWebSocket, }), )(MyComponent); export default EnhancedComponent;
Debug
Known issues
gotchaconnectSocket requires three arguments: urlMapper, onMessage, propsMapper. Forgetting one will cause runtime errors.
fix
Always provide all three functions.
affects: >=0.0.0
gotchaurlMapper must return a string starting with ws:// or wss://. Non-WebSocket URLs will fail silently.
fix
Ensure URL uses ws:// or wss:// protocol.
affects: >=0.0.0
gotchaonMessage function receives the datapoint object; its shape depends on MCS server format. Incorrect assumptions cause silent data loss.
fix
Log the received datapoint to inspect its structure.
affects: >=0.0.0
deprecatedLibrary depends on recompose, which is deprecated in favor of React Hooks. No active maintenance.
fix
Consider migrating to modern WebSocket hooks like useWebSocket.
affects: >=0.3.0
Errors
Common errors & fixes
Uncaught TypeError: connectSocket is not a function
Default import used instead of named import
fix
Change to import { connectSocket } from 'mcs-lite-connect';
WebSocket connection to 'ws://...' failed: Connection closed before receiving a handshake response
Server not running or wrong URL
fix
Check that MCS server is running and URL is correct.
Upgrade
Version history
0.3.41latest on npm
Audit
Dependencies
recomposerequiredProvides higher-order component utilities like compose, lifecycle, withState
websocketrequiredW3CWebSocket implementation for Node.js WebSocket client
Agent activity
9 hits · last 30 days
node
7
Amazon
1
OpenAI (training)
1
Resources
mcs-lite-connect — npm install mcs-lite-connect · libregistry