Skip to content

Commit

Permalink
web: Rename Player to PlayerElement, matches all over *Elements
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinnerbone committed Oct 6, 2024
1 parent 1a83fa4 commit c50c0f9
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 28 deletions.
2 changes: 1 addition & 1 deletion web/packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export * from "./build-info";
export * from "./movie-metadata";
export * from "./public/flash";
export * from "./public/legacy";
export * from "./public/player";
export * from "./public/player-element";
4 changes: 2 additions & 2 deletions web/packages/core/src/internal/internal-source-api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { buildInfo } from "../build-info";
import { pluginPolyfill, polyfill } from "../polyfills";
import { Player } from "../public/player";
import { PlayerElement } from "../public/player-element";
import { registerElement } from "./register-element";
import { RufflePlayerElement } from "./player/ruffle-player-element";
import { InstallationOptions } from "../public/setup";
Expand Down Expand Up @@ -40,7 +40,7 @@ export const internalSourceApi = {
* @returns The player element. This is a DOM element that may be inserted
* into the current page as you wish.
*/
createPlayer(): Player {
createPlayer(): PlayerElement {
const name = registerElement("ruffle-player", RufflePlayerElement);
return document.createElement(name) as RufflePlayerElement;
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { DataLoadOptions, URLLoadOptions } from "../../public/config";
import type { MovieMetadata } from "../../movie-metadata";
import { InnerPlayer, ReadyState } from "./inner";
import { Player } from "../../public/player";
import { PlayerElement } from "../../public/player-element";

/**
* The ruffle player element that should be inserted onto the page.
*
* This element will represent the rendered and intractable flash movie.
*/
export class RufflePlayerElement extends HTMLElement implements Player {
export class RufflePlayerElement extends HTMLElement implements PlayerElement {
#inner: InnerPlayer;

get onFSCommand(): ((command: string, args: string) => boolean) | null {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ import { FlashAPI } from "./flash";
* In addition to usual HTML attributes, this player contains methods and properties that belong to both
* the **Flash JS API** and **legacy Ruffle API**s.
*/
export interface Player extends HTMLElement, LegacyRuffleAPI, FlashAPI {}
export interface PlayerElement extends HTMLElement, LegacyRuffleAPI, FlashAPI {}
4 changes: 2 additions & 2 deletions web/packages/core/src/public/setup/source-api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Player } from "../player";
import { PlayerElement } from "../player-element";

/**
* Represents this particular version of Ruffle.
Expand Down Expand Up @@ -34,5 +34,5 @@ export interface SourceAPI {
* @returns The player element. This is a DOM element that may be inserted
* into the current page as you wish.
*/
createPlayer(): Player;
createPlayer(): PlayerElement;
}
9 changes: 2 additions & 7 deletions web/packages/demo/src/player.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import React, { ReactNode, DragEvent } from "react";
import {
Setup,
Player as RufflePlayer,
MovieMetadata,
Config,
} from "ruffle-core";
import { Setup, PlayerElement, MovieMetadata, Config } from "ruffle-core";

export interface PlayerAttributes {
id?: string | undefined;
Expand All @@ -19,7 +14,7 @@ export interface PlayerAttributes {

export class Player extends React.Component<PlayerAttributes> {
private readonly container: React.RefObject<HTMLDivElement>;
private player: RufflePlayer | null = null;
private player: PlayerElement | null = null;

// [NA] Ruffle has a bug where if you load a swf whilst it's already loading another swf, it breaks
// Combine this with React testing everything by loading things twice to catch bugs - well, they caught the bug for sure.
Expand Down
4 changes: 2 additions & 2 deletions web/packages/extension/src/player.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as utils from "./utils";
import { Setup } from "ruffle-core";

import type { Config, Player } from "ruffle-core";
import type { Config, PlayerElement } from "ruffle-core";

declare global {
interface Navigator {
Expand All @@ -15,7 +15,7 @@ declare global {

Setup.installRuffle("local");
const ruffle = (window.RufflePlayer as Setup.PublicAPI).newest()!;
let player: Player;
let player: PlayerElement;

const playerContainer = document.getElementById("player-container")!;
const overlay = document.getElementById("overlay")!;
Expand Down
4 changes: 2 additions & 2 deletions web/packages/selfhosted/test/js_api/load.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { loadJsAPI, playAndMonitor } from "../utils.js";
import { use } from "chai";
import chaiHtml from "chai-html";
import { Player } from "ruffle-core";
import { PlayerElement } from "ruffle-core";

use(chaiHtml);

Expand All @@ -12,7 +12,7 @@ describe("RufflePlayer.load", () => {
const player = await browser.$("<ruffle-player>");
await browser.execute(async (playerElement) => {
// https://github.com/webdriverio/webdriverio/issues/6486
const player = playerElement as unknown as Player;
const player = playerElement as unknown as PlayerElement;
await player.load("/test_assets/example.swf");
}, player);
await playAndMonitor(browser, player);
Expand Down
4 changes: 2 additions & 2 deletions web/packages/selfhosted/test/js_api/metadata.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { loadJsAPI } from "../utils.js";
import { expect, use } from "chai";
import chaiHtml from "chai-html";
import { Player } from "ruffle-core";
import { PlayerElement } from "ruffle-core";

use(chaiHtml);

Expand All @@ -12,7 +12,7 @@ describe("RufflePlayer.metadata", () => {
const player = await browser.$("<ruffle-player>");
const metadata = await browser.execute(
// https://github.com/webdriverio/webdriverio/issues/6486
(player) => (player as unknown as Player).metadata,
(player) => (player as unknown as PlayerElement).metadata,
player,
);
// [NA] Work around a chrome 87 bug where it's (somehow) adding extra data to this object
Expand Down
14 changes: 7 additions & 7 deletions web/packages/selfhosted/test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import { Player, Setup } from "ruffle-core";
import { PlayerElement, Setup } from "ruffle-core";

declare global {
interface Window {
Expand All @@ -8,7 +8,7 @@ declare global {
}

declare module "ruffle-core" {
interface Player {
interface PlayerElement {
__ruffle_log__: string;
}
}
Expand All @@ -31,7 +31,7 @@ export async function isRufflePlayerLoaded(
(player) =>
// https://github.com/webdriverio/webdriverio/issues/6486
// TODO: How can we import ReadyState enum?
(player as unknown as Player).readyState,
(player as unknown as PlayerElement).readyState,
player,
)) === 2
);
Expand Down Expand Up @@ -103,7 +103,7 @@ export async function setupAndPlay(
) {
await browser.execute((playerElement) => {
// https://github.com/webdriverio/webdriverio/issues/6486
const player = playerElement as unknown as Player;
const player = playerElement as unknown as PlayerElement;
player.__ruffle_log__ = "";
player.traceObserver = (msg) => {
player.__ruffle_log__ += msg + "\n";
Expand All @@ -122,7 +122,7 @@ export async function getTraceOutput(
return (
(await browser.execute((player) => {
// https://github.com/webdriverio/webdriverio/issues/6486
return (player as unknown as Player).__ruffle_log__;
return (player as unknown as PlayerElement).__ruffle_log__;
}, player)) !== ""
);
},
Expand All @@ -134,7 +134,7 @@ export async function getTraceOutput(
// Get the output, and replace it with an empty string for any future test
return await browser.execute((playerElement) => {
// https://github.com/webdriverio/webdriverio/issues/6486
const player = playerElement as unknown as Player;
const player = playerElement as unknown as PlayerElement;
const log = player.__ruffle_log__;
player.__ruffle_log__ = "";
return log;
Expand Down Expand Up @@ -190,7 +190,7 @@ export function loadJsAPI(swf?: string) {
await browser.execute(
async (player, swf) => {
// https://github.com/webdriverio/webdriverio/issues/6486
await (player as unknown as Player).load(swf);
await (player as unknown as PlayerElement).load(swf);
},
player,
swf,
Expand Down

0 comments on commit c50c0f9

Please sign in to comment.