Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@signalwire/core

Package Overview
Dependencies
Maintainers
2
Versions
200
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@signalwire/core - npm Package Compare versions

Comparing version 3.6.1-dev.202203041041.b1b022a.0 to 3.7.0-dev.202203090855.4692b05.0

dist/core/src/BaseConsumer.test.d.ts

3

dist/core/src/BaseComponent.d.ts

@@ -25,2 +25,3 @@ import type { Task } from '@redux-saga/types';

private _destroyer?;
private _handleCompoundEvents;
/**

@@ -167,2 +168,4 @@ * A Namespace let us scope specific instances inside of a

protected _attachListeners(namespace?: string): void;
/** @internal */
protected getCompoundEvents(): Map<EventEmitter.EventNames<EventTypes>, EventEmitter.EventNames<EventTypes>[]>;
/**

@@ -169,0 +172,0 @@ * Returns a structure with the emitter transforms that we want to `apply`

@@ -13,5 +13,7 @@ import { BaseComponent, EventEmitter, BaseComponentOptions, JSONRPCSubscribeMethod } from '.';

protected subscribeParams?: Record<string, any>;
private _latestExecuteParams;
constructor(options: BaseComponentOptions<EventTypes>);
private shouldExecuteSubscribe;
subscribe(): Promise<unknown>;
}
//# sourceMappingURL=BaseConsumer.d.ts.map
import { createAction, Action } from './toolkit';
import { JSONRPCRequest, SessionAuthError } from '../utils/interfaces';
import { ExecuteActionParams } from './interfaces';
import { EventEmitter } from '..';
export declare const initAction: import("./toolkit").ActionCreatorWithoutPayload<"swSdk/init">;

@@ -34,3 +35,8 @@ export declare const destroyAction: import("./toolkit").ActionCreatorWithoutPayload<"swSdk/destroy">;

export declare const getCustomSagaActionType: (id: string, action: Action) => string;
export declare const compoundEventAttachAction: import("./toolkit").ActionCreatorWithPayload<{
compoundEvents: EventEmitter.EventNames<EventEmitter.ValidEventTypes>[];
event: EventEmitter.EventNames<EventEmitter.ValidEventTypes>;
namespace?: string | undefined;
}, "compound_event:attach">;
export { createAction };
//# sourceMappingURL=actions.d.ts.map

2

dist/core/src/types/video.d.ts

@@ -12,3 +12,3 @@ import { VideoRoomSessionEventNames, VideoRoomEvent, InternalVideoRoomSessionEventNames, InternalVideoRoomEvent } from './videoRoomSession';

export declare type RTCTrackEventName = 'track';
export declare type VideoPosition = 'self' | 'auto' | `reserved-${number}` | `standard-${number}` | 'off-canvas';
export declare type VideoPosition = 'auto' | `reserved-${number}` | `standard-${number}` | 'off-canvas';
export declare type VideoPositions = Record<string, VideoPosition>;

@@ -15,0 +15,0 @@ /**

@@ -111,2 +111,3 @@ /// <reference types="node" />

export declare type SessionEvents = `session.${SessionStatus}`;
export declare type CompoundEvents = 'compound_event:attach';
/**

@@ -113,0 +114,0 @@ * List of all the events the client can listen to.

import { EventTransform } from '..';
export declare const serializeableProxy: ({ instance, proxiedObj, payload, }: {
export declare const serializeableProxy: ({ instance, proxiedObj, payload, transformedPayload, transform, }: {
instance: any;
proxiedObj: any;
payload: any;
transformedPayload: any;
transform: any;
}) => any;

@@ -7,0 +9,0 @@ interface ProxyFactoryOptions {

@@ -6,3 +6,3 @@ {

"license": "MIT",
"version": "3.6.1-dev.202203041041.b1b022a.0",
"version": "3.7.0-dev.202203090855.4692b05.0",
"main": "dist/index.node.js",

@@ -9,0 +9,0 @@ "module": "dist/index.esm.js",

@@ -216,2 +216,4 @@ import { BaseComponent } from './BaseComponent'

expect(mockFn).toHaveBeenNthCalledWith(1, {
_eventsNamespace: 'new-namespace',
eventChannel: 'new-event-channel',
instance,

@@ -223,2 +225,4 @@ inject: 'something',

expect(mockFn).toHaveBeenNthCalledWith(2, {
_eventsNamespace: 'new-namespace',
eventChannel: 'new-event-channel',
instance,

@@ -225,0 +229,0 @@ inject: 'something',

@@ -37,2 +37,3 @@ import type { Task } from '@redux-saga/types'

} from './redux/features/session/sessionSelectors'
import { compoundEventAttachAction } from './redux/actions'
import { AuthError } from './CustomErrors'

@@ -92,2 +93,40 @@ import { proxyFactory } from './utils/proxyUtils'

private _handleCompoundEvents(event: EventEmitter.EventNames<EventTypes>) {
const internalEvent = this._getInternalEvent(event)
let compoundEvents
for (const evt of this.getCompoundEvents().keys()) {
if (this._getInternalEvent(evt) === internalEvent) {
compoundEvents = this.getCompoundEvents().get(evt)
break
}
}
if (!compoundEvents || compoundEvents.length === 0) {
return
}
this.store.dispatch(
compoundEventAttachAction({
compoundEvents,
event: internalEvent,
namespace: this._eventsNamespace,
})
)
compoundEvents.forEach((compoundEvent) => {
/**
* In the future we might want to support defining
* custom compound event handlers by specifying not
* only the event but its event handler as well. For
* now we don't have a need for that so we'll keep it
* simple and just track the event without going
* through the emitter (since we don't need the
* handler).
*/
if (typeof compoundEvent === 'string') {
this._trackEvent(compoundEvent)
}
})
}
/**

@@ -441,2 +480,4 @@ * A Namespace let us scope specific instances inside of a

) {
this._handleCompoundEvents(event)
const internalEvent = this._getInternalEvent(event)

@@ -697,2 +738,10 @@ this._trackEvent(internalEvent)

/** @internal */
protected getCompoundEvents(): Map<
EventEmitter.EventNames<EventTypes>,
EventEmitter.EventNames<EventTypes>[]
> {
return new Map()
}
/**

@@ -699,0 +748,0 @@ * Returns a structure with the emitter transforms that we want to `apply`

@@ -21,2 +21,3 @@ import {

protected subscribeParams?: Record<string, any> = {}
private _latestExecuteParams: ExecuteParams

@@ -36,31 +37,47 @@ constructor(public options: BaseComponentOptions<EventTypes>) {

subscribe() {
private shouldExecuteSubscribe(execParams: ExecuteParams) {
return (
!this._latestExecuteParams ||
JSON.stringify(execParams) !== JSON.stringify(this._latestExecuteParams)
)
}
async subscribe() {
const subscriptions = this.getSubscriptions()
if (subscriptions.length === 0) {
this.logger.warn(
'`subscribe()` was called without any listeners attached.'
)
return
}
const execParams: ExecuteParams = {
method: this.subscribeMethod,
params: {
...this.subscribeParams,
event_channel: this.getStateProperty('eventChannel'),
events: subscriptions,
},
}
if (!this.shouldExecuteSubscribe(execParams)) {
this.logger.debug(
'BaseConsumer.subscribe() - Skipped .execute() since the execParams are exactly the same as last time'
)
return
}
this._latestExecuteParams = execParams
return new Promise(async (resolve, reject) => {
const subscriptions = this.getSubscriptions()
if (subscriptions.length > 0) {
const execParams: ExecuteParams = {
method: this.subscribeMethod,
params: {
...this.subscribeParams,
event_channel: this.getStateProperty('eventChannel'),
events: subscriptions,
},
}
try {
this.applyEmitterTransforms()
this.attachWorkers()
await this.execute(execParams)
} catch (error) {
return reject(error)
}
} else {
this.logger.warn(
'`subscribe()` was called without any listeners attached.'
)
try {
this.applyEmitterTransforms()
this.attachWorkers()
await this.execute(execParams)
return resolve(undefined)
} catch (error) {
return reject(error)
}
return resolve(undefined)
})
}
}

@@ -6,4 +6,6 @@ import { createAction, Action } from './toolkit'

SessionEvents,
CompoundEvents,
} from '../utils/interfaces'
import { ExecuteActionParams } from './interfaces'
import { EventEmitter } from '..'

@@ -67,2 +69,11 @@ export const initAction = createAction('swSdk/init')

export const compoundEventAttachAction = createAction<
{
compoundEvents: EventEmitter.EventNames<EventEmitter.ValidEventTypes>[]
event: EventEmitter.EventNames<EventEmitter.ValidEventTypes>
namespace?: string
},
CompoundEvents
>('compound_event:attach')
export { createAction }

@@ -38,3 +38,2 @@ import {

export type VideoPosition =
| 'self'
| 'auto'

@@ -41,0 +40,0 @@ | `reserved-${number}`

@@ -184,2 +184,4 @@ import type { SagaIterator } from '@redux-saga/types'

export type CompoundEvents = 'compound_event:attach'
/**

@@ -435,2 +437,1 @@ * List of all the events the client can listen to.

}

@@ -50,2 +50,4 @@ import { EventTransform } from '..'

payload,
transformedPayload,
transform,
}: {

@@ -55,10 +57,31 @@ instance: any

payload: any
transformedPayload: any
transform: any
}) => {
const data = {
...payload,
...transformedPayload,
/**
* We manually add `_eventsNamespace` and `eventChannel`
* as an attempt to make this object as close as Proxy,
* but `_eventsNamespace` is actually required when
* using `instance` inside of workers. Without this the
* events will be queued because `_eventsNamespace` is
* undefined.
*/
_eventsNamespace: transform.getInstanceEventNamespace
? transform.getInstanceEventNamespace(payload)
: undefined,
eventChannel: transform.getInstanceEventChannel
? transform.getInstanceEventChannel(payload)
: undefined,
...getAllMethods(instance),
}
return Object.defineProperties(
proxiedObj,
Object.entries(data).reduce((reducer, [key, value]) => {
if (value === undefined) {
return reducer
}
reducer[key] = {

@@ -68,4 +91,6 @@ value,

configurable: true,
// We mostly need this for our tests where we're
// overwritting things like `execute`.
/**
* We mostly need this for our tests where we're
* overwritting things like `execute`.
*/
writable: true,

@@ -99,2 +124,10 @@ }

})
/**
* Having `_eventsNamespace` defined will make
* BaseComponent.shouldAddToQueue === false, which
* will allow us to attach events right away
* (otherwise the events will be queued until the
* `namespace` is ready)
*/
} else if (

@@ -122,4 +155,6 @@ prop === '_eventsNamespace' &&

proxiedObj,
payload: transformedPayload,
payload,
transformedPayload,
transform,
})
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc