web: core no longer uses webpack, but selfhosted still does

This commit is contained in:
Nathan Adams 2020-11-13 21:40:15 +01:00 committed by Mike Welsh
parent 7701ef9c26
commit 8abb8df299
9 changed files with 12 additions and 84 deletions

View File

@ -1 +0,0 @@
module.exports = require("./src");

View File

@ -4,9 +4,13 @@
"description": "Core bindings for Ruffle",
"license": "(MIT OR Apache-2.0)",
"private": true,
"main": "./pkg/index.js",
"types": "./pkg/index.d.ts",
"files": ["pkg/"],
"scripts": {
"build": "webpack",
"prepare": "webpack",
"build": "npm run build:wasm && npm run build:ts",
"build:ts": "tsc -d",
"build:wasm": "wasm-pack build ../../ --out-dir packages/core/pkg",
"test": "mocha -r esm -r ts-node/register test/**.ts"
},
"devDependencies": {
@ -20,9 +24,7 @@
"mocha": "^8.0.1",
"ts-node": "^9.0.0",
"typedoc": "^0.19.2",
"typescript": "^4.0.5",
"webpack": "^5.1.3",
"webpack-cli": "^4.0.0"
"typescript": "^4.0.5"
},
"dependencies": {
"@types/source-map": "^0.5.2"

View File

@ -1,62 +0,0 @@
import { FLASH_MIMETYPE } from "./ruffle-player.js";
/**
* Detect Flash using a handful of APIs.
*
* If you run this function after loading `plugin-polyfill`, you will only see
* the info we added to the current window, which is wrong. Alternatively, if
* you want to error-check your plugin falsification, use this function after
* installing the falsification.
*
* This detect is largely similar to the one used by `swfobject` but with
* certain browser detects removed.
*
* Returns if the browser has Flash and the version we detected.
*/
export default function detect_flash() {
let has_flash = false;
let version = [0, 0, 0];
if (
navigator &&
navigator.plugins &&
navigator.plugins["Shockwave Flash"] &&
navigator.plugins["Shockwave Flash"].description
) {
let description = navigator.plugins["Shockwave Flash"].description;
if (
navigator.mimeTypes &&
navigator.mimeTypes[FLASH_MIMETYPE] &&
navigator.mimeTypes[FLASH_MIMETYPE].enabledPlugin
) {
has_flash = true;
description = description.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
version[0] = parseInt(description.replace(/^(.*)\..*$/, "$1"));
version[1] = parseInt(description.replace(/^.*\.(.*)\s.*$/, "$1"));
version[2] = /[a-zA-Z]/.test(description)
? parseInt(description.replace(/^.*[a-zA-Z]+(.*)$/, "$1"))
: 0;
}
} else if (window && window.ActiveXObject) {
try {
let activex_flash = new window.ActiveXObject(
"ShockwaveFlash.ShockwaveFlash"
);
if (activex_flash) {
let player_version = activex_flash.GetVariable("$version");
if (player_version) {
version = player_version
.split(" ")[1]
.split(",")
.map(parseInt);
}
}
} catch (e) {
/* Ignore error on non-IE browsers */
}
}
return has_flash, version;
}

View File

@ -26,7 +26,7 @@ async function fetch_ruffle() {
//We currently assume that if we are not executing inside the extension,
//then we can use webpack to get Ruffle.
const ruffle_module = await import("../../../pkg/ruffle");
const ruffle_module = await import("../pkg/ruffle_web");
return ruffle_module.Ruffle;
}

View File

@ -1,4 +1,4 @@
import { Ruffle } from "../../../pkg/ruffle";
import { Ruffle } from "../pkg/ruffle_web";
import { load_ruffle } from "./load-ruffle";
import { ruffle_shadow_template } from "./shadow-template";

View File

@ -1 +0,0 @@
module.exports = require("ruffle-core");

View File

@ -21,6 +21,7 @@
"devDependencies": {
"webpack-cli": "^4.0.0",
"webpack-dev-server": "^3.11.0",
"@wdio/cli": "^6.1.12"
"@wdio/cli": "^6.1.12",
"webpack": "^5.1.3"
}
}

View File

@ -36,9 +36,6 @@ module.exports = (env, argv) => {
syncWebAssembly: true,
},
devtool: "source-map",
resolve: {
extensions: [".ts", ".tsx", ".js", ".wasm"],
},
plugins: [
new CleanWebpackPlugin(),
new webpack.DefinePlugin({
@ -50,13 +47,5 @@ module.exports = (env, argv) => {
patterns: [{ from: "LICENSE*" }, { from: "README.md" }],
}),
],
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
},
],
},
};
};

View File

@ -841,7 +841,7 @@ impl AudioBackend for WebAudioBackend {
}
}
#[wasm_bindgen(module = "/packages/core/src/ruffle-imports.ts")]
#[wasm_bindgen(raw_module = "./ruffle-imports.js")]
extern "C" {
/// Imported JS method to copy data into an `AudioBuffer`.
/// We'd prefer to use `AudioBuffer.copyToChannel`, but this isn't supported