add exitUrl script
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import * as tg from "generic-type-guard";
|
||||
|
||||
export const isExitUrlEvent =
|
||||
new tg.IsInterface().withProperties({
|
||||
url: tg.isString,
|
||||
}).get();
|
||||
|
||||
/**
|
||||
* A message sent from the iFrame to the game to trigger Exit Url
|
||||
*/
|
||||
export type ExitUrlEvent = tg.GuardedType<typeof isExitUrlEvent>;
|
||||
@@ -12,6 +12,7 @@ import {ClosePopupEvent, isClosePopupEvent} from "./Events/ClosePopupEvent";
|
||||
import {scriptUtils} from "./ScriptUtils";
|
||||
import {GoToPageEvent, isGoToPageEvent} from "./Events/GoToPageEvent";
|
||||
import {isOpenCoWebsite, OpenCoWebSiteEvent} from "./Events/OpenCoWebSiteEvent";
|
||||
import { isExitUrlEvent } from './Events/ExitUrlEvent';
|
||||
|
||||
|
||||
/**
|
||||
@@ -55,6 +56,9 @@ class IframeListener {
|
||||
private readonly _unregisterIFrameStream: Subject<void> = new Subject();
|
||||
public readonly unregisterIFrameStream = this._unregisterIFrameStream.asObservable();
|
||||
|
||||
private readonly _exitUrlStream: Subject<string> = new Subject();
|
||||
public readonly exitUrlStream = this._exitUrlStream.asObservable();
|
||||
|
||||
private readonly iframes = new Set<HTMLIFrameElement>();
|
||||
private readonly scripts = new Map<string, HTMLIFrameElement>();
|
||||
|
||||
@@ -109,6 +113,9 @@ class IframeListener {
|
||||
}
|
||||
else if (payload.type === 'removeBubble'){
|
||||
this._removeBubbleStream.next();
|
||||
}
|
||||
else if (payload.type === 'exitUrl' && isExitUrlEvent(payload.data)){
|
||||
this._exitUrlStream.next(payload.data.url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user