Skip to content

Commit 076a39f

Browse files
committed
web: Rename config.ts to default.ts, made config/index and export config as .Config
1 parent c15c273 commit 076a39f

19 files changed

+44
-61
lines changed

web/packages/core/src/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
*/
66

77
export * from "./public-api";
8-
export * from "./public/config/config";
9-
export * from "./public/config/load-options";
8+
export * as Config from "./public/config";
109
export * from "./build-info";
1110
export * from "./movie-metadata";
1211
export * from "./install";

web/packages/core/src/internal/builder.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import type { RuffleInstanceBuilder } from "../../dist/ruffle_web";
2-
import {
3-
BaseLoadOptions,
4-
Duration,
5-
SecsDuration,
6-
} from "../public/config/load-options";
2+
import { BaseLoadOptions, Duration, SecsDuration } from "../public/config";
73

84
/**
95
* Checks if the given value is explicitly `T` (not null, not undefined)

web/packages/core/src/internal/player/inner.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
UnmuteOverlay,
88
URLLoadOptions,
99
WindowMode,
10-
} from "../../public/config/load-options";
10+
DEFAULT_CONFIG,
11+
} from "../../public/config";
1112
import type { MovieMetadata } from "../../movie-metadata";
1213
import { ruffleShadowTemplate } from "../ui/shadow-template";
1314
import { text, textAsParagraphs } from "../i18n";
@@ -25,7 +26,6 @@ import { showPanicScreen } from "../ui/panic";
2526
import { createRuffleBuilder } from "../../load-ruffle";
2627
import { lookupElement } from "../register-element";
2728
import { configureBuilder } from "../builder";
28-
import { DEFAULT_CONFIG } from "../../public/config/config";
2929

3030
const DIMENSION_REGEX = /^\s*(\d+(\.\d+)?(%)?)/;
3131

web/packages/core/src/internal/player/ruffle-player-element.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import type {
2-
DataLoadOptions,
3-
URLLoadOptions,
4-
} from "../../public/config/load-options";
1+
import type { DataLoadOptions, URLLoadOptions } from "../../public/config";
52
import type { MovieMetadata } from "../../movie-metadata";
63
import { InnerPlayer, ReadyState } from "./inner";
74
import { Player } from "../../public/player";

web/packages/core/src/polyfills.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import { RuffleObjectElement } from "./internal/player/ruffle-object-element";
22
import { RuffleEmbedElement } from "./internal/player/ruffle-embed-element";
33
import { installPlugin, FLASH_PLUGIN } from "./plugin-polyfill";
44
import { publicPath } from "./public-path";
5-
import type {
6-
DataLoadOptions,
7-
URLLoadOptions,
8-
} from "./public/config/load-options";
5+
import type { DataLoadOptions, URLLoadOptions } from "./public/config";
96
import { isExtension } from "./current-script";
107

118
const globalConfig: DataLoadOptions | URLLoadOptions | object =

web/packages/core/src/public-api.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { Version } from "./version";
22
import { VersionRange } from "./version-range";
33
import { SourceAPI } from "./source-api";
4-
import type {
5-
DataLoadOptions,
6-
URLLoadOptions,
7-
} from "./public/config/load-options";
4+
import type { DataLoadOptions, URLLoadOptions } from "./public/config";
85

96
declare global {
107
interface Window {

web/packages/core/src/public-path.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseLoadOptions } from "./public/config/load-options";
1+
import { BaseLoadOptions } from "./public/config";
22
import { currentScriptURL, isExtension } from "./current-script";
33

44
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./default";
2+
export * from "./load-options";

web/packages/core/src/public/legacy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DataLoadOptions, URLLoadOptions } from "./config/load-options";
1+
import { DataLoadOptions, URLLoadOptions } from "./config";
22
import { MovieMetadata } from "../movie-metadata";
33
import { ReadyState } from "../internal/player/inner";
44

web/packages/demo/src/App.tsx

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Player } from "./player.tsx";
22
import { useRef, useState, DragEvent, useCallback } from "react";
3-
import { BaseLoadOptions, MovieMetadata } from "ruffle-core";
3+
import type { Config, MovieMetadata } from "ruffle-core";
44
import { Navbar } from "./navbar.tsx";
55
import { MetadataPanel } from "./metadata.tsx";
66

77
interface AppProperties {
8-
ruffleBaseConfig: BaseLoadOptions;
8+
ruffleBaseConfig: Config.BaseLoadOptions;
99
allowUrlLoading: boolean;
1010
allowSampleSwfs: boolean;
1111
}
@@ -33,9 +33,12 @@ export function App({
3333
};
3434

3535
// useCallback because this will be called from useEffect, we need this function to not change
36-
const onSelectUrl = useCallback((url: string, options: BaseLoadOptions) => {
37-
player.current?.loadUrl(url, options);
38-
}, []);
36+
const onSelectUrl = useCallback(
37+
(url: string, options: Config.BaseLoadOptions) => {
38+
player.current?.loadUrl(url, options);
39+
},
40+
[],
41+
);
3942

4043
const onSelectFile = (file: File) => {
4144
player.current?.loadFile(file);

web/packages/demo/src/main.tsx

+5-11
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,18 @@ import "./common.css";
44
import "./lato.css";
55
import "./index.css";
66
import { App } from "./App.tsx";
7-
import {
8-
AutoPlay,
9-
Letterbox,
10-
LogLevel,
11-
installRuffle,
12-
UnmuteOverlay,
13-
} from "ruffle-core";
7+
import { Config, installRuffle } from "ruffle-core";
148

159
installRuffle("local");
1610

1711
ReactDOM.createRoot(document.getElementById("root")!).render(
1812
<React.StrictMode>
1913
<App
2014
ruffleBaseConfig={{
21-
autoplay: AutoPlay.On,
22-
unmuteOverlay: UnmuteOverlay.Hidden,
23-
logLevel: LogLevel.Warn,
24-
letterbox: Letterbox.On,
15+
autoplay: Config.AutoPlay.On,
16+
unmuteOverlay: Config.UnmuteOverlay.Hidden,
17+
logLevel: Config.LogLevel.Warn,
18+
letterbox: Config.Letterbox.On,
2519
forceScale: true,
2620
forceAlign: true,
2721
}}

web/packages/demo/src/navbar.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
useState,
88
DragEvent,
99
} from "react";
10-
import { BaseLoadOptions } from "ruffle-core";
10+
import type { Config } from "ruffle-core";
1111
import { DemoSwf, SampleSelection } from "./navbar/samples.tsx";
1212

1313
declare global {
@@ -25,7 +25,7 @@ interface NavbarProps {
2525
allowSampleSwfs: boolean;
2626
onToggleMetadata: () => void;
2727
onReloadMovie: () => void;
28-
onSelectUrl: (url: string, options: BaseLoadOptions) => void;
28+
onSelectUrl: (url: string, options: Config.BaseLoadOptions) => void;
2929
onSelectFile: (file: File) => void;
3030
selectedFilename: string | null;
3131
setSelectedFilename: (value: string | null) => void;

web/packages/demo/src/navbar/samples.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
useEffect,
77
useState,
88
} from "react";
9-
import { BaseLoadOptions } from "ruffle-core";
9+
import type { Config } from "ruffle-core";
1010

1111
type SampleCategory = "Animation" | "Game";
1212

@@ -20,7 +20,7 @@ export interface DemoSwf {
2020
title?: string;
2121
author?: string;
2222
authorLink?: string;
23-
config?: BaseLoadOptions;
23+
config?: Config.BaseLoadOptions;
2424
type: SampleCategory | null;
2525
}
2626

@@ -29,7 +29,7 @@ interface SampleSelectionProperties {
2929
selectedSample: DemoSwf | null;
3030
setSelectedSample: (value: DemoSwf | null) => void;
3131
setSelectedFilename: (name: string | null) => void;
32-
onSelectUrl: (url: string, config: BaseLoadOptions) => void;
32+
onSelectUrl: (url: string, config: Config.BaseLoadOptions) => void;
3333
}
3434

3535
export function SampleSelection({

web/packages/demo/src/player.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import {
33
PublicAPI,
44
Player as RufflePlayer,
55
MovieMetadata,
6-
BaseLoadOptions,
6+
Config,
77
} from "ruffle-core";
88

99
export interface PlayerAttributes {
1010
id?: string | undefined;
1111
children?: ReactNode;
1212
onLoadedMetadata: (metadata: MovieMetadata) => void;
13-
baseConfig?: BaseLoadOptions;
13+
baseConfig?: Config.BaseLoadOptions;
1414
onDragEnter: (event: DragEvent<HTMLElement>) => void;
1515
onDragLeave: (event: DragEvent<HTMLElement>) => void;
1616
onDragOver: (event: DragEvent<HTMLElement>) => void;
@@ -78,7 +78,7 @@ export class Player extends React.Component<PlayerAttributes> {
7878
}
7979
}
8080

81-
loadUrl(url: string, options: BaseLoadOptions) {
81+
loadUrl(url: string, options: Config.BaseLoadOptions) {
8282
if (!this.isLoading) {
8383
this.isLoading = true;
8484
this.player

web/packages/extension/src/common.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as utils from "./utils";
2-
import type { BaseLoadOptions } from "ruffle-core";
2+
import type { Config } from "ruffle-core";
33

4-
export interface Options extends BaseLoadOptions {
4+
export interface Options extends Config.BaseLoadOptions {
55
ruffleEnable: boolean;
66
ignoreOptout: boolean;
77
autostart: boolean;

web/packages/extension/src/messages.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { BaseLoadOptions } from "ruffle-core";
1+
import type { Config } from "ruffle-core";
22

33
export interface LoadMessage {
44
type: "load";
5-
config: BaseLoadOptions;
5+
config: Config.BaseLoadOptions;
66
}
77

88
export interface PingMessage {

web/packages/extension/src/player.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import * as utils from "./utils";
22
import { installRuffle, PublicAPI } from "ruffle-core";
3-
import type {
4-
Letterbox,
5-
Player,
6-
DataLoadOptions,
7-
URLLoadOptions,
8-
} from "ruffle-core";
3+
4+
import type { Config, Player } from "ruffle-core";
95

106
declare global {
117
interface Navigator {
@@ -39,7 +35,7 @@ const grant = document.getElementById("grant")! as HTMLButtonElement;
3935
// This is the base config always used by the extension player.
4036
// It has the highest priority and its options cannot be overwritten.
4137
const baseExtensionConfig = {
42-
letterbox: "on" as Letterbox,
38+
letterbox: "on" as Config.Letterbox,
4339
forceScale: true,
4440
forceAlign: true,
4541
showSwfDownload: true,
@@ -102,7 +98,9 @@ function unload() {
10298
}
10399
}
104100

105-
async function load(options: string | DataLoadOptions | URLLoadOptions) {
101+
async function load(
102+
options: string | Config.DataLoadOptions | Config.URLLoadOptions,
103+
) {
106104
unload();
107105
player = ruffle.createPlayer();
108106
player.id = "player";

web/packages/extension/src/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { Options } from "./common";
2-
import { DEFAULT_CONFIG as CORE_DEFAULT_CONFIG } from "ruffle-core";
2+
import { Config } from "ruffle-core";
33

44
const DEFAULT_OPTIONS: Required<Options> = {
5-
...CORE_DEFAULT_CONFIG,
5+
...Config.DEFAULT_CONFIG,
66
ruffleEnable: true,
77
ignoreOptout: false,
88
autostart: false,

0 commit comments

Comments
 (0)