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,9 +1,9 @@
|
||||||
/* 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";
|
||||||
|
@ -22,15 +22,17 @@ module.exports = (env, argv) => {
|
||||||
mode: mode,
|
mode: mode,
|
||||||
plugins: [
|
plugins: [
|
||||||
new CleanWebpackPlugin(),
|
new CleanWebpackPlugin(),
|
||||||
new CopyWebpackPlugin([{
|
new CopyWebpackPlugin([
|
||||||
|
{
|
||||||
from: path.resolve(__dirname, "www/index.html"),
|
from: path.resolve(__dirname, "www/index.html"),
|
||||||
to: "index.html"
|
to: "index.html",
|
||||||
}]),
|
},
|
||||||
|
]),
|
||||||
new WasmPackPlugin({
|
new WasmPackPlugin({
|
||||||
crateDirectory: path.resolve(__dirname, ".."),
|
crateDirectory: path.resolve(__dirname, ".."),
|
||||||
outName: "ruffle",
|
outName: "ruffle",
|
||||||
forceMode: mode,
|
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,7 +70,8 @@ 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";
|
||||||
|
@ -72,9 +80,8 @@ function sampleFileSelected() {
|
||||||
|
|
||||||
localFileInput.value = null;
|
localFileInput.value = null;
|
||||||
loadRemoteFile(selected_value);
|
loadRemoteFile(selected_value);
|
||||||
}
|
} else {
|
||||||
else {
|
replacePlayer();
|
||||||
replacePlayer()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,15 +96,14 @@ function localFileSelected() {
|
||||||
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))
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,26 +16,40 @@
|
||||||
*/
|
*/
|
||||||
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,8 +1,8 @@
|
||||||
/* 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";
|
||||||
|
@ -27,7 +27,7 @@ module.exports = (env, argv) => {
|
||||||
crateDirectory: path.resolve(__dirname, ".."),
|
crateDirectory: path.resolve(__dirname, ".."),
|
||||||
outName: "ruffle",
|
outName: "ruffle",
|
||||||
forceMode: mode,
|
forceMode: mode,
|
||||||
})
|
}),
|
||||||
]
|
],
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -128,12 +128,33 @@ 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`.
|
||||||
|
@ -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,22 +1,22 @@
|
||||||
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.
|
||||||
|
@ -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]);
|
||||||
|
|
|
@ -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 {
|
||||||
|
@ -90,7 +93,8 @@ export class PublicAPI {
|
||||||
* 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)) {
|
||||||
|
@ -129,7 +133,11 @@ 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);
|
||||||
|
@ -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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -237,7 +245,10 @@ export class PublicAPI {
|
||||||
*/
|
*/
|
||||||
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);
|
||||||
|
@ -251,7 +262,10 @@ export class PublicAPI {
|
||||||
// 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"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,11 @@
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
|
|
@ -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 {
|
||||||
|
@ -37,7 +44,12 @@ export default class RuffleEmbed extends RufflePlayer {
|
||||||
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 {
|
||||||
|
@ -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}; }`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,10 @@ export class SourceAPI {
|
||||||
* 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;
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,13 @@ 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]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,9 +83,17 @@ export class Version {
|
||||||
* @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)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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]) {
|
||||||
|
@ -151,9 +185,11 @@ export class Version {
|
||||||
* @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
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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(
|
||||||
|
window.RufflePlayer,
|
||||||
|
"local",
|
||||||
|
new SourceAPI("local")
|
||||||
|
);
|
||||||
__webpack_public_path__ = public_path(window.RufflePlayer.config, "local");
|
__webpack_public_path__ = public_path(window.RufflePlayer.config, "local");
|
|
@ -1,8 +1,8 @@
|
||||||
/* 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";
|
||||||
|
@ -27,7 +27,7 @@ module.exports = (env, argv) => {
|
||||||
crateDirectory: path.resolve(__dirname, ".."),
|
crateDirectory: path.resolve(__dirname, ".."),
|
||||||
outName: "ruffle",
|
outName: "ruffle",
|
||||||
forceMode: mode,
|
forceMode: mode,
|
||||||
})
|
}),
|
||||||
]
|
],
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue