web: Reformatted all javascript with prettier
This commit is contained in:
parent
56e467b557
commit
a4b705c731
|
@ -11,6 +11,6 @@
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-console": "off",
|
"no-console": "off",
|
||||||
"no-constant-condition": ["error", {"checkLoops": false}]
|
"no-constant-condition": ["error", { "checkLoops": false }]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
{
|
{
|
||||||
"tabWidth": 4
|
"tabWidth": 4
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
{
|
{
|
||||||
"name": "ruffle-demo",
|
"name": "ruffle-demo",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"description": "Demo of Ruffle Flash emulator",
|
"description": "Demo of Ruffle Flash emulator",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack",
|
"build": "webpack",
|
||||||
"serve": "webpack-dev-server"
|
"serve": "webpack-dev-server"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@wasm-tool/wasm-pack-plugin": "^1.2.0",
|
"@wasm-tool/wasm-pack-plugin": "^1.2.0",
|
||||||
"clean-webpack-plugin": "^3.0.0",
|
"clean-webpack-plugin": "^3.0.0",
|
||||||
"copy-webpack-plugin": "^5.1.1",
|
"copy-webpack-plugin": "^5.1.1",
|
||||||
"html-webpack-plugin": "^3.2.0",
|
"html-webpack-plugin": "^3.2.0",
|
||||||
"webpack": "^4.42.0",
|
"webpack": "^4.42.0",
|
||||||
"webpack-cli": "^3.3.11",
|
"webpack-cli": "^3.3.11",
|
||||||
"webpack-dev-server": "^3.10.3"
|
"webpack-dev-server": "^3.10.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,38 @@
|
||||||
/* eslint-env node */
|
/* eslint-env node */
|
||||||
|
|
||||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
||||||
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
||||||
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
|
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
|
||||||
const path = require('path');
|
const path = require("path");
|
||||||
|
|
||||||
module.exports = (env, argv) => {
|
module.exports = (env, argv) => {
|
||||||
let mode = "production";
|
let mode = "production";
|
||||||
if (argv && argv.mode) {
|
if (argv && argv.mode) {
|
||||||
mode = argv.mode;
|
mode = argv.mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Building ${mode}...`);
|
console.log(`Building ${mode}...`);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
entry: path.resolve(__dirname, "www/index.js"),
|
entry: path.resolve(__dirname, "www/index.js"),
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, "dist"),
|
path: path.resolve(__dirname, "dist"),
|
||||||
filename: "index.js",
|
filename: "index.js",
|
||||||
},
|
},
|
||||||
mode: mode,
|
mode: mode,
|
||||||
plugins: [
|
plugins: [
|
||||||
new CleanWebpackPlugin(),
|
new CleanWebpackPlugin(),
|
||||||
new CopyWebpackPlugin([{
|
new CopyWebpackPlugin([
|
||||||
from: path.resolve(__dirname, "www/index.html"),
|
{
|
||||||
to: "index.html"
|
from: path.resolve(__dirname, "www/index.html"),
|
||||||
}]),
|
to: "index.html",
|
||||||
new WasmPackPlugin({
|
},
|
||||||
crateDirectory: path.resolve(__dirname, ".."),
|
]),
|
||||||
outName: "ruffle",
|
new WasmPackPlugin({
|
||||||
forceMode: mode,
|
crateDirectory: path.resolve(__dirname, ".."),
|
||||||
})
|
outName: "ruffle",
|
||||||
]
|
forceMode: mode,
|
||||||
}
|
}),
|
||||||
|
],
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,52 +1,59 @@
|
||||||
import { PublicAPI } from "../../js-src/public-api";
|
import { PublicAPI } from "../../js-src/public-api";
|
||||||
import { SourceAPI } from "../../js-src/source-api";
|
import { SourceAPI } from "../../js-src/source-api";
|
||||||
|
|
||||||
window.RufflePlayer = PublicAPI.negotiate(window.RufflePlayer, "local", new SourceAPI("local"));
|
window.RufflePlayer = PublicAPI.negotiate(
|
||||||
|
window.RufflePlayer,
|
||||||
|
"local",
|
||||||
|
new SourceAPI("local")
|
||||||
|
);
|
||||||
|
|
||||||
let ruffle;
|
let ruffle;
|
||||||
let player;
|
let player;
|
||||||
let jsonData;
|
let jsonData;
|
||||||
|
|
||||||
let container = document.getElementById('main');
|
let container = document.getElementById("main");
|
||||||
let author_container = document.getElementById("author-container");
|
let author_container = document.getElementById("author-container");
|
||||||
let author = document.getElementById("author");
|
let author = document.getElementById("author");
|
||||||
let sampleFileInputContainer = document.getElementById("sample-swfs-container");
|
let sampleFileInputContainer = document.getElementById("sample-swfs-container");
|
||||||
let sampleFileInput = document.getElementById("sample-swfs");
|
let sampleFileInput = document.getElementById("sample-swfs");
|
||||||
let localFileInput = document.getElementById("local-file");
|
let localFileInput = document.getElementById("local-file");
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', () => {
|
window.addEventListener("DOMContentLoaded", () => {
|
||||||
ruffle = window.RufflePlayer.newest();
|
ruffle = window.RufflePlayer.newest();
|
||||||
player = ruffle.create_player();
|
player = ruffle.create_player();
|
||||||
player.id = "player";
|
player.id = "player";
|
||||||
container.appendChild(player);
|
container.appendChild(player);
|
||||||
fetch("swfs.json").then(response => {
|
fetch("swfs.json").then((response) => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
response.json().then( data => {
|
response.json().then((data) => {
|
||||||
const list = document.getElementById("sample-swfs");
|
const list = document.getElementById("sample-swfs");
|
||||||
jsonData = data;
|
jsonData = data;
|
||||||
jsonData.swfs.forEach(item => {
|
jsonData.swfs.forEach((item) => {
|
||||||
let temp = document.createElement("option");
|
let temp = document.createElement("option");
|
||||||
temp.innerHTML = item.title;
|
temp.innerHTML = item.title;
|
||||||
temp.setAttribute("value",item.location);
|
temp.setAttribute("value", item.location);
|
||||||
list.appendChild(temp);
|
list.appendChild(temp);
|
||||||
});
|
});
|
||||||
document.getElementById("sample-swfs-container").style.display = "inline-block";
|
document.getElementById("sample-swfs-container").style.display =
|
||||||
let rn = Math.floor(Math.random() * Math.floor(sampleFileInput.children.length - 1));
|
"inline-block";
|
||||||
|
let rn = Math.floor(
|
||||||
|
Math.random() *
|
||||||
|
Math.floor(sampleFileInput.children.length - 1)
|
||||||
|
);
|
||||||
sampleFileInput.selectedIndex = rn + 1;
|
sampleFileInput.selectedIndex = rn + 1;
|
||||||
loadRemoteFile(jsonData.swfs[rn].location);
|
loadRemoteFile(jsonData.swfs[rn].location);
|
||||||
author_container.style.display = "block";
|
author_container.style.display = "block";
|
||||||
author.innerHTML = jsonData.swfs[rn].author;
|
author.innerHTML = jsonData.swfs[rn].author;
|
||||||
author.href = jsonData.swfs[rn].authorLink;
|
author.href = jsonData.swfs[rn].authorLink;
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
sampleFileInputContainer.style.display = "none";
|
||||||
sampleFileInputContainer.style.display = "none";
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if(sampleFileInput) {
|
if (sampleFileInput) {
|
||||||
sampleFileInput.addEventListener("change",sampleFileSelected,false);
|
sampleFileInput.addEventListener("change", sampleFileSelected, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (localFileInput) {
|
if (localFileInput) {
|
||||||
|
@ -63,18 +70,18 @@ if (window.location.search && window.location.search != "") {
|
||||||
}
|
}
|
||||||
|
|
||||||
function sampleFileSelected() {
|
function sampleFileSelected() {
|
||||||
let selected_value = sampleFileInput.children[sampleFileInput.selectedIndex].value;
|
let selected_value =
|
||||||
|
sampleFileInput.children[sampleFileInput.selectedIndex].value;
|
||||||
let selected_index = sampleFileInput.selectedIndex - 1; //We subtract 1 here because the dropdown menu inlcudes a "None" option.
|
let selected_index = sampleFileInput.selectedIndex - 1; //We subtract 1 here because the dropdown menu inlcudes a "None" option.
|
||||||
if (selected_value != "none") {
|
if (selected_value != "none") {
|
||||||
author_container.style.display = "block";
|
author_container.style.display = "block";
|
||||||
author.innerHTML = jsonData.swfs[selected_index].author;
|
author.innerHTML = jsonData.swfs[selected_index].author;
|
||||||
author.href = jsonData.swfs[selected_index].authorLink;
|
author.href = jsonData.swfs[selected_index].authorLink;
|
||||||
|
|
||||||
localFileInput.value = null;
|
localFileInput.value = null;
|
||||||
loadRemoteFile(selected_value);
|
loadRemoteFile(selected_value);
|
||||||
}
|
} else {
|
||||||
else {
|
replacePlayer();
|
||||||
replacePlayer()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,22 +90,21 @@ function localFileSelected() {
|
||||||
author_container.style.display = "none";
|
author_container.style.display = "none";
|
||||||
author.innerHTML = "";
|
author.innerHTML = "";
|
||||||
author.href = "";
|
author.href = "";
|
||||||
|
|
||||||
let file = localFileInput.files[0];
|
let file = localFileInput.files[0];
|
||||||
if (file) {
|
if (file) {
|
||||||
let fileReader = new FileReader();
|
let fileReader = new FileReader();
|
||||||
fileReader.onload = () => {
|
fileReader.onload = () => {
|
||||||
player.play_swf_data(fileReader.result);
|
player.play_swf_data(fileReader.result);
|
||||||
}
|
};
|
||||||
fileReader.readAsArrayBuffer(file);
|
fileReader.readAsArrayBuffer(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadRemoteFile(url) {
|
function loadRemoteFile(url) {
|
||||||
fetch(url)
|
fetch(url).then((response) => {
|
||||||
.then(response => {
|
response.arrayBuffer().then((data) => player.play_swf_data(data));
|
||||||
response.arrayBuffer().then(data => player.play_swf_data(data))
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function replacePlayer() {
|
function replacePlayer() {
|
||||||
|
@ -109,4 +115,4 @@ function replacePlayer() {
|
||||||
author_container.style.display = "none";
|
author_container.style.display = "none";
|
||||||
author.innerHTML = "";
|
author.innerHTML = "";
|
||||||
author.href = "";
|
author.href = "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,41 +1,55 @@
|
||||||
/**
|
/**
|
||||||
* Pierce the extension sandbox by copying our code into window space.
|
* Pierce the extension sandbox by copying our code into window space.
|
||||||
*
|
*
|
||||||
* The isolation extension content scripts get is neat, but it causes problems
|
* The isolation extension content scripts get is neat, but it causes problems
|
||||||
* based on what browser you use:
|
* based on what browser you use:
|
||||||
*
|
*
|
||||||
* 1. On Chrome, you are explicitly banned from registering custom elements
|
* 1. On Chrome, you are explicitly banned from registering custom elements
|
||||||
* 2. On Firefox, you can register custom elements but they can't expose any
|
* 2. On Firefox, you can register custom elements but they can't expose any
|
||||||
* useful API surface, and can't even see their own methods.
|
* useful API surface, and can't even see their own methods.
|
||||||
*
|
*
|
||||||
* This code exists to pierce the extension sandbox, while maintaining:
|
* This code exists to pierce the extension sandbox, while maintaining:
|
||||||
*
|
*
|
||||||
* 1. The isolation of not interfering with the page's execution environment
|
* 1. The isolation of not interfering with the page's execution environment
|
||||||
* unintentionally.
|
* unintentionally.
|
||||||
* 2. The ability to load extension resources such as .wasm files
|
* 2. The ability to load extension resources such as .wasm files
|
||||||
*/
|
*/
|
||||||
let page_optout = document.documentElement.hasAttribute("data-ruffle-optout");
|
let page_optout = document.documentElement.hasAttribute("data-ruffle-optout");
|
||||||
try {
|
try {
|
||||||
if ((!page_optout) && window.top && window.top.document && window.top.document.documentElement) {
|
if (
|
||||||
|
!page_optout &&
|
||||||
|
window.top &&
|
||||||
|
window.top.document &&
|
||||||
|
window.top.document.documentElement
|
||||||
|
) {
|
||||||
/* In case the opting out page uses iframes */
|
/* In case the opting out page uses iframes */
|
||||||
page_optout = window.top.document.documentElement.hasAttribute("data-ruffle-optout");
|
page_optout = window.top.document.documentElement.hasAttribute(
|
||||||
|
"data-ruffle-optout"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
} catch (e) {
|
||||||
catch (e) {
|
|
||||||
console.log("Unable to check top-level optout: " + e.message);
|
console.log("Unable to check top-level optout: " + e.message);
|
||||||
}
|
}
|
||||||
let obfuscated_event_prefix = "rufEvent" + Math.floor(Math.random() * 100000000000);
|
let obfuscated_event_prefix =
|
||||||
|
"rufEvent" + Math.floor(Math.random() * 100000000000);
|
||||||
let ext_path = "";
|
let ext_path = "";
|
||||||
if (chrome && chrome.extension && chrome.extension.getURL) {
|
if (chrome && chrome.extension && chrome.extension.getURL) {
|
||||||
ext_path = chrome.extension.getURL("dist/ruffle.js").replace("dist/ruffle.js", "");
|
ext_path = chrome.extension
|
||||||
|
.getURL("dist/ruffle.js")
|
||||||
|
.replace("dist/ruffle.js", "");
|
||||||
} else if (browser && browser.runtime && browser.runtime.getURL) {
|
} else if (browser && browser.runtime && browser.runtime.getURL) {
|
||||||
ext_path = browser.runtime.getURL("dist/ruffle.js").replace("dist/ruffle.js", "");
|
ext_path = browser.runtime
|
||||||
|
.getURL("dist/ruffle.js")
|
||||||
|
.replace("dist/ruffle.js", "");
|
||||||
}
|
}
|
||||||
if (!(page_optout || window.RufflePlayer)) {
|
if (!(page_optout || window.RufflePlayer)) {
|
||||||
let setup_scriptelem = document.createElement("script");
|
let setup_scriptelem = document.createElement("script");
|
||||||
let setup_src = "var runtime_path = \"" +
|
let setup_src =
|
||||||
ext_path + "\";\nvar obfuscated_event_prefix = \"" +
|
'var runtime_path = "' +
|
||||||
obfuscated_event_prefix + "\";" +
|
ext_path +
|
||||||
|
'";\nvar obfuscated_event_prefix = "' +
|
||||||
|
obfuscated_event_prefix +
|
||||||
|
'";' +
|
||||||
'(function(){class RuffleMimeType{constructor(a,b,c){this.type=a,this.description=b,this.suffixes=c}}class RuffleMimeTypeArray{constructor(a){this.__mimetypes=[],this.__named_mimetypes={};for(let b of a)this.install(b)}install(a){let b=this.__mimetypes.length;this.__mimetypes.push(a),this.__named_mimetypes[a.type]=a,this[a.type]=a,this[b]=a}item(a){return this.__mimetypes[a]}namedItem(a){return this.__named_mimetypes[a]}get length(){return this.__mimetypes.length}}class RufflePlugin extends RuffleMimeTypeArray{constructor(a,b,c,d){super(d),this.name=a,this.description=b,this.filename=c}install(a){a.enabledPlugin||(a.enabledPlugin=this),super.install(a)}}class RufflePluginArray{constructor(a){this.__plugins=[],this.__named_plugins={};for(let b of a)this.install(b)}install(a){let b=this.__plugins.length;this.__plugins.push(a),this.__named_plugins[a.name]=a,this[a.name]=a,this[b]=a}item(a){return this.__plugins[a]}namedItem(a){return this.__named_plugins[a]}get length(){return this.__plugins.length}}const FLASH_PLUGIN=new RufflePlugin("Shockwave Flash","Shockwave Flash 32.0 r0","ruffle.js",[new RuffleMimeType("application/futuresplash","Shockwave Flash","spl"),new RuffleMimeType("application/x-shockwave-flash","Shockwave Flash","swf"),new RuffleMimeType("application/x-shockwave-flash2-preview","Shockwave Flash","swf"),new RuffleMimeType("application/vnd.adobe.flash-movie","Shockwave Flash","swf")]);function install_plugin(a){navigator.plugins.install||Object.defineProperty(navigator,"plugins",{value:new RufflePluginArray(navigator.plugins),writable:!1}),navigator.plugins.install(a),0<a.length&&!navigator.mimeTypes.install&&Object.defineProperty(navigator,"mimeTypes",{value:new RuffleMimeTypeArray(navigator.mimeTypes),writable:!1});for(var b=0;b<a.length;b+=1)navigator.mimeTypes.install(a[b])}install_plugin(FLASH_PLUGIN);})();';
|
'(function(){class RuffleMimeType{constructor(a,b,c){this.type=a,this.description=b,this.suffixes=c}}class RuffleMimeTypeArray{constructor(a){this.__mimetypes=[],this.__named_mimetypes={};for(let b of a)this.install(b)}install(a){let b=this.__mimetypes.length;this.__mimetypes.push(a),this.__named_mimetypes[a.type]=a,this[a.type]=a,this[b]=a}item(a){return this.__mimetypes[a]}namedItem(a){return this.__named_mimetypes[a]}get length(){return this.__mimetypes.length}}class RufflePlugin extends RuffleMimeTypeArray{constructor(a,b,c,d){super(d),this.name=a,this.description=b,this.filename=c}install(a){a.enabledPlugin||(a.enabledPlugin=this),super.install(a)}}class RufflePluginArray{constructor(a){this.__plugins=[],this.__named_plugins={};for(let b of a)this.install(b)}install(a){let b=this.__plugins.length;this.__plugins.push(a),this.__named_plugins[a.name]=a,this[a.name]=a,this[b]=a}item(a){return this.__plugins[a]}namedItem(a){return this.__named_plugins[a]}get length(){return this.__plugins.length}}const FLASH_PLUGIN=new RufflePlugin("Shockwave Flash","Shockwave Flash 32.0 r0","ruffle.js",[new RuffleMimeType("application/futuresplash","Shockwave Flash","spl"),new RuffleMimeType("application/x-shockwave-flash","Shockwave Flash","swf"),new RuffleMimeType("application/x-shockwave-flash2-preview","Shockwave Flash","swf"),new RuffleMimeType("application/vnd.adobe.flash-movie","Shockwave Flash","swf")]);function install_plugin(a){navigator.plugins.install||Object.defineProperty(navigator,"plugins",{value:new RufflePluginArray(navigator.plugins),writable:!1}),navigator.plugins.install(a),0<a.length&&!navigator.mimeTypes.install&&Object.defineProperty(navigator,"mimeTypes",{value:new RuffleMimeTypeArray(navigator.mimeTypes),writable:!1});for(var b=0;b<a.length;b+=1)navigator.mimeTypes.install(a[b])}install_plugin(FLASH_PLUGIN);})();';
|
||||||
let scriptelem = document.createElement("script");
|
let scriptelem = document.createElement("script");
|
||||||
setup_scriptelem.innerHTML = setup_src;
|
setup_scriptelem.innerHTML = setup_src;
|
||||||
|
@ -45,8 +59,8 @@ if (!(page_optout || window.RufflePlayer)) {
|
||||||
(document.head || document.documentElement).appendChild(setup_scriptelem);
|
(document.head || document.documentElement).appendChild(setup_scriptelem);
|
||||||
window.RufflePlayer = {};
|
window.RufflePlayer = {};
|
||||||
window.RufflePlayer.config = {
|
window.RufflePlayer.config = {
|
||||||
"public_path": ext_path + "dist/",
|
public_path: ext_path + "dist/",
|
||||||
"polyfills": ["static-content", "dynamic-content"]
|
polyfills: ["static-content", "dynamic-content"],
|
||||||
/* We only want "static-content" & "dynamic-content" because we *
|
/* We only want "static-content" & "dynamic-content" because we *
|
||||||
* inject the plugin polyfill above & use all_frames in *
|
* inject the plugin polyfill above & use all_frames in *
|
||||||
* manifest.json for (i)frames. */
|
* manifest.json for (i)frames. */
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
import { PublicAPI } from "../../js-src/public-api";
|
import { PublicAPI } from "../../js-src/public-api";
|
||||||
import { SourceAPI } from "../../js-src/source-api";
|
import { SourceAPI } from "../../js-src/source-api";
|
||||||
|
|
||||||
window.RufflePlayer = PublicAPI.negotiate(window.RufflePlayer, "extension", new SourceAPI());
|
window.RufflePlayer = PublicAPI.negotiate(
|
||||||
|
window.RufflePlayer,
|
||||||
|
"extension",
|
||||||
|
new SourceAPI()
|
||||||
|
);
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
{
|
{
|
||||||
"name": "ruffle-extension",
|
"name": "ruffle-extension",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"description": "Extension packaging for Ruffle Flash Emulator",
|
"description": "Extension packaging for Ruffle Flash Emulator",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack",
|
"build": "webpack",
|
||||||
"serve": "webpack-dev-server"
|
"serve": "webpack-dev-server"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@wasm-tool/wasm-pack-plugin": "^1.2.0",
|
"@wasm-tool/wasm-pack-plugin": "^1.2.0",
|
||||||
"clean-webpack-plugin": "^3.0.0",
|
"clean-webpack-plugin": "^3.0.0",
|
||||||
"copy-webpack-plugin": "^5.1.0",
|
"copy-webpack-plugin": "^5.1.0",
|
||||||
"webpack": "^4.41.2",
|
"webpack": "^4.41.2",
|
||||||
"webpack-cli": "^3.3.10",
|
"webpack-cli": "^3.3.10",
|
||||||
"webpack-dev-server": "^3.9.0"
|
"webpack-dev-server": "^3.9.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
/* eslint-env node */
|
/* eslint-env node */
|
||||||
|
|
||||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
||||||
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
|
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
|
||||||
const path = require('path');
|
const path = require("path");
|
||||||
|
|
||||||
module.exports = (env, argv) => {
|
module.exports = (env, argv) => {
|
||||||
let mode = "production";
|
let mode = "production";
|
||||||
if (argv && argv.mode) {
|
if (argv && argv.mode) {
|
||||||
mode = argv.mode;
|
mode = argv.mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Building ${mode}...`);
|
console.log(`Building ${mode}...`);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
entry: path.resolve(__dirname, "js/index.js"),
|
entry: path.resolve(__dirname, "js/index.js"),
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, "build/dist"),
|
path: path.resolve(__dirname, "build/dist"),
|
||||||
filename: "ruffle.js",
|
filename: "ruffle.js",
|
||||||
chunkFilename: "core.ruffle.js",
|
chunkFilename: "core.ruffle.js",
|
||||||
jsonpFunction: "RufflePlayerExtensionLoader",
|
jsonpFunction: "RufflePlayerExtensionLoader",
|
||||||
},
|
},
|
||||||
mode: mode,
|
mode: mode,
|
||||||
plugins: [
|
plugins: [
|
||||||
new CleanWebpackPlugin(),
|
new CleanWebpackPlugin(),
|
||||||
new WasmPackPlugin({
|
new WasmPackPlugin({
|
||||||
crateDirectory: path.resolve(__dirname, ".."),
|
crateDirectory: path.resolve(__dirname, ".."),
|
||||||
outName: "ruffle",
|
outName: "ruffle",
|
||||||
forceMode: mode,
|
forceMode: mode,
|
||||||
})
|
}),
|
||||||
]
|
],
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load ruffle from an automatically-detected location.
|
* Load ruffle from an automatically-detected location.
|
||||||
*
|
*
|
||||||
* This function returns a new instance of Ruffle and downloads it every time.
|
* This function returns a new instance of Ruffle and downloads it every time.
|
||||||
* You should not use it directly; this module will memoize the resource
|
* You should not use it directly; this module will memoize the resource
|
||||||
* download.
|
* download.
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
async function fetch_ruffle() {
|
async function fetch_ruffle() {
|
||||||
try {
|
try {
|
||||||
//If runtime_path is defined then we are executing inside the extension
|
//If runtime_path is defined then we are executing inside the extension
|
||||||
//closure. In that case, we configure our local Webpack instance
|
//closure. In that case, we configure our local Webpack instance
|
||||||
__webpack_public_path__ = runtime_path + "dist/";
|
__webpack_public_path__ = runtime_path + "dist/";
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//Checking an undefined closure variable usually throws ReferencError,
|
//Checking an undefined closure variable usually throws ReferencError,
|
||||||
|
@ -23,7 +23,7 @@ async function fetch_ruffle() {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//We currently assume that if we are not executing inside the extension,
|
//We currently assume that if we are not executing inside the extension,
|
||||||
//then we can use webpack to get Ruffle.
|
//then we can use webpack to get Ruffle.
|
||||||
let ruffle_module = await import("../pkg/ruffle");
|
let ruffle_module = await import("../pkg/ruffle");
|
||||||
|
@ -34,7 +34,7 @@ let last_loaded_ruffle = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain an instance of `Ruffle`.
|
* Obtain an instance of `Ruffle`.
|
||||||
*
|
*
|
||||||
* This function returns a promise which yields `Ruffle` asynchronously.
|
* This function returns a promise which yields `Ruffle` asynchronously.
|
||||||
*/
|
*/
|
||||||
export default function load_ruffle() {
|
export default function load_ruffle() {
|
||||||
|
@ -43,4 +43,4 @@ export default function load_ruffle() {
|
||||||
}
|
}
|
||||||
|
|
||||||
return last_loaded_ruffle;
|
return last_loaded_ruffle;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,10 @@ class RuffleMimeType {
|
||||||
/**
|
/**
|
||||||
* Replacement object for `MimeTypeArray` that lets us install new fake mime
|
* Replacement object for `MimeTypeArray` that lets us install new fake mime
|
||||||
* types.
|
* types.
|
||||||
*
|
*
|
||||||
* Unlike plugins we can at least enumerate mime types in Firefox, so we don't
|
* Unlike plugins we can at least enumerate mime types in Firefox, so we don't
|
||||||
* lose data.
|
* lose data.
|
||||||
*
|
*
|
||||||
* We also expose a method called `install` which adds a new plugin. This is
|
* We also expose a method called `install` which adds a new plugin. This is
|
||||||
* used to falsify Flash detection. If the existing `navigator.mimeTypes` has an
|
* used to falsify Flash detection. If the existing `navigator.mimeTypes` has an
|
||||||
* `install` method, you should not use `RuffleMimeTypeArray` as some other
|
* `install` method, you should not use `RuffleMimeTypeArray` as some other
|
||||||
|
@ -34,8 +34,8 @@ class RuffleMimeTypeArray {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Install a MIME Type into the array.
|
* Install a MIME Type into the array.
|
||||||
*
|
*
|
||||||
* @param {MimeType | RuffleMimeType} mimetype
|
* @param {MimeType | RuffleMimeType} mimetype
|
||||||
*/
|
*/
|
||||||
install(mimetype) {
|
install(mimetype) {
|
||||||
let id = this.__mimetypes.length;
|
let id = this.__mimetypes.length;
|
||||||
|
@ -82,15 +82,15 @@ class RufflePlugin extends RuffleMimeTypeArray {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replacement object for `PluginArray` that lets us install new fake plugins.
|
* Replacement object for `PluginArray` that lets us install new fake plugins.
|
||||||
*
|
*
|
||||||
* This object needs to wrap the native plugin array, since the user might have
|
* This object needs to wrap the native plugin array, since the user might have
|
||||||
* actual plugins installed. Firefox doesn't let us enumerate the array, though,
|
* actual plugins installed. Firefox doesn't let us enumerate the array, though,
|
||||||
* which has some consequences. Namely, we can't actually perfectly wrap the
|
* which has some consequences. Namely, we can't actually perfectly wrap the
|
||||||
* native plugin array, at least unless there's some secret "unresolved object
|
* native plugin array, at least unless there's some secret "unresolved object
|
||||||
* property name handler" that I've never known before in JS...
|
* property name handler" that I've never known before in JS...
|
||||||
*
|
*
|
||||||
* We can still wrap `namedItem` perfectly at least.
|
* We can still wrap `namedItem` perfectly at least.
|
||||||
*
|
*
|
||||||
* We also expose a method called `install` which adds a new plugin. This is
|
* We also expose a method called `install` which adds a new plugin. This is
|
||||||
* used to falsify Flash detection. If the existing `navigator.plugins` has an
|
* used to falsify Flash detection. If the existing `navigator.plugins` has an
|
||||||
* `install` method, you should not use `RufflePluginArray` as some other plugin
|
* `install` method, you should not use `RufflePluginArray` as some other plugin
|
||||||
|
@ -128,16 +128,37 @@ class RufflePluginArray {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FLASH_PLUGIN = new RufflePlugin("Shockwave Flash", "Shockwave Flash 32.0 r0", "ruffle.js", [
|
export const FLASH_PLUGIN = new RufflePlugin(
|
||||||
new RuffleMimeType("application/futuresplash", "Shockwave Flash", "spl"),
|
"Shockwave Flash",
|
||||||
new RuffleMimeType("application/x-shockwave-flash", "Shockwave Flash", "swf"),
|
"Shockwave Flash 32.0 r0",
|
||||||
new RuffleMimeType("application/x-shockwave-flash2-preview", "Shockwave Flash", "swf"),
|
"ruffle.js",
|
||||||
new RuffleMimeType("application/vnd.adobe.flash-movie", "Shockwave Flash", "swf")
|
[
|
||||||
]);
|
new RuffleMimeType(
|
||||||
|
"application/futuresplash",
|
||||||
|
"Shockwave Flash",
|
||||||
|
"spl"
|
||||||
|
),
|
||||||
|
new RuffleMimeType(
|
||||||
|
"application/x-shockwave-flash",
|
||||||
|
"Shockwave Flash",
|
||||||
|
"swf"
|
||||||
|
),
|
||||||
|
new RuffleMimeType(
|
||||||
|
"application/x-shockwave-flash2-preview",
|
||||||
|
"Shockwave Flash",
|
||||||
|
"swf"
|
||||||
|
),
|
||||||
|
new RuffleMimeType(
|
||||||
|
"application/vnd.adobe.flash-movie",
|
||||||
|
"Shockwave Flash",
|
||||||
|
"swf"
|
||||||
|
),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Install a fake plugin such that detectors will see it in `navigator.plugins`.
|
* Install a fake plugin such that detectors will see it in `navigator.plugins`.
|
||||||
*
|
*
|
||||||
* This function takes care to check if the existing implementation of
|
* This function takes care to check if the existing implementation of
|
||||||
* `navigator.plugins` already accepts fake plugin entries. If so, it will use
|
* `navigator.plugins` already accepts fake plugin entries. If so, it will use
|
||||||
* that version of the plugin array. This allows the plugin polyfill to compose
|
* that version of the plugin array. This allows the plugin polyfill to compose
|
||||||
|
@ -147,7 +168,7 @@ export function install_plugin(plugin) {
|
||||||
if (!navigator.plugins.install) {
|
if (!navigator.plugins.install) {
|
||||||
Object.defineProperty(navigator, "plugins", {
|
Object.defineProperty(navigator, "plugins", {
|
||||||
value: new RufflePluginArray(navigator.plugins),
|
value: new RufflePluginArray(navigator.plugins),
|
||||||
writable: false
|
writable: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +177,7 @@ export function install_plugin(plugin) {
|
||||||
if (plugin.length > 0 && !navigator.mimeTypes.install) {
|
if (plugin.length > 0 && !navigator.mimeTypes.install) {
|
||||||
Object.defineProperty(navigator, "mimeTypes", {
|
Object.defineProperty(navigator, "mimeTypes", {
|
||||||
value: new RuffleMimeTypeArray(navigator.mimeTypes),
|
value: new RuffleMimeTypeArray(navigator.mimeTypes),
|
||||||
writable: false
|
writable: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
import RuffleObject from "./ruffle-object";
|
import RuffleObject from "./ruffle-object";
|
||||||
import RuffleEmbed from "./ruffle-embed";
|
import RuffleEmbed from "./ruffle-embed";
|
||||||
import { install_plugin, FLASH_PLUGIN } from "./plugin-polyfill";
|
import { install_plugin, FLASH_PLUGIN } from "./plugin-polyfill";
|
||||||
import { public_path } from "./public-path"
|
import { public_path } from "./public-path";
|
||||||
|
|
||||||
if (!window.RufflePlayer) {
|
if (!window.RufflePlayer) {
|
||||||
window.RufflePlayer={};
|
window.RufflePlayer = {};
|
||||||
}
|
}
|
||||||
let top_level_ruffle_config;
|
let top_level_ruffle_config;
|
||||||
let ruffle_script_src=public_path({}, "ruffle.js");
|
let ruffle_script_src = public_path({}, "ruffle.js");
|
||||||
if (window.RufflePlayer.config) {
|
if (window.RufflePlayer.config) {
|
||||||
top_level_ruffle_config=window.RufflePlayer.config;
|
top_level_ruffle_config = window.RufflePlayer.config;
|
||||||
ruffle_script_src=public_path(window.RufflePlayer.config, "ruffle.js");
|
ruffle_script_src = public_path(window.RufflePlayer.config, "ruffle.js");
|
||||||
}
|
}
|
||||||
/* public_path returns the directory where the file is, *
|
/* public_path returns the directory where the file is, *
|
||||||
* so we need to append the filename. We don't need to *
|
* so we need to append the filename. We don't need to *
|
||||||
* worry about the directory not having a slash because *
|
* worry about the directory not having a slash because *
|
||||||
* public_path appends a slash. */
|
* public_path appends a slash. */
|
||||||
ruffle_script_src+="ruffle.js";
|
ruffle_script_src += "ruffle.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Polyfill native elements with Ruffle equivalents.
|
* Polyfill native elements with Ruffle equivalents.
|
||||||
*
|
*
|
||||||
* This polyfill isn't fool-proof: If there's a chance site JavaScript has
|
* This polyfill isn't fool-proof: If there's a chance site JavaScript has
|
||||||
* access to a pre-polyfill element, then this will break horribly. We can
|
* access to a pre-polyfill element, then this will break horribly. We can
|
||||||
* keep native objects out of the DOM, and thus out of JavaScript's grubby
|
* keep native objects out of the DOM, and thus out of JavaScript's grubby
|
||||||
|
@ -48,7 +48,10 @@ function replace_flash_instances() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Serious error encountered when polyfilling native Flash elements: " + err);
|
console.error(
|
||||||
|
"Serious error encountered when polyfilling native Flash elements: " +
|
||||||
|
err
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,18 +59,19 @@ function polyfill_static_content() {
|
||||||
replace_flash_instances();
|
replace_flash_instances();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function polyfill_dynamic_content() {
|
function polyfill_dynamic_content() {
|
||||||
// Listen for changes to the DOM. If nodes are added, re-check for any Flash instances.
|
// Listen for changes to the DOM. If nodes are added, re-check for any Flash instances.
|
||||||
const observer = new MutationObserver(function (mutationsList) {
|
const observer = new MutationObserver(function (mutationsList) {
|
||||||
// If any nodes were added, re-run the polyfill to replace any new instances.
|
// If any nodes were added, re-run the polyfill to replace any new instances.
|
||||||
let nodesAdded = mutationsList.some(mutation => mutation.addedNodes.length > 0);
|
let nodesAdded = mutationsList.some(
|
||||||
|
(mutation) => mutation.addedNodes.length > 0
|
||||||
|
);
|
||||||
if (nodesAdded) {
|
if (nodesAdded) {
|
||||||
replace_flash_instances();
|
replace_flash_instances();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
observer.observe(document, { childList: true, subtree: true});
|
observer.observe(document, { childList: true, subtree: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
function falsify_plugin_detection() {
|
function falsify_plugin_detection() {
|
||||||
|
@ -75,39 +79,37 @@ function falsify_plugin_detection() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function load_ruffle_player_into_frame(event) {
|
function load_ruffle_player_into_frame(event) {
|
||||||
let current_frame=event.currentTarget.contentWindow;
|
let current_frame = event.currentTarget.contentWindow;
|
||||||
let frame_document;
|
let frame_document;
|
||||||
console.log("Event handled");
|
console.log("Event handled");
|
||||||
try {
|
try {
|
||||||
frame_document=current_frame.document;
|
frame_document = current_frame.document;
|
||||||
if (!frame_document) {
|
if (!frame_document) {
|
||||||
console.log("Frame has no document.");
|
console.log("Frame has no document.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} catch (e) {
|
||||||
catch(e) {
|
|
||||||
console.log("Error Getting Frame: " + e.message);
|
console.log("Error Getting Frame: " + e.message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!current_frame.RufflePlayer) {
|
if (!current_frame.RufflePlayer) {
|
||||||
/* Make sure we populate the frame's window.RufflePlayer.config */
|
/* Make sure we populate the frame's window.RufflePlayer.config */
|
||||||
current_frame.RufflePlayer={};
|
current_frame.RufflePlayer = {};
|
||||||
current_frame.RufflePlayer.config=top_level_ruffle_config;
|
current_frame.RufflePlayer.config = top_level_ruffle_config;
|
||||||
let script = frame_document.createElement("script");
|
let script = frame_document.createElement("script");
|
||||||
script.src=ruffle_script_src; /* Load this script(ruffle.js) into the frame */
|
script.src = ruffle_script_src; /* Load this script(ruffle.js) into the frame */
|
||||||
frame_document.body.appendChild(script);
|
frame_document.body.appendChild(script);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
console.log("(i)frame already has RufflePlayer");
|
console.log("(i)frame already has RufflePlayer");
|
||||||
}
|
}
|
||||||
polyfill_frames_common(current_frame);
|
polyfill_frames_common(current_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
function polyfill_frames_common(depth) {
|
function polyfill_frames_common(depth) {
|
||||||
let current_iframes=depth.document.getElementsByTagName("iframe");
|
let current_iframes = depth.document.getElementsByTagName("iframe");
|
||||||
let current_frames=depth.document.getElementsByTagName("frame");
|
let current_frames = depth.document.getElementsByTagName("frame");
|
||||||
for (let i=0;i<current_iframes.length;i++) {
|
for (let i = 0; i < current_iframes.length; i++) {
|
||||||
let current_frame=current_iframes[i];
|
let current_frame = current_iframes[i];
|
||||||
/* Apperently, using addEventListener attatches the event *
|
/* Apperently, using addEventListener attatches the event *
|
||||||
* to the dummy document, which is overwritten when the *
|
* to the dummy document, which is overwritten when the *
|
||||||
* iframe is loaded, so we do this. It can only works if *
|
* iframe is loaded, so we do this. It can only works if *
|
||||||
|
@ -117,12 +119,12 @@ function polyfill_frames_common(depth) {
|
||||||
* of depth.frames to get the iframes at the depth. *
|
* of depth.frames to get the iframes at the depth. *
|
||||||
* Also, this way we should be able to handle frame *
|
* Also, this way we should be able to handle frame *
|
||||||
* frame navigation, which is good. */
|
* frame navigation, which is good. */
|
||||||
current_frame.onload=load_ruffle_player_into_frame;
|
current_frame.onload = load_ruffle_player_into_frame;
|
||||||
polyfill_frames_common(current_frame.contentWindow);
|
polyfill_frames_common(current_frame.contentWindow);
|
||||||
}
|
}
|
||||||
for (let i=0;i<current_frames.length;i++) {
|
for (let i = 0; i < current_frames.length; i++) {
|
||||||
let current_frame=current_frames[i];
|
let current_frame = current_frames[i];
|
||||||
current_frame.onload=load_ruffle_player_into_frame;
|
current_frame.onload = load_ruffle_player_into_frame;
|
||||||
polyfill_frames_common(current_frame.contentWindow);
|
polyfill_frames_common(current_frame.contentWindow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +135,9 @@ function polyfill_static_frames() {
|
||||||
|
|
||||||
function ruffle_frame_listener(mutationsList) {
|
function ruffle_frame_listener(mutationsList) {
|
||||||
/* Basically the same as the listener for dynamic embeds. */
|
/* Basically the same as the listener for dynamic embeds. */
|
||||||
let nodesAdded = mutationsList.some(mutation => mutation.addedNodes.length > 0);
|
let nodesAdded = mutationsList.some(
|
||||||
|
(mutation) => mutation.addedNodes.length > 0
|
||||||
|
);
|
||||||
if (nodesAdded) {
|
if (nodesAdded) {
|
||||||
polyfill_frames_common(window);
|
polyfill_frames_common(window);
|
||||||
}
|
}
|
||||||
|
@ -141,7 +145,7 @@ function ruffle_frame_listener(mutationsList) {
|
||||||
|
|
||||||
function polyfill_dynamic_frames() {
|
function polyfill_dynamic_frames() {
|
||||||
const observer = new MutationObserver(ruffle_frame_listener);
|
const observer = new MutationObserver(ruffle_frame_listener);
|
||||||
observer.observe(document, {childList: true, subtree: true});
|
observer.observe(document, { childList: true, subtree: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
function polyfill_frames() {
|
function polyfill_frames() {
|
||||||
|
@ -155,7 +159,7 @@ let polyfills = {
|
||||||
"static-content": polyfill_static_content,
|
"static-content": polyfill_static_content,
|
||||||
"dynamic-content": polyfill_dynamic_content,
|
"dynamic-content": polyfill_dynamic_content,
|
||||||
"plugin-detect": falsify_plugin_detection,
|
"plugin-detect": falsify_plugin_detection,
|
||||||
"frames": polyfill_frames
|
frames: polyfill_frames,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function polyfill(polyfill_list) {
|
export function polyfill(polyfill_list) {
|
||||||
|
@ -164,8 +168,12 @@ export function polyfill(polyfill_list) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Object.prototype.hasOwnProperty.call(polyfills, polyfill_list[i])) {
|
if (
|
||||||
throw new Error("Requested nonexistent polyfill: " + polyfill_list[i]);
|
!Object.prototype.hasOwnProperty.call(polyfills, polyfill_list[i])
|
||||||
|
) {
|
||||||
|
throw new Error(
|
||||||
|
"Requested nonexistent polyfill: " + polyfill_list[i]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
running_polyfills.push(polyfill_list[i]);
|
running_polyfills.push(polyfill_list[i]);
|
||||||
|
|
|
@ -3,28 +3,28 @@ import { VersionRange } from "./version-range.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the Ruffle public API.
|
* Represents the Ruffle public API.
|
||||||
*
|
*
|
||||||
* The public API exists primarily to allow multiple installs of Ruffle on a
|
* The public API exists primarily to allow multiple installs of Ruffle on a
|
||||||
* page (e.g. an extension install and a local one) to cooperate. In an ideal
|
* page (e.g. an extension install and a local one) to cooperate. In an ideal
|
||||||
* situation, all Ruffle sources on the page install themselves into a single
|
* situation, all Ruffle sources on the page install themselves into a single
|
||||||
* public API, and then the public API picks the newest version by default.
|
* public API, and then the public API picks the newest version by default.
|
||||||
*
|
*
|
||||||
* This API *is* versioned, in case we need to upgrade it. However, it must be
|
* This API *is* versioned, in case we need to upgrade it. However, it must be
|
||||||
* backwards- and forwards-compatible with all known sources.
|
* backwards- and forwards-compatible with all known sources.
|
||||||
*/
|
*/
|
||||||
export class PublicAPI {
|
export class PublicAPI {
|
||||||
/**
|
/**
|
||||||
* Construct the Ruffle public API.
|
* Construct the Ruffle public API.
|
||||||
*
|
*
|
||||||
* Do not use this function to negotiate a public API. Instead, use
|
* Do not use this function to negotiate a public API. Instead, use
|
||||||
* `public_api` to register your Ruffle source with an existing public API
|
* `public_api` to register your Ruffle source with an existing public API
|
||||||
* if it exists.
|
* if it exists.
|
||||||
*
|
*
|
||||||
* Constructing a Public API will also trigger it to initialize Ruffle once
|
* Constructing a Public API will also trigger it to initialize Ruffle once
|
||||||
* the page loads, if the API has not already been superceded.
|
* the page loads, if the API has not already been superceded.
|
||||||
*
|
*
|
||||||
* @param {object} prev What used to be in the public API slot.
|
* @param {object} prev What used to be in the public API slot.
|
||||||
*
|
*
|
||||||
* This is used to upgrade from a prior version of the public API, or from
|
* This is used to upgrade from a prior version of the public API, or from
|
||||||
* a user-defined configuration object placed in the public API slot.
|
* a user-defined configuration object placed in the public API slot.
|
||||||
*/
|
*/
|
||||||
|
@ -44,7 +44,10 @@ export class PublicAPI {
|
||||||
this.newest_name = prev.newest_name;
|
this.newest_name = prev.newest_name;
|
||||||
|
|
||||||
prev.superceded();
|
prev.superceded();
|
||||||
} else if (prev.constructor === Object && prev.config !== undefined) {
|
} else if (
|
||||||
|
prev.constructor === Object &&
|
||||||
|
prev.config !== undefined
|
||||||
|
) {
|
||||||
/// We're the first, install user configuration
|
/// We're the first, install user configuration
|
||||||
this.config = prev.config;
|
this.config = prev.config;
|
||||||
} else {
|
} else {
|
||||||
|
@ -62,7 +65,7 @@ export class PublicAPI {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The version of the public API.
|
* The version of the public API.
|
||||||
*
|
*
|
||||||
* This allows a page with an old version of the Public API to be upgraded
|
* This allows a page with an old version of the Public API to be upgraded
|
||||||
* to a new version of the API. The public API is intended to be changed
|
* to a new version of the API. The public API is intended to be changed
|
||||||
* very infrequently, if at all, but this provides an escape mechanism for
|
* very infrequently, if at all, but this provides an escape mechanism for
|
||||||
|
@ -74,7 +77,7 @@ export class PublicAPI {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a given source with the Ruffle Public API.
|
* Register a given source with the Ruffle Public API.
|
||||||
*
|
*
|
||||||
* @param {string} name The name of the source.
|
* @param {string} name The name of the source.
|
||||||
* @param {object} api The public API object. This must conform to the shape
|
* @param {object} api The public API object. This must conform to the shape
|
||||||
* of `SourceAPI`.
|
* of `SourceAPI`.
|
||||||
|
@ -82,15 +85,16 @@ export class PublicAPI {
|
||||||
register_source(name, api) {
|
register_source(name, api) {
|
||||||
this.sources[name] = api;
|
this.sources[name] = api;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine the name of the newest registered source in the Public API.
|
* Determine the name of the newest registered source in the Public API.
|
||||||
*
|
*
|
||||||
* @returns {(string|bool)} The name of the source, or `false` if no source
|
* @returns {(string|bool)} The name of the source, or `false` if no source
|
||||||
* has yet to be registered.
|
* has yet to be registered.
|
||||||
*/
|
*/
|
||||||
newest_source_name() {
|
newest_source_name() {
|
||||||
let newest_name = false, newest_version = Version.from_semver("0.0.0");
|
let newest_name = false,
|
||||||
|
newest_version = Version.from_semver("0.0.0");
|
||||||
|
|
||||||
for (let k in this.sources) {
|
for (let k in this.sources) {
|
||||||
if (Object.prototype.hasOwnProperty.call(this.sources, k)) {
|
if (Object.prototype.hasOwnProperty.call(this.sources, k)) {
|
||||||
|
@ -107,7 +111,7 @@ export class PublicAPI {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Negotiate and start Ruffle.
|
* Negotiate and start Ruffle.
|
||||||
*
|
*
|
||||||
* This function reads the config parameter to determine which polyfills
|
* This function reads the config parameter to determine which polyfills
|
||||||
* should be enabled. If the configuration parameter is missing, then we
|
* should be enabled. If the configuration parameter is missing, then we
|
||||||
* use a built-in set of defaults sufficient to fool sites with static
|
* use a built-in set of defaults sufficient to fool sites with static
|
||||||
|
@ -129,16 +133,20 @@ export class PublicAPI {
|
||||||
* we would need to have all polyfills but frames added *
|
* we would need to have all polyfills but frames added *
|
||||||
* to the extension's javascript because it uses the *
|
* to the extension's javascript because it uses the *
|
||||||
* "all_frames" manifest property to handle frames. */
|
* "all_frames" manifest property to handle frames. */
|
||||||
polyfills = ["plugin-detect", "static-content", "dynamic-content"];
|
polyfills = [
|
||||||
|
"plugin-detect",
|
||||||
|
"static-content",
|
||||||
|
"dynamic-content",
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sources[this.newest_name].polyfill(polyfills);
|
this.sources[this.newest_name].polyfill(polyfills);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look up the newest Ruffle source and return it's API.
|
* Look up the newest Ruffle source and return it's API.
|
||||||
*
|
*
|
||||||
* @returns {SourceAPI} An instance of the Source API.
|
* @returns {SourceAPI} An instance of the Source API.
|
||||||
*/
|
*/
|
||||||
newest() {
|
newest() {
|
||||||
|
@ -148,10 +156,10 @@ export class PublicAPI {
|
||||||
/**
|
/**
|
||||||
* Look up a specific Ruffle version (or any version satisfying a given set
|
* Look up a specific Ruffle version (or any version satisfying a given set
|
||||||
* of requirements) and return it's API.
|
* of requirements) and return it's API.
|
||||||
*
|
*
|
||||||
* @param {string} ver_requirement A set of semantic version requirement
|
* @param {string} ver_requirement A set of semantic version requirement
|
||||||
* strings that the player version must satisfy.
|
* strings that the player version must satisfy.
|
||||||
*
|
*
|
||||||
* @returns {SourceAPI|null} An instance of the Source API, if one or more
|
* @returns {SourceAPI|null} An instance of the Source API, if one or more
|
||||||
* sources satisfied the requirement.
|
* sources satisfied the requirement.
|
||||||
*/
|
*/
|
||||||
|
@ -164,7 +172,7 @@ export class PublicAPI {
|
||||||
let version = Version.from_semver(this.sources[k].version);
|
let version = Version.from_semver(this.sources[k].version);
|
||||||
|
|
||||||
if (requirement.satisfied_by(version)) {
|
if (requirement.satisfied_by(version)) {
|
||||||
valid_source = this.sources[k]
|
valid_source = this.sources[k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,11 +207,11 @@ export class PublicAPI {
|
||||||
/**
|
/**
|
||||||
* Indicates that this version of the public API has been superceded by a
|
* Indicates that this version of the public API has been superceded by a
|
||||||
* newer version.
|
* newer version.
|
||||||
*
|
*
|
||||||
* This should only be called by a newer version of the Public API.
|
* This should only be called by a newer version of the Public API.
|
||||||
* Identical versions of the Public API should not supercede older versions
|
* Identical versions of the Public API should not supercede older versions
|
||||||
* of that same API.
|
* of that same API.
|
||||||
*
|
*
|
||||||
* Unfortunately, we can't disable polyfills after-the-fact, so this
|
* Unfortunately, we can't disable polyfills after-the-fact, so this
|
||||||
* only lets you disable the init event...
|
* only lets you disable the init event...
|
||||||
*/
|
*/
|
||||||
|
@ -213,45 +221,51 @@ export class PublicAPI {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Join a source into the public API, if it doesn't already exist.
|
* Join a source into the public API, if it doesn't already exist.
|
||||||
*
|
*
|
||||||
* @param {*} prev_ruffle The previous iteration of the Ruffle API.
|
* @param {*} prev_ruffle The previous iteration of the Ruffle API.
|
||||||
*
|
*
|
||||||
* The `prev_ruffle` param lists the previous object in the RufflePlayer
|
* The `prev_ruffle` param lists the previous object in the RufflePlayer
|
||||||
* slot. We perform some checks to see if this is a Ruffle public API or a
|
* slot. We perform some checks to see if this is a Ruffle public API or a
|
||||||
* conflicting object. If this is conflicting, then a new public API will
|
* conflicting object. If this is conflicting, then a new public API will
|
||||||
* be constructed (see the constructor information for what happens to
|
* be constructed (see the constructor information for what happens to
|
||||||
* `prev_ruffle`).
|
* `prev_ruffle`).
|
||||||
*
|
*
|
||||||
* Note that Public API upgrades are deliberately not enabled in this
|
* Note that Public API upgrades are deliberately not enabled in this
|
||||||
* version of Ruffle, since there is no Public API to upgrade from.
|
* version of Ruffle, since there is no Public API to upgrade from.
|
||||||
*
|
*
|
||||||
* @param {string|undefined} source_name The name of this particular
|
* @param {string|undefined} source_name The name of this particular
|
||||||
* Ruffle source.
|
* Ruffle source.
|
||||||
*
|
*
|
||||||
* @param {object|undefined} source_api The Ruffle source to add.
|
* @param {object|undefined} source_api The Ruffle source to add.
|
||||||
*
|
*
|
||||||
* If both parameters are provided they will be used to define a new Ruffle
|
* If both parameters are provided they will be used to define a new Ruffle
|
||||||
* source to register with the public API.
|
* source to register with the public API.
|
||||||
*
|
*
|
||||||
* @returns {object} The Ruffle Public API.
|
* @returns {object} The Ruffle Public API.
|
||||||
*/
|
*/
|
||||||
static negotiate(prev_ruffle, source_name, source_api) {
|
static negotiate(prev_ruffle, source_name, source_api) {
|
||||||
let public_api;
|
let public_api;
|
||||||
if (prev_ruffle !== undefined && prev_ruffle.constructor.name == PublicAPI.name) {
|
if (
|
||||||
|
prev_ruffle !== undefined &&
|
||||||
|
prev_ruffle.constructor.name == PublicAPI.name
|
||||||
|
) {
|
||||||
public_api = prev_ruffle;
|
public_api = prev_ruffle;
|
||||||
} else {
|
} else {
|
||||||
public_api = new PublicAPI(prev_ruffle);
|
public_api = new PublicAPI(prev_ruffle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source_name !== undefined && source_api !== undefined) {
|
if (source_name !== undefined && source_api !== undefined) {
|
||||||
public_api.register_source(source_name, source_api);
|
public_api.register_source(source_name, source_api);
|
||||||
|
|
||||||
// Install the faux plugin detection immediately.
|
// Install the faux plugin detection immediately.
|
||||||
// This is necessary because scripts such as SWFObject check for the
|
// This is necessary because scripts such as SWFObject check for the
|
||||||
// Flash Player immediately when they load.
|
// Flash Player immediately when they load.
|
||||||
// TODO: Maybe there's a better place for this.
|
// TODO: Maybe there's a better place for this.
|
||||||
let polyfills = public_api.config.polyfills;
|
let polyfills = public_api.config.polyfills;
|
||||||
if (polyfills === undefined || polyfills.includes("plugin-detect")) {
|
if (
|
||||||
|
polyfills === undefined ||
|
||||||
|
polyfills.includes("plugin-detect")
|
||||||
|
) {
|
||||||
source_api.polyfill(["plugin-detect"]);
|
source_api.polyfill(["plugin-detect"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
/**
|
/**
|
||||||
* Attempt to discover the public path of the current Ruffle source. This can
|
* Attempt to discover the public path of the current Ruffle source. This can
|
||||||
* be used to configure Webpack.
|
* be used to configure Webpack.
|
||||||
*
|
*
|
||||||
* We have several points of configuration for how the Ruffle public path can
|
* We have several points of configuration for how the Ruffle public path can
|
||||||
* be determined:
|
* be determined:
|
||||||
*
|
*
|
||||||
* 1. The public path can be specified on a per-source basis using the
|
* 1. The public path can be specified on a per-source basis using the
|
||||||
* RufflePlayer config, for example:
|
* RufflePlayer config, for example:
|
||||||
* `window.RufflePlayer.config.public_paths.local = "/dist/";`
|
* `window.RufflePlayer.config.public_paths.local = "/dist/";`
|
||||||
|
@ -13,14 +13,18 @@
|
||||||
* 3. If there is absolutely no configuration that yields a public path then we
|
* 3. If there is absolutely no configuration that yields a public path then we
|
||||||
* return the parent path of where this script is hosted, which should be
|
* return the parent path of where this script is hosted, which should be
|
||||||
* the correct default in most cases.
|
* the correct default in most cases.
|
||||||
*
|
*
|
||||||
* @param {object} config The `window.RufflePlayer.config` object.
|
* @param {object} config The `window.RufflePlayer.config` object.
|
||||||
* @param {string} source_name The name of the source.
|
* @param {string} source_name The name of the source.
|
||||||
* @returns {string} The public path for the given source.
|
* @returns {string} The public path for the given source.
|
||||||
*/
|
*/
|
||||||
export function public_path(config, source_name) {
|
export function public_path(config, source_name) {
|
||||||
let public_path = "";
|
let public_path = "";
|
||||||
if (config !== undefined && config.public_paths !== undefined && config.public_paths[source_name] !== undefined) {
|
if (
|
||||||
|
config !== undefined &&
|
||||||
|
config.public_paths !== undefined &&
|
||||||
|
config.public_paths[source_name] !== undefined
|
||||||
|
) {
|
||||||
public_path = config.public_paths[source_name];
|
public_path = config.public_paths[source_name];
|
||||||
} else if (config !== undefined && config.public_path !== undefined) {
|
} else if (config !== undefined && config.public_path !== undefined) {
|
||||||
public_path = config.public_path;
|
public_path = config.public_path;
|
||||||
|
@ -32,7 +36,7 @@ export function public_path(config, source_name) {
|
||||||
console.warn("Unable to get currentScript URL");
|
console.warn("Unable to get currentScript URL");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Webpack expects the paths to end with a /.
|
// Webpack expects the paths to end with a /.
|
||||||
if (public_path !== "" && !public_path.endsWith("/")) {
|
if (public_path !== "" && !public_path.endsWith("/")) {
|
||||||
public_path += "/";
|
public_path += "/";
|
||||||
|
|
|
@ -5,13 +5,13 @@ var private_registry = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lookup a previously registered custom element.
|
* Lookup a previously registered custom element.
|
||||||
*
|
*
|
||||||
* @param {string} element_name The internal element name, previously used to
|
* @param {string} element_name The internal element name, previously used to
|
||||||
* register the element with the private registry.
|
* register the element with the private registry.
|
||||||
*
|
*
|
||||||
* @returns {object|null} The element data in the registry, or null if there is
|
* @returns {object|null} The element data in the registry, or null if there is
|
||||||
* no such element name registered.
|
* no such element name registered.
|
||||||
*
|
*
|
||||||
* The returned object will have `name`, `class`, and `internal_name`
|
* The returned object will have `name`, `class`, and `internal_name`
|
||||||
* properties listing the external name, implementing class, and internal name
|
* properties listing the external name, implementing class, and internal name
|
||||||
* respectively.
|
* respectively.
|
||||||
|
@ -20,9 +20,9 @@ export function lookup_element(element_name) {
|
||||||
let data = private_registry[element_name];
|
let data = private_registry[element_name];
|
||||||
if (data !== undefined) {
|
if (data !== undefined) {
|
||||||
return {
|
return {
|
||||||
"internal_name": element_name,
|
internal_name: element_name,
|
||||||
"name": data.name,
|
name: data.name,
|
||||||
"class": data.class
|
class: data.class,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
@ -31,21 +31,21 @@ export function lookup_element(element_name) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a custom element.
|
* Register a custom element.
|
||||||
*
|
*
|
||||||
* This function is designed to be tolerant of naming conflicts. If
|
* This function is designed to be tolerant of naming conflicts. If
|
||||||
* registration fails, we modify the name, and try again. As a result, this
|
* registration fails, we modify the name, and try again. As a result, this
|
||||||
* function returns the real element name to use.
|
* function returns the real element name to use.
|
||||||
*
|
*
|
||||||
* Calling this function multiple times will *not* register multiple elements.
|
* Calling this function multiple times will *not* register multiple elements.
|
||||||
* We store a private registry mapping internal element names to DOM names.
|
* We store a private registry mapping internal element names to DOM names.
|
||||||
* Thus, the proper way to use this function is to call it every time you are
|
* Thus, the proper way to use this function is to call it every time you are
|
||||||
* about to work with custom element names.
|
* about to work with custom element names.
|
||||||
*
|
*
|
||||||
* @param {string} element_name The internal name of the element.
|
* @param {string} element_name The internal name of the element.
|
||||||
* @param {function} element_class The class of the element.
|
* @param {function} element_class The class of the element.
|
||||||
*
|
*
|
||||||
* You must call this function with the same class every time.
|
* You must call this function with the same class every time.
|
||||||
*
|
*
|
||||||
* @returns {string} The actual element name.
|
* @returns {string} The actual element name.
|
||||||
* @throws Throws an error if two different elements were registered with the
|
* @throws Throws an error if two different elements were registered with the
|
||||||
* same internal name.
|
* same internal name.
|
||||||
|
@ -70,9 +70,9 @@ export function register_element(element_name, element_class) {
|
||||||
|
|
||||||
window.customElements.define(external_name, element_class);
|
window.customElements.define(external_name, element_class);
|
||||||
private_registry[element_name] = {
|
private_registry[element_name] = {
|
||||||
"class": element_class,
|
class: element_class,
|
||||||
"name": external_name,
|
name: external_name,
|
||||||
"internal_name": element_name
|
internal_name: element_name,
|
||||||
};
|
};
|
||||||
|
|
||||||
return external_name;
|
return external_name;
|
||||||
|
@ -82,4 +82,4 @@ export function register_element(element_name, element_class) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
import { FLASH_MIMETYPE, FUTURESPLASH_MIMETYPE, FLASH7_AND_8_MIMETYPE, FLASH_MOVIE_MIMETYPE, is_swf_filename, RufflePlayer } from "./ruffle-player.js";
|
import {
|
||||||
|
FLASH_MIMETYPE,
|
||||||
|
FUTURESPLASH_MIMETYPE,
|
||||||
|
FLASH7_AND_8_MIMETYPE,
|
||||||
|
FLASH_MOVIE_MIMETYPE,
|
||||||
|
is_swf_filename,
|
||||||
|
RufflePlayer,
|
||||||
|
} from "./ruffle-player.js";
|
||||||
import { register_element } from "./register-element";
|
import { register_element } from "./register-element";
|
||||||
|
|
||||||
export default class RuffleEmbed extends RufflePlayer {
|
export default class RuffleEmbed extends RufflePlayer {
|
||||||
|
@ -35,9 +42,14 @@ export default class RuffleEmbed extends RufflePlayer {
|
||||||
|
|
||||||
static is_interdictable(elem) {
|
static is_interdictable(elem) {
|
||||||
if (!elem.src) {
|
if (!elem.src) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (elem.type === FLASH_MIMETYPE || elem.type === FUTURESPLASH_MIMETYPE || elem.type == FLASH7_AND_8_MIMETYPE || elem.type == FLASH_MOVIE_MIMETYPE) {
|
if (
|
||||||
|
elem.type === FLASH_MIMETYPE ||
|
||||||
|
elem.type === FUTURESPLASH_MIMETYPE ||
|
||||||
|
elem.type == FLASH7_AND_8_MIMETYPE ||
|
||||||
|
elem.type == FLASH_MOVIE_MIMETYPE
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
} else if (elem.type === undefined || elem.type === "") {
|
} else if (elem.type === undefined || elem.type === "") {
|
||||||
return is_swf_filename(elem.src);
|
return is_swf_filename(elem.src);
|
||||||
|
|
|
@ -1,4 +1,12 @@
|
||||||
import { FLASH_MIMETYPE, FUTURESPLASH_MIMETYPE, FLASH7_AND_8_MIMETYPE, FLASH_MOVIE_MIMETYPE, FLASH_ACTIVEX_CLASSID, is_swf_filename, RufflePlayer } from "./ruffle-player.js";
|
import {
|
||||||
|
FLASH_MIMETYPE,
|
||||||
|
FUTURESPLASH_MIMETYPE,
|
||||||
|
FLASH7_AND_8_MIMETYPE,
|
||||||
|
FLASH_MOVIE_MIMETYPE,
|
||||||
|
FLASH_ACTIVEX_CLASSID,
|
||||||
|
is_swf_filename,
|
||||||
|
RufflePlayer,
|
||||||
|
} from "./ruffle-player.js";
|
||||||
import { register_element } from "./register-element";
|
import { register_element } from "./register-element";
|
||||||
|
|
||||||
export default class RuffleObject extends RufflePlayer {
|
export default class RuffleObject extends RufflePlayer {
|
||||||
|
@ -8,7 +16,7 @@ export default class RuffleObject extends RufflePlayer {
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
|
|
||||||
this.params = RuffleObject.params_of(this);
|
this.params = RuffleObject.params_of(this);
|
||||||
|
|
||||||
//Kick off the SWF download.
|
//Kick off the SWF download.
|
||||||
|
@ -31,7 +39,7 @@ export default class RuffleObject extends RufflePlayer {
|
||||||
if (!elem.data) {
|
if (!elem.data) {
|
||||||
let has_movie = false;
|
let has_movie = false;
|
||||||
let params = elem.getElementsByTagName("param");
|
let params = elem.getElementsByTagName("param");
|
||||||
for (let i = 0;i < params.length;i ++) {
|
for (let i = 0; i < params.length; i++) {
|
||||||
if (params[i].name == "movie" && params[i].value) {
|
if (params[i].name == "movie" && params[i].value) {
|
||||||
has_movie = true;
|
has_movie = true;
|
||||||
}
|
}
|
||||||
|
@ -40,11 +48,23 @@ export default class RuffleObject extends RufflePlayer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (elem.type === FLASH_MIMETYPE || elem.type === FUTURESPLASH_MIMETYPE || elem.type == FLASH7_AND_8_MIMETYPE || elem.type == FLASH_MOVIE_MIMETYPE) {
|
if (
|
||||||
|
elem.type === FLASH_MIMETYPE ||
|
||||||
|
elem.type === FUTURESPLASH_MIMETYPE ||
|
||||||
|
elem.type == FLASH7_AND_8_MIMETYPE ||
|
||||||
|
elem.type == FLASH_MOVIE_MIMETYPE
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
} else if (elem.attributes && elem.attributes.classid && elem.attributes.classid.value === FLASH_ACTIVEX_CLASSID) {
|
} else if (
|
||||||
|
elem.attributes &&
|
||||||
|
elem.attributes.classid &&
|
||||||
|
elem.attributes.classid.value === FLASH_ACTIVEX_CLASSID
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
} else if ((elem.type === undefined || elem.type === "") && elem.attributes.classid === undefined) {
|
} else if (
|
||||||
|
(elem.type === undefined || elem.type === "") &&
|
||||||
|
elem.attributes.classid === undefined
|
||||||
|
) {
|
||||||
let params = RuffleObject.params_of(elem);
|
let params = RuffleObject.params_of(elem);
|
||||||
if (params && params.movie) {
|
if (params && params.movie) {
|
||||||
return is_swf_filename(params.movie);
|
return is_swf_filename(params.movie);
|
||||||
|
|
|
@ -14,14 +14,17 @@ export class RufflePlayer extends HTMLElement {
|
||||||
constructor(...args) {
|
constructor(...args) {
|
||||||
let self = super(...args);
|
let self = super(...args);
|
||||||
|
|
||||||
self.shadow = self.attachShadow({ mode: 'closed' });
|
self.shadow = self.attachShadow({ mode: "closed" });
|
||||||
self.shadow.appendChild(ruffle_shadow_template.content.cloneNode(true));
|
self.shadow.appendChild(ruffle_shadow_template.content.cloneNode(true));
|
||||||
|
|
||||||
self.dynamic_styles = self.shadow.getElementById("dynamic_styles");
|
self.dynamic_styles = self.shadow.getElementById("dynamic_styles");
|
||||||
self.container = self.shadow.getElementById("container");
|
self.container = self.shadow.getElementById("container");
|
||||||
self.play_button = self.shadow.getElementById("play_button");
|
self.play_button = self.shadow.getElementById("play_button");
|
||||||
if (self.play_button) {
|
if (self.play_button) {
|
||||||
self.play_button.addEventListener("click", self.play_button_clicked.bind(self));
|
self.play_button.addEventListener(
|
||||||
|
"click",
|
||||||
|
self.play_button_clicked.bind(self)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.instance = null;
|
self.instance = null;
|
||||||
|
@ -59,16 +62,24 @@ export class RufflePlayer extends HTMLElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.attributes.width) {
|
if (this.attributes.width) {
|
||||||
let width = RufflePlayer.html_dimension_to_css_dimension(this.attributes.width.value);
|
let width = RufflePlayer.html_dimension_to_css_dimension(
|
||||||
|
this.attributes.width.value
|
||||||
|
);
|
||||||
if (width !== null) {
|
if (width !== null) {
|
||||||
this.dynamic_styles.sheet.insertRule(`:host { width: ${width}; }`);
|
this.dynamic_styles.sheet.insertRule(
|
||||||
|
`:host { width: ${width}; }`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.attributes.height) {
|
if (this.attributes.height) {
|
||||||
let height = RufflePlayer.html_dimension_to_css_dimension(this.attributes.height.value);
|
let height = RufflePlayer.html_dimension_to_css_dimension(
|
||||||
|
this.attributes.height.value
|
||||||
|
);
|
||||||
if (height !== null) {
|
if (height !== null) {
|
||||||
this.dynamic_styles.sheet.insertRule(`:host { height: ${height}; }`);
|
this.dynamic_styles.sheet.insertRule(
|
||||||
|
`:host { height: ${height}; }`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +87,7 @@ export class RufflePlayer extends HTMLElement {
|
||||||
/**
|
/**
|
||||||
* Determine if this element is the fallback content of another Ruffle
|
* Determine if this element is the fallback content of another Ruffle
|
||||||
* player.
|
* player.
|
||||||
*
|
*
|
||||||
* This heurustic assumes Ruffle objects will never use their fallback
|
* This heurustic assumes Ruffle objects will never use their fallback
|
||||||
* content. If this changes, then this code also needs to change.
|
* content. If this changes, then this code also needs to change.
|
||||||
*/
|
*/
|
||||||
|
@ -111,10 +122,19 @@ export class RufflePlayer extends HTMLElement {
|
||||||
await this.play_swf_data(data);
|
await this.play_swf_data(data);
|
||||||
console.log("Playing " + url);
|
console.log("Playing " + url);
|
||||||
} else {
|
} else {
|
||||||
console.error("SWF load failed: " + response.status + " " + response.statusText + " for " + url);
|
console.error(
|
||||||
|
"SWF load failed: " +
|
||||||
|
response.status +
|
||||||
|
" " +
|
||||||
|
response.statusText +
|
||||||
|
" for " +
|
||||||
|
url
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.warn("Ignoring attempt to play a disconnected or suspended Ruffle element");
|
console.warn(
|
||||||
|
"Ignoring attempt to play a disconnected or suspended Ruffle element"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Serious error occured loading SWF file: " + err);
|
console.error("Serious error occured loading SWF file: " + err);
|
||||||
|
@ -153,7 +173,9 @@ export class RufflePlayer extends HTMLElement {
|
||||||
this.play_button.style.display = "block";
|
this.play_button.style.display = "block";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.warn("Ignoring attempt to play a disconnected or suspended Ruffle element");
|
console.warn(
|
||||||
|
"Ignoring attempt to play a disconnected or suspended Ruffle element"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +188,10 @@ export class RufflePlayer extends HTMLElement {
|
||||||
for (let attrib of elem.attributes) {
|
for (let attrib of elem.attributes) {
|
||||||
if (attrib.specified) {
|
if (attrib.specified) {
|
||||||
// Issue 468: Chrome "Click to Active Flash" box stomps on title attribute
|
// Issue 468: Chrome "Click to Active Flash" box stomps on title attribute
|
||||||
if (attrib.name === "title" && attrib.value === "Adobe Flash Player") {
|
if (
|
||||||
|
attrib.name === "title" &&
|
||||||
|
attrib.value === "Adobe Flash Player"
|
||||||
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +199,9 @@ export class RufflePlayer extends HTMLElement {
|
||||||
this.setAttribute(attrib.name, attrib.value);
|
this.setAttribute(attrib.name, attrib.value);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// The embed may have invalid attributes, so handle these gracefully.
|
// The embed may have invalid attributes, so handle these gracefully.
|
||||||
console.warn(`Unable to set attribute ${attrib.name} on Ruffle instance`);
|
console.warn(
|
||||||
|
`Unable to set attribute ${attrib.name} on Ruffle instance`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,7 +225,7 @@ export class RufflePlayer extends HTMLElement {
|
||||||
let out = match[1];
|
let out = match[1];
|
||||||
if (!match[3]) {
|
if (!match[3]) {
|
||||||
// Unitless -- add px for CSS.
|
// Unitless -- add px for CSS.
|
||||||
out += "px"
|
out += "px";
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -211,5 +238,9 @@ export class RufflePlayer extends HTMLElement {
|
||||||
* Returns whether the given filename ends in an "swf" extension.
|
* Returns whether the given filename ends in an "swf" extension.
|
||||||
*/
|
*/
|
||||||
export function is_swf_filename(filename) {
|
export function is_swf_filename(filename) {
|
||||||
return filename && typeof filename === "string" && filename.search(/\.swf\s*$/i) >= 0;
|
return (
|
||||||
|
filename &&
|
||||||
|
typeof filename === "string" &&
|
||||||
|
filename.search(/\.swf\s*$/i) >= 0
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { RufflePlayer } from "./ruffle-player";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents this particular version of Ruffle.
|
* Represents this particular version of Ruffle.
|
||||||
*
|
*
|
||||||
* Multiple APIs can be instantiated from different sources; e.g. an "extension"
|
* Multiple APIs can be instantiated from different sources; e.g. an "extension"
|
||||||
* version, versus a "local" version. This expresses to the Public API
|
* version, versus a "local" version. This expresses to the Public API
|
||||||
* negotiator (see `PublicAPI`) what this particular version of Ruffle is and
|
* negotiator (see `PublicAPI`) what this particular version of Ruffle is and
|
||||||
|
@ -13,7 +13,7 @@ import { RufflePlayer } from "./ruffle-player";
|
||||||
export class SourceAPI {
|
export class SourceAPI {
|
||||||
/**
|
/**
|
||||||
* Construct a Source API.
|
* Construct a Source API.
|
||||||
*
|
*
|
||||||
* @param {string} source_name The name of this particular source.
|
* @param {string} source_name The name of this particular source.
|
||||||
*/
|
*/
|
||||||
constructor(source_name) {
|
constructor(source_name) {
|
||||||
|
@ -23,32 +23,35 @@ export class SourceAPI {
|
||||||
get version() {
|
get version() {
|
||||||
return "0.1.0";
|
return "0.1.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start up a particular set of polyfills.
|
* Start up a particular set of polyfills.
|
||||||
*
|
*
|
||||||
* Polyfills, once enabled, may not be disabled. However, this function may
|
* Polyfills, once enabled, may not be disabled. However, this function may
|
||||||
* be called again with a different list to enable further polyfills.
|
* be called again with a different list to enable further polyfills.
|
||||||
*
|
*
|
||||||
* Do not run polyfills for more than one Ruffle source at a time.
|
* Do not run polyfills for more than one Ruffle source at a time.
|
||||||
*
|
*
|
||||||
* @param {array} polyfills A list of polyfills. See the `polyfills` module
|
* @param {array} polyfills A list of polyfills. See the `polyfills` module
|
||||||
* for a list of allowable strings.
|
* for a list of allowable strings.
|
||||||
*/
|
*/
|
||||||
polyfill(polyfills) {
|
polyfill(polyfills) {
|
||||||
polyfill(polyfills);
|
polyfill(polyfills);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Ruffle player element using this particular version of Ruffle.
|
* Create a Ruffle player element using this particular version of Ruffle.
|
||||||
*
|
*
|
||||||
* @returns {RufflePlayer} The player element. This is a DOM element that
|
* @returns {RufflePlayer} The player element. This is a DOM element that
|
||||||
* may be inserted into the current page as you wish.
|
* may be inserted into the current page as you wish.
|
||||||
*/
|
*/
|
||||||
create_player() {
|
create_player() {
|
||||||
let player_element_name = register_element("ruffle-player", RufflePlayer);
|
let player_element_name = register_element(
|
||||||
|
"ruffle-player",
|
||||||
|
RufflePlayer
|
||||||
|
);
|
||||||
let player = document.createElement(player_element_name);
|
let player = document.createElement(player_element_name);
|
||||||
|
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ export class VersionRange {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if a given version satisfies this range.
|
* Determine if a given version satisfies this range.
|
||||||
*
|
*
|
||||||
* @param {Version} fver A version object to test against.
|
* @param {Version} fver A version object to test against.
|
||||||
* @return {bool} Whether or not the given version matches this range.
|
* @return {bool} Whether or not the given version matches this range.
|
||||||
*/
|
*/
|
||||||
|
@ -22,18 +22,25 @@ export class VersionRange {
|
||||||
let comparator = this.requirements[i][j][0];
|
let comparator = this.requirements[i][j][0];
|
||||||
let version = this.requirements[i][j][1];
|
let version = this.requirements[i][j][1];
|
||||||
|
|
||||||
matches = matches && version.is_stable_or_compatible_prerelease(fver);
|
matches =
|
||||||
|
matches && version.is_stable_or_compatible_prerelease(fver);
|
||||||
|
|
||||||
if (comparator === "" || comparator === "=") {
|
if (comparator === "" || comparator === "=") {
|
||||||
matches = matches && version.is_equal(fver);
|
matches = matches && version.is_equal(fver);
|
||||||
} else if (comparator === ">") {
|
} else if (comparator === ">") {
|
||||||
matches = matches && version.has_precedence_over(fver);
|
matches = matches && version.has_precedence_over(fver);
|
||||||
} else if (comparator === ">=") {
|
} else if (comparator === ">=") {
|
||||||
matches = matches && (version.has_precedence_over(fver) || version.is_equal(fver));
|
matches =
|
||||||
|
matches &&
|
||||||
|
(version.has_precedence_over(fver) ||
|
||||||
|
version.is_equal(fver));
|
||||||
} else if (comparator === "<") {
|
} else if (comparator === "<") {
|
||||||
matches = matches && fver.has_precedence_over(version);
|
matches = matches && fver.has_precedence_over(version);
|
||||||
} else if (comparator === "<=") {
|
} else if (comparator === "<=") {
|
||||||
matches = matches && (fver.has_precedence_over(version) || version.is_equal(fver));
|
matches =
|
||||||
|
matches &&
|
||||||
|
(fver.has_precedence_over(version) ||
|
||||||
|
version.is_equal(fver));
|
||||||
} else if (comparator === "^") {
|
} else if (comparator === "^") {
|
||||||
matches = matches && version.is_compatible_with(fver);
|
matches = matches && version.is_compatible_with(fver);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +52,7 @@ export class VersionRange {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a requirement string into a version range.
|
* Parse a requirement string into a version range.
|
||||||
*
|
*
|
||||||
* @param {string} requirement The version requirements, consisting of a
|
* @param {string} requirement The version requirements, consisting of a
|
||||||
* series of space-separated strings, each one being a semver version
|
* series of space-separated strings, each one being a semver version
|
||||||
* optionally prefixed by a comparator (e.g. <, <=, >, >=, =, or ^), or the
|
* optionally prefixed by a comparator (e.g. <, <=, >, >=, =, or ^), or the
|
||||||
|
@ -66,7 +73,9 @@ export class VersionRange {
|
||||||
} else {
|
} else {
|
||||||
let match = /[0-9]/.exec(components[i]);
|
let match = /[0-9]/.exec(components[i]);
|
||||||
let comparator = components[i].slice(0, match.index).trim();
|
let comparator = components[i].slice(0, match.index).trim();
|
||||||
let version = Version.from_semver(components[i].slice(match.index).trim());
|
let version = Version.from_semver(
|
||||||
|
components[i].slice(match.index).trim()
|
||||||
|
);
|
||||||
|
|
||||||
requirement_set.push([comparator, version]);
|
requirement_set.push([comparator, version]);
|
||||||
}
|
}
|
||||||
|
@ -79,4 +88,4 @@ export class VersionRange {
|
||||||
|
|
||||||
return new VersionRange(requirement_set);
|
return new VersionRange(requirement_set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
export class Version {
|
export class Version {
|
||||||
/**
|
/**
|
||||||
* Construct a Version from components.
|
* Construct a Version from components.
|
||||||
*
|
*
|
||||||
* @param {number} major The major version
|
* @param {number} major The major version
|
||||||
* @param {number} minor The minor version
|
* @param {number} minor The minor version
|
||||||
* @param {number} patch The patch version
|
* @param {number} patch The patch version
|
||||||
|
@ -20,10 +20,10 @@ export class Version {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a version from a semver 2 compliant string.
|
* Construct a version from a semver 2 compliant string.
|
||||||
*
|
*
|
||||||
* This function is intended for use with semver 2 compliant strings.
|
* This function is intended for use with semver 2 compliant strings.
|
||||||
* Malformatted strins may still parse correctly, however.
|
* Malformatted strins may still parse correctly, however.
|
||||||
*
|
*
|
||||||
* @param {string} version_string A semver 2.0.0 compliant version string.
|
* @param {string} version_string A semver 2.0.0 compliant version string.
|
||||||
* @return {Version} A version object.
|
* @return {Version} A version object.
|
||||||
*/
|
*/
|
||||||
|
@ -32,7 +32,7 @@ export class Version {
|
||||||
pr_split = build_split[0].split("-"),
|
pr_split = build_split[0].split("-"),
|
||||||
version_split = pr_split[0].split("."),
|
version_split = pr_split[0].split("."),
|
||||||
version = [];
|
version = [];
|
||||||
|
|
||||||
version.push(parseInt(version_split[0]));
|
version.push(parseInt(version_split[0]));
|
||||||
|
|
||||||
if (version_split[1] != undefined) {
|
if (version_split[1] != undefined) {
|
||||||
|
@ -59,37 +59,51 @@ export class Version {
|
||||||
version.push(undefined);
|
version.push(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Version(version[0], version[1], version[2], version[3], version[4]);
|
return new Version(
|
||||||
|
version[0],
|
||||||
|
version[1],
|
||||||
|
version[2],
|
||||||
|
version[3],
|
||||||
|
version[4]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if a given version is compatible with this one.
|
* Returns true if a given version is compatible with this one.
|
||||||
*
|
*
|
||||||
* Compatibility is defined as having the same nonzero major version
|
* Compatibility is defined as having the same nonzero major version
|
||||||
* number, or if both major versions are zero, the same nonzero minor
|
* number, or if both major versions are zero, the same nonzero minor
|
||||||
* version number, or if both minor versions are zero, the same nonzero
|
* version number, or if both minor versions are zero, the same nonzero
|
||||||
* patch version number.
|
* patch version number.
|
||||||
*
|
*
|
||||||
* This implements the ^ operator in npm's semver package, with the
|
* This implements the ^ operator in npm's semver package, with the
|
||||||
* exception of the prerelease exclusion rule.
|
* exception of the prerelease exclusion rule.
|
||||||
*
|
*
|
||||||
* @param {Version} fver The other version to test against
|
* @param {Version} fver The other version to test against
|
||||||
* @return {bool}
|
* @return {bool}
|
||||||
*/
|
*/
|
||||||
is_compatible_with(fver) {
|
is_compatible_with(fver) {
|
||||||
return this.major !== 0 && this.major === fver.major ||
|
return (
|
||||||
this.major === 0 && fver.major === 0 && this.minor === fver.minor ||
|
(this.major !== 0 && this.major === fver.major) ||
|
||||||
this.major === 0 && fver.major === 0 && this.minor === 0 && fver.minor === 0 && this.patch === fver.patch;
|
(this.major === 0 &&
|
||||||
|
fver.major === 0 &&
|
||||||
|
this.minor === fver.minor) ||
|
||||||
|
(this.major === 0 &&
|
||||||
|
fver.major === 0 &&
|
||||||
|
this.minor === 0 &&
|
||||||
|
fver.minor === 0 &&
|
||||||
|
this.patch === fver.patch)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this version has precedence over (is newer than) another
|
* Returns true if this version has precedence over (is newer than) another
|
||||||
* version.
|
* version.
|
||||||
*
|
*
|
||||||
* Precedence is defined as in the Semver 2 spec. This implements the >
|
* Precedence is defined as in the Semver 2 spec. This implements the >
|
||||||
* operator in npm's semver package, with the exception of the prerelease
|
* operator in npm's semver package, with the exception of the prerelease
|
||||||
* exclusion rule.
|
* exclusion rule.
|
||||||
*
|
*
|
||||||
* @param {Version} fver The other version to test against
|
* @param {Version} fver The other version to test against
|
||||||
* @return {bool} True if this version has precedence over the other one.
|
* @return {bool} True if this version has precedence over the other one.
|
||||||
*/
|
*/
|
||||||
|
@ -116,18 +130,38 @@ export class Version {
|
||||||
return true;
|
return true;
|
||||||
} else if (this.pr_ident !== undefined && fver.pr_ident !== undefined) {
|
} else if (this.pr_ident !== undefined && fver.pr_ident !== undefined) {
|
||||||
let is_numeric = /^[0-9]*$/;
|
let is_numeric = /^[0-9]*$/;
|
||||||
for (let i = 0; i < this.pr_ident.length && i < fver.pr_ident.length; i += 1) {
|
for (
|
||||||
if (!is_numeric.test(this.pr_ident[i]) && is_numeric.test(fver.pr_ident[i])) {
|
let i = 0;
|
||||||
|
i < this.pr_ident.length && i < fver.pr_ident.length;
|
||||||
|
i += 1
|
||||||
|
) {
|
||||||
|
if (
|
||||||
|
!is_numeric.test(this.pr_ident[i]) &&
|
||||||
|
is_numeric.test(fver.pr_ident[i])
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
} else if (is_numeric.test(this.pr_ident[i]) && is_numeric.test(fver.pr_ident[i])) {
|
} else if (
|
||||||
if (parseInt(this.pr_ident[i]) > parseInt(fver.pr_ident[i])) {
|
is_numeric.test(this.pr_ident[i]) &&
|
||||||
|
is_numeric.test(fver.pr_ident[i])
|
||||||
|
) {
|
||||||
|
if (
|
||||||
|
parseInt(this.pr_ident[i]) > parseInt(fver.pr_ident[i])
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
} else if (parseInt(this.pr_ident[i]) < parseInt(fver.pr_ident[i])) {
|
} else if (
|
||||||
|
parseInt(this.pr_ident[i]) < parseInt(fver.pr_ident[i])
|
||||||
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (is_numeric.test(this.pr_ident[i]) && !is_numeric.test(fver.pr_ident[i])) {
|
} else if (
|
||||||
|
is_numeric.test(this.pr_ident[i]) &&
|
||||||
|
!is_numeric.test(fver.pr_ident[i])
|
||||||
|
) {
|
||||||
return false;
|
return false;
|
||||||
} else if (!is_numeric.test(this.pr_ident[i]) && !is_numeric.test(fver.pr_ident[i])) {
|
} else if (
|
||||||
|
!is_numeric.test(this.pr_ident[i]) &&
|
||||||
|
!is_numeric.test(fver.pr_ident[i])
|
||||||
|
) {
|
||||||
if (this.pr_ident[i] > fver.pr_ident[i]) {
|
if (this.pr_ident[i] > fver.pr_ident[i]) {
|
||||||
return true;
|
return true;
|
||||||
} else if (this.pr_ident[i] < fver.pr_ident[i]) {
|
} else if (this.pr_ident[i] < fver.pr_ident[i]) {
|
||||||
|
@ -135,7 +169,7 @@ export class Version {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.pr_ident.length > fver.pr_ident.length;
|
return this.pr_ident.length > fver.pr_ident.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,27 +178,29 @@ export class Version {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests if a given version is equivalent to this one.
|
* Tests if a given version is equivalent to this one.
|
||||||
*
|
*
|
||||||
* Build and prerelease tags are ignored.
|
* Build and prerelease tags are ignored.
|
||||||
*
|
*
|
||||||
* @param {Version} fver The other version to test against
|
* @param {Version} fver The other version to test against
|
||||||
* @return {bool} True if the given version is equivalent.
|
* @return {bool} True if the given version is equivalent.
|
||||||
*/
|
*/
|
||||||
is_equal(fver) {
|
is_equal(fver) {
|
||||||
return this.major === fver.major &&
|
return (
|
||||||
|
this.major === fver.major &&
|
||||||
this.minor === fver.minor &&
|
this.minor === fver.minor &&
|
||||||
this.patch === fver.patch;
|
this.patch === fver.patch
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests if a given version is stable or a compatible prerelease for this
|
* Tests if a given version is stable or a compatible prerelease for this
|
||||||
* version.
|
* version.
|
||||||
*
|
*
|
||||||
* This implements the prerelease exclusion rule of NPM semver: a
|
* This implements the prerelease exclusion rule of NPM semver: a
|
||||||
* prerelease version can only pass this check if the major/minor/patch
|
* prerelease version can only pass this check if the major/minor/patch
|
||||||
* components of both versions are the same. Otherwise, the prerelease
|
* components of both versions are the same. Otherwise, the prerelease
|
||||||
* version always fails.
|
* version always fails.
|
||||||
*
|
*
|
||||||
* @param {Version} fver The other version to test against
|
* @param {Version} fver The other version to test against
|
||||||
* @return {bool} True if the given version is either stable, or a
|
* @return {bool} True if the given version is either stable, or a
|
||||||
* prerelease in the same series as this one.
|
* prerelease in the same series as this one.
|
||||||
|
@ -173,9 +209,11 @@ export class Version {
|
||||||
if (fver.pr_ident === undefined) {
|
if (fver.pr_ident === undefined) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return this.major === fver.major &&
|
return (
|
||||||
|
this.major === fver.major &&
|
||||||
this.minor === fver.minor &&
|
this.minor === fver.minor &&
|
||||||
this.patch === fver.patch;
|
this.patch === fver.patch
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "ruffle",
|
"name": "ruffle",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"description": "Root project of ruffle web",
|
"description": "Root project of ruffle web",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-eslint": "^10.1.0",
|
"babel-eslint": "^10.1.0",
|
||||||
"eslint": "^7.0.0",
|
"eslint": "^7.0.0",
|
||||||
"eslint-config-prettier": "^6.11.0",
|
"eslint-config-prettier": "^6.11.0",
|
||||||
"eslint-plugin-prettier": "^3.1.3",
|
"eslint-plugin-prettier": "^3.1.3",
|
||||||
"prettier": "^2.0.5"
|
"prettier": "^2.0.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,5 +2,9 @@ import { PublicAPI } from "../../js-src/public-api";
|
||||||
import { SourceAPI } from "../../js-src/source-api";
|
import { SourceAPI } from "../../js-src/source-api";
|
||||||
import { public_path } from "../../js-src/public-path";
|
import { public_path } from "../../js-src/public-path";
|
||||||
|
|
||||||
window.RufflePlayer = PublicAPI.negotiate(window.RufflePlayer, "local", new SourceAPI("local"));
|
window.RufflePlayer = PublicAPI.negotiate(
|
||||||
__webpack_public_path__ = public_path(window.RufflePlayer.config, "local");
|
window.RufflePlayer,
|
||||||
|
"local",
|
||||||
|
new SourceAPI("local")
|
||||||
|
);
|
||||||
|
__webpack_public_path__ = public_path(window.RufflePlayer.config, "local");
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
{
|
{
|
||||||
"name": "ruffle-selfhosted",
|
"name": "ruffle-selfhosted",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"description": "Put Flash back on the web with Ruffle on your own site",
|
"description": "Put Flash back on the web with Ruffle on your own site",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "webpack",
|
"build": "webpack",
|
||||||
"serve": "webpack-dev-server"
|
"serve": "webpack-dev-server"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@wasm-tool/wasm-pack-plugin": "^1.3.1",
|
"@wasm-tool/wasm-pack-plugin": "^1.3.1",
|
||||||
"clean-webpack-plugin": "^3.0.0",
|
"clean-webpack-plugin": "^3.0.0",
|
||||||
"webpack": "^4.43.0",
|
"webpack": "^4.43.0",
|
||||||
"webpack-cli": "^3.3.11",
|
"webpack-cli": "^3.3.11",
|
||||||
"webpack-dev-server": "^3.11.0"
|
"webpack-dev-server": "^3.11.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
/* eslint-env node */
|
/* eslint-env node */
|
||||||
|
|
||||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
||||||
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
|
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
|
||||||
const path = require('path');
|
const path = require("path");
|
||||||
|
|
||||||
module.exports = (env, argv) => {
|
module.exports = (env, argv) => {
|
||||||
let mode = "production";
|
let mode = "production";
|
||||||
if (argv && argv.mode) {
|
if (argv && argv.mode) {
|
||||||
mode = argv.mode;
|
mode = argv.mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Building ${mode}...`);
|
console.log(`Building ${mode}...`);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
entry: path.resolve(__dirname, "js/ruffle.js"),
|
entry: path.resolve(__dirname, "js/ruffle.js"),
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, "dist"),
|
path: path.resolve(__dirname, "dist"),
|
||||||
filename: "ruffle.js",
|
filename: "ruffle.js",
|
||||||
chunkFilename: "core.ruffle.[contenthash].js",
|
chunkFilename: "core.ruffle.[contenthash].js",
|
||||||
jsonpFunction: "RufflePlayerLoader",
|
jsonpFunction: "RufflePlayerLoader",
|
||||||
},
|
},
|
||||||
mode: mode,
|
mode: mode,
|
||||||
plugins: [
|
plugins: [
|
||||||
new CleanWebpackPlugin(),
|
new CleanWebpackPlugin(),
|
||||||
new WasmPackPlugin({
|
new WasmPackPlugin({
|
||||||
crateDirectory: path.resolve(__dirname, ".."),
|
crateDirectory: path.resolve(__dirname, ".."),
|
||||||
outName: "ruffle",
|
outName: "ruffle",
|
||||||
forceMode: mode,
|
forceMode: mode,
|
||||||
})
|
}),
|
||||||
]
|
],
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue