@wordpress/sync
Version:
44 lines (40 loc) • 1.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createWebRTCConnection = createWebRTCConnection;
var _webrtcHttpStreamSignaling = require("./webrtc-http-stream-signaling");
/**
* External dependencies
*/
// import { WebrtcProvider } from 'y-webrtc';
/**
* Internal dependencies
*/
/** @typedef {import('./types').ObjectType} ObjectType */
/** @typedef {import('./types').ObjectID} ObjectID */
/** @typedef {import('./types').CRDTDoc} CRDTDoc */
/**
* Function that creates a new WebRTC Connection.
*
* @param {Object} config The object ID.
*
* @param {Array<string>} config.signaling
* @param {string} config.password
* @return {Function} Promise that resolves when the connection is established.
*/
function createWebRTCConnection({
signaling,
password
}) {
return function (/** @type {string} */objectId, /** @type {string} */objectType, /** @type {import("yjs").Doc} */doc) {
const roomName = `${objectType}-${objectId}`;
new _webrtcHttpStreamSignaling.WebrtcProviderWithHttpSignaling(roomName, doc, {
signaling,
// @ts-ignore
password
});
return Promise.resolve(() => true);
};
}
//# sourceMappingURL=create-webrtc-connection.js.map