From d08334daafd1c69bc20cffe2ba3d3b84b13a8df9 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Sat, 1 Jun 2024 14:52:51 +0200 Subject: [PATCH] web: Rename Ruffle to RuffleHandle --- web/packages/core/src/load-ruffle.ts | 12 ++++++------ web/packages/core/src/ruffle-player.ts | 6 +++--- web/src/lib.rs | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/web/packages/core/src/load-ruffle.ts b/web/packages/core/src/load-ruffle.ts index 91ea449a3a095..375fbeb10b247 100644 --- a/web/packages/core/src/load-ruffle.ts +++ b/web/packages/core/src/load-ruffle.ts @@ -9,7 +9,7 @@ import { signExtensions, referenceTypes, } from "wasm-feature-detect"; -import type { Ruffle } from "../dist/ruffle_web"; +import type { RuffleHandle } from "../dist/ruffle_web"; import { setPolyfillsOnLoad } from "./js-polyfills"; import { publicPath } from "./public-path"; import { BaseLoadOptions } from "./load-options"; @@ -36,7 +36,7 @@ type ProgressCallback = (bytesLoaded: number, bytesTotal: number) => void; async function fetchRuffle( config: BaseLoadOptions, progressCallback?: ProgressCallback, -): Promise { +): Promise { // Apply some pure JavaScript polyfills to prevent conflicts with external // libraries, if needed. setPolyfillsOnLoad(); @@ -66,7 +66,7 @@ async function fetchRuffle( // Note: The argument passed to import() has to be a simple string literal, // otherwise some bundler will get confused and won't include the module? - const { default: init, Ruffle } = await (extensionsSupported + const { default: init, RuffleHandle } = await (extensionsSupported ? import("../dist/ruffle_web-wasm_extensions") : import("../dist/ruffle_web")); let response; @@ -114,10 +114,10 @@ async function fetchRuffle( await init(response); - return Ruffle; + return RuffleHandle; } -let nativeConstructor: Promise | null = null; +let nativeConstructor: Promise | null = null; /** * Obtain an instance of `Ruffle`. @@ -135,7 +135,7 @@ export async function loadRuffle( player: RufflePlayer, config: BaseLoadOptions, progressCallback?: ProgressCallback, -): Promise { +): Promise { if (nativeConstructor === null) { nativeConstructor = fetchRuffle(config, progressCallback); } diff --git a/web/packages/core/src/ruffle-player.ts b/web/packages/core/src/ruffle-player.ts index ab6474c3ac43e..cd55c00441852 100644 --- a/web/packages/core/src/ruffle-player.ts +++ b/web/packages/core/src/ruffle-player.ts @@ -1,4 +1,4 @@ -import type { Ruffle } from "../dist/ruffle_web"; +import type { RuffleHandle } from "../dist/ruffle_web"; import { loadRuffle } from "./load-ruffle"; import { applyStaticStyles, ruffleShadowTemplate } from "./shadow-template"; import { lookupElement } from "./register-element"; @@ -165,7 +165,7 @@ export class RufflePlayer extends HTMLElement { private loadedConfig?: URLLoadOptions | DataLoadOptions; private swfUrl?: URL; - private instance: Ruffle | null; + private instance: RuffleHandle | null; private lastActivePlayingState: boolean; private _metadata: MovieMetadata | null; @@ -767,7 +767,7 @@ export class RufflePlayer extends HTMLElement { } const actuallyUsedRendererName = this.instance!.renderer_name(); - const constructor = this.instance!.constructor; + const constructor = this.instance!.constructor; console.log( "%c" + diff --git a/web/src/lib.rs b/web/src/lib.rs index a35907c6150b4..7c51fc1161a22 100644 --- a/web/src/lib.rs +++ b/web/src/lib.rs @@ -341,10 +341,10 @@ struct MovieMetadata { /// This type is exported to JS, and is used to interact with the library. #[wasm_bindgen] #[derive(Clone, Copy)] -pub struct Ruffle(DefaultKey); +pub struct RuffleHandle(DefaultKey); #[wasm_bindgen] -impl Ruffle { +impl RuffleHandle { #[allow(clippy::new_ret_no_self)] #[wasm_bindgen(constructor)] pub fn new(parent: HtmlElement, js_player: JavascriptPlayer, config: JsValue) -> Promise { @@ -593,7 +593,7 @@ impl Ruffle { } } -impl Ruffle { +impl RuffleHandle { async fn new_internal( parent: HtmlElement, js_player: JavascriptPlayer,