mirror of
https://github.com/wassname/talk.git
synced 2026-07-16 11:22:16 +08:00
* Move talk-server/config to talk-common/config * Refactor build into /src/core/build and use common config * Add embed webpack config * Start implementing embed * Implement embed * Add pym types * Add event emitter to Talk Context * Add MatchMedia test for passing values from the context * Add support for click far away * Integrate pym click events to registerClickFarAway * Add tests * Resolve merge issues * Apply PR review
31 lines
762 B
TypeScript
31 lines
762 B
TypeScript
import { EventEmitter2 } from "eventemitter2";
|
|
import qs from "query-string";
|
|
|
|
import createStreamInterface from "./Stream";
|
|
|
|
export interface Config {
|
|
assetID?: string;
|
|
assetURL?: string;
|
|
rootURL?: string;
|
|
id?: string;
|
|
events?: (eventEmitter: EventEmitter2) => void;
|
|
}
|
|
|
|
export function render(config: Config = {}) {
|
|
// Parse query params
|
|
const query = qs.parse(location.search);
|
|
const eventEmitter = new EventEmitter2({ wildcard: true });
|
|
|
|
if (config.events) {
|
|
config.events(eventEmitter);
|
|
}
|
|
|
|
return createStreamInterface({
|
|
assetID: config.assetID || query.assetID,
|
|
assetURL: config.assetURL || query.assetURL,
|
|
id: config.id || "talk-embed-stream",
|
|
rootURL: config.rootURL || location.origin,
|
|
eventEmitter,
|
|
});
|
|
}
|