Skip to content

Commit

Permalink
web: Split off installRuffle, PublicAPI and SourceAPI to Setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinnerbone committed Oct 6, 2024
1 parent 7db69a9 commit 1a83fa4
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 21 deletions.
3 changes: 1 addition & 2 deletions web/packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
* Types should only be exported here if they are intended to be part of that public API, not internal.
*/

export * from "./public-api";
export * as Setup from "./public/setup";
export * as Config from "./public/config";
export * from "./build-info";
export * from "./movie-metadata";
export * from "./install";
export * from "./public/flash";
export * from "./public/legacy";
export * from "./public/player";
2 changes: 1 addition & 1 deletion web/packages/core/src/internal/internal-source-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { pluginPolyfill, polyfill } from "../polyfills";
import { Player } from "../public/player";
import { registerElement } from "./register-element";
import { RufflePlayerElement } from "./player/ruffle-player-element";
import { InstallationOptions } from "../install";
import { InstallationOptions } from "../public/setup";

/**
* The actual source API that describes this installation.
Expand Down
3 changes: 3 additions & 0 deletions web/packages/core/src/public/setup/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./public-api";
export * from "./source-api";
export * from "./install";
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PublicAPI } from "./public-api";

import { internalSourceApi } from "./internal/internal-source-api";
import { internalSourceApi } from "../../internal/internal-source-api";

/**
* Options to use with this specific installation of Ruffle.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Version } from "./version";
import { VersionRange } from "./version-range";
import { Version } from "../../version";
import { VersionRange } from "../../version-range";
import { SourceAPI } from "./source-api";
import type { DataLoadOptions, URLLoadOptions } from "./public/config";
import type { DataLoadOptions, URLLoadOptions } from "../config";

declare global {
interface Window {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Player } from "./public/player";
import { Player } from "../player";

/**
* Represents this particular version of Ruffle.
Expand Down
4 changes: 2 additions & 2 deletions web/packages/demo/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import "./common.css";
import "./lato.css";
import "./index.css";
import { App } from "./App.tsx";
import { Config, installRuffle } from "ruffle-core";
import { Config, Setup } from "ruffle-core";

installRuffle("local");
Setup.installRuffle("local");

ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
Expand Down
4 changes: 2 additions & 2 deletions web/packages/demo/src/player.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { ReactNode, DragEvent } from "react";
import {
PublicAPI,
Setup,
Player as RufflePlayer,
MovieMetadata,
Config,
Expand Down Expand Up @@ -33,7 +33,7 @@ export class Player extends React.Component<PlayerAttributes> {
}

componentDidMount() {
this.player = (window.RufflePlayer as PublicAPI)
this.player = (window.RufflePlayer as Setup.PublicAPI)
.newest()!
.createPlayer()!;
this.player.id = "player";
Expand Down
6 changes: 3 additions & 3 deletions web/packages/extension/src/player.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as utils from "./utils";
import { installRuffle, PublicAPI } from "ruffle-core";
import { Setup } from "ruffle-core";

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

Expand All @@ -13,8 +13,8 @@ declare global {
}
}

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

const playerContainer = document.getElementById("player-container")!;
Expand Down
4 changes: 2 additions & 2 deletions web/packages/extension/src/ruffle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { installRuffle } from "ruffle-core";
import { Setup } from "ruffle-core";
import { Message } from "./messages";

function handleMessage(message: Message) {
Expand All @@ -15,7 +15,7 @@ function handleMessage(message: Message) {
...window.RufflePlayer.config,
openInNewTab,
};
installRuffle("extension");
Setup.installRuffle("extension");
return {};
}
case "ping":
Expand Down
4 changes: 2 additions & 2 deletions web/packages/selfhosted/js/ruffle.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// eslint-disable-next-line no-unused-vars
/* global __webpack_public_path__:writable */

import { installRuffle } from "ruffle-core";
import { Setup } from "ruffle-core";

let currentScriptURL = null;

Expand Down Expand Up @@ -46,7 +46,7 @@ function publicPath(config) {
return path;
}

installRuffle("local", {
Setup.installRuffle("local", {
onFirstLoad: () => {
__webpack_public_path__ = publicPath(window.RufflePlayer?.config);
},
Expand Down
4 changes: 2 additions & 2 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, PublicAPI } from "ruffle-core";
import { Player, Setup } from "ruffle-core";

declare global {
interface Window {
Expand Down Expand Up @@ -178,7 +178,7 @@ export function loadJsAPI(swf?: string) {
await injectRuffleAndWait(browser);

player = (await browser.execute(() => {
const ruffle = (window.RufflePlayer as PublicAPI).newest();
const ruffle = (window.RufflePlayer as Setup.PublicAPI).newest();
const player = ruffle!.createPlayer();
const container = document.getElementById("test-container");
container!.appendChild(player);
Expand Down

0 comments on commit 1a83fa4

Please sign in to comment.