diff --git a/web/packages/core/src/index.ts b/web/packages/core/src/index.ts index d7bbda995d72..6549424782d8 100644 --- a/web/packages/core/src/index.ts +++ b/web/packages/core/src/index.ts @@ -5,8 +5,7 @@ */ export * from "./public-api"; -export * from "./public/config/config"; -export * from "./public/config/load-options"; +export * as Config from "./public/config"; export * from "./build-info"; export * from "./movie-metadata"; export * from "./install"; diff --git a/web/packages/core/src/internal/builder.ts b/web/packages/core/src/internal/builder.ts index d527bf47e51c..f60083800441 100644 --- a/web/packages/core/src/internal/builder.ts +++ b/web/packages/core/src/internal/builder.ts @@ -1,9 +1,5 @@ import type { RuffleInstanceBuilder } from "../../dist/ruffle_web"; -import { - BaseLoadOptions, - Duration, - SecsDuration, -} from "../public/config/load-options"; +import { BaseLoadOptions, Duration, SecsDuration } from "../public/config"; /** * Checks if the given value is explicitly `T` (not null, not undefined) diff --git a/web/packages/core/src/internal/player/inner.tsx b/web/packages/core/src/internal/player/inner.tsx index 5acb115a6582..3cb0231dba19 100644 --- a/web/packages/core/src/internal/player/inner.tsx +++ b/web/packages/core/src/internal/player/inner.tsx @@ -7,7 +7,8 @@ import { UnmuteOverlay, URLLoadOptions, WindowMode, -} from "../../public/config/load-options"; + DEFAULT_CONFIG, +} from "../../public/config"; import type { MovieMetadata } from "../../movie-metadata"; import { ruffleShadowTemplate } from "../ui/shadow-template"; import { text, textAsParagraphs } from "../i18n"; @@ -25,7 +26,6 @@ import { showPanicScreen } from "../ui/panic"; import { createRuffleBuilder } from "../../load-ruffle"; import { lookupElement } from "../register-element"; import { configureBuilder } from "../builder"; -import { DEFAULT_CONFIG } from "../../public/config/config"; const DIMENSION_REGEX = /^\s*(\d+(\.\d+)?(%)?)/; diff --git a/web/packages/core/src/internal/player/ruffle-player-element.tsx b/web/packages/core/src/internal/player/ruffle-player-element.tsx index af7ea3a59459..6b2e1ba5ca64 100644 --- a/web/packages/core/src/internal/player/ruffle-player-element.tsx +++ b/web/packages/core/src/internal/player/ruffle-player-element.tsx @@ -1,7 +1,4 @@ -import type { - DataLoadOptions, - URLLoadOptions, -} from "../../public/config/load-options"; +import type { DataLoadOptions, URLLoadOptions } from "../../public/config"; import type { MovieMetadata } from "../../movie-metadata"; import { InnerPlayer, ReadyState } from "./inner"; import { Player } from "../../public/player"; diff --git a/web/packages/core/src/polyfills.ts b/web/packages/core/src/polyfills.ts index 0b76614c9178..eb5b58c5e609 100644 --- a/web/packages/core/src/polyfills.ts +++ b/web/packages/core/src/polyfills.ts @@ -2,10 +2,7 @@ import { RuffleObjectElement } from "./internal/player/ruffle-object-element"; import { RuffleEmbedElement } from "./internal/player/ruffle-embed-element"; import { installPlugin, FLASH_PLUGIN } from "./plugin-polyfill"; import { publicPath } from "./public-path"; -import type { - DataLoadOptions, - URLLoadOptions, -} from "./public/config/load-options"; +import type { DataLoadOptions, URLLoadOptions } from "./public/config"; import { isExtension } from "./current-script"; const globalConfig: DataLoadOptions | URLLoadOptions | object = diff --git a/web/packages/core/src/public-api.ts b/web/packages/core/src/public-api.ts index 45aaf9850cee..87727063080b 100644 --- a/web/packages/core/src/public-api.ts +++ b/web/packages/core/src/public-api.ts @@ -1,10 +1,7 @@ import { Version } from "./version"; import { VersionRange } from "./version-range"; import { SourceAPI } from "./source-api"; -import type { - DataLoadOptions, - URLLoadOptions, -} from "./public/config/load-options"; +import type { DataLoadOptions, URLLoadOptions } from "./public/config"; declare global { interface Window { diff --git a/web/packages/core/src/public-path.ts b/web/packages/core/src/public-path.ts index ba4ab8cd4eba..fb6576a68806 100644 --- a/web/packages/core/src/public-path.ts +++ b/web/packages/core/src/public-path.ts @@ -1,4 +1,4 @@ -import { BaseLoadOptions } from "./public/config/load-options"; +import { BaseLoadOptions } from "./public/config"; import { currentScriptURL, isExtension } from "./current-script"; /** diff --git a/web/packages/core/src/public/config/config.ts b/web/packages/core/src/public/config/default.ts similarity index 100% rename from web/packages/core/src/public/config/config.ts rename to web/packages/core/src/public/config/default.ts diff --git a/web/packages/core/src/public/config/index.ts b/web/packages/core/src/public/config/index.ts new file mode 100644 index 000000000000..50157bea6391 --- /dev/null +++ b/web/packages/core/src/public/config/index.ts @@ -0,0 +1,2 @@ +export * from "./default"; +export * from "./load-options"; diff --git a/web/packages/core/src/public/legacy.ts b/web/packages/core/src/public/legacy.ts index 47e7a3cc65af..3ec704e14e95 100644 --- a/web/packages/core/src/public/legacy.ts +++ b/web/packages/core/src/public/legacy.ts @@ -1,4 +1,4 @@ -import { DataLoadOptions, URLLoadOptions } from "./config/load-options"; +import { DataLoadOptions, URLLoadOptions } from "./config"; import { MovieMetadata } from "../movie-metadata"; import { ReadyState } from "../internal/player/inner"; diff --git a/web/packages/demo/src/App.tsx b/web/packages/demo/src/App.tsx index fec9df73b026..0c6cc9d4e789 100644 --- a/web/packages/demo/src/App.tsx +++ b/web/packages/demo/src/App.tsx @@ -1,11 +1,11 @@ import { Player } from "./player.tsx"; import { useRef, useState, DragEvent, useCallback } from "react"; -import { BaseLoadOptions, MovieMetadata } from "ruffle-core"; +import type { Config, MovieMetadata } from "ruffle-core"; import { Navbar } from "./navbar.tsx"; import { MetadataPanel } from "./metadata.tsx"; interface AppProperties { - ruffleBaseConfig: BaseLoadOptions; + ruffleBaseConfig: Config.BaseLoadOptions; allowUrlLoading: boolean; allowSampleSwfs: boolean; } @@ -33,9 +33,12 @@ export function App({ }; // useCallback because this will be called from useEffect, we need this function to not change - const onSelectUrl = useCallback((url: string, options: BaseLoadOptions) => { - player.current?.loadUrl(url, options); - }, []); + const onSelectUrl = useCallback( + (url: string, options: Config.BaseLoadOptions) => { + player.current?.loadUrl(url, options); + }, + [], + ); const onSelectFile = (file: File) => { player.current?.loadFile(file); diff --git a/web/packages/demo/src/main.tsx b/web/packages/demo/src/main.tsx index 846c45ad35ba..6913e454c195 100644 --- a/web/packages/demo/src/main.tsx +++ b/web/packages/demo/src/main.tsx @@ -4,13 +4,7 @@ import "./common.css"; import "./lato.css"; import "./index.css"; import { App } from "./App.tsx"; -import { - AutoPlay, - Letterbox, - LogLevel, - installRuffle, - UnmuteOverlay, -} from "ruffle-core"; +import { Config, installRuffle } from "ruffle-core"; installRuffle("local"); @@ -18,10 +12,10 @@ ReactDOM.createRoot(document.getElementById("root")!).render( void; onReloadMovie: () => void; - onSelectUrl: (url: string, options: BaseLoadOptions) => void; + onSelectUrl: (url: string, options: Config.BaseLoadOptions) => void; onSelectFile: (file: File) => void; selectedFilename: string | null; setSelectedFilename: (value: string | null) => void; diff --git a/web/packages/demo/src/navbar/samples.tsx b/web/packages/demo/src/navbar/samples.tsx index f2fb15be988f..5ecd4f98a9f4 100644 --- a/web/packages/demo/src/navbar/samples.tsx +++ b/web/packages/demo/src/navbar/samples.tsx @@ -6,7 +6,7 @@ import { useEffect, useState, } from "react"; -import { BaseLoadOptions } from "ruffle-core"; +import type { Config } from "ruffle-core"; type SampleCategory = "Animation" | "Game"; @@ -20,7 +20,7 @@ export interface DemoSwf { title?: string; author?: string; authorLink?: string; - config?: BaseLoadOptions; + config?: Config.BaseLoadOptions; type: SampleCategory | null; } @@ -29,7 +29,7 @@ interface SampleSelectionProperties { selectedSample: DemoSwf | null; setSelectedSample: (value: DemoSwf | null) => void; setSelectedFilename: (name: string | null) => void; - onSelectUrl: (url: string, config: BaseLoadOptions) => void; + onSelectUrl: (url: string, config: Config.BaseLoadOptions) => void; } export function SampleSelection({ diff --git a/web/packages/demo/src/player.tsx b/web/packages/demo/src/player.tsx index eb1f2cdfdd51..55bdb271dbeb 100644 --- a/web/packages/demo/src/player.tsx +++ b/web/packages/demo/src/player.tsx @@ -3,14 +3,14 @@ import { PublicAPI, Player as RufflePlayer, MovieMetadata, - BaseLoadOptions, + Config, } from "ruffle-core"; export interface PlayerAttributes { id?: string | undefined; children?: ReactNode; onLoadedMetadata: (metadata: MovieMetadata) => void; - baseConfig?: BaseLoadOptions; + baseConfig?: Config.BaseLoadOptions; onDragEnter: (event: DragEvent) => void; onDragLeave: (event: DragEvent) => void; onDragOver: (event: DragEvent) => void; @@ -78,7 +78,7 @@ export class Player extends React.Component { } } - loadUrl(url: string, options: BaseLoadOptions) { + loadUrl(url: string, options: Config.BaseLoadOptions) { if (!this.isLoading) { this.isLoading = true; this.player diff --git a/web/packages/extension/src/common.ts b/web/packages/extension/src/common.ts index 19293db4804f..4dec1094742b 100644 --- a/web/packages/extension/src/common.ts +++ b/web/packages/extension/src/common.ts @@ -1,7 +1,7 @@ import * as utils from "./utils"; -import type { BaseLoadOptions } from "ruffle-core"; +import type { Config } from "ruffle-core"; -export interface Options extends BaseLoadOptions { +export interface Options extends Config.BaseLoadOptions { ruffleEnable: boolean; ignoreOptout: boolean; autostart: boolean; diff --git a/web/packages/extension/src/messages.ts b/web/packages/extension/src/messages.ts index 3d1d3b477948..9eda0b2caae9 100644 --- a/web/packages/extension/src/messages.ts +++ b/web/packages/extension/src/messages.ts @@ -1,8 +1,8 @@ -import { BaseLoadOptions } from "ruffle-core"; +import type { Config } from "ruffle-core"; export interface LoadMessage { type: "load"; - config: BaseLoadOptions; + config: Config.BaseLoadOptions; } export interface PingMessage { diff --git a/web/packages/extension/src/player.ts b/web/packages/extension/src/player.ts index 7daeb91837d3..e0ed228274b2 100644 --- a/web/packages/extension/src/player.ts +++ b/web/packages/extension/src/player.ts @@ -1,11 +1,7 @@ import * as utils from "./utils"; import { installRuffle, PublicAPI } from "ruffle-core"; -import type { - Letterbox, - Player, - DataLoadOptions, - URLLoadOptions, -} from "ruffle-core"; + +import type { Config, Player } from "ruffle-core"; declare global { interface Navigator { @@ -39,7 +35,7 @@ const grant = document.getElementById("grant")! as HTMLButtonElement; // This is the base config always used by the extension player. // It has the highest priority and its options cannot be overwritten. const baseExtensionConfig = { - letterbox: "on" as Letterbox, + letterbox: "on" as Config.Letterbox, forceScale: true, forceAlign: true, showSwfDownload: true, @@ -102,7 +98,9 @@ function unload() { } } -async function load(options: string | DataLoadOptions | URLLoadOptions) { +async function load( + options: string | Config.DataLoadOptions | Config.URLLoadOptions, +) { unload(); player = ruffle.createPlayer(); player.id = "player"; diff --git a/web/packages/extension/src/utils.ts b/web/packages/extension/src/utils.ts index c2d3e1a25bbd..35815cf2ff55 100644 --- a/web/packages/extension/src/utils.ts +++ b/web/packages/extension/src/utils.ts @@ -1,8 +1,8 @@ import type { Options } from "./common"; -import { DEFAULT_CONFIG as CORE_DEFAULT_CONFIG } from "ruffle-core"; +import { Config } from "ruffle-core"; const DEFAULT_OPTIONS: Required = { - ...CORE_DEFAULT_CONFIG, + ...Config.DEFAULT_CONFIG, ruffleEnable: true, ignoreOptout: false, autostart: false,