-
-
Notifications
You must be signed in to change notification settings - Fork 763
/
source-api.ts
49 lines (45 loc) · 1.46 KB
/
source-api.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { pluginPolyfill, polyfill } from "./polyfills";
import { registerElement } from "./register-element";
import { RufflePlayer } from "./ruffle-player";
import { buildInfo } from "./build-info";
/**
* Represents this particular version of Ruffle.
*
* Multiple APIs can be instantiated from different sources; e.g. an "extension"
* version, versus a "local" version. This expresses to the Public API
* negotiator (see [[PublicAPI]]) what this particular version of Ruffle is and
* how to control it.
*/
export const SourceAPI = {
/**
* The version of this particular API, as a string in a semver compatible format.
*/
version:
buildInfo.versionNumber + "+" + buildInfo.buildDate.substring(0, 10),
/**
* Start up the polyfills.
*
* Do not run polyfills for more than one Ruffle source at a time.
*/
polyfill(): void {
polyfill();
},
/**
* Polyfill the plugin detection.
*
* This needs to run before any plugin detection script does.
*/
pluginPolyfill(): void {
pluginPolyfill();
},
/**
* Create a Ruffle player element using this particular version of Ruffle.
*
* @returns The player element. This is a DOM element that may be inserted
* into the current page as you wish.
*/
createPlayer(): RufflePlayer {
const name = registerElement("ruffle-player", RufflePlayer);
return <RufflePlayer>document.createElement(name);
},
};