[next] Add support for embed (#1762)

* 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
This commit is contained in:
Kiwi
2018-08-02 15:29:18 +00:00
committed by Wyatt Johnson
parent cf3b706bbc
commit 6d7056d831
72 changed files with 1995 additions and 1046 deletions
+41
View File
@@ -0,0 +1,41 @@
import pym from "pym.js";
import { CleanupCallback, Decorator } from "./decorators";
interface PymControlConfig {
id: string;
url: string;
title: string;
decorators?: ReadonlyArray<Decorator>;
}
export default class PymControl {
private pym: pym.Parent;
private cleanups: CleanupCallback[];
constructor(config: PymControlConfig) {
const decorators = config.decorators || [];
this.pym = new pym.Parent(config.id, config.url, {
title: config.title,
id: `${config.id}_iframe`,
name: `${config.id}_iframe`,
});
this.cleanups = decorators
.map(enhance => enhance(this.pym))
.filter(cb => cb) as CleanupCallback[];
}
public sendMessage(id: string, raw?: string) {
this.pym.sendMessage(id, raw || "");
}
public remove() {
this.cleanups.forEach(cb => cb());
this.cleanups = [];
// Remove the pym parent.
this.pym.remove();
}
}