2020-11-17 21:53:04 +00:00
|
|
|
import { pluginPolyfill, polyfill } from "./polyfills";
|
2020-11-17 19:54:58 +00:00
|
|
|
import { registerElement } from "./register-element";
|
2020-11-12 22:32:53 +00:00
|
|
|
import { RufflePlayer } from "./ruffle-player";
|
2019-10-13 02:01:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents this particular version of Ruffle.
|
2020-05-12 22:24:41 +00:00
|
|
|
*
|
2019-10-13 02:01:01 +00:00
|
|
|
* Multiple APIs can be instantiated from different sources; e.g. an "extension"
|
|
|
|
* version, versus a "local" version. This expresses to the Public API
|
2020-11-14 21:20:42 +00:00
|
|
|
* negotiator (see [[PublicAPI]]) what this particular version of Ruffle is and
|
2019-10-13 02:01:01 +00:00
|
|
|
* how to control it.
|
|
|
|
*/
|
2022-06-03 18:50:51 +00:00
|
|
|
export const SourceAPI = {
|
2019-10-15 02:52:53 +00:00
|
|
|
/**
|
2022-06-03 18:50:51 +00:00
|
|
|
* The version of this particular API, as a string in a semver compatible format.
|
2020-11-14 21:20:42 +00:00
|
|
|
*/
|
2022-06-03 18:50:51 +00:00
|
|
|
version: "%VERSION_NUMBER%",
|
2020-05-12 22:24:41 +00:00
|
|
|
|
2019-10-14 18:56:30 +00:00
|
|
|
/**
|
2020-08-12 02:22:06 +00:00
|
|
|
* Start up the polyfills.
|
2020-05-12 22:24:41 +00:00
|
|
|
*
|
2019-10-20 19:14:02 +00:00
|
|
|
* Do not run polyfills for more than one Ruffle source at a time.
|
2020-12-03 18:09:07 +00:00
|
|
|
*
|
|
|
|
* @param isExt Whether or not Ruffle is running as a browser's extension.
|
2019-10-14 18:56:30 +00:00
|
|
|
*/
|
2020-12-03 18:09:07 +00:00
|
|
|
polyfill(isExt: boolean): void {
|
|
|
|
polyfill(isExt);
|
2022-06-03 18:50:51 +00:00
|
|
|
},
|
2020-11-14 21:20:42 +00:00
|
|
|
|
2020-08-12 02:22:06 +00:00
|
|
|
/**
|
|
|
|
* Polyfill the plugin detection.
|
|
|
|
*
|
|
|
|
* This needs to run before any plugin detection script does.
|
|
|
|
*/
|
2020-11-14 21:21:35 +00:00
|
|
|
pluginPolyfill(): void {
|
2020-11-17 21:53:04 +00:00
|
|
|
pluginPolyfill();
|
2022-06-03 18:50:51 +00:00
|
|
|
},
|
2020-05-12 22:24:41 +00:00
|
|
|
|
2019-10-20 19:14:02 +00:00
|
|
|
/**
|
|
|
|
* Create a Ruffle player element using this particular version of Ruffle.
|
2020-05-12 22:24:41 +00:00
|
|
|
*
|
2020-11-14 21:20:42 +00:00
|
|
|
* @returns The player element. This is a DOM element that may be inserted
|
|
|
|
* into the current page as you wish.
|
2019-10-20 19:14:02 +00:00
|
|
|
*/
|
2020-11-14 21:22:28 +00:00
|
|
|
createPlayer(): RufflePlayer {
|
2020-11-17 19:54:58 +00:00
|
|
|
const name = registerElement("ruffle-player", RufflePlayer);
|
2020-11-14 21:23:10 +00:00
|
|
|
return <RufflePlayer>document.createElement(name);
|
2022-06-03 18:50:51 +00:00
|
|
|
},
|
|
|
|
};
|