@afterswf/embed 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -4
- package/dist/HISTORY.txt +18 -0
- package/dist/VERSIONS.txt +5 -5
- package/dist/embed.js +1 -1
- package/dist/embed.js.map +1 -1
- package/dist/embed.mjs +1 -1
- package/dist/embed.mjs.map +1 -1
- package/dist/runtime.js +2 -2
- package/dist/runtime.js.map +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +7 -6
- package/dist/assets/progressBg.jpg +0 -0
- package/dist/assets/progressLine.jpg +0 -0
- package/dist/assets/splash.jpg +0 -0
package/README.md
CHANGED
|
@@ -12,9 +12,10 @@ better drop-in replacement for the original SWFObject.
|
|
|
12
12
|
| SWFObject 2.x | `swfobject` (and `swfObject`) supports `embedSWF`, `registerObject`, `createSWF`, `removeSWF`, `getObjectById`, `hasFlashPlayerVersion`, `getFlashPlayerVersion` (which reports Flash Player 32), `addDomLoadEvent`, `addLoadEvent` and `getQueryParamValue`, with SWFObject's callback behaviour |
|
|
13
13
|
| SWFObject 1.5 | `new SWFObject(swf, id, width, height, version, bgcolor)`, with `addParam`, `addVariable` and `write` |
|
|
14
14
|
| Hard-coded embeds | Flash `<object>` and `<embed>` markup is replaced with players, including markup added after the page has loaded |
|
|
15
|
-
| Flash parameters | `flashvars`, `bgcolor
|
|
15
|
+
| Flash parameters | `flashvars`, `bgcolor` and `scale` work as in Flash, except that `exactFit` crops like `noBorder`; others, such as `salign` and `wmode`, are accepted and ignored. Attributes such as `id`, `class` and `name` are kept |
|
|
16
16
|
| ExternalInterface | `ExternalInterface.call()` in AS2 and AS3 runs in the page, and functions added with `addCallback()` become methods of the player element, with their return values |
|
|
17
17
|
| Load errors | Errors loading a SWF fire the player element's `error` event |
|
|
18
|
+
| Loading screen | A plain loading bar in the page's text colour on a transparent background, instead of the AwayFL splash. Once loaded, the stage colour fills any space around the stage, as in Flash. Set `progress` to `false` to hide the bar, or `splash` to an image URL to show one |
|
|
18
19
|
|
|
19
20
|
### More advanced AS3 content
|
|
20
21
|
|
|
@@ -29,6 +30,7 @@ better drop-in replacement for the original SWFObject.
|
|
|
29
30
|
| Event targets | Events from an aggregated `EventDispatcher` report the right `currentTarget`, which GreenSock relies on | [playerglobal](https://github.com/afterswf/playerglobal) |
|
|
30
31
|
| Mouse cursors | `flash.ui.MouseCursorData` is available, so `Mouse.registerCursor` works | [playerglobal](https://github.com/afterswf/playerglobal) |
|
|
31
32
|
| Removing children | `removeChild` no longer throws error #2025 for children that have already been detached internally, which could stop playback | [playerglobal](https://github.com/afterswf/playerglobal) |
|
|
33
|
+
| AS1/2 | SWFs loaded with `loadMovie` use their own symbols, `setNewTextFormat` only changes the properties that are set, and the drawing API no longer throws errors | [avm1](https://github.com/afterswf/avm1) |
|
|
32
34
|
|
|
33
35
|
### Using it as a module
|
|
34
36
|
|
|
@@ -68,8 +70,11 @@ their `prepare` scripts:
|
|
|
68
70
|
npx yarn@1 install --frozen-lockfile
|
|
69
71
|
```
|
|
70
72
|
|
|
71
|
-
To build without the sibling checkouts, point the packages at
|
|
72
|
-
(`"@awayfl/avm2": "
|
|
73
|
+
To build without the sibling checkouts, point the packages at the published forks instead
|
|
74
|
+
(`"@awayfl/avm2": "npm:@afterswf/avm2@^0.2.241"` etc.), or at GitHub for unreleased changes
|
|
75
|
+
(`"@awayfl/avm2": "github:afterswf/avm2#main"` etc.), which npm will clone, build and pack.
|
|
76
|
+
|
|
77
|
+
To publish a release, follow [RELEASING.md](./RELEASING.md).
|
|
73
78
|
|
|
74
79
|
The build uses the official `@rollup/plugin-typescript` instead of `rollup-plugin-typescript2`, which fails
|
|
75
80
|
with current versions of Node and rollup, and pins rollup and TypeScript to versions known to work.
|
|
@@ -97,7 +102,7 @@ There are 3 main ways to use AwayFL on your site:
|
|
|
97
102
|
* Hard-coded Flash `<object>` and `<embed>` markup is replaced with players too, including markup added to the page later. To turn this off, set `AWAY_EMBED_CFG.autoUpgrade = false`.
|
|
98
103
|
* Flash parameters (`<param>`s, SWFObject's `params`, or `<embed>` attributes):
|
|
99
104
|
* `flashvars` become `loaderInfo.parameters` in AS3 and `_root` variables in AS1/2, as do any query string parameters in the SWF's URL
|
|
100
|
-
* `bgcolor` overrides the SWF's background colour, and `scale`
|
|
105
|
+
* `bgcolor` overrides the SWF's background colour, and `scale` sets the stage's scale mode (`salign` isn't supported yet, so the stage is centred)
|
|
101
106
|
* others, such as `wmode`, `allowScriptAccess` and `quality`, are accepted and ignored
|
|
102
107
|
* Attributes such as `id`, `class` (or SWFObject's `styleclass`), `name` and `style` are copied onto the `<awayfl-player>` element.
|
|
103
108
|
* `ExternalInterface` (AS2 and AS3) connects to the page as it did with the Flash plugin: `ExternalInterface.call()` runs in the page, and functions added with `ExternalInterface.addCallback()` become methods of the player element, e.g. `swfobject.getObjectById('game').myCallback()`.
|
package/dist/HISTORY.txt
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
Bundle version: 0.1.5
|
|
2
|
+
Build at: Mon Oct 26 2026 14:02:27 GMT+0000 (Greenwich Mean Time)
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Bundle version: 0.1.4
|
|
8
|
+
Build at: Mon Oct 26 2026 12:35:05 GMT+0000 (Greenwich Mean Time)
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
Bundle version: 0.1.4
|
|
14
|
+
Build at: Mon Oct 26 2026 11:39:55 GMT+0000 (Greenwich Mean Time)
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
1
19
|
Bundle version: 0.1.4
|
|
2
20
|
Build at: Sun Oct 25 2026 19:22:51 GMT+0000 (Greenwich Mean Time)
|
|
3
21
|
---
|
package/dist/VERSIONS.txt
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
Bundle version: 0.1.
|
|
2
|
-
Build at:
|
|
1
|
+
Bundle version: 0.1.5
|
|
2
|
+
Build at: Mon Oct 26 2026 14:02:26 GMT+0000 (Greenwich Mean Time)
|
|
3
3
|
==========
|
|
4
4
|
Modules:
|
|
5
|
-
@awayfl/avm1:0.2.
|
|
5
|
+
@awayfl/avm1:0.2.182
|
|
6
6
|
@awayfl/avm2:0.2.241
|
|
7
7
|
@awayfl/awayfl-player:0.2.54
|
|
8
|
-
@awayfl/playerglobal:0.2.
|
|
8
|
+
@awayfl/playerglobal:0.2.461
|
|
9
9
|
@awayfl/swf-loader:0.4.135
|
|
10
10
|
@awayjs/core:0.9.61
|
|
11
11
|
@awayjs/graphics:0.5.101
|
|
12
12
|
@awayjs/materials:0.6.24
|
|
13
13
|
@awayjs/renderer:0.11.99
|
|
14
|
-
@awayjs/scene:0.13.
|
|
14
|
+
@awayjs/scene:0.13.326
|
|
15
15
|
@awayjs/stage:0.11.172
|
|
16
16
|
@awayjs/view:0.6.90
|
package/dist/embed.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var AwayEmbed=function(t){"use strict";var e="undefined"!=typeof document?document.currentScript:null;const n=["application/x-shockwave-flash","application/futuresplash"],r=/\.swf([?#]|$)/i,i=["classid","codebase","type","pluginspage","data","src","width","height"],s=["flashvars","bgcolor","scale","salign","wmode","quality","menu","play","loop","base","allowscriptaccess","allowfullscreen","allowfullscreeninteractive","allownetworking","devicefont","seamlesstabbing","swliveconnect","swremote","swfversion","expressinstall"];function o(t){const e={};for(const n of Array.from(t.children))"param"===n.localName&&n.getAttribute("name")&&(e[n.getAttribute("name").toLowerCase()]=n.getAttribute("value")||"");return e}function a(t){const e=t.localName;if("object"!==e&&"embed"!==e)return!1;if(n.indexOf((t.getAttribute("type")||"").toLowerCase())>-1||"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"===(t.getAttribute("classid")||"").toLowerCase())return!0;const i="embed"===e?t.getAttribute("src"):t.getAttribute("data")||o(t).movie;return r.test(i||"")}function l(t){for(let e=t.parentElement;e;e=e.parentElement)if(a(e))return!0;return!1}function c(t,e){const n=document.createElement("awayfl-player");for(const e in t)try{n.setAttribute(e,t[e])}catch(t){console.warn(`[AwayFL] Skipping invalid attribute "${e}"`)}for(const t in e){const r=document.createElement("param");r.name=t,r.value=e[t],n.appendChild(r)}return n}function d(t){const e=function(t){const e={attributes:{},params:{}},n=[t].concat(Array.from(t.querySelectorAll("object, embed")).filter(a)),r=(t,e,n)=>{e in t||(t[e]=n)};for(const t of n){const n="embed"===t.localName,a=o(t);e.src=e.src||t.getAttribute(n?"src":"data")||a.movie||a.src;for(const o of Array.from(t.attributes)){const t=o.name.toLowerCase();"width"===t||"height"===t?r(e.attributes,t,o.value):n&&s.indexOf(t)>-1?r(e.params,t,o.value):-1===i.indexOf(t)&&r(e.attributes,t,o.value)}for(const t in a)"movie"!==t&&"src"!==t&&r(e.params,t,a[t])}return e}(t);if(!e.src)return null;const n=c(Object.assign({src:e.src},e.attributes),e.params);return t.parentNode.replaceChild(n,t),n}function u(t=document){t instanceof Element&&a(t)?l(t)||d(t):t.querySelectorAll("object, embed").forEach(t=>{t.isConnected&&a(t)&&!l(t)&&d(t)})}const h=[32,0,0],f=navigator.userAgent.toLowerCase(),g=(navigator.platform||"").toLowerCase(),m={w3:!0,pv:h.slice(),wk:!!/webkit/.test(f)&&parseFloat(f.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")),ie:!1,win:/win/.test(g||f),mac:/mac/.test(g||f)};let p=!1,b=!0,_=null,w=null;function y(){return"loading"!==document.readyState}function C(t){return"string"==typeof t?document.getElementById(t):t}function v(t){return!!t&&"awayfl-player"===t.localName}function E(t){y()?t():document.addEventListener("DOMContentLoaded",()=>t())}function A(t){const e=String(t).split("."),n=[parseInt(e[0],10),parseInt(e[1],10)||0,parseInt(e[2],10)||0],r=h;return r[0]>n[0]||r[0]===n[0]&&r[1]>n[1]||r[0]===n[0]&&r[1]===n[1]&&r[2]>=n[2]}function L(t,e,n,r){const i=document.head;if(!i)return;const s="string"==typeof n&&n?n:"screen";r&&(_=null,w=null),_&&w===s||(_=document.createElement("style"),_.media=s,w=s,i.appendChild(_)),_.appendChild(document.createTextNode(t+" {"+e+"}"))}function O(t,e){if(!b||!t)return;const n=e?"visible":"hidden",r=document.getElementById(t);y()&&r?r.style.visibility=n:L("#"+CSS.escape(t),"visibility:"+n)}function F(t,e,n){const r=C(n);if(!r||!t||!t.data)return;void 0===t.id&&r.id&&(t.id=r.id);const i={src:""+t.data};for(const e in t){const n=e.toLowerCase();"styleclass"===n?i.class=""+t[e]:"classid"!==n&&"data"!==n&&(i[e]=""+t[e])}const s={};for(const t in e)"movie"!==t.toLowerCase()&&(s[t]=""+e[t]);const o=c(i,s);return r.parentNode.replaceChild(o,r),o}function S(t){return/[\\\"<>\.;]/.test(t)?encodeURIComponent(t):t}const B={registerObject:function(t,e,n,r){t&&e?(O(t,!1),E(()=>{const n={success:!1,id:t};if(A(e)){let e=document.getElementById(t);e&&!v(e)&&(e=a(e)?d(e):null),e&&(n.success=!0,n.ref=e)}O(t,!0),r&&r(n)})):r&&r({success:!1,id:t})},getObjectById:function(t){const e=document.getElementById(t);return v(e)?e:null},embedSWF:function(t,e,n,r,i,s,o,a,l,c){const d="string"==typeof e?e:e&&e.id,u={success:!1,id:d};t&&e&&n&&r?(O(d,!1),E(()=>{const s=Object.assign({},l,{data:t,width:""+n,height:""+r}),h=Object.assign({},a),f=function(t){return t&&"object"==typeof t?Object.keys(t).map(e=>e+"="+(p?encodeURIComponent(t[e]):t[e])).join("&"):""}(o);if(f&&(h.flashvars=void 0!==h.flashvars?h.flashvars+"&"+f:f),!i||A(i)){const t=F(s,h,e);s.id==d&&O(d,!0),u.success=!!t,t&&(u.ref=t)}else O(d,!0);c&&c(u)})):c&&c(u)},switchOffAutoHideShow(){b=!1},enableUriEncoding(t){p=void 0===t||!!t},ua:m,getFlashPlayerVersion:()=>({major:h[0],minor:h[1],release:h[2]}),hasFlashPlayerVersion:A,createSWF:(t,e,n)=>F(t,e,n),showExpressInstall(t,e,n,r){console.warn("[AwayFL] Express Install is not needed or supported"),r&&r({success:!1,id:n})},removeSWF:function(t){const e=document.getElementById(t);e&&(v(e)||a(e))&&e.remove()},createCSS:L,addDomLoadEvent:E,addLoadEvent:function(t){"complete"===document.readyState?setTimeout(t):window.addEventListener("load",()=>t())},getQueryParamValue:function(t){let e=document.location.search||document.location.hash;if(e){if(/\?/.test(e)&&(e=e.split("?")[1]),null==t)return S(e);const n=e.split("&");for(let e=0;e<n.length;e++)if(n[e].substring(0,n[e].indexOf("="))==t)return S(n[e].substring(n[e].indexOf("=")+1))}return""},expressInstallCallback(){}};class j{constructor(t,e,n,r,i,s,o){this._attributes={},this._params={},this._variables={},this.setAttribute("swf",t),this.setAttribute("id",e),this.setAttribute("width",""+n),this.setAttribute("height",""+r),this.setAttribute("version",i),s&&this.addParam("bgcolor",s),this.addParam("quality",o||"high")}setAttribute(t,e){this._attributes[t]=e}getAttribute(t){return this._attributes[t]||""}addParam(t,e){this._params[t]=e}getParams(){return this._params}addVariable(t,e){this._variables[t]=e}getVariable(t){return this._variables[t]||""}getVariables(){return this._variables}getVariablePairs(){return Object.keys(this._variables).map(t=>t+"="+this._variables[t])}useExpressInstall(t){}write(t){const e=C(t);if(!e)return!1;const n=this.getAttribute("id"),r=Object.assign({},this._params),i=this.getVariablePairs().join("&");i&&(r.flashvars=i);const s=c({src:this.getAttribute("swf"),id:n,name:n,width:this.getAttribute("width"),height:this.getAttribute("height")},r);return e.innerHTML="",e.appendChild(s),!0}}const I=new URL(".",e&&e.src||new URL("embed.js",document.baseURI).href).href,N={movie:"src",data:"src",flashvars:"flashvars",bgcolor:"bgcolor",scale:"scaleMode",salign:"stageAlign"},U={showall:"showAll",all:"showAll",noborder:"noBorder",exactfit:"exactFit",noscale:"noScale"};function q(t){const e={};if("string"==typeof t)new URLSearchParams(t).forEach((t,n)=>{e[n]=t});else if(t)for(const n in t)e[n]=String(t[n]);return e}function P(t){const e=/^#?([0-9a-f]{6})$/i.exec(t||"");return e?parseInt(e[1],16):null}function x(t){return/^\d+(\.\d+)?$/.test(""+t)?t+"px":""+t}class k extends HTMLElement{static get observedAttributes(){return["src","width","height"]}get player(){return this._player}get config(){return this._runConfig}set config(t){this._runConfig=t}get src(){return this._runConfig.src||this.getAttribute("src")}set src(t){this._runConfig.src=t}set width(t){this._runConfig.width=t}get width(){return this._runConfig.width||this.getAttribute("width")}set height(t){this._runConfig.height=t}get height(){return this._runConfig.height||this.getAttribute("height")}set runtimeBaseUrl(t){this._runConfig.runtimeBaseUrl=t}get runtimeBaseUrl(){return this._runConfig.runtimeBaseUrl}constructor(){super(),this._runConfig={},this.onError=this.onError.bind(this),this._root=this.attachShadow({mode:"closed"})}_getRuntimeUrl(){const t=this._runConfig.runtimeBaseUrl;return{loader:new URL("loader.js",t).href,runtime:new URL("runtime.js",t).href,baseUrl:t}}_dropPlayer(){this._gameFrame&&(this._gameFrame.remove(),this._player=null)}onError(t){const e=this._runConfig.onError&&self[this._runConfig.onError];"function"==typeof e&&e(t),this.dispatchEvent(new ErrorEvent("error",{error:new Error("Awayfl runtime error"),message:(null==t?void 0:t.message)||t}))}_attachRuntimeEvents(){const t=this._gameFrame.contentWindow;t.addEventListener("awayfl-player-init",({detail:t})=>{this._player=t},{once:!0}),t.addEventListener("awayfl-player-load",()=>{const t=this._runConfig.onLoad&&self[this._runConfig.onLoad];"function"==typeof t&&t(),this.dispatchEvent(new CustomEvent("load")),this._gameFrame.style.display=""},{once:!0}),t.addEventListener("awayfl-player-error",({detail:t})=>this.onError(t),{once:!0}),t.addEventListener("awayfl-player-progress",({detail:t})=>{const e=this._runConfig.onProgress&&self[this._runConfig.onProgress];"function"==typeof e&&e(t),this.dispatchEvent(new CustomEvent("progress",{detail:t}))})}_buildTemplate(t){const e='<!DOCTYPE html>\n<head>\n\t<meta name="viewport"\n\t\tcontent="height=device-height, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui" />\n\t<title>AwayFL Embedded Player 0.1.4</title>\n\t<style>\n\t\t* {\n\t\t\tmargin: 0;\n\t\t\tpadding: 0;\n\t\t}\n\n\t\tcanvas {\n\t\t\toutline: none\n\t\t}\n\n\t\thtml, body, #container {\n\t\t\tmargin: 0;\n\t\t\toverflow: hidden;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\n\t\t#splash__image {\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t\tposition: absolute;\n\t\t\tbackground-size: contain;\n\t\t\tbackground-position: center;\n\t\t\tbackground-repeat: no-repeat;\n\t\t\tvisibility: visible;\n\t\t\ttransition: all 0.5s;\n\t\t\tz-index: 10;\n\t\t}\n\n\t\t#progress__root {\n\t\t\tposition: absolute;\n\t\t}\n\n\t\t#progress__line {\n\t\t\twidth: 0;\n\t\t\theight: 100%;\n\t\t\ttransition: all 0.5s;\n\t\t}\n\t</style>\n\t<script src="__LOADER_URL__"><\/script>\n</head>\n\n<body>\n\t<div id="splash__image">\n\t\t<div id="progress__root">\n\t\t\t<div id="progress__line"></div>\n\t\t</div>\n\t</div>\n\t<script>\n\t\twindow.addEventListener("load", () => {\n\n\t\t\tconst config = JSON.parse(__GAME_CONFIG__);\n\t\t\tconst fail = (error) => {\n\t\t\t\tconsole.error(\'[AwayFL]\', error);\n\t\t\t\twindow.dispatchEvent(new CustomEvent(\'awayfl-player-error\', {detail: error}));\n\t\t\t};\n\n\t\t\tAWAYFL.LegacyLoader.init(config);\n\t\t\tAWAYFL.LegacyLoader.runGame((fill) => {\n\t\t\t\twindow.dispatchEvent(new CustomEvent(\'awayfl-player-progress\', {detail: fill}));\n\t\t\t}, (config, hideLoader) => {\n\t\t\t\tconst player = new AWAYFL.Player(document, config);\n\t\t\t\twindow.dispatchEvent(new CustomEvent(\'awayfl-player-init\', {detail: player}));\n\t\t\t\tplayer\n\t\t\t\t\t.loadAndPlay()\n\t\t\t\t\t.then((_, hide) => {\n\t\t\t\t\t\twindow.dispatchEvent(new CustomEvent(\'awayfl-player-load\'));\n\t\t\t\t\t\thide && hide() || window.swfParseComplete && window.swfParseComplete();;\n\t\t\t\t\t})\n\t\t\t\t\t.catch(fail);\n\t\t\t}).catch(fail);\n\t\t});\n\t<\/script>\n</body>',n=this._getRuntimeUrl(),r={width:t.clientWidth,height:t.clientHeight,backgroundColor:this._runConfig.backgroundColor,splash:this._runConfig.splash,progress:this._runConfig.progress,runtime:[n.runtime],binary:[{path:this._runConfig.src,resourceType:"GAME",name:"Game",meta:{}}],baseUrl:n.baseUrl,maxStageScale:+this._runConfig.maxStageScale,flashvars:q(this._runConfig.flashvars),stageScaleMode:this._runConfig.scaleMode,stageAlign:this._runConfig.stageAlign,stageColor:P(this._runConfig.bgcolor),runtimeFlags:{defaultSmoothBitmap:!!this._runConfig.smoothBitmaps,enableBlends:!!this._runConfig.enableBlends,enableFilters:!!this._runConfig.enableFilters}};return e.replace(/__LOADER_URL__/,n.loader).replace(/__GAME_CONFIG__/,JSON.stringify(JSON.stringify(r)))}_constructPlayer(){const t=this._root,e=document.createElement("iframe");e.style.display=this._runConfig.hideBeforeLoad?"none":"",this._gameFrame=e,t.appendChild(e),e.addEventListener("load",this._attachRuntimeEvents.bind(this),{once:!0}),e.addEventListener("error",this.onError),e.srcdoc=this._buildTemplate(e)}_configKey(t){const e=t.toLowerCase();return e in N?N[e]:Object.keys(k.BINDING_CONFIG).find(t=>t.toLowerCase()===e)}_mapAttrs(){const t=this.querySelectorAll("param"),e=this._runConfig;t.forEach(t=>{const n=this._configKey(t.name);n&&(e[n]=t.value)}),this.getAttributeNames().forEach(t=>{const n=this._configKey(t);n&&(e[n]=this.getAttribute(t))})}_loadGlobalConfig(){const t=window.AWAY_EMBED_CFG||{},e=k.BINDING_CONFIG;for(const[n,r]of Object.entries(t))n in e&&(this._runConfig[n]=r)}_setDefaults(){const t=k.BINDING_CONFIG;for(const e in t){if(t[e].required&&void 0===this._runConfig[e])throw`Parameter ${e} is required!`;void 0===this._runConfig[e]&&(this._runConfig[e]=t[e].default)}}_normalizeConfig(){const t=this._runConfig;t.runtimeBaseUrl=new URL(t.runtimeBaseUrl.replace(/\/?$/,"/"),document.baseURI).href,void 0===t.splash&&(t.splash=new URL("assets/splash.jpg",t.runtimeBaseUrl).href),t.scaleMode=U[(""+t.scaleMode).toLowerCase()]||t.scaleMode,t.stageAlign&&(t.stageAlign=function(t){const e=t.toUpperCase();return(e.indexOf("T")>-1?"T":e.indexOf("B")>-1?"B":"")+(e.indexOf("L")>-1?"L":e.indexOf("R")>-1?"R":"")}(t.stageAlign)||void 0);for(const e of["autoplay","hideBeforeLoad","smoothBitmaps","enableBlends","enableFilters"])"string"==typeof t[e]&&(t[e]=!/^(false|0)$/i.test(t[e].trim()));"false"===t.splash&&(t.splash=!1),"false"===t.progress&&(t.progress=!1),t.bgcolor&&(t.backgroundColor=null===P(t.bgcolor)?t.bgcolor:"#"+t.bgcolor.replace("#",""))}_updateStyle(){this._style.textContent=`\n :host {\n display: inline-block;\n contain: content;\n width: ${x(this._runConfig.width)};\n height: ${x(this._runConfig.height)};\n }\n iframe {\n display: block;\n width: 100%;\n height: 100%;\n border: none;\n }\n `}connectedCallback(){setTimeout(()=>{this._loaderHolder=this.querySelector("div.awayfl__loader"),this._loadGlobalConfig(),this._mapAttrs(),this._setDefaults(),this._normalizeConfig(),this._style=document.createElement("style"),this._updateStyle(),this._root.appendChild(this._style),this._constructPlayer()})}disconnectedCallback(){this._dropPlayer()}attributeChangedCallback(t,e,n){if(this.isConnected)return"src"===t&&this._player?(this._dropPlayer(),this._runConfig.src=n,void this._constructPlayer()):void("width"!==t&&"height"!==t||!this._style||(this._runConfig[t]=n,this._updateStyle()))}}k.BINDING_CONFIG={version:{required:!1,default:"latest"},runtimeBaseUrl:{required:!1,default:I},src:{required:!0},width:{required:!1,default:550},height:{required:!1,default:400},onLoad:{required:!1},onProgress:{required:!1},onError:{required:!1},scaleMode:{required:!1,default:"showAll"},stageAlign:{required:!1},autoplay:{required:!1,default:!0},hideBeforeLoad:{required:!1,default:!1},maxStageScale:{required:!1,default:void 0},backgroundColor:{required:!1,default:"black"},bgcolor:{required:!1},flashvars:{required:!1},splash:{required:!1},progress:{required:!1,default:{direction:"lr",back:"#130d02",line:"#f29f01",rect:[.25,.77,.5,.01]}},smoothBitmaps:{required:!1,default:!1},enableBlends:{required:!1,default:!1},enableFilters:{required:!1,default:!1}},customElements.get("awayfl-player")||customElements.define("awayfl-player",k);const R=window;function G(t,e){const n=Object.getOwnPropertyDescriptor(window,t);!n||n.configurable?Object.defineProperty(window,t,{configurable:!0,enumerable:!0,get:()=>e,set:n=>{n!==e&&console.info(`[AwayFL] Ignoring the page's ${t}, as AwayFL provides it`)}}):R[t]=e}return(R.swfobject||R.swfObject||R.SWFObject)&&console.info("[AwayFL] Replacing the page's SWFObject"),G("swfobject",B),G("swfObject",B),G("SWFObject",j),E(()=>setTimeout(()=>{!1!==(R.AWAY_EMBED_CFG||{}).autoUpgrade&&(u(),function(){let t=[];const e=()=>{const e=t;t=[],e.forEach(t=>t.isConnected&&u(t))};new MutationObserver(n=>{const r=!t.length;for(const e of n)e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&t.push(e)});r&&t.length&&setTimeout(e)}).observe(document.documentElement,{childList:!0,subtree:!0})}())})),t.AwayPlayerComponent=k,t.SWFObject=j,t.VERSION="0.1.4",t.configure=function(t){R.AWAY_EMBED_CFG=Object.assign(R.AWAY_EMBED_CFG||{},t)},t.swfObject=B,t.swfobject=B,t}({});
|
|
1
|
+
var AwayEmbed=function(t){"use strict";var e="undefined"!=typeof document?document.currentScript:null;const n=["application/x-shockwave-flash","application/futuresplash"],r=/\.swf([?#]|$)/i,i=["classid","codebase","type","pluginspage","data","src","width","height"],s=["flashvars","bgcolor","scale","salign","wmode","quality","menu","play","loop","base","allowscriptaccess","allowfullscreen","allowfullscreeninteractive","allownetworking","devicefont","seamlesstabbing","swliveconnect","swremote","swfversion","expressinstall"];function o(t){const e={};for(const n of Array.from(t.children))"param"===n.localName&&n.getAttribute("name")&&(e[n.getAttribute("name").toLowerCase()]=n.getAttribute("value")||"");return e}function a(t){const e=t.localName;if("object"!==e&&"embed"!==e)return!1;if(n.indexOf((t.getAttribute("type")||"").toLowerCase())>-1||"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"===(t.getAttribute("classid")||"").toLowerCase())return!0;const i="embed"===e?t.getAttribute("src"):t.getAttribute("data")||o(t).movie;return r.test(i||"")}function l(t){for(let e=t.parentElement;e;e=e.parentElement)if(a(e))return!0;return!1}function c(t,e){const n=document.createElement("awayfl-player");for(const e in t)try{n.setAttribute(e,t[e])}catch(t){console.warn(`[AwayFL] Skipping invalid attribute "${e}"`)}for(const t in e){const r=document.createElement("param");r.name=t,r.value=e[t],n.appendChild(r)}return n}function d(t){const e=function(t){const e={attributes:{},params:{}},n=[t].concat(Array.from(t.querySelectorAll("object, embed")).filter(a)),r=(t,e,n)=>{e in t||(t[e]=n)};for(const t of n){const n="embed"===t.localName,a=o(t);e.src=e.src||t.getAttribute(n?"src":"data")||a.movie||a.src;for(const o of Array.from(t.attributes)){const t=o.name.toLowerCase();"width"===t||"height"===t?r(e.attributes,t,o.value):n&&s.indexOf(t)>-1?r(e.params,t,o.value):-1===i.indexOf(t)&&r(e.attributes,t,o.value)}for(const t in a)"movie"!==t&&"src"!==t&&r(e.params,t,a[t])}return e}(t);if(!e.src)return null;const n=c(Object.assign({src:e.src},e.attributes),e.params);return t.parentNode.replaceChild(n,t),n}function u(t=document){t instanceof Element&&a(t)?l(t)||d(t):t.querySelectorAll("object, embed").forEach(t=>{t.isConnected&&a(t)&&!l(t)&&d(t)})}const h=[32,0,0],f=navigator.userAgent.toLowerCase(),g=(navigator.platform||"").toLowerCase(),m={w3:!0,pv:h.slice(),wk:!!/webkit/.test(f)&&parseFloat(f.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")),ie:!1,win:/win/.test(g||f),mac:/mac/.test(g||f)};let p=!1,b=!0,_=null,w=null;function y(){return"loading"!==document.readyState}function C(t){return"string"==typeof t?document.getElementById(t):t}function v(t){return!!t&&"awayfl-player"===t.localName}function E(t){y()?t():document.addEventListener("DOMContentLoaded",()=>t())}function A(t){const e=String(t).split("."),n=[parseInt(e[0],10),parseInt(e[1],10)||0,parseInt(e[2],10)||0],r=h;return r[0]>n[0]||r[0]===n[0]&&r[1]>n[1]||r[0]===n[0]&&r[1]===n[1]&&r[2]>=n[2]}function L(t,e,n,r){const i=document.head;if(!i)return;const s="string"==typeof n&&n?n:"screen";r&&(_=null,w=null),_&&w===s||(_=document.createElement("style"),_.media=s,w=s,i.appendChild(_)),_.appendChild(document.createTextNode(t+" {"+e+"}"))}function O(t,e){if(!b||!t)return;const n=e?"visible":"hidden",r=document.getElementById(t);y()&&r?r.style.visibility=n:L("#"+CSS.escape(t),"visibility:"+n)}function F(t,e,n){const r=C(n);if(!r||!t||!t.data)return;void 0===t.id&&r.id&&(t.id=r.id);const i={src:""+t.data};for(const e in t){const n=e.toLowerCase();"styleclass"===n?i.class=""+t[e]:"classid"!==n&&"data"!==n&&(i[e]=""+t[e])}const s={};for(const t in e)"movie"!==t.toLowerCase()&&(s[t]=""+e[t]);const o=c(i,s);return r.parentNode.replaceChild(o,r),o}function S(t){return/[\\\"<>\.;]/.test(t)?encodeURIComponent(t):t}const j={registerObject:function(t,e,n,r){t&&e?(O(t,!1),E(()=>{const n={success:!1,id:t};if(A(e)){let e=document.getElementById(t);e&&!v(e)&&(e=a(e)?d(e):null),e&&(n.success=!0,n.ref=e)}O(t,!0),r&&r(n)})):r&&r({success:!1,id:t})},getObjectById:function(t){const e=document.getElementById(t);return v(e)?e:null},embedSWF:function(t,e,n,r,i,s,o,a,l,c){const d="string"==typeof e?e:e&&e.id,u={success:!1,id:d};t&&e&&n&&r?(O(d,!1),E(()=>{const s=Object.assign({},l,{data:t,width:""+n,height:""+r}),h=Object.assign({},a),f=function(t){return t&&"object"==typeof t?Object.keys(t).map(e=>e+"="+(p?encodeURIComponent(t[e]):t[e])).join("&"):""}(o);if(f&&(h.flashvars=void 0!==h.flashvars?h.flashvars+"&"+f:f),!i||A(i)){const t=F(s,h,e);s.id==d&&O(d,!0),u.success=!!t,t&&(u.ref=t)}else O(d,!0);c&&c(u)})):c&&c(u)},switchOffAutoHideShow(){b=!1},enableUriEncoding(t){p=void 0===t||!!t},ua:m,getFlashPlayerVersion:()=>({major:h[0],minor:h[1],release:h[2]}),hasFlashPlayerVersion:A,createSWF:(t,e,n)=>F(t,e,n),showExpressInstall(t,e,n,r){console.warn("[AwayFL] Express Install is not needed or supported"),r&&r({success:!1,id:n})},removeSWF:function(t){const e=document.getElementById(t);e&&(v(e)||a(e))&&e.remove()},createCSS:L,addDomLoadEvent:E,addLoadEvent:function(t){"complete"===document.readyState?setTimeout(t):window.addEventListener("load",()=>t())},getQueryParamValue:function(t){let e=document.location.search||document.location.hash;if(e){if(/\?/.test(e)&&(e=e.split("?")[1]),null==t)return S(e);const n=e.split("&");for(let e=0;e<n.length;e++)if(n[e].substring(0,n[e].indexOf("="))==t)return S(n[e].substring(n[e].indexOf("=")+1))}return""},expressInstallCallback(){}};class B{constructor(t,e,n,r,i,s,o){this._attributes={},this._params={},this._variables={},this.setAttribute("swf",t),this.setAttribute("id",e),this.setAttribute("width",""+n),this.setAttribute("height",""+r),this.setAttribute("version",i),s&&this.addParam("bgcolor",s),this.addParam("quality",o||"high")}setAttribute(t,e){this._attributes[t]=e}getAttribute(t){return this._attributes[t]||""}addParam(t,e){this._params[t]=e}getParams(){return this._params}addVariable(t,e){this._variables[t]=e}getVariable(t){return this._variables[t]||""}getVariables(){return this._variables}getVariablePairs(){return Object.keys(this._variables).map(t=>t+"="+this._variables[t])}useExpressInstall(t){}write(t){const e=C(t);if(!e)return!1;const n=this.getAttribute("id"),r=Object.assign({},this._params),i=this.getVariablePairs().join("&");i&&(r.flashvars=i);const s=c({src:this.getAttribute("swf"),id:n,name:n,width:this.getAttribute("width"),height:this.getAttribute("height")},r);return e.innerHTML="",e.appendChild(s),!0}}const I=new URL(".",e&&e.src||new URL("embed.js",document.baseURI).href).href,q={direction:"lr",rect:[.25,.495,.5,.01]},N={movie:"src",data:"src",flashvars:"flashvars",bgcolor:"bgcolor",scale:"scaleMode",salign:"stageAlign"},x={showall:"showAll",all:"showAll",noborder:"noBorder",exactfit:"exactFit",noscale:"noScale"};function P(t){const e={};if("string"==typeof t)new URLSearchParams(t).forEach((t,n)=>{e[n]=t});else if(t)for(const n in t)e[n]=String(t[n]);return e}function U(t){const e=/^#?([0-9a-f]{6})$/i.exec(t||"");return e?parseInt(e[1],16):null}function k(t){return/^\d+(\.\d+)?$/.test(""+t)?t+"px":""+t}class R extends HTMLElement{static get observedAttributes(){return["src","width","height"]}get player(){return this._player}get config(){return this._runConfig}set config(t){this._runConfig=t}get src(){return this._runConfig.src||this.getAttribute("src")}set src(t){this._runConfig.src=t}set width(t){this._runConfig.width=t}get width(){return this._runConfig.width||this.getAttribute("width")}set height(t){this._runConfig.height=t}get height(){return this._runConfig.height||this.getAttribute("height")}set runtimeBaseUrl(t){this._runConfig.runtimeBaseUrl=t}get runtimeBaseUrl(){return this._runConfig.runtimeBaseUrl}constructor(){super(),this._runConfig={},this.onError=this.onError.bind(this),this._root=this.attachShadow({mode:"closed"})}_getRuntimeUrl(){const t=this._runConfig.runtimeBaseUrl;return{loader:new URL("loader.js",t).href,runtime:new URL("runtime.js",t).href,baseUrl:t}}_dropPlayer(){this._gameFrame&&(this._gameFrame.remove(),this._player=null)}onError(t){const e=this._runConfig.onError&&self[this._runConfig.onError];"function"==typeof e&&e(t),this.dispatchEvent(new ErrorEvent("error",{error:new Error("Awayfl runtime error"),message:(null==t?void 0:t.message)||t}))}_attachRuntimeEvents(){const t=this._gameFrame.contentWindow;t.addEventListener("awayfl-player-init",({detail:t})=>{this._player=t},{once:!0}),t.addEventListener("awayfl-player-load",()=>{const t=this._runConfig.onLoad&&self[this._runConfig.onLoad];"function"==typeof t&&t(),this.dispatchEvent(new CustomEvent("load")),this._gameFrame.style.display=""},{once:!0}),t.addEventListener("awayfl-player-error",({detail:t})=>this.onError(t),{once:!0}),t.addEventListener("awayfl-player-progress",({detail:t})=>{const e=this._runConfig.onProgress&&self[this._runConfig.onProgress];"function"==typeof e&&e(t),this.dispatchEvent(new CustomEvent("progress",{detail:t}))})}_progressConfig(){const t=this._runConfig.progress;if(!t)return!1;const e=getComputedStyle(this).color;return Object.assign(Object.assign({line:e,back:`color-mix(in srgb, ${e} 20%, transparent)`},q),"object"==typeof t?t:{})}_buildTemplate(t){const e='<!DOCTYPE html>\n<head>\n\t<meta name="viewport"\n\t\tcontent="height=device-height, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui" />\n\t<title>AwayFL Embedded Player 0.1.5</title>\n\t<style>\n\t\t* {\n\t\t\tmargin: 0;\n\t\t\tpadding: 0;\n\t\t}\n\n\t\tcanvas {\n\t\t\toutline: none\n\t\t}\n\n\t\thtml, body, #container {\n\t\t\tmargin: 0;\n\t\t\toverflow: hidden;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\n\t\t#splash__image {\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t\tposition: absolute;\n\t\t\tbackground-size: contain;\n\t\t\tbackground-position: center;\n\t\t\tbackground-repeat: no-repeat;\n\t\t\tvisibility: visible;\n\t\t\ttransition: all 0.5s;\n\t\t\tz-index: 10;\n\t\t}\n\n\t\t#progress__root {\n\t\t\tposition: absolute;\n\t\t\tmin-height: 2px;\n\t\t}\n\n\t\t#progress__line {\n\t\t\twidth: 0;\n\t\t\theight: 100%;\n\t\t\ttransition: all 0.5s;\n\t\t}\n\t</style>\n\t<script src="__LOADER_URL__"><\/script>\n</head>\n\n<body>\n\t<div id="splash__image">\n\t\t<div id="progress__root">\n\t\t\t<div id="progress__line"></div>\n\t\t</div>\n\t</div>\n\t<script>\n\t\twindow.addEventListener("load", () => {\n\n\t\t\tconst config = JSON.parse(__GAME_CONFIG__);\n\t\t\tconst fail = (error) => {\n\t\t\t\tconsole.error(\'[AwayFL]\', error);\n\t\t\t\twindow.dispatchEvent(new CustomEvent(\'awayfl-player-error\', {detail: error}));\n\t\t\t};\n\n\t\t\tAWAYFL.LegacyLoader.init(config);\n\t\t\tAWAYFL.LegacyLoader.runGame((fill) => {\n\t\t\t\twindow.dispatchEvent(new CustomEvent(\'awayfl-player-progress\', {detail: fill}));\n\t\t\t}, (config, hideLoader) => {\n\t\t\t\tconst player = new AWAYFL.Player(document, config);\n\t\t\t\twindow.dispatchEvent(new CustomEvent(\'awayfl-player-init\', {detail: player}));\n\t\t\t\tplayer\n\t\t\t\t\t.loadAndPlay()\n\t\t\t\t\t.then((_, hide) => {\n\t\t\t\t\t\twindow.dispatchEvent(new CustomEvent(\'awayfl-player-load\'));\n\t\t\t\t\t\thide && hide() || window.swfParseComplete && window.swfParseComplete();;\n\t\t\t\t\t})\n\t\t\t\t\t.catch(fail);\n\t\t\t}).catch(fail);\n\t\t});\n\t<\/script>\n</body>',n=this._getRuntimeUrl(),r={width:t.clientWidth,height:t.clientHeight,backgroundColor:this._runConfig.backgroundColor,splash:this._runConfig.splash,progress:this._progressConfig(),runtime:[n.runtime],binary:[{path:this._runConfig.src,resourceType:"GAME",name:"Game",meta:{}}],baseUrl:n.baseUrl,maxStageScale:+this._runConfig.maxStageScale,flashvars:P(this._runConfig.flashvars),stageScaleMode:this._runConfig.scaleMode,stageAlign:this._runConfig.stageAlign,stageColor:U(this._runConfig.bgcolor),runtimeFlags:{defaultSmoothBitmap:!!this._runConfig.smoothBitmaps,enableBlends:!!this._runConfig.enableBlends,enableFilters:!!this._runConfig.enableFilters}};return e.replace(/__LOADER_URL__/,n.loader).replace(/__GAME_CONFIG__/,JSON.stringify(JSON.stringify(r)))}_constructPlayer(){const t=this._root,e=document.createElement("iframe");e.style.display=this._runConfig.hideBeforeLoad?"none":"",this._gameFrame=e,t.appendChild(e),e.addEventListener("load",this._attachRuntimeEvents.bind(this),{once:!0}),e.addEventListener("error",this.onError),e.srcdoc=this._buildTemplate(e)}_configKey(t){const e=t.toLowerCase();return e in N?N[e]:Object.keys(R.BINDING_CONFIG).find(t=>t.toLowerCase()===e)}_mapAttrs(){const t=this.querySelectorAll("param"),e=this._runConfig;t.forEach(t=>{const n=this._configKey(t.name);n&&(e[n]=t.value)}),this.getAttributeNames().forEach(t=>{const n=this._configKey(t);n&&(e[n]=this.getAttribute(t))})}_loadGlobalConfig(){const t=window.AWAY_EMBED_CFG||{},e=R.BINDING_CONFIG;for(const[n,r]of Object.entries(t))n in e&&(this._runConfig[n]=r)}_setDefaults(){const t=R.BINDING_CONFIG;for(const e in t){if(t[e].required&&void 0===this._runConfig[e])throw`Parameter ${e} is required!`;void 0===this._runConfig[e]&&(this._runConfig[e]=t[e].default)}}_normalizeConfig(){const t=this._runConfig;t.runtimeBaseUrl=new URL(t.runtimeBaseUrl.replace(/\/?$/,"/"),document.baseURI).href,t.scaleMode=x[(""+t.scaleMode).toLowerCase()]||t.scaleMode,t.stageAlign&&(t.stageAlign=function(t){const e=t.toUpperCase();return(e.indexOf("T")>-1?"T":e.indexOf("B")>-1?"B":"")+(e.indexOf("L")>-1?"L":e.indexOf("R")>-1?"R":"")}(t.stageAlign)||void 0);for(const e of["autoplay","hideBeforeLoad","smoothBitmaps","enableBlends","enableFilters"])"string"==typeof t[e]&&(t[e]=!/^(false|0)$/i.test(t[e].trim()));"false"===t.splash&&(t.splash=!1),"false"===t.progress&&(t.progress=!1),t.bgcolor&&(t.backgroundColor=null===U(t.bgcolor)?t.bgcolor:"#"+t.bgcolor.replace("#",""))}_updateStyle(){this._style.textContent=`\n :host {\n display: inline-block;\n contain: content;\n width: ${k(this._runConfig.width)};\n height: ${k(this._runConfig.height)};\n }\n iframe {\n display: block;\n width: 100%;\n height: 100%;\n border: none;\n /* matches the frame's own document, or browsers make the frame opaque */\n color-scheme: light;\n }\n `}connectedCallback(){setTimeout(()=>{this._loaderHolder=this.querySelector("div.awayfl__loader"),this._loadGlobalConfig(),this._mapAttrs(),this._setDefaults(),this._normalizeConfig(),this._style=document.createElement("style"),this._updateStyle(),this._root.appendChild(this._style),this._constructPlayer()})}disconnectedCallback(){this._dropPlayer()}attributeChangedCallback(t,e,n){if(this.isConnected)return"src"===t&&this._player?(this._dropPlayer(),this._runConfig.src=n,void this._constructPlayer()):void("width"!==t&&"height"!==t||!this._style||(this._runConfig[t]=n,this._updateStyle()))}}R.BINDING_CONFIG={version:{required:!1,default:"latest"},runtimeBaseUrl:{required:!1,default:I},src:{required:!0},width:{required:!1,default:550},height:{required:!1,default:400},onLoad:{required:!1},onProgress:{required:!1},onError:{required:!1},scaleMode:{required:!1,default:"showAll"},stageAlign:{required:!1},autoplay:{required:!1,default:!0},hideBeforeLoad:{required:!1,default:!1},maxStageScale:{required:!1,default:void 0},backgroundColor:{required:!1},bgcolor:{required:!1},flashvars:{required:!1},splash:{required:!1},progress:{required:!1,default:q},smoothBitmaps:{required:!1,default:!1},enableBlends:{required:!1,default:!1},enableFilters:{required:!1,default:!1}},customElements.get("awayfl-player")||customElements.define("awayfl-player",R);const G=window;function M(t,e){const n=Object.getOwnPropertyDescriptor(window,t);!n||n.configurable?Object.defineProperty(window,t,{configurable:!0,enumerable:!0,get:()=>e,set:n=>{n!==e&&console.info(`[AwayFL] Ignoring the page's ${t}, as AwayFL provides it`)}}):G[t]=e}return(G.swfobject||G.swfObject||G.SWFObject)&&console.info("[AwayFL] Replacing the page's SWFObject"),M("swfobject",j),M("swfObject",j),M("SWFObject",B),E(()=>setTimeout(()=>{!1!==(G.AWAY_EMBED_CFG||{}).autoUpgrade&&(u(),function(){let t=[];const e=()=>{const e=t;t=[],e.forEach(t=>t.isConnected&&u(t))};new MutationObserver(n=>{const r=!t.length;for(const e of n)e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&t.push(e)});r&&t.length&&setTimeout(e)}).observe(document.documentElement,{childList:!0,subtree:!0})}())})),t.AwayPlayerComponent=R,t.SWFObject=B,t.VERSION="0.1.5",t.configure=function(t){G.AWAY_EMBED_CFG=Object.assign(G.AWAY_EMBED_CFG||{},t)},t.swfObject=j,t.swfobject=j,t}({});
|
|
2
2
|
//# sourceMappingURL=embed.js.map
|
package/dist/embed.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embed.js","sources":["../src/embed/flashMarkup.ts","../src/embed/swfobject.ts","../src/embed/AwayPlayerComponent.ts","../src/embed/index.ts"],"sourcesContent":["const FLASH_CLASSID = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';\nconst FLASH_TYPES = ['application/x-shockwave-flash', 'application/futuresplash'];\nconst SWF_URL = /\\.swf([?#]|$)/i;\n/**\n * Attributes that describe the plugin rather than the element, so aren't copied\n */\nconst PLUGIN_ATTRIBUTES = ['classid', 'codebase', 'type', 'pluginspage', 'data', 'src', 'width', 'height'];\n/**\n * Flash parameters, which <embed> takes as attributes\n */\nconst EMBED_PARAMS = [\n 'flashvars', 'bgcolor', 'scale', 'salign', 'wmode', 'quality', 'menu', 'play', 'loop', 'base',\n 'allowscriptaccess', 'allowfullscreen', 'allowfullscreeninteractive', 'allownetworking',\n 'devicefont', 'seamlesstabbing', 'swliveconnect', 'swremote', 'swfversion', 'expressinstall',\n];\nfunction paramsOf(el) {\n const params = {};\n for (const child of Array.from(el.children)) {\n if (child.localName === 'param' && child.getAttribute('name')) {\n params[child.getAttribute('name').toLowerCase()] = child.getAttribute('value') || '';\n }\n }\n return params;\n}\nexport function isFlashElement(el) {\n const tag = el.localName;\n if (tag !== 'object' && tag !== 'embed') {\n return false;\n }\n if (FLASH_TYPES.indexOf((el.getAttribute('type') || '').toLowerCase()) > -1\n || (el.getAttribute('classid') || '').toLowerCase() === FLASH_CLASSID) {\n return true;\n }\n const url = tag === 'embed'\n ? el.getAttribute('src')\n : el.getAttribute('data') || paramsOf(el).movie;\n return SWF_URL.test(url || '');\n}\nfunction hasFlashAncestor(el) {\n for (let parent = el.parentElement; parent; parent = parent.parentElement) {\n if (isFlashElement(parent)) {\n return true;\n }\n }\n return false;\n}\n/**\n * Reads an <object>/<embed> and any Flash elements nested in it (the usual\n * cross-browser markup), the outermost taking precedence\n */\nfunction readFlashMarkup(outer) {\n const markup = { attributes: {}, params: {} };\n const elements = [outer].concat(Array.from(outer.querySelectorAll('object, embed')).filter(isFlashElement));\n const set = (map, name, value) => {\n if (!(name in map)) {\n map[name] = value;\n }\n };\n for (const el of elements) {\n const isEmbed = el.localName === 'embed';\n const params = paramsOf(el);\n markup.src = markup.src\n || el.getAttribute(isEmbed ? 'src' : 'data')\n || params.movie\n || params.src;\n for (const attr of Array.from(el.attributes)) {\n const name = attr.name.toLowerCase();\n if (name === 'width' || name === 'height') {\n set(markup.attributes, name, attr.value);\n }\n else if (isEmbed && EMBED_PARAMS.indexOf(name) > -1) {\n set(markup.params, name, attr.value);\n }\n else if (PLUGIN_ATTRIBUTES.indexOf(name) === -1) {\n set(markup.attributes, name, attr.value);\n }\n }\n for (const name in params) {\n if (name !== 'movie' && name !== 'src') {\n set(markup.params, name, params[name]);\n }\n }\n }\n return markup;\n}\nexport function createPlayer(attributes, params) {\n const player = document.createElement('awayfl-player');\n for (const name in attributes) {\n try {\n player.setAttribute(name, attributes[name]);\n }\n catch (e) {\n console.warn(`[AwayFL] Skipping invalid attribute \"${name}\"`);\n }\n }\n for (const name in params) {\n const param = document.createElement('param');\n param.name = name;\n param.value = params[name];\n player.appendChild(param);\n }\n return player;\n}\n/**\n * Replaces Flash <object>/<embed> markup with an AwayFL player\n */\nexport function upgradeElement(el) {\n const markup = readFlashMarkup(el);\n if (!markup.src) {\n return null;\n }\n const player = createPlayer(Object.assign({ src: markup.src }, markup.attributes), markup.params);\n el.parentNode.replaceChild(player, el);\n return player;\n}\nexport function upgradeAll(root = document) {\n if (root instanceof Element && isFlashElement(root)) {\n if (!hasFlashAncestor(root)) {\n upgradeElement(root);\n }\n return;\n }\n root.querySelectorAll('object, embed').forEach((el) => {\n // nested elements are detached once their outermost element is upgraded\n if (el.isConnected && isFlashElement(el) && !hasFlashAncestor(el)) {\n upgradeElement(el);\n }\n });\n}\n/**\n * Upgrades Flash markup added to the page after it has loaded\n */\nexport function observeFlashMarkup() {\n let pending = [];\n const flush = () => {\n const added = pending;\n pending = [];\n added.forEach((el) => el.isConnected && upgradeAll(el));\n };\n new MutationObserver((records) => {\n const wasEmpty = !pending.length;\n for (const record of records) {\n record.addedNodes.forEach((node) => {\n if (node.nodeType === Node.ELEMENT_NODE) {\n pending.push(node);\n }\n });\n }\n // wait for the script adding the markup to finish, e.g. appending its <param>s\n if (wasEmpty && pending.length) {\n setTimeout(flush);\n }\n }).observe(document.documentElement, { childList: true, subtree: true });\n}\n","import { createPlayer, isFlashElement, upgradeElement } from './flashMarkup';\n/**\n * The Flash Player version reported to pages, so they don't take their \"no Flash\" branch\n */\nconst PLAYER_VERSION = [32, 0, 0];\nconst userAgent = navigator.userAgent.toLowerCase();\nconst platform = (navigator.platform || '').toLowerCase();\nconst ua = {\n w3: true,\n pv: PLAYER_VERSION.slice(),\n wk: /webkit/.test(userAgent) ? parseFloat(userAgent.replace(/^.*webkit\\/(\\d+(\\.\\d+)?).*$/, '$1')) : false,\n ie: false,\n win: /win/.test(platform || userAgent),\n mac: /mac/.test(platform || userAgent),\n};\nlet encodeURIEnabled = false;\nlet autoHideShow = true;\nlet dynamicStylesheet = null;\nlet dynamicStylesheetMedia = null;\nfunction isDomLoaded() {\n return document.readyState !== 'loading';\n}\nfunction getElement(id) {\n return typeof id === 'string' ? document.getElementById(id) : id;\n}\n// by tag, as the element may be another build's class if both are loaded\nfunction isPlayer(el) {\n return !!el && el.localName === 'awayfl-player';\n}\nexport function addDomLoadEvent(fn) {\n if (isDomLoaded()) {\n fn();\n }\n else {\n document.addEventListener('DOMContentLoaded', () => fn());\n }\n}\nfunction addLoadEvent(fn) {\n if (document.readyState === 'complete') {\n setTimeout(fn);\n }\n else {\n window.addEventListener('load', () => fn());\n }\n}\nfunction hasPlayerVersion(versionStr) {\n const v = String(versionStr).split('.');\n const required = [parseInt(v[0], 10), parseInt(v[1], 10) || 0, parseInt(v[2], 10) || 0];\n const pv = PLAYER_VERSION;\n return pv[0] > required[0]\n || (pv[0] === required[0] && pv[1] > required[1])\n || (pv[0] === required[0] && pv[1] === required[1] && pv[2] >= required[2]);\n}\nfunction createCSS(selStr, declStr, mediaStr, newStyleBoolean) {\n const head = document.head;\n if (!head) {\n return;\n }\n const media = typeof mediaStr === 'string' && mediaStr ? mediaStr : 'screen';\n if (newStyleBoolean) {\n dynamicStylesheet = null;\n dynamicStylesheetMedia = null;\n }\n if (!dynamicStylesheet || dynamicStylesheetMedia !== media) {\n dynamicStylesheet = document.createElement('style');\n dynamicStylesheet.media = media;\n dynamicStylesheetMedia = media;\n head.appendChild(dynamicStylesheet);\n }\n dynamicStylesheet.appendChild(document.createTextNode(selStr + ' {' + declStr + '}'));\n}\n/**\n * Hides alternative content until it's replaced, as SWFObject does\n */\nfunction setVisibility(id, isVisible) {\n if (!autoHideShow || !id) {\n return;\n }\n const visibility = isVisible ? 'visible' : 'hidden';\n const el = document.getElementById(id);\n if (isDomLoaded() && el) {\n el.style.visibility = visibility;\n }\n else {\n createCSS('#' + CSS.escape(id), 'visibility:' + visibility);\n }\n}\nfunction createSWF(attObj, parObj, replaceElemIdStr) {\n const el = getElement(replaceElemIdStr);\n if (!el || !attObj || !attObj.data) {\n return undefined;\n }\n if (typeof attObj.id === 'undefined' && el.id) {\n attObj.id = el.id;\n }\n const attributes = { src: '' + attObj.data };\n for (const key in attObj) {\n const name = key.toLowerCase();\n if (name === 'styleclass') {\n attributes['class'] = '' + attObj[key];\n }\n else if (name !== 'classid' && name !== 'data') {\n attributes[key] = '' + attObj[key];\n }\n }\n const params = {};\n for (const key in parObj) {\n if (key.toLowerCase() !== 'movie') {\n params[key] = '' + parObj[key];\n }\n }\n const player = createPlayer(attributes, params);\n el.parentNode.replaceChild(player, el);\n return player;\n}\nfunction buildFlashVars(flashvarsObj) {\n if (!flashvarsObj || typeof flashvarsObj !== 'object') {\n return '';\n }\n return Object.keys(flashvarsObj)\n .map((key) => key + '=' + (encodeURIEnabled ? encodeURIComponent(flashvarsObj[key]) : flashvarsObj[key]))\n .join('&');\n}\nfunction embedSWF(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, _xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) {\n const id = typeof replaceElemIdStr === 'string' ? replaceElemIdStr : replaceElemIdStr && replaceElemIdStr.id;\n const callbackObj = { success: false, id };\n // unlike SWFObject the version is optional, as AwayFL's own examples omit it\n if (!swfUrlStr || !replaceElemIdStr || !widthStr || !heightStr) {\n callbackFn && callbackFn(callbackObj);\n return;\n }\n setVisibility(id, false);\n addDomLoadEvent(() => {\n // copied, as pages often reuse these objects for several SWFs\n const att = Object.assign({}, attObj, { data: swfUrlStr, width: '' + widthStr, height: '' + heightStr });\n const par = Object.assign({}, parObj);\n const flashvars = buildFlashVars(flashvarsObj);\n if (flashvars) {\n par.flashvars = typeof par.flashvars !== 'undefined' ? par.flashvars + '&' + flashvars : flashvars;\n }\n if (!swfVersionStr || hasPlayerVersion(swfVersionStr)) {\n const ref = createSWF(att, par, replaceElemIdStr);\n if (att.id == id) {\n setVisibility(id, true);\n }\n callbackObj.success = !!ref;\n if (ref) {\n callbackObj.ref = ref;\n }\n }\n else {\n // show the alternative content\n setVisibility(id, true);\n }\n callbackFn && callbackFn(callbackObj);\n });\n}\n/**\n * Static publishing: replaces the page's <object> markup with a player\n */\nfunction registerObject(objectIdStr, swfVersionStr, _xiSwfUrlStr, callbackFn) {\n if (!objectIdStr || !swfVersionStr) {\n callbackFn && callbackFn({ success: false, id: objectIdStr });\n return;\n }\n setVisibility(objectIdStr, false);\n addDomLoadEvent(() => {\n const callbackObj = { success: false, id: objectIdStr };\n if (hasPlayerVersion(swfVersionStr)) {\n let ref = document.getElementById(objectIdStr);\n // may already have been upgraded with the rest of the page's markup\n if (ref && !isPlayer(ref)) {\n ref = isFlashElement(ref) ? upgradeElement(ref) : null;\n }\n if (ref) {\n callbackObj.success = true;\n callbackObj.ref = ref;\n }\n }\n setVisibility(objectIdStr, true);\n callbackFn && callbackFn(callbackObj);\n });\n}\nfunction getObjectById(objectIdStr) {\n const el = document.getElementById(objectIdStr);\n return isPlayer(el) ? el : null;\n}\nfunction removeSWF(objElemIdStr) {\n const el = document.getElementById(objElemIdStr);\n if (el && (isPlayer(el) || isFlashElement(el))) {\n el.remove();\n }\n}\nfunction urlEncodeIfNecessary(s) {\n return /[\\\\\\\"<>\\.;]/.test(s) ? encodeURIComponent(s) : s;\n}\nfunction getQueryParamValue(param) {\n let q = document.location.search || document.location.hash;\n if (q) {\n if (/\\?/.test(q)) {\n q = q.split('?')[1];\n }\n if (param == null) {\n return urlEncodeIfNecessary(q);\n }\n const pairs = q.split('&');\n for (let i = 0; i < pairs.length; i++) {\n if (pairs[i].substring(0, pairs[i].indexOf('=')) == param) {\n return urlEncodeIfNecessary(pairs[i].substring(pairs[i].indexOf('=') + 1));\n }\n }\n }\n return '';\n}\nexport const swfobject = {\n registerObject,\n getObjectById,\n embedSWF,\n switchOffAutoHideShow() {\n autoHideShow = false;\n },\n enableUriEncoding(enable) {\n encodeURIEnabled = typeof enable === 'undefined' ? true : !!enable;\n },\n ua,\n getFlashPlayerVersion() {\n return { major: PLAYER_VERSION[0], minor: PLAYER_VERSION[1], release: PLAYER_VERSION[2] };\n },\n hasFlashPlayerVersion: hasPlayerVersion,\n createSWF(attObj, parObj, replaceElemIdStr) {\n return createSWF(attObj, parObj, replaceElemIdStr);\n },\n showExpressInstall(_att, _par, replaceElemIdStr, callbackFn) {\n console.warn('[AwayFL] Express Install is not needed or supported');\n callbackFn && callbackFn({ success: false, id: replaceElemIdStr });\n },\n removeSWF,\n createCSS,\n addDomLoadEvent,\n addLoadEvent,\n getQueryParamValue,\n expressInstallCallback() { },\n};\n/**\n * SWFObject 1.5: `new SWFObject(swf, id, width, height, version, bgcolor).write(elementId)`,\n * which renders the SWF inside the target element\n */\nexport class SWFObject {\n constructor(swf, id, w, h, ver, c, quality) {\n this._attributes = {};\n this._params = {};\n this._variables = {};\n this.setAttribute('swf', swf);\n this.setAttribute('id', id);\n this.setAttribute('width', '' + w);\n this.setAttribute('height', '' + h);\n this.setAttribute('version', ver);\n if (c) {\n this.addParam('bgcolor', c);\n }\n this.addParam('quality', quality || 'high');\n }\n setAttribute(name, value) {\n this._attributes[name] = value;\n }\n getAttribute(name) {\n return this._attributes[name] || '';\n }\n addParam(name, value) {\n this._params[name] = value;\n }\n getParams() {\n return this._params;\n }\n addVariable(name, value) {\n this._variables[name] = value;\n }\n getVariable(name) {\n return this._variables[name] || '';\n }\n getVariables() {\n return this._variables;\n }\n getVariablePairs() {\n return Object.keys(this._variables).map((key) => key + '=' + this._variables[key]);\n }\n useExpressInstall(_path) { }\n write(elementId) {\n const target = getElement(elementId);\n if (!target) {\n return false;\n }\n const id = this.getAttribute('id');\n const params = Object.assign({}, this._params);\n const flashvars = this.getVariablePairs().join('&');\n if (flashvars) {\n params.flashvars = flashvars;\n }\n const player = createPlayer({\n src: this.getAttribute('swf'),\n id,\n name: id,\n width: this.getAttribute('width'),\n height: this.getAttribute('height'),\n }, params);\n target.innerHTML = '';\n target.appendChild(player);\n return true;\n }\n}\n","//@ts-ignore\nimport template from \"./embed.html\";\n// rollup turns import.meta.url into document.currentScript's src in the classic\n// script build; in the ES module build it's the module's own URL\nconst scriptBaseUrl = new URL('.', import.meta.url).href;\nconst defaultProgress = {\n \"direction\": \"lr\",\n \"back\": \"#130d02\",\n \"line\": \"#f29f01\",\n \"rect\": [\n 0.25,\n 0.77,\n 0.5,\n 0.01\n ]\n};\n/**\n * Flash <object>/<embed> parameter and attribute names that map onto config keys.\n * Others, such as wmode, allowScriptAccess, quality and menu, have no equivalent\n * and are ignored.\n */\nconst FLASH_PARAMS = {\n movie: 'src',\n data: 'src',\n flashvars: 'flashvars',\n bgcolor: 'bgcolor',\n scale: 'scaleMode',\n salign: 'stageAlign',\n};\nconst SCALE_MODES = {\n showall: 'showAll',\n all: 'showAll',\n noborder: 'noBorder',\n exactfit: 'exactFit',\n noscale: 'noScale',\n};\nexport function parseFlashVars(value) {\n const result = {};\n if (typeof value === 'string') {\n new URLSearchParams(value).forEach((v, k) => {\n result[k] = v;\n });\n }\n else if (value) {\n for (const key in value) {\n result[key] = String(value[key]);\n }\n }\n return result;\n}\nfunction parseColor(value) {\n const match = /^#?([0-9a-f]{6})$/i.exec(value || '');\n return match ? parseInt(match[1], 16) : null;\n}\nfunction normalizeAlign(value) {\n const v = value.toUpperCase();\n return (v.indexOf('T') > -1 ? 'T' : v.indexOf('B') > -1 ? 'B' : '')\n + (v.indexOf('L') > -1 ? 'L' : v.indexOf('R') > -1 ? 'R' : '');\n}\nfunction cssSize(value) {\n return /^\\d+(\\.\\d+)?$/.test('' + value) ? value + 'px' : '' + value;\n}\nexport class AwayPlayerComponent extends HTMLElement {\n static get observedAttributes() {\n return [\n 'src',\n 'width',\n 'height'\n ];\n }\n get player() {\n return this._player;\n }\n get config() {\n return this._runConfig;\n }\n set config(cfg) {\n this._runConfig = cfg;\n }\n get src() {\n return this._runConfig.src || this.getAttribute('src');\n }\n set src(v) {\n this._runConfig.src = v;\n }\n set width(v) {\n this._runConfig.width = v;\n }\n get width() {\n return this._runConfig.width || this.getAttribute('width');\n }\n set height(v) {\n this._runConfig.height = v;\n }\n get height() {\n return this._runConfig.height || this.getAttribute('height');\n }\n set runtimeBaseUrl(v) {\n this._runConfig.runtimeBaseUrl = v;\n }\n get runtimeBaseUrl() {\n return this._runConfig.runtimeBaseUrl;\n }\n constructor() {\n super();\n this._runConfig = {};\n this.onError = this.onError.bind(this);\n this._root = this.attachShadow({ mode: 'closed' });\n }\n _getRuntimeUrl() {\n const baseUrl = this._runConfig.runtimeBaseUrl;\n const loader = new URL('loader.js', baseUrl).href;\n const runtime = new URL('runtime.js', baseUrl).href;\n /**\n * @todo support runtime version\n **/\n return {\n loader,\n runtime,\n baseUrl,\n };\n }\n _dropPlayer() {\n if (this._gameFrame) {\n this._gameFrame.remove();\n this._player = null;\n }\n }\n onError(_arg) {\n const f = this._runConfig.onError && self[this._runConfig.onError];\n if (typeof f === 'function') {\n f(_arg);\n }\n this.dispatchEvent(new ErrorEvent('error', {\n error: new Error('Awayfl runtime error'),\n message: (_arg === null || _arg === void 0 ? void 0 : _arg.message) || _arg,\n }));\n }\n _attachRuntimeEvents() {\n const fd = this._gameFrame.contentWindow;\n //@ts-ignore\n fd.addEventListener('awayfl-player-init', ({ detail }) => {\n this._player = detail;\n }, { once: true });\n fd.addEventListener('awayfl-player-load', () => {\n const f = this._runConfig.onLoad && self[this._runConfig.onLoad];\n if (typeof f === 'function') {\n f();\n }\n this.dispatchEvent(new CustomEvent('load'));\n this._gameFrame.style.display = '';\n }, { once: true });\n //@ts-ignore\n fd.addEventListener('awayfl-player-error', ({ detail }) => this.onError(detail), { once: true });\n //@ts-ignore\n fd.addEventListener('awayfl-player-progress', ({ detail }) => {\n const f = this._runConfig.onProgress && self[this._runConfig.onProgress];\n if (typeof f === 'function') {\n f(detail);\n }\n this.dispatchEvent(new CustomEvent('progress', { detail }));\n });\n }\n _buildTemplate(frame) {\n const t = template;\n const urls = this._getRuntimeUrl();\n const gameConfig = {\n width: frame.clientWidth,\n height: frame.clientHeight,\n backgroundColor: this._runConfig.backgroundColor,\n splash: this._runConfig.splash,\n progress: this._runConfig.progress,\n runtime: [urls.runtime],\n binary: [{\n path: this._runConfig.src,\n resourceType: 'GAME',\n name: 'Game',\n meta: {}\n }],\n //debug: true,\n baseUrl: urls.baseUrl,\n maxStageScale: +this._runConfig.maxStageScale,\n flashvars: parseFlashVars(this._runConfig.flashvars),\n stageScaleMode: this._runConfig.scaleMode,\n stageAlign: this._runConfig.stageAlign,\n stageColor: parseColor(this._runConfig.bgcolor),\n runtimeFlags: {\n defaultSmoothBitmap: !!this._runConfig.smoothBitmaps,\n enableBlends: !!this._runConfig.enableBlends,\n enableFilters: !!this._runConfig.enableFilters,\n }\n };\n return t\n .replace(/__LOADER_URL__/, urls.loader)\n .replace(/__GAME_CONFIG__/, JSON.stringify(JSON.stringify(gameConfig)));\n }\n _constructPlayer() {\n const root = this._root;\n const frame = document.createElement('iframe');\n frame.style.display = this._runConfig.hideBeforeLoad ? 'none' : '';\n this._gameFrame = frame;\n root.appendChild(frame);\n frame.addEventListener('load', this._attachRuntimeEvents.bind(this), {\n once: true\n });\n frame.addEventListener('error', this.onError);\n frame.srcdoc = this._buildTemplate(frame);\n }\n /**\n * Config key for a param or attribute name, matched case-insensitively as\n * HTML lowercases attribute names and Flash param names ignore case\n */\n _configKey(name) {\n const lower = name.toLowerCase();\n if (lower in FLASH_PARAMS) {\n return FLASH_PARAMS[lower];\n }\n return Object.keys(AwayPlayerComponent.BINDING_CONFIG)\n .find((key) => key.toLowerCase() === lower);\n }\n _mapAttrs() {\n const params = this.querySelectorAll('param');\n const config = this._runConfig;\n params.forEach(node => {\n const key = this._configKey(node.name);\n if (key) {\n config[key] = node.value;\n }\n });\n this.getAttributeNames().forEach(name => {\n const key = this._configKey(name);\n if (key) {\n config[key] = this.getAttribute(name);\n }\n });\n }\n _loadGlobalConfig() {\n const global = window;\n const globalCfg = global.AWAY_EMBED_CFG || {};\n const scheme = AwayPlayerComponent.BINDING_CONFIG;\n for (const [key, value] of Object.entries(globalCfg)) {\n if (key in scheme) {\n this._runConfig[key] = value;\n }\n }\n }\n _setDefaults() {\n const scheme = AwayPlayerComponent.BINDING_CONFIG;\n for (const key in scheme) {\n if (scheme[key].required && typeof this._runConfig[key] === 'undefined') {\n throw `Parameter ${key} is required!`;\n }\n if (typeof this._runConfig[key] === 'undefined') {\n this._runConfig[key] = scheme[key].default;\n }\n }\n }\n _normalizeConfig() {\n const config = this._runConfig;\n // absolute and ending in a slash, so the runtime's files resolve inside it\n config.runtimeBaseUrl = new URL(config.runtimeBaseUrl.replace(/\\/?$/, '/'), document.baseURI).href;\n if (config.splash === undefined) {\n config.splash = new URL('assets/splash.jpg', config.runtimeBaseUrl).href;\n }\n config.scaleMode = SCALE_MODES[('' + config.scaleMode).toLowerCase()] || config.scaleMode;\n if (config.stageAlign) {\n config.stageAlign = normalizeAlign(config.stageAlign) || undefined;\n }\n // params and attributes are strings, but \"false\" shouldn't mean true\n for (const key of ['autoplay', 'hideBeforeLoad', 'smoothBitmaps', 'enableBlends', 'enableFilters']) {\n if (typeof config[key] === 'string') {\n config[key] = !/^(false|0)$/i.test(config[key].trim());\n }\n }\n if (config.splash === 'false') {\n config.splash = false;\n }\n if (config.progress === 'false') {\n config.progress = false;\n }\n if (config.bgcolor) {\n config.backgroundColor = parseColor(config.bgcolor) === null\n ? config.bgcolor\n : '#' + config.bgcolor.replace('#', '');\n }\n }\n _updateStyle() {\n this._style.textContent = `\n :host {\n display: inline-block;\n contain: content;\n width: ${cssSize(this._runConfig.width)};\n height: ${cssSize(this._runConfig.height)};\n }\n iframe {\n display: block;\n width: 100%;\n height: 100%;\n border: none;\n }\n `;\n }\n connectedCallback() {\n setTimeout(() => {\n this._loaderHolder = this.querySelector('div.awayfl__loader');\n this._loadGlobalConfig();\n this._mapAttrs();\n this._setDefaults();\n this._normalizeConfig();\n this._style = document.createElement('style');\n this._updateStyle();\n this._root.appendChild(this._style);\n this._constructPlayer();\n });\n }\n disconnectedCallback() {\n this._dropPlayer();\n }\n attributeChangedCallback(name, _oldValue, newValue) {\n if (!this.isConnected) {\n return;\n }\n // if SRC changed, drop runtime and load again\n if (name === 'src' && this._player) {\n this._dropPlayer();\n this._runConfig.src = newValue;\n this._constructPlayer();\n return;\n }\n if ((name === 'width' || name === 'height') && this._style) {\n this._runConfig[name] = newValue;\n this._updateStyle();\n }\n }\n}\nAwayPlayerComponent.BINDING_CONFIG = {\n version: { required: false, default: 'latest' },\n runtimeBaseUrl: { required: false, default: scriptBaseUrl },\n src: { required: true },\n width: { required: false, default: 550 },\n height: { required: false, default: 400 },\n onLoad: { required: false },\n onProgress: { required: false },\n onError: { required: false },\n scaleMode: { required: false, default: 'showAll' },\n stageAlign: { required: false },\n autoplay: { required: false, default: true },\n hideBeforeLoad: { required: false, default: false },\n maxStageScale: { required: false, default: undefined },\n backgroundColor: { required: false, default: 'black' },\n bgcolor: { required: false },\n flashvars: { required: false },\n // defaults to the splash in runtimeBaseUrl's assets\n splash: { required: false },\n progress: { required: false, default: defaultProgress },\n // runtime\n smoothBitmaps: { required: false, default: false },\n enableBlends: { required: false, default: false },\n enableFilters: { required: false, default: false },\n};\n// both the script and module builds may be loaded\nif (!customElements.get('awayfl-player')) {\n customElements.define('awayfl-player', AwayPlayerComponent);\n}\n","import { observeFlashMarkup, upgradeAll } from './flashMarkup';\nimport { addDomLoadEvent, swfobject, SWFObject } from './swfobject';\nexport { AwayPlayerComponent } from './AwayPlayerComponent';\nexport { swfobject, swfobject as swfObject, SWFObject };\n//@ts-ignore\nexport const VERSION = \"__VERSION__\";\nconst global = window;\n/**\n * Sets options for players, the same as defining AWAY_EMBED_CFG\n */\nexport function configure(config) {\n global.AWAY_EMBED_CFG = Object.assign(global.AWAY_EMBED_CFG || {}, config);\n}\n/**\n * Defines a global that keeps AwayFL's value if a page's own swfobject.js assigns\n * over it later, so embed.js works whether it's included before or after it\n */\nfunction defineGlobal(name, value) {\n const existing = Object.getOwnPropertyDescriptor(window, name);\n if (existing && !existing.configurable) {\n global[name] = value;\n return;\n }\n Object.defineProperty(window, name, {\n configurable: true,\n enumerable: true,\n get: () => value,\n set: (other) => {\n if (other !== value) {\n console.info(`[AwayFL] Ignoring the page's ${name}, as AwayFL provides it`);\n }\n },\n });\n}\nif (global.swfobject || global.swfObject || global.SWFObject) {\n console.info('[AwayFL] Replacing the page\\'s SWFObject');\n}\ndefineGlobal('swfobject', swfobject);\ndefineGlobal('swfObject', swfobject);\ndefineGlobal('SWFObject', SWFObject);\n// upgrade <object>/<embed> markup, including on pages that don't use SWFObject;\n// a tick later, so a module importing this can call configure() first\naddDomLoadEvent(() => setTimeout(() => {\n if ((global.AWAY_EMBED_CFG || {}).autoUpgrade !== false) {\n upgradeAll();\n observeFlashMarkup();\n }\n}));\n"],"names":["FLASH_TYPES","SWF_URL","PLUGIN_ATTRIBUTES","EMBED_PARAMS","paramsOf","el","params","child","Array","from","children","localName","getAttribute","toLowerCase","isFlashElement","tag","indexOf","url","movie","test","hasFlashAncestor","parent","parentElement","createPlayer","attributes","player","document","createElement","name","setAttribute","e","console","warn","param","value","appendChild","upgradeElement","markup","outer","elements","concat","querySelectorAll","filter","set","map","isEmbed","src","attr","readFlashMarkup","Object","assign","parentNode","replaceChild","upgradeAll","root","Element","forEach","isConnected","PLAYER_VERSION","userAgent","navigator","platform","ua","w3","pv","slice","wk","parseFloat","replace","ie","win","mac","encodeURIEnabled","autoHideShow","dynamicStylesheet","dynamicStylesheetMedia","isDomLoaded","readyState","getElement","id","getElementById","isPlayer","addDomLoadEvent","fn","addEventListener","hasPlayerVersion","versionStr","v","String","split","required","parseInt","createCSS","selStr","declStr","mediaStr","newStyleBoolean","head","media","createTextNode","setVisibility","isVisible","visibility","style","CSS","escape","createSWF","attObj","parObj","replaceElemIdStr","data","key","urlEncodeIfNecessary","s","encodeURIComponent","swfobject","registerObject","objectIdStr","swfVersionStr","_xiSwfUrlStr","callbackFn","callbackObj","success","ref","getObjectById","embedSWF","swfUrlStr","widthStr","heightStr","flashvarsObj","att","width","height","par","flashvars","keys","join","buildFlashVars","switchOffAutoHideShow","enableUriEncoding","enable","getFlashPlayerVersion","major","minor","release","hasFlashPlayerVersion","showExpressInstall","_att","_par","removeSWF","objElemIdStr","remove","addLoadEvent","setTimeout","window","getQueryParamValue","q","location","search","hash","pairs","i","length","substring","expressInstallCallback","SWFObject","constructor","swf","w","h","ver","c","quality","this","_attributes","_params","_variables","addParam","getParams","addVariable","getVariable","getVariables","getVariablePairs","useExpressInstall","_path","write","elementId","target","innerHTML","scriptBaseUrl","URL","_documentCurrentScript","baseURI","href","FLASH_PARAMS","bgcolor","scale","salign","SCALE_MODES","showall","all","noborder","exactfit","noscale","parseFlashVars","result","URLSearchParams","k","parseColor","match","exec","cssSize","AwayPlayerComponent","HTMLElement","observedAttributes","_player","config","_runConfig","cfg","runtimeBaseUrl","super","onError","bind","_root","attachShadow","mode","_getRuntimeUrl","baseUrl","loader","runtime","_dropPlayer","_gameFrame","_arg","f","self","dispatchEvent","ErrorEvent","error","Error","message","_attachRuntimeEvents","fd","contentWindow","detail","once","onLoad","CustomEvent","display","onProgress","_buildTemplate","frame","t","urls","gameConfig","clientWidth","clientHeight","backgroundColor","splash","progress","binary","path","resourceType","meta","maxStageScale","stageScaleMode","scaleMode","stageAlign","stageColor","runtimeFlags","defaultSmoothBitmap","smoothBitmaps","enableBlends","enableFilters","JSON","stringify","_constructPlayer","hideBeforeLoad","srcdoc","_configKey","lower","BINDING_CONFIG","find","_mapAttrs","node","getAttributeNames","_loadGlobalConfig","globalCfg","AWAY_EMBED_CFG","scheme","entries","_setDefaults","default","_normalizeConfig","undefined","toUpperCase","normalizeAlign","trim","_updateStyle","_style","textContent","connectedCallback","_loaderHolder","querySelector","disconnectedCallback","attributeChangedCallback","_oldValue","newValue","version","autoplay","direction","back","line","rect","customElements","get","define","global","defineGlobal","existing","getOwnPropertyDescriptor","configurable","defineProperty","enumerable","other","info","swfObject","autoUpgrade","pending","flush","added","MutationObserver","records","wasEmpty","record","addedNodes","nodeType","Node","ELEMENT_NODE","push","observe","documentElement","childList","subtree","observeFlashMarkup"],"mappings":"sGAAA,MACMA,EAAc,CAAC,gCAAiC,4BAChDC,EAAU,iBAIVC,EAAoB,CAAC,UAAW,WAAY,OAAQ,cAAe,OAAQ,MAAO,QAAS,UAI3FC,EAAe,CACjB,YAAa,UAAW,QAAS,SAAU,QAAS,UAAW,OAAQ,OAAQ,OAAQ,OACvF,oBAAqB,kBAAmB,6BAA8B,kBACtE,aAAc,kBAAmB,gBAAiB,WAAY,aAAc,kBAEhF,SAASC,EAASC,GACd,MAAMC,EAAS,CAAA,EACf,IAAK,MAAMC,K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","../src/embed/swfobject.ts","../src/embed/AwayPlayerComponent.ts","../src/embed/index.ts"],"sourcesContent":["const FLASH_CLASSID = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';\nconst FLASH_TYPES = ['application/x-shockwave-flash', 'application/futuresplash'];\nconst SWF_URL = /\\.swf([?#]|$)/i;\n/**\n * Attributes that describe the plugin rather than the element, so aren't copied\n */\nconst PLUGIN_ATTRIBUTES = ['classid', 'codebase', 'type', 'pluginspage', 'data', 'src', 'width', 'height'];\n/**\n * Flash parameters, which <embed> takes as attributes\n */\nconst EMBED_PARAMS = [\n 'flashvars', 'bgcolor', 'scale', 'salign', 'wmode', 'quality', 'menu', 'play', 'loop', 'base',\n 'allowscriptaccess', 'allowfullscreen', 'allowfullscreeninteractive', 'allownetworking',\n 'devicefont', 'seamlesstabbing', 'swliveconnect', 'swremote', 'swfversion', 'expressinstall',\n];\nfunction paramsOf(el) {\n const params = {};\n for (const child of Array.from(el.children)) {\n if (child.localName === 'param' && child.getAttribute('name')) {\n params[child.getAttribute('name').toLowerCase()] = child.getAttribute('value') || '';\n }\n }\n return params;\n}\nexport function isFlashElement(el) {\n const tag = el.localName;\n if (tag !== 'object' && tag !== 'embed') {\n return false;\n }\n if (FLASH_TYPES.indexOf((el.getAttribute('type') || '').toLowerCase()) > -1\n || (el.getAttribute('classid') || '').toLowerCase() === FLASH_CLASSID) {\n return true;\n }\n const url = tag === 'embed'\n ? el.getAttribute('src')\n : el.getAttribute('data') || paramsOf(el).movie;\n return SWF_URL.test(url || '');\n}\nfunction hasFlashAncestor(el) {\n for (let parent = el.parentElement; parent; parent = parent.parentElement) {\n if (isFlashElement(parent)) {\n return true;\n }\n }\n return false;\n}\n/**\n * Reads an <object>/<embed> and any Flash elements nested in it (the usual\n * cross-browser markup), the outermost taking precedence\n */\nfunction readFlashMarkup(outer) {\n const markup = { attributes: {}, params: {} };\n const elements = [outer].concat(Array.from(outer.querySelectorAll('object, embed')).filter(isFlashElement));\n const set = (map, name, value) => {\n if (!(name in map)) {\n map[name] = value;\n }\n };\n for (const el of elements) {\n const isEmbed = el.localName === 'embed';\n const params = paramsOf(el);\n markup.src = markup.src\n || el.getAttribute(isEmbed ? 'src' : 'data')\n || params.movie\n || params.src;\n for (const attr of Array.from(el.attributes)) {\n const name = attr.name.toLowerCase();\n if (name === 'width' || name === 'height') {\n set(markup.attributes, name, attr.value);\n }\n else if (isEmbed && EMBED_PARAMS.indexOf(name) > -1) {\n set(markup.params, name, attr.value);\n }\n else if (PLUGIN_ATTRIBUTES.indexOf(name) === -1) {\n set(markup.attributes, name, attr.value);\n }\n }\n for (const name in params) {\n if (name !== 'movie' && name !== 'src') {\n set(markup.params, name, params[name]);\n }\n }\n }\n return markup;\n}\nexport function createPlayer(attributes, params) {\n const player = document.createElement('awayfl-player');\n for (const name in attributes) {\n try {\n player.setAttribute(name, attributes[name]);\n }\n catch (e) {\n console.warn(`[AwayFL] Skipping invalid attribute \"${name}\"`);\n }\n }\n for (const name in params) {\n const param = document.createElement('param');\n param.name = name;\n param.value = params[name];\n player.appendChild(param);\n }\n return player;\n}\n/**\n * Replaces Flash <object>/<embed> markup with an AwayFL player\n */\nexport function upgradeElement(el) {\n const markup = readFlashMarkup(el);\n if (!markup.src) {\n return null;\n }\n const player = createPlayer(Object.assign({ src: markup.src }, markup.attributes), markup.params);\n el.parentNode.replaceChild(player, el);\n return player;\n}\nexport function upgradeAll(root = document) {\n if (root instanceof Element && isFlashElement(root)) {\n if (!hasFlashAncestor(root)) {\n upgradeElement(root);\n }\n return;\n }\n root.querySelectorAll('object, embed').forEach((el) => {\n // nested elements are detached once their outermost element is upgraded\n if (el.isConnected && isFlashElement(el) && !hasFlashAncestor(el)) {\n upgradeElement(el);\n }\n });\n}\n/**\n * Upgrades Flash markup added to the page after it has loaded\n */\nexport function observeFlashMarkup() {\n let pending = [];\n const flush = () => {\n const added = pending;\n pending = [];\n added.forEach((el) => el.isConnected && upgradeAll(el));\n };\n new MutationObserver((records) => {\n const wasEmpty = !pending.length;\n for (const record of records) {\n record.addedNodes.forEach((node) => {\n if (node.nodeType === Node.ELEMENT_NODE) {\n pending.push(node);\n }\n });\n }\n // wait for the script adding the markup to finish, e.g. appending its <param>s\n if (wasEmpty && pending.length) {\n setTimeout(flush);\n }\n }).observe(document.documentElement, { childList: true, subtree: true });\n}\n","import { createPlayer, isFlashElement, upgradeElement } from './flashMarkup';\n/**\n * The Flash Player version reported to pages, so they don't take their \"no Flash\" branch\n */\nconst PLAYER_VERSION = [32, 0, 0];\nconst userAgent = navigator.userAgent.toLowerCase();\nconst platform = (navigator.platform || '').toLowerCase();\nconst ua = {\n w3: true,\n pv: PLAYER_VERSION.slice(),\n wk: /webkit/.test(userAgent) ? parseFloat(userAgent.replace(/^.*webkit\\/(\\d+(\\.\\d+)?).*$/, '$1')) : false,\n ie: false,\n win: /win/.test(platform || userAgent),\n mac: /mac/.test(platform || userAgent),\n};\nlet encodeURIEnabled = false;\nlet autoHideShow = true;\nlet dynamicStylesheet = null;\nlet dynamicStylesheetMedia = null;\nfunction isDomLoaded() {\n return document.readyState !== 'loading';\n}\nfunction getElement(id) {\n return typeof id === 'string' ? document.getElementById(id) : id;\n}\n// by tag, as the element may be another build's class if both are loaded\nfunction isPlayer(el) {\n return !!el && el.localName === 'awayfl-player';\n}\nexport function addDomLoadEvent(fn) {\n if (isDomLoaded()) {\n fn();\n }\n else {\n document.addEventListener('DOMContentLoaded', () => fn());\n }\n}\nfunction addLoadEvent(fn) {\n if (document.readyState === 'complete') {\n setTimeout(fn);\n }\n else {\n window.addEventListener('load', () => fn());\n }\n}\nfunction hasPlayerVersion(versionStr) {\n const v = String(versionStr).split('.');\n const required = [parseInt(v[0], 10), parseInt(v[1], 10) || 0, parseInt(v[2], 10) || 0];\n const pv = PLAYER_VERSION;\n return pv[0] > required[0]\n || (pv[0] === required[0] && pv[1] > required[1])\n || (pv[0] === required[0] && pv[1] === required[1] && pv[2] >= required[2]);\n}\nfunction createCSS(selStr, declStr, mediaStr, newStyleBoolean) {\n const head = document.head;\n if (!head) {\n return;\n }\n const media = typeof mediaStr === 'string' && mediaStr ? mediaStr : 'screen';\n if (newStyleBoolean) {\n dynamicStylesheet = null;\n dynamicStylesheetMedia = null;\n }\n if (!dynamicStylesheet || dynamicStylesheetMedia !== media) {\n dynamicStylesheet = document.createElement('style');\n dynamicStylesheet.media = media;\n dynamicStylesheetMedia = media;\n head.appendChild(dynamicStylesheet);\n }\n dynamicStylesheet.appendChild(document.createTextNode(selStr + ' {' + declStr + '}'));\n}\n/**\n * Hides alternative content until it's replaced, as SWFObject does\n */\nfunction setVisibility(id, isVisible) {\n if (!autoHideShow || !id) {\n return;\n }\n const visibility = isVisible ? 'visible' : 'hidden';\n const el = document.getElementById(id);\n if (isDomLoaded() && el) {\n el.style.visibility = visibility;\n }\n else {\n createCSS('#' + CSS.escape(id), 'visibility:' + visibility);\n }\n}\nfunction createSWF(attObj, parObj, replaceElemIdStr) {\n const el = getElement(replaceElemIdStr);\n if (!el || !attObj || !attObj.data) {\n return undefined;\n }\n if (typeof attObj.id === 'undefined' && el.id) {\n attObj.id = el.id;\n }\n const attributes = { src: '' + attObj.data };\n for (const key in attObj) {\n const name = key.toLowerCase();\n if (name === 'styleclass') {\n attributes['class'] = '' + attObj[key];\n }\n else if (name !== 'classid' && name !== 'data') {\n attributes[key] = '' + attObj[key];\n }\n }\n const params = {};\n for (const key in parObj) {\n if (key.toLowerCase() !== 'movie') {\n params[key] = '' + parObj[key];\n }\n }\n const player = createPlayer(attributes, params);\n el.parentNode.replaceChild(player, el);\n return player;\n}\nfunction buildFlashVars(flashvarsObj) {\n if (!flashvarsObj || typeof flashvarsObj !== 'object') {\n return '';\n }\n return Object.keys(flashvarsObj)\n .map((key) => key + '=' + (encodeURIEnabled ? encodeURIComponent(flashvarsObj[key]) : flashvarsObj[key]))\n .join('&');\n}\nfunction embedSWF(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, _xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) {\n const id = typeof replaceElemIdStr === 'string' ? replaceElemIdStr : replaceElemIdStr && replaceElemIdStr.id;\n const callbackObj = { success: false, id };\n // unlike SWFObject the version is optional, as AwayFL's own examples omit it\n if (!swfUrlStr || !replaceElemIdStr || !widthStr || !heightStr) {\n callbackFn && callbackFn(callbackObj);\n return;\n }\n setVisibility(id, false);\n addDomLoadEvent(() => {\n // copied, as pages often reuse these objects for several SWFs\n const att = Object.assign({}, attObj, { data: swfUrlStr, width: '' + widthStr, height: '' + heightStr });\n const par = Object.assign({}, parObj);\n const flashvars = buildFlashVars(flashvarsObj);\n if (flashvars) {\n par.flashvars = typeof par.flashvars !== 'undefined' ? par.flashvars + '&' + flashvars : flashvars;\n }\n if (!swfVersionStr || hasPlayerVersion(swfVersionStr)) {\n const ref = createSWF(att, par, replaceElemIdStr);\n if (att.id == id) {\n setVisibility(id, true);\n }\n callbackObj.success = !!ref;\n if (ref) {\n callbackObj.ref = ref;\n }\n }\n else {\n // show the alternative content\n setVisibility(id, true);\n }\n callbackFn && callbackFn(callbackObj);\n });\n}\n/**\n * Static publishing: replaces the page's <object> markup with a player\n */\nfunction registerObject(objectIdStr, swfVersionStr, _xiSwfUrlStr, callbackFn) {\n if (!objectIdStr || !swfVersionStr) {\n callbackFn && callbackFn({ success: false, id: objectIdStr });\n return;\n }\n setVisibility(objectIdStr, false);\n addDomLoadEvent(() => {\n const callbackObj = { success: false, id: objectIdStr };\n if (hasPlayerVersion(swfVersionStr)) {\n let ref = document.getElementById(objectIdStr);\n // may already have been upgraded with the rest of the page's markup\n if (ref && !isPlayer(ref)) {\n ref = isFlashElement(ref) ? upgradeElement(ref) : null;\n }\n if (ref) {\n callbackObj.success = true;\n callbackObj.ref = ref;\n }\n }\n setVisibility(objectIdStr, true);\n callbackFn && callbackFn(callbackObj);\n });\n}\nfunction getObjectById(objectIdStr) {\n const el = document.getElementById(objectIdStr);\n return isPlayer(el) ? el : null;\n}\nfunction removeSWF(objElemIdStr) {\n const el = document.getElementById(objElemIdStr);\n if (el && (isPlayer(el) || isFlashElement(el))) {\n el.remove();\n }\n}\nfunction urlEncodeIfNecessary(s) {\n return /[\\\\\\\"<>\\.;]/.test(s) ? encodeURIComponent(s) : s;\n}\nfunction getQueryParamValue(param) {\n let q = document.location.search || document.location.hash;\n if (q) {\n if (/\\?/.test(q)) {\n q = q.split('?')[1];\n }\n if (param == null) {\n return urlEncodeIfNecessary(q);\n }\n const pairs = q.split('&');\n for (let i = 0; i < pairs.length; i++) {\n if (pairs[i].substring(0, pairs[i].indexOf('=')) == param) {\n return urlEncodeIfNecessary(pairs[i].substring(pairs[i].indexOf('=') + 1));\n }\n }\n }\n return '';\n}\nexport const swfobject = {\n registerObject,\n getObjectById,\n embedSWF,\n switchOffAutoHideShow() {\n autoHideShow = false;\n },\n enableUriEncoding(enable) {\n encodeURIEnabled = typeof enable === 'undefined' ? true : !!enable;\n },\n ua,\n getFlashPlayerVersion() {\n return { major: PLAYER_VERSION[0], minor: PLAYER_VERSION[1], release: PLAYER_VERSION[2] };\n },\n hasFlashPlayerVersion: hasPlayerVersion,\n createSWF(attObj, parObj, replaceElemIdStr) {\n return createSWF(attObj, parObj, replaceElemIdStr);\n },\n showExpressInstall(_att, _par, replaceElemIdStr, callbackFn) {\n console.warn('[AwayFL] Express Install is not needed or supported');\n callbackFn && callbackFn({ success: false, id: replaceElemIdStr });\n },\n removeSWF,\n createCSS,\n addDomLoadEvent,\n addLoadEvent,\n getQueryParamValue,\n expressInstallCallback() { },\n};\n/**\n * SWFObject 1.5: `new SWFObject(swf, id, width, height, version, bgcolor).write(elementId)`,\n * which renders the SWF inside the target element\n */\nexport class SWFObject {\n constructor(swf, id, w, h, ver, c, quality) {\n this._attributes = {};\n this._params = {};\n this._variables = {};\n this.setAttribute('swf', swf);\n this.setAttribute('id', id);\n this.setAttribute('width', '' + w);\n this.setAttribute('height', '' + h);\n this.setAttribute('version', ver);\n if (c) {\n this.addParam('bgcolor', c);\n }\n this.addParam('quality', quality || 'high');\n }\n setAttribute(name, value) {\n this._attributes[name] = value;\n }\n getAttribute(name) {\n return this._attributes[name] || '';\n }\n addParam(name, value) {\n this._params[name] = value;\n }\n getParams() {\n return this._params;\n }\n addVariable(name, value) {\n this._variables[name] = value;\n }\n getVariable(name) {\n return this._variables[name] || '';\n }\n getVariables() {\n return this._variables;\n }\n getVariablePairs() {\n return Object.keys(this._variables).map((key) => key + '=' + this._variables[key]);\n }\n useExpressInstall(_path) { }\n write(elementId) {\n const target = getElement(elementId);\n if (!target) {\n return false;\n }\n const id = this.getAttribute('id');\n const params = Object.assign({}, this._params);\n const flashvars = this.getVariablePairs().join('&');\n if (flashvars) {\n params.flashvars = flashvars;\n }\n const player = createPlayer({\n src: this.getAttribute('swf'),\n id,\n name: id,\n width: this.getAttribute('width'),\n height: this.getAttribute('height'),\n }, params);\n target.innerHTML = '';\n target.appendChild(player);\n return true;\n }\n}\n","//@ts-ignore\nimport template from \"./embed.html\";\n// rollup turns import.meta.url into document.currentScript's src in the classic\n// script build; in the ES module build it's the module's own URL\nconst scriptBaseUrl = new URL('.', import.meta.url).href;\n// a plain bar across the middle; its colours come from the element's text colour\nconst defaultProgress = {\n \"direction\": \"lr\",\n \"rect\": [\n 0.25,\n 0.495,\n 0.5,\n 0.01\n ]\n};\n/**\n * Flash <object>/<embed> parameter and attribute names that map onto config keys.\n * Others, such as wmode, allowScriptAccess, quality and menu, have no equivalent\n * and are ignored.\n */\nconst FLASH_PARAMS = {\n movie: 'src',\n data: 'src',\n flashvars: 'flashvars',\n bgcolor: 'bgcolor',\n scale: 'scaleMode',\n salign: 'stageAlign',\n};\nconst SCALE_MODES = {\n showall: 'showAll',\n all: 'showAll',\n noborder: 'noBorder',\n exactfit: 'exactFit',\n noscale: 'noScale',\n};\nexport function parseFlashVars(value) {\n const result = {};\n if (typeof value === 'string') {\n new URLSearchParams(value).forEach((v, k) => {\n result[k] = v;\n });\n }\n else if (value) {\n for (const key in value) {\n result[key] = String(value[key]);\n }\n }\n return result;\n}\nfunction parseColor(value) {\n const match = /^#?([0-9a-f]{6})$/i.exec(value || '');\n return match ? parseInt(match[1], 16) : null;\n}\nfunction normalizeAlign(value) {\n const v = value.toUpperCase();\n return (v.indexOf('T') > -1 ? 'T' : v.indexOf('B') > -1 ? 'B' : '')\n + (v.indexOf('L') > -1 ? 'L' : v.indexOf('R') > -1 ? 'R' : '');\n}\nfunction cssSize(value) {\n return /^\\d+(\\.\\d+)?$/.test('' + value) ? value + 'px' : '' + value;\n}\nexport class AwayPlayerComponent extends HTMLElement {\n static get observedAttributes() {\n return [\n 'src',\n 'width',\n 'height'\n ];\n }\n get player() {\n return this._player;\n }\n get config() {\n return this._runConfig;\n }\n set config(cfg) {\n this._runConfig = cfg;\n }\n get src() {\n return this._runConfig.src || this.getAttribute('src');\n }\n set src(v) {\n this._runConfig.src = v;\n }\n set width(v) {\n this._runConfig.width = v;\n }\n get width() {\n return this._runConfig.width || this.getAttribute('width');\n }\n set height(v) {\n this._runConfig.height = v;\n }\n get height() {\n return this._runConfig.height || this.getAttribute('height');\n }\n set runtimeBaseUrl(v) {\n this._runConfig.runtimeBaseUrl = v;\n }\n get runtimeBaseUrl() {\n return this._runConfig.runtimeBaseUrl;\n }\n constructor() {\n super();\n this._runConfig = {};\n this.onError = this.onError.bind(this);\n this._root = this.attachShadow({ mode: 'closed' });\n }\n _getRuntimeUrl() {\n const baseUrl = this._runConfig.runtimeBaseUrl;\n const loader = new URL('loader.js', baseUrl).href;\n const runtime = new URL('runtime.js', baseUrl).href;\n /**\n * @todo support runtime version\n **/\n return {\n loader,\n runtime,\n baseUrl,\n };\n }\n _dropPlayer() {\n if (this._gameFrame) {\n this._gameFrame.remove();\n this._player = null;\n }\n }\n onError(_arg) {\n const f = this._runConfig.onError && self[this._runConfig.onError];\n if (typeof f === 'function') {\n f(_arg);\n }\n this.dispatchEvent(new ErrorEvent('error', {\n error: new Error('Awayfl runtime error'),\n message: (_arg === null || _arg === void 0 ? void 0 : _arg.message) || _arg,\n }));\n }\n _attachRuntimeEvents() {\n const fd = this._gameFrame.contentWindow;\n //@ts-ignore\n fd.addEventListener('awayfl-player-init', ({ detail }) => {\n this._player = detail;\n }, { once: true });\n fd.addEventListener('awayfl-player-load', () => {\n const f = this._runConfig.onLoad && self[this._runConfig.onLoad];\n if (typeof f === 'function') {\n f();\n }\n this.dispatchEvent(new CustomEvent('load'));\n this._gameFrame.style.display = '';\n }, { once: true });\n //@ts-ignore\n fd.addEventListener('awayfl-player-error', ({ detail }) => this.onError(detail), { once: true });\n //@ts-ignore\n fd.addEventListener('awayfl-player-progress', ({ detail }) => {\n const f = this._runConfig.onProgress && self[this._runConfig.onProgress];\n if (typeof f === 'function') {\n f(detail);\n }\n this.dispatchEvent(new CustomEvent('progress', { detail }));\n });\n }\n /**\n * The loading bar, in the element's text colour on a fainter track unless\n * colours are given, so it suits the page it's on\n */\n _progressConfig() {\n const progress = this._runConfig.progress;\n if (!progress) {\n return false;\n }\n const color = getComputedStyle(this).color;\n return Object.assign(Object.assign({ line: color, back: `color-mix(in srgb, ${color} 20%, transparent)` }, defaultProgress), (typeof progress === 'object' ? progress : {}));\n }\n _buildTemplate(frame) {\n const t = template;\n const urls = this._getRuntimeUrl();\n const gameConfig = {\n width: frame.clientWidth,\n height: frame.clientHeight,\n backgroundColor: this._runConfig.backgroundColor,\n splash: this._runConfig.splash,\n progress: this._progressConfig(),\n runtime: [urls.runtime],\n binary: [{\n path: this._runConfig.src,\n resourceType: 'GAME',\n name: 'Game',\n meta: {}\n }],\n //debug: true,\n baseUrl: urls.baseUrl,\n maxStageScale: +this._runConfig.maxStageScale,\n flashvars: parseFlashVars(this._runConfig.flashvars),\n stageScaleMode: this._runConfig.scaleMode,\n stageAlign: this._runConfig.stageAlign,\n stageColor: parseColor(this._runConfig.bgcolor),\n runtimeFlags: {\n defaultSmoothBitmap: !!this._runConfig.smoothBitmaps,\n enableBlends: !!this._runConfig.enableBlends,\n enableFilters: !!this._runConfig.enableFilters,\n }\n };\n return t\n .replace(/__LOADER_URL__/, urls.loader)\n .replace(/__GAME_CONFIG__/, JSON.stringify(JSON.stringify(gameConfig)));\n }\n _constructPlayer() {\n const root = this._root;\n const frame = document.createElement('iframe');\n frame.style.display = this._runConfig.hideBeforeLoad ? 'none' : '';\n this._gameFrame = frame;\n root.appendChild(frame);\n frame.addEventListener('load', this._attachRuntimeEvents.bind(this), {\n once: true\n });\n frame.addEventListener('error', this.onError);\n frame.srcdoc = this._buildTemplate(frame);\n }\n /**\n * Config key for a param or attribute name, matched case-insensitively as\n * HTML lowercases attribute names and Flash param names ignore case\n */\n _configKey(name) {\n const lower = name.toLowerCase();\n if (lower in FLASH_PARAMS) {\n return FLASH_PARAMS[lower];\n }\n return Object.keys(AwayPlayerComponent.BINDING_CONFIG)\n .find((key) => key.toLowerCase() === lower);\n }\n _mapAttrs() {\n const params = this.querySelectorAll('param');\n const config = this._runConfig;\n params.forEach(node => {\n const key = this._configKey(node.name);\n if (key) {\n config[key] = node.value;\n }\n });\n this.getAttributeNames().forEach(name => {\n const key = this._configKey(name);\n if (key) {\n config[key] = this.getAttribute(name);\n }\n });\n }\n _loadGlobalConfig() {\n const global = window;\n const globalCfg = global.AWAY_EMBED_CFG || {};\n const scheme = AwayPlayerComponent.BINDING_CONFIG;\n for (const [key, value] of Object.entries(globalCfg)) {\n if (key in scheme) {\n this._runConfig[key] = value;\n }\n }\n }\n _setDefaults() {\n const scheme = AwayPlayerComponent.BINDING_CONFIG;\n for (const key in scheme) {\n if (scheme[key].required && typeof this._runConfig[key] === 'undefined') {\n throw `Parameter ${key} is required!`;\n }\n if (typeof this._runConfig[key] === 'undefined') {\n this._runConfig[key] = scheme[key].default;\n }\n }\n }\n _normalizeConfig() {\n const config = this._runConfig;\n // absolute and ending in a slash, so the runtime's files resolve inside it\n config.runtimeBaseUrl = new URL(config.runtimeBaseUrl.replace(/\\/?$/, '/'), document.baseURI).href;\n config.scaleMode = SCALE_MODES[('' + config.scaleMode).toLowerCase()] || config.scaleMode;\n if (config.stageAlign) {\n config.stageAlign = normalizeAlign(config.stageAlign) || undefined;\n }\n // params and attributes are strings, but \"false\" shouldn't mean true\n for (const key of ['autoplay', 'hideBeforeLoad', 'smoothBitmaps', 'enableBlends', 'enableFilters']) {\n if (typeof config[key] === 'string') {\n config[key] = !/^(false|0)$/i.test(config[key].trim());\n }\n }\n if (config.splash === 'false') {\n config.splash = false;\n }\n if (config.progress === 'false') {\n config.progress = false;\n }\n if (config.bgcolor) {\n config.backgroundColor = parseColor(config.bgcolor) === null\n ? config.bgcolor\n : '#' + config.bgcolor.replace('#', '');\n }\n }\n _updateStyle() {\n this._style.textContent = `\n :host {\n display: inline-block;\n contain: content;\n width: ${cssSize(this._runConfig.width)};\n height: ${cssSize(this._runConfig.height)};\n }\n iframe {\n display: block;\n width: 100%;\n height: 100%;\n border: none;\n /* matches the frame's own document, or browsers make the frame opaque */\n color-scheme: light;\n }\n `;\n }\n connectedCallback() {\n setTimeout(() => {\n this._loaderHolder = this.querySelector('div.awayfl__loader');\n this._loadGlobalConfig();\n this._mapAttrs();\n this._setDefaults();\n this._normalizeConfig();\n this._style = document.createElement('style');\n this._updateStyle();\n this._root.appendChild(this._style);\n this._constructPlayer();\n });\n }\n disconnectedCallback() {\n this._dropPlayer();\n }\n attributeChangedCallback(name, _oldValue, newValue) {\n if (!this.isConnected) {\n return;\n }\n // if SRC changed, drop runtime and load again\n if (name === 'src' && this._player) {\n this._dropPlayer();\n this._runConfig.src = newValue;\n this._constructPlayer();\n return;\n }\n if ((name === 'width' || name === 'height') && this._style) {\n this._runConfig[name] = newValue;\n this._updateStyle();\n }\n }\n}\nAwayPlayerComponent.BINDING_CONFIG = {\n version: { required: false, default: 'latest' },\n runtimeBaseUrl: { required: false, default: scriptBaseUrl },\n src: { required: true },\n width: { required: false, default: 550 },\n height: { required: false, default: 400 },\n onLoad: { required: false },\n onProgress: { required: false },\n onError: { required: false },\n scaleMode: { required: false, default: 'showAll' },\n stageAlign: { required: false },\n autoplay: { required: false, default: true },\n hideBeforeLoad: { required: false, default: false },\n maxStageScale: { required: false, default: undefined },\n // transparent while loading, then the stage colour, as in Flash\n backgroundColor: { required: false },\n bgcolor: { required: false },\n flashvars: { required: false },\n // an image to show while loading\n splash: { required: false },\n progress: { required: false, default: defaultProgress },\n // runtime\n smoothBitmaps: { required: false, default: false },\n enableBlends: { required: false, default: false },\n enableFilters: { required: false, default: false },\n};\n// both the script and module builds may be loaded\nif (!customElements.get('awayfl-player')) {\n customElements.define('awayfl-player', AwayPlayerComponent);\n}\n","import { observeFlashMarkup, upgradeAll } from './flashMarkup';\nimport { addDomLoadEvent, swfobject, SWFObject } from './swfobject';\nexport { AwayPlayerComponent } from './AwayPlayerComponent';\nexport { swfobject, swfobject as swfObject, SWFObject };\n//@ts-ignore\nexport const VERSION = \"__VERSION__\";\nconst global = window;\n/**\n * Sets options for players, the same as defining AWAY_EMBED_CFG\n */\nexport function configure(config) {\n global.AWAY_EMBED_CFG = Object.assign(global.AWAY_EMBED_CFG || {}, config);\n}\n/**\n * Defines a global that keeps AwayFL's value if a page's own swfobject.js assigns\n * over it later, so embed.js works whether it's included before or after it\n */\nfunction defineGlobal(name, value) {\n const existing = Object.getOwnPropertyDescriptor(window, name);\n if (existing && !existing.configurable) {\n global[name] = value;\n return;\n }\n Object.defineProperty(window, name, {\n configurable: true,\n enumerable: true,\n get: () => value,\n set: (other) => {\n if (other !== value) {\n console.info(`[AwayFL] Ignoring the page's ${name}, as AwayFL provides it`);\n }\n },\n });\n}\nif (global.swfobject || global.swfObject || global.SWFObject) {\n console.info('[AwayFL] Replacing the page\\'s SWFObject');\n}\ndefineGlobal('swfobject', swfobject);\ndefineGlobal('swfObject', swfobject);\ndefineGlobal('SWFObject', SWFObject);\n// upgrade <object>/<embed> markup, including on pages that don't use SWFObject;\n// a tick later, so a module importing this can call configure() first\naddDomLoadEvent(() => setTimeout(() => {\n if ((global.AWAY_EMBED_CFG || {}).autoUpgrade !== false) {\n upgradeAll();\n observeFlashMarkup();\n }\n}));\n"],"names":["FLASH_TYPES","SWF_URL","PLUGIN_ATTRIBUTES","EMBED_PARAMS","paramsOf","el","params","child","Array","from","children","localName","getAttribute","toLowerCase","isFlashElement","tag","indexOf","url","movie","test","hasFlashAncestor","parent","parentElement","createPlayer","attributes","player","document","createElement","name","setAttribute","e","console","warn","param","value","appendChild","upgradeElement","markup","outer","elements","concat","querySelectorAll","filter","set","map","isEmbed","src","attr","readFlashMarkup","Object","assign","parentNode","replaceChild","upgradeAll","root","Element","forEach","isConnected","PLAYER_VERSION","userAgent","navigator","platform","ua","w3","pv","slice","wk","parseFloat","replace","ie","win","mac","encodeURIEnabled","autoHideShow","dynamicStylesheet","dynamicStylesheetMedia","isDomLoaded","readyState","getElement","id","getElementById","isPlayer","addDomLoadEvent","fn","addEventListener","hasPlayerVersion","versionStr","v","String","split","required","parseInt","createCSS","selStr","declStr","mediaStr","newStyleBoolean","head","media","createTextNode","setVisibility","isVisible","visibility","style","CSS","escape","createSWF","attObj","parObj","replaceElemIdStr","data","key","urlEncodeIfNecessary","s","encodeURIComponent","swfobject","registerObject","objectIdStr","swfVersionStr","_xiSwfUrlStr","callbackFn","callbackObj","success","ref","getObjectById","embedSWF","swfUrlStr","widthStr","heightStr","flashvarsObj","att","width","height","par","flashvars","keys","join","buildFlashVars","switchOffAutoHideShow","enableUriEncoding","enable","getFlashPlayerVersion","major","minor","release","hasFlashPlayerVersion","showExpressInstall","_att","_par","removeSWF","objElemIdStr","remove","addLoadEvent","setTimeout","window","getQueryParamValue","q","location","search","hash","pairs","i","length","substring","expressInstallCallback","SWFObject","constructor","swf","w","h","ver","c","quality","this","_attributes","_params","_variables","addParam","getParams","addVariable","getVariable","getVariables","getVariablePairs","useExpressInstall","_path","write","elementId","target","innerHTML","scriptBaseUrl","URL","_documentCurrentScript","baseURI","href","defaultProgress","direction","rect","FLASH_PARAMS","bgcolor","scale","salign","SCALE_MODES","showall","all","noborder","exactfit","noscale","parseFlashVars","result","URLSearchParams","k","parseColor","match","exec","cssSize","AwayPlayerComponent","HTMLElement","observedAttributes","_player","config","_runConfig","cfg","runtimeBaseUrl","super","onError","bind","_root","attachShadow","mode","_getRuntimeUrl","baseUrl","loader","runtime","_dropPlayer","_gameFrame","_arg","f","self","dispatchEvent","ErrorEvent","error","Error","message","_attachRuntimeEvents","fd","contentWindow","detail","once","onLoad","CustomEvent","display","onProgress","_progressConfig","progress","color","getComputedStyle","line","back","_buildTemplate","frame","t","urls","gameConfig","clientWidth","clientHeight","backgroundColor","splash","binary","path","resourceType","meta","maxStageScale","stageScaleMode","scaleMode","stageAlign","stageColor","runtimeFlags","defaultSmoothBitmap","smoothBitmaps","enableBlends","enableFilters","JSON","stringify","_constructPlayer","hideBeforeLoad","srcdoc","_configKey","lower","BINDING_CONFIG","find","_mapAttrs","node","getAttributeNames","_loadGlobalConfig","globalCfg","AWAY_EMBED_CFG","scheme","entries","_setDefaults","default","_normalizeConfig","toUpperCase","normalizeAlign","undefined","trim","_updateStyle","_style","textContent","connectedCallback","_loaderHolder","querySelector","disconnectedCallback","attributeChangedCallback","_oldValue","newValue","version","autoplay","customElements","get","define","global","defineGlobal","existing","getOwnPropertyDescriptor","configurable","defineProperty","enumerable","other","info","swfObject","autoUpgrade","pending","flush","added","MutationObserver","records","wasEmpty","record","addedNodes","nodeType","Node","ELEMENT_NODE","push","observe","documentElement","childList","subtree","observeFlashMarkup"],"mappings":"sGAAA,MACMA,EAAc,CAAC,gCAAiC,4BAChDC,EAAU,iBAIVC,EAAoB,CAAC,UAAW,WAAY,OAAQ,cAAe,OAAQ,MAAO,QAAS,UAI3FC,EAAe,CACjB,YAAa,UAAW,QAAS,SAAU,QAAS,UAAW,OAAQ,OAAQ,OAAQ,OACvF,oBAAqB,kBAAmB,6BAA8B,kBACtE,aAAc,kBAAmB,gBAAiB,WAAY,aAAc,kBAEhF,SAASC,EAASC,GACd,MAAMC,EAAS,CAAA,EACf,IAAK,MAAMC,KAASC,MAAMC,KAAKJ,E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AAO8Q,EAAOzB,gBAAkB,CAAA,EAAI5E,EACvE"}
|
package/dist/embed.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const t=["application/x-shockwave-flash","application/futuresplash"],e=/\.swf([?#]|$)/i,n=["classid","codebase","type","pluginspage","data","src","width","height"],r=["flashvars","bgcolor","scale","salign","wmode","quality","menu","play","loop","base","allowscriptaccess","allowfullscreen","allowfullscreeninteractive","allownetworking","devicefont","seamlesstabbing","swliveconnect","swremote","swfversion","expressinstall"];function i(t){const e={};for(const n of Array.from(t.children))"param"===n.localName&&n.getAttribute("name")&&(e[n.getAttribute("name").toLowerCase()]=n.getAttribute("value")||"");return e}function s(n){const r=n.localName;if("object"!==r&&"embed"!==r)return!1;if(t.indexOf((n.getAttribute("type")||"").toLowerCase())>-1||"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"===(n.getAttribute("classid")||"").toLowerCase())return!0;const s="embed"===r?n.getAttribute("src"):n.getAttribute("data")||i(n).movie;return e.test(s||"")}function o(t){for(let e=t.parentElement;e;e=e.parentElement)if(s(e))return!0;return!1}function a(t,e){const n=document.createElement("awayfl-player");for(const e in t)try{n.setAttribute(e,t[e])}catch(t){console.warn(`[AwayFL] Skipping invalid attribute "${e}"`)}for(const t in e){const r=document.createElement("param");r.name=t,r.value=e[t],n.appendChild(r)}return n}function l(t){const e=function(t){const e={attributes:{},params:{}},o=[t].concat(Array.from(t.querySelectorAll("object, embed")).filter(s)),a=(t,e,n)=>{e in t||(t[e]=n)};for(const t of o){const s="embed"===t.localName,o=i(t);e.src=e.src||t.getAttribute(s?"src":"data")||o.movie||o.src;for(const i of Array.from(t.attributes)){const t=i.name.toLowerCase();"width"===t||"height"===t?a(e.attributes,t,i.value):s&&r.indexOf(t)>-1?a(e.params,t,i.value):-1===n.indexOf(t)&&a(e.attributes,t,i.value)}for(const t in o)"movie"!==t&&"src"!==t&&a(e.params,t,o[t])}return e}(t);if(!e.src)return null;const o=a(Object.assign({src:e.src},e.attributes),e.params);return t.parentNode.replaceChild(o,t),o}function c(t=document){t instanceof Element&&s(t)?o(t)||l(t):t.querySelectorAll("object, embed").forEach(t=>{t.isConnected&&s(t)&&!o(t)&&l(t)})}const d=[32,0,0],u=navigator.userAgent.toLowerCase(),h=(navigator.platform||"").toLowerCase(),f={w3:!0,pv:d.slice(),wk:!!/webkit/.test(u)&&parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")),ie:!1,win:/win/.test(h||u),mac:/mac/.test(h||u)};let g=!1,m=!0,p=null,b=null;function _(){return"loading"!==document.readyState}function w(t){return"string"==typeof t?document.getElementById(t):t}function y(t){return!!t&&"awayfl-player"===t.localName}function C(t){_()?t():document.addEventListener("DOMContentLoaded",()=>t())}function v(t){const e=String(t).split("."),n=[parseInt(e[0],10),parseInt(e[1],10)||0,parseInt(e[2],10)||0],r=d;return r[0]>n[0]||r[0]===n[0]&&r[1]>n[1]||r[0]===n[0]&&r[1]===n[1]&&r[2]>=n[2]}function E(t,e,n,r){const i=document.head;if(!i)return;const s="string"==typeof n&&n?n:"screen";r&&(p=null,b=null),p&&b===s||(p=document.createElement("style"),p.media=s,b=s,i.appendChild(p)),p.appendChild(document.createTextNode(t+" {"+e+"}"))}function A(t,e){if(!m||!t)return;const n=e?"visible":"hidden",r=document.getElementById(t);_()&&r?r.style.visibility=n:E("#"+CSS.escape(t),"visibility:"+n)}function L(t,e,n){const r=w(n);if(!r||!t||!t.data)return;void 0===t.id&&r.id&&(t.id=r.id);const i={src:""+t.data};for(const e in t){const n=e.toLowerCase();"styleclass"===n?i.class=""+t[e]:"classid"!==n&&"data"!==n&&(i[e]=""+t[e])}const s={};for(const t in e)"movie"!==t.toLowerCase()&&(s[t]=""+e[t]);const o=a(i,s);return r.parentNode.replaceChild(o,r),o}function O(t){return/[\\\"<>\.;]/.test(t)?encodeURIComponent(t):t}const F={registerObject:function(t,e,n,r){t&&e?(A(t,!1),C(()=>{const n={success:!1,id:t};if(v(e)){let e=document.getElementById(t);e&&!y(e)&&(e=s(e)?l(e):null),e&&(n.success=!0,n.ref=e)}A(t,!0),r&&r(n)})):r&&r({success:!1,id:t})},getObjectById:function(t){const e=document.getElementById(t);return y(e)?e:null},embedSWF:function(t,e,n,r,i,s,o,a,l,c){const d="string"==typeof e?e:e&&e.id,u={success:!1,id:d};t&&e&&n&&r?(A(d,!1),C(()=>{const s=Object.assign({},l,{data:t,width:""+n,height:""+r}),h=Object.assign({},a),f=function(t){return t&&"object"==typeof t?Object.keys(t).map(e=>e+"="+(g?encodeURIComponent(t[e]):t[e])).join("&"):""}(o);if(f&&(h.flashvars=void 0!==h.flashvars?h.flashvars+"&"+f:f),!i||v(i)){const t=L(s,h,e);s.id==d&&A(d,!0),u.success=!!t,t&&(u.ref=t)}else A(d,!0);c&&c(u)})):c&&c(u)},switchOffAutoHideShow(){m=!1},enableUriEncoding(t){g=void 0===t||!!t},ua:f,getFlashPlayerVersion:()=>({major:d[0],minor:d[1],release:d[2]}),hasFlashPlayerVersion:v,createSWF:(t,e,n)=>L(t,e,n),showExpressInstall(t,e,n,r){console.warn("[AwayFL] Express Install is not needed or supported"),r&&r({success:!1,id:n})},removeSWF:function(t){const e=document.getElementById(t);e&&(y(e)||s(e))&&e.remove()},createCSS:E,addDomLoadEvent:C,addLoadEvent:function(t){"complete"===document.readyState?setTimeout(t):window.addEventListener("load",()=>t())},getQueryParamValue:function(t){let e=document.location.search||document.location.hash;if(e){if(/\?/.test(e)&&(e=e.split("?")[1]),null==t)return O(e);const n=e.split("&");for(let e=0;e<n.length;e++)if(n[e].substring(0,n[e].indexOf("="))==t)return O(n[e].substring(n[e].indexOf("=")+1))}return""},expressInstallCallback(){}};class B{constructor(t,e,n,r,i,s,o){this._attributes={},this._params={},this._variables={},this.setAttribute("swf",t),this.setAttribute("id",e),this.setAttribute("width",""+n),this.setAttribute("height",""+r),this.setAttribute("version",i),s&&this.addParam("bgcolor",s),this.addParam("quality",o||"high")}setAttribute(t,e){this._attributes[t]=e}getAttribute(t){return this._attributes[t]||""}addParam(t,e){this._params[t]=e}getParams(){return this._params}addVariable(t,e){this._variables[t]=e}getVariable(t){return this._variables[t]||""}getVariables(){return this._variables}getVariablePairs(){return Object.keys(this._variables).map(t=>t+"="+this._variables[t])}useExpressInstall(t){}write(t){const e=w(t);if(!e)return!1;const n=this.getAttribute("id"),r=Object.assign({},this._params),i=this.getVariablePairs().join("&");i&&(r.flashvars=i);const s=a({src:this.getAttribute("swf"),id:n,name:n,width:this.getAttribute("width"),height:this.getAttribute("height")},r);return e.innerHTML="",e.appendChild(s),!0}}const S=new URL(".",import.meta.url).href,I={movie:"src",data:"src",flashvars:"flashvars",bgcolor:"bgcolor",scale:"scaleMode",salign:"stageAlign"},j={showall:"showAll",all:"showAll",noborder:"noBorder",exactfit:"exactFit",noscale:"noScale"};function q(t){const e={};if("string"==typeof t)new URLSearchParams(t).forEach((t,n)=>{e[n]=t});else if(t)for(const n in t)e[n]=String(t[n]);return e}function N(t){const e=/^#?([0-9a-f]{6})$/i.exec(t||"");return e?parseInt(e[1],16):null}function x(t){return/^\d+(\.\d+)?$/.test(""+t)?t+"px":""+t}class P extends HTMLElement{static get observedAttributes(){return["src","width","height"]}get player(){return this._player}get config(){return this._runConfig}set config(t){this._runConfig=t}get src(){return this._runConfig.src||this.getAttribute("src")}set src(t){this._runConfig.src=t}set width(t){this._runConfig.width=t}get width(){return this._runConfig.width||this.getAttribute("width")}set height(t){this._runConfig.height=t}get height(){return this._runConfig.height||this.getAttribute("height")}set runtimeBaseUrl(t){this._runConfig.runtimeBaseUrl=t}get runtimeBaseUrl(){return this._runConfig.runtimeBaseUrl}constructor(){super(),this._runConfig={},this.onError=this.onError.bind(this),this._root=this.attachShadow({mode:"closed"})}_getRuntimeUrl(){const t=this._runConfig.runtimeBaseUrl;return{loader:new URL("loader.js",t).href,runtime:new URL("runtime.js",t).href,baseUrl:t}}_dropPlayer(){this._gameFrame&&(this._gameFrame.remove(),this._player=null)}onError(t){const e=this._runConfig.onError&&self[this._runConfig.onError];"function"==typeof e&&e(t),this.dispatchEvent(new ErrorEvent("error",{error:new Error("Awayfl runtime error"),message:(null==t?void 0:t.message)||t}))}_attachRuntimeEvents(){const t=this._gameFrame.contentWindow;t.addEventListener("awayfl-player-init",({detail:t})=>{this._player=t},{once:!0}),t.addEventListener("awayfl-player-load",()=>{const t=this._runConfig.onLoad&&self[this._runConfig.onLoad];"function"==typeof t&&t(),this.dispatchEvent(new CustomEvent("load")),this._gameFrame.style.display=""},{once:!0}),t.addEventListener("awayfl-player-error",({detail:t})=>this.onError(t),{once:!0}),t.addEventListener("awayfl-player-progress",({detail:t})=>{const e=this._runConfig.onProgress&&self[this._runConfig.onProgress];"function"==typeof e&&e(t),this.dispatchEvent(new CustomEvent("progress",{detail:t}))})}_buildTemplate(t){const e='<!DOCTYPE html>\n<head>\n\t<meta name="viewport"\n\t\tcontent="height=device-height, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui" />\n\t<title>AwayFL Embedded Player 0.1.4</title>\n\t<style>\n\t\t* {\n\t\t\tmargin: 0;\n\t\t\tpadding: 0;\n\t\t}\n\n\t\tcanvas {\n\t\t\toutline: none\n\t\t}\n\n\t\thtml, body, #container {\n\t\t\tmargin: 0;\n\t\t\toverflow: hidden;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\n\t\t#splash__image {\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t\tposition: absolute;\n\t\t\tbackground-size: contain;\n\t\t\tbackground-position: center;\n\t\t\tbackground-repeat: no-repeat;\n\t\t\tvisibility: visible;\n\t\t\ttransition: all 0.5s;\n\t\t\tz-index: 10;\n\t\t}\n\n\t\t#progress__root {\n\t\t\tposition: absolute;\n\t\t}\n\n\t\t#progress__line {\n\t\t\twidth: 0;\n\t\t\theight: 100%;\n\t\t\ttransition: all 0.5s;\n\t\t}\n\t</style>\n\t<script src="__LOADER_URL__"><\/script>\n</head>\n\n<body>\n\t<div id="splash__image">\n\t\t<div id="progress__root">\n\t\t\t<div id="progress__line"></div>\n\t\t</div>\n\t</div>\n\t<script>\n\t\twindow.addEventListener("load", () => {\n\n\t\t\tconst config = JSON.parse(__GAME_CONFIG__);\n\t\t\tconst fail = (error) => {\n\t\t\t\tconsole.error(\'[AwayFL]\', error);\n\t\t\t\twindow.dispatchEvent(new CustomEvent(\'awayfl-player-error\', {detail: error}));\n\t\t\t};\n\n\t\t\tAWAYFL.LegacyLoader.init(config);\n\t\t\tAWAYFL.LegacyLoader.runGame((fill) => {\n\t\t\t\twindow.dispatchEvent(new CustomEvent(\'awayfl-player-progress\', {detail: fill}));\n\t\t\t}, (config, hideLoader) => {\n\t\t\t\tconst player = new AWAYFL.Player(document, config);\n\t\t\t\twindow.dispatchEvent(new CustomEvent(\'awayfl-player-init\', {detail: player}));\n\t\t\t\tplayer\n\t\t\t\t\t.loadAndPlay()\n\t\t\t\t\t.then((_, hide) => {\n\t\t\t\t\t\twindow.dispatchEvent(new CustomEvent(\'awayfl-player-load\'));\n\t\t\t\t\t\thide && hide() || window.swfParseComplete && window.swfParseComplete();;\n\t\t\t\t\t})\n\t\t\t\t\t.catch(fail);\n\t\t\t}).catch(fail);\n\t\t});\n\t<\/script>\n</body>',n=this._getRuntimeUrl(),r={width:t.clientWidth,height:t.clientHeight,backgroundColor:this._runConfig.backgroundColor,splash:this._runConfig.splash,progress:this._runConfig.progress,runtime:[n.runtime],binary:[{path:this._runConfig.src,resourceType:"GAME",name:"Game",meta:{}}],baseUrl:n.baseUrl,maxStageScale:+this._runConfig.maxStageScale,flashvars:q(this._runConfig.flashvars),stageScaleMode:this._runConfig.scaleMode,stageAlign:this._runConfig.stageAlign,stageColor:N(this._runConfig.bgcolor),runtimeFlags:{defaultSmoothBitmap:!!this._runConfig.smoothBitmaps,enableBlends:!!this._runConfig.enableBlends,enableFilters:!!this._runConfig.enableFilters}};return e.replace(/__LOADER_URL__/,n.loader).replace(/__GAME_CONFIG__/,JSON.stringify(JSON.stringify(r)))}_constructPlayer(){const t=this._root,e=document.createElement("iframe");e.style.display=this._runConfig.hideBeforeLoad?"none":"",this._gameFrame=e,t.appendChild(e),e.addEventListener("load",this._attachRuntimeEvents.bind(this),{once:!0}),e.addEventListener("error",this.onError),e.srcdoc=this._buildTemplate(e)}_configKey(t){const e=t.toLowerCase();return e in I?I[e]:Object.keys(P.BINDING_CONFIG).find(t=>t.toLowerCase()===e)}_mapAttrs(){const t=this.querySelectorAll("param"),e=this._runConfig;t.forEach(t=>{const n=this._configKey(t.name);n&&(e[n]=t.value)}),this.getAttributeNames().forEach(t=>{const n=this._configKey(t);n&&(e[n]=this.getAttribute(t))})}_loadGlobalConfig(){const t=window.AWAY_EMBED_CFG||{},e=P.BINDING_CONFIG;for(const[n,r]of Object.entries(t))n in e&&(this._runConfig[n]=r)}_setDefaults(){const t=P.BINDING_CONFIG;for(const e in t){if(t[e].required&&void 0===this._runConfig[e])throw`Parameter ${e} is required!`;void 0===this._runConfig[e]&&(this._runConfig[e]=t[e].default)}}_normalizeConfig(){const t=this._runConfig;t.runtimeBaseUrl=new URL(t.runtimeBaseUrl.replace(/\/?$/,"/"),document.baseURI).href,void 0===t.splash&&(t.splash=new URL("assets/splash.jpg",t.runtimeBaseUrl).href),t.scaleMode=j[(""+t.scaleMode).toLowerCase()]||t.scaleMode,t.stageAlign&&(t.stageAlign=function(t){const e=t.toUpperCase();return(e.indexOf("T")>-1?"T":e.indexOf("B")>-1?"B":"")+(e.indexOf("L")>-1?"L":e.indexOf("R")>-1?"R":"")}(t.stageAlign)||void 0);for(const e of["autoplay","hideBeforeLoad","smoothBitmaps","enableBlends","enableFilters"])"string"==typeof t[e]&&(t[e]=!/^(false|0)$/i.test(t[e].trim()));"false"===t.splash&&(t.splash=!1),"false"===t.progress&&(t.progress=!1),t.bgcolor&&(t.backgroundColor=null===N(t.bgcolor)?t.bgcolor:"#"+t.bgcolor.replace("#",""))}_updateStyle(){this._style.textContent=`\n :host {\n display: inline-block;\n contain: content;\n width: ${x(this._runConfig.width)};\n height: ${x(this._runConfig.height)};\n }\n iframe {\n display: block;\n width: 100%;\n height: 100%;\n border: none;\n }\n `}connectedCallback(){setTimeout(()=>{this._loaderHolder=this.querySelector("div.awayfl__loader"),this._loadGlobalConfig(),this._mapAttrs(),this._setDefaults(),this._normalizeConfig(),this._style=document.createElement("style"),this._updateStyle(),this._root.appendChild(this._style),this._constructPlayer()})}disconnectedCallback(){this._dropPlayer()}attributeChangedCallback(t,e,n){if(this.isConnected)return"src"===t&&this._player?(this._dropPlayer(),this._runConfig.src=n,void this._constructPlayer()):void("width"!==t&&"height"!==t||!this._style||(this._runConfig[t]=n,this._updateStyle()))}}P.BINDING_CONFIG={version:{required:!1,default:"latest"},runtimeBaseUrl:{required:!1,default:S},src:{required:!0},width:{required:!1,default:550},height:{required:!1,default:400},onLoad:{required:!1},onProgress:{required:!1},onError:{required:!1},scaleMode:{required:!1,default:"showAll"},stageAlign:{required:!1},autoplay:{required:!1,default:!0},hideBeforeLoad:{required:!1,default:!1},maxStageScale:{required:!1,default:void 0},backgroundColor:{required:!1,default:"black"},bgcolor:{required:!1},flashvars:{required:!1},splash:{required:!1},progress:{required:!1,default:{direction:"lr",back:"#130d02",line:"#f29f01",rect:[.25,.77,.5,.01]}},smoothBitmaps:{required:!1,default:!1},enableBlends:{required:!1,default:!1},enableFilters:{required:!1,default:!1}},customElements.get("awayfl-player")||customElements.define("awayfl-player",P);const U="0.1.4",k=window;function G(t){k.AWAY_EMBED_CFG=Object.assign(k.AWAY_EMBED_CFG||{},t)}function R(t,e){const n=Object.getOwnPropertyDescriptor(window,t);!n||n.configurable?Object.defineProperty(window,t,{configurable:!0,enumerable:!0,get:()=>e,set:n=>{n!==e&&console.info(`[AwayFL] Ignoring the page's ${t}, as AwayFL provides it`)}}):k[t]=e}(k.swfobject||k.swfObject||k.SWFObject)&&console.info("[AwayFL] Replacing the page's SWFObject"),R("swfobject",F),R("swfObject",F),R("SWFObject",B),C(()=>setTimeout(()=>{!1!==(k.AWAY_EMBED_CFG||{}).autoUpgrade&&(c(),function(){let t=[];const e=()=>{const e=t;t=[],e.forEach(t=>t.isConnected&&c(t))};new MutationObserver(n=>{const r=!t.length;for(const e of n)e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&t.push(e)});r&&t.length&&setTimeout(e)}).observe(document.documentElement,{childList:!0,subtree:!0})}())}));export{P as AwayPlayerComponent,B as SWFObject,U as VERSION,G as configure,F as swfObject,F as swfobject};
|
|
1
|
+
const t=["application/x-shockwave-flash","application/futuresplash"],e=/\.swf([?#]|$)/i,n=["classid","codebase","type","pluginspage","data","src","width","height"],r=["flashvars","bgcolor","scale","salign","wmode","quality","menu","play","loop","base","allowscriptaccess","allowfullscreen","allowfullscreeninteractive","allownetworking","devicefont","seamlesstabbing","swliveconnect","swremote","swfversion","expressinstall"];function i(t){const e={};for(const n of Array.from(t.children))"param"===n.localName&&n.getAttribute("name")&&(e[n.getAttribute("name").toLowerCase()]=n.getAttribute("value")||"");return e}function s(n){const r=n.localName;if("object"!==r&&"embed"!==r)return!1;if(t.indexOf((n.getAttribute("type")||"").toLowerCase())>-1||"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"===(n.getAttribute("classid")||"").toLowerCase())return!0;const s="embed"===r?n.getAttribute("src"):n.getAttribute("data")||i(n).movie;return e.test(s||"")}function o(t){for(let e=t.parentElement;e;e=e.parentElement)if(s(e))return!0;return!1}function a(t,e){const n=document.createElement("awayfl-player");for(const e in t)try{n.setAttribute(e,t[e])}catch(t){console.warn(`[AwayFL] Skipping invalid attribute "${e}"`)}for(const t in e){const r=document.createElement("param");r.name=t,r.value=e[t],n.appendChild(r)}return n}function l(t){const e=function(t){const e={attributes:{},params:{}},o=[t].concat(Array.from(t.querySelectorAll("object, embed")).filter(s)),a=(t,e,n)=>{e in t||(t[e]=n)};for(const t of o){const s="embed"===t.localName,o=i(t);e.src=e.src||t.getAttribute(s?"src":"data")||o.movie||o.src;for(const i of Array.from(t.attributes)){const t=i.name.toLowerCase();"width"===t||"height"===t?a(e.attributes,t,i.value):s&&r.indexOf(t)>-1?a(e.params,t,i.value):-1===n.indexOf(t)&&a(e.attributes,t,i.value)}for(const t in o)"movie"!==t&&"src"!==t&&a(e.params,t,o[t])}return e}(t);if(!e.src)return null;const o=a(Object.assign({src:e.src},e.attributes),e.params);return t.parentNode.replaceChild(o,t),o}function c(t=document){t instanceof Element&&s(t)?o(t)||l(t):t.querySelectorAll("object, embed").forEach(t=>{t.isConnected&&s(t)&&!o(t)&&l(t)})}const d=[32,0,0],u=navigator.userAgent.toLowerCase(),h=(navigator.platform||"").toLowerCase(),f={w3:!0,pv:d.slice(),wk:!!/webkit/.test(u)&&parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")),ie:!1,win:/win/.test(h||u),mac:/mac/.test(h||u)};let g=!1,m=!0,p=null,b=null;function _(){return"loading"!==document.readyState}function w(t){return"string"==typeof t?document.getElementById(t):t}function y(t){return!!t&&"awayfl-player"===t.localName}function C(t){_()?t():document.addEventListener("DOMContentLoaded",()=>t())}function v(t){const e=String(t).split("."),n=[parseInt(e[0],10),parseInt(e[1],10)||0,parseInt(e[2],10)||0],r=d;return r[0]>n[0]||r[0]===n[0]&&r[1]>n[1]||r[0]===n[0]&&r[1]===n[1]&&r[2]>=n[2]}function E(t,e,n,r){const i=document.head;if(!i)return;const s="string"==typeof n&&n?n:"screen";r&&(p=null,b=null),p&&b===s||(p=document.createElement("style"),p.media=s,b=s,i.appendChild(p)),p.appendChild(document.createTextNode(t+" {"+e+"}"))}function A(t,e){if(!m||!t)return;const n=e?"visible":"hidden",r=document.getElementById(t);_()&&r?r.style.visibility=n:E("#"+CSS.escape(t),"visibility:"+n)}function L(t,e,n){const r=w(n);if(!r||!t||!t.data)return;void 0===t.id&&r.id&&(t.id=r.id);const i={src:""+t.data};for(const e in t){const n=e.toLowerCase();"styleclass"===n?i.class=""+t[e]:"classid"!==n&&"data"!==n&&(i[e]=""+t[e])}const s={};for(const t in e)"movie"!==t.toLowerCase()&&(s[t]=""+e[t]);const o=a(i,s);return r.parentNode.replaceChild(o,r),o}function O(t){return/[\\\"<>\.;]/.test(t)?encodeURIComponent(t):t}const F={registerObject:function(t,e,n,r){t&&e?(A(t,!1),C(()=>{const n={success:!1,id:t};if(v(e)){let e=document.getElementById(t);e&&!y(e)&&(e=s(e)?l(e):null),e&&(n.success=!0,n.ref=e)}A(t,!0),r&&r(n)})):r&&r({success:!1,id:t})},getObjectById:function(t){const e=document.getElementById(t);return y(e)?e:null},embedSWF:function(t,e,n,r,i,s,o,a,l,c){const d="string"==typeof e?e:e&&e.id,u={success:!1,id:d};t&&e&&n&&r?(A(d,!1),C(()=>{const s=Object.assign({},l,{data:t,width:""+n,height:""+r}),h=Object.assign({},a),f=function(t){return t&&"object"==typeof t?Object.keys(t).map(e=>e+"="+(g?encodeURIComponent(t[e]):t[e])).join("&"):""}(o);if(f&&(h.flashvars=void 0!==h.flashvars?h.flashvars+"&"+f:f),!i||v(i)){const t=L(s,h,e);s.id==d&&A(d,!0),u.success=!!t,t&&(u.ref=t)}else A(d,!0);c&&c(u)})):c&&c(u)},switchOffAutoHideShow(){m=!1},enableUriEncoding(t){g=void 0===t||!!t},ua:f,getFlashPlayerVersion:()=>({major:d[0],minor:d[1],release:d[2]}),hasFlashPlayerVersion:v,createSWF:(t,e,n)=>L(t,e,n),showExpressInstall(t,e,n,r){console.warn("[AwayFL] Express Install is not needed or supported"),r&&r({success:!1,id:n})},removeSWF:function(t){const e=document.getElementById(t);e&&(y(e)||s(e))&&e.remove()},createCSS:E,addDomLoadEvent:C,addLoadEvent:function(t){"complete"===document.readyState?setTimeout(t):window.addEventListener("load",()=>t())},getQueryParamValue:function(t){let e=document.location.search||document.location.hash;if(e){if(/\?/.test(e)&&(e=e.split("?")[1]),null==t)return O(e);const n=e.split("&");for(let e=0;e<n.length;e++)if(n[e].substring(0,n[e].indexOf("="))==t)return O(n[e].substring(n[e].indexOf("=")+1))}return""},expressInstallCallback(){}};class S{constructor(t,e,n,r,i,s,o){this._attributes={},this._params={},this._variables={},this.setAttribute("swf",t),this.setAttribute("id",e),this.setAttribute("width",""+n),this.setAttribute("height",""+r),this.setAttribute("version",i),s&&this.addParam("bgcolor",s),this.addParam("quality",o||"high")}setAttribute(t,e){this._attributes[t]=e}getAttribute(t){return this._attributes[t]||""}addParam(t,e){this._params[t]=e}getParams(){return this._params}addVariable(t,e){this._variables[t]=e}getVariable(t){return this._variables[t]||""}getVariables(){return this._variables}getVariablePairs(){return Object.keys(this._variables).map(t=>t+"="+this._variables[t])}useExpressInstall(t){}write(t){const e=w(t);if(!e)return!1;const n=this.getAttribute("id"),r=Object.assign({},this._params),i=this.getVariablePairs().join("&");i&&(r.flashvars=i);const s=a({src:this.getAttribute("swf"),id:n,name:n,width:this.getAttribute("width"),height:this.getAttribute("height")},r);return e.innerHTML="",e.appendChild(s),!0}}const B=new URL(".",import.meta.url).href,j={direction:"lr",rect:[.25,.495,.5,.01]},I={movie:"src",data:"src",flashvars:"flashvars",bgcolor:"bgcolor",scale:"scaleMode",salign:"stageAlign"},q={showall:"showAll",all:"showAll",noborder:"noBorder",exactfit:"exactFit",noscale:"noScale"};function x(t){const e={};if("string"==typeof t)new URLSearchParams(t).forEach((t,n)=>{e[n]=t});else if(t)for(const n in t)e[n]=String(t[n]);return e}function N(t){const e=/^#?([0-9a-f]{6})$/i.exec(t||"");return e?parseInt(e[1],16):null}function P(t){return/^\d+(\.\d+)?$/.test(""+t)?t+"px":""+t}class U extends HTMLElement{static get observedAttributes(){return["src","width","height"]}get player(){return this._player}get config(){return this._runConfig}set config(t){this._runConfig=t}get src(){return this._runConfig.src||this.getAttribute("src")}set src(t){this._runConfig.src=t}set width(t){this._runConfig.width=t}get width(){return this._runConfig.width||this.getAttribute("width")}set height(t){this._runConfig.height=t}get height(){return this._runConfig.height||this.getAttribute("height")}set runtimeBaseUrl(t){this._runConfig.runtimeBaseUrl=t}get runtimeBaseUrl(){return this._runConfig.runtimeBaseUrl}constructor(){super(),this._runConfig={},this.onError=this.onError.bind(this),this._root=this.attachShadow({mode:"closed"})}_getRuntimeUrl(){const t=this._runConfig.runtimeBaseUrl;return{loader:new URL("loader.js",t).href,runtime:new URL("runtime.js",t).href,baseUrl:t}}_dropPlayer(){this._gameFrame&&(this._gameFrame.remove(),this._player=null)}onError(t){const e=this._runConfig.onError&&self[this._runConfig.onError];"function"==typeof e&&e(t),this.dispatchEvent(new ErrorEvent("error",{error:new Error("Awayfl runtime error"),message:(null==t?void 0:t.message)||t}))}_attachRuntimeEvents(){const t=this._gameFrame.contentWindow;t.addEventListener("awayfl-player-init",({detail:t})=>{this._player=t},{once:!0}),t.addEventListener("awayfl-player-load",()=>{const t=this._runConfig.onLoad&&self[this._runConfig.onLoad];"function"==typeof t&&t(),this.dispatchEvent(new CustomEvent("load")),this._gameFrame.style.display=""},{once:!0}),t.addEventListener("awayfl-player-error",({detail:t})=>this.onError(t),{once:!0}),t.addEventListener("awayfl-player-progress",({detail:t})=>{const e=this._runConfig.onProgress&&self[this._runConfig.onProgress];"function"==typeof e&&e(t),this.dispatchEvent(new CustomEvent("progress",{detail:t}))})}_progressConfig(){const t=this._runConfig.progress;if(!t)return!1;const e=getComputedStyle(this).color;return Object.assign(Object.assign({line:e,back:`color-mix(in srgb, ${e} 20%, transparent)`},j),"object"==typeof t?t:{})}_buildTemplate(t){const e='<!DOCTYPE html>\n<head>\n\t<meta name="viewport"\n\t\tcontent="height=device-height, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui" />\n\t<title>AwayFL Embedded Player 0.1.5</title>\n\t<style>\n\t\t* {\n\t\t\tmargin: 0;\n\t\t\tpadding: 0;\n\t\t}\n\n\t\tcanvas {\n\t\t\toutline: none\n\t\t}\n\n\t\thtml, body, #container {\n\t\t\tmargin: 0;\n\t\t\toverflow: hidden;\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t}\n\n\t\t#splash__image {\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t\tposition: absolute;\n\t\t\tbackground-size: contain;\n\t\t\tbackground-position: center;\n\t\t\tbackground-repeat: no-repeat;\n\t\t\tvisibility: visible;\n\t\t\ttransition: all 0.5s;\n\t\t\tz-index: 10;\n\t\t}\n\n\t\t#progress__root {\n\t\t\tposition: absolute;\n\t\t\tmin-height: 2px;\n\t\t}\n\n\t\t#progress__line {\n\t\t\twidth: 0;\n\t\t\theight: 100%;\n\t\t\ttransition: all 0.5s;\n\t\t}\n\t</style>\n\t<script src="__LOADER_URL__"><\/script>\n</head>\n\n<body>\n\t<div id="splash__image">\n\t\t<div id="progress__root">\n\t\t\t<div id="progress__line"></div>\n\t\t</div>\n\t</div>\n\t<script>\n\t\twindow.addEventListener("load", () => {\n\n\t\t\tconst config = JSON.parse(__GAME_CONFIG__);\n\t\t\tconst fail = (error) => {\n\t\t\t\tconsole.error(\'[AwayFL]\', error);\n\t\t\t\twindow.dispatchEvent(new CustomEvent(\'awayfl-player-error\', {detail: error}));\n\t\t\t};\n\n\t\t\tAWAYFL.LegacyLoader.init(config);\n\t\t\tAWAYFL.LegacyLoader.runGame((fill) => {\n\t\t\t\twindow.dispatchEvent(new CustomEvent(\'awayfl-player-progress\', {detail: fill}));\n\t\t\t}, (config, hideLoader) => {\n\t\t\t\tconst player = new AWAYFL.Player(document, config);\n\t\t\t\twindow.dispatchEvent(new CustomEvent(\'awayfl-player-init\', {detail: player}));\n\t\t\t\tplayer\n\t\t\t\t\t.loadAndPlay()\n\t\t\t\t\t.then((_, hide) => {\n\t\t\t\t\t\twindow.dispatchEvent(new CustomEvent(\'awayfl-player-load\'));\n\t\t\t\t\t\thide && hide() || window.swfParseComplete && window.swfParseComplete();;\n\t\t\t\t\t})\n\t\t\t\t\t.catch(fail);\n\t\t\t}).catch(fail);\n\t\t});\n\t<\/script>\n</body>',n=this._getRuntimeUrl(),r={width:t.clientWidth,height:t.clientHeight,backgroundColor:this._runConfig.backgroundColor,splash:this._runConfig.splash,progress:this._progressConfig(),runtime:[n.runtime],binary:[{path:this._runConfig.src,resourceType:"GAME",name:"Game",meta:{}}],baseUrl:n.baseUrl,maxStageScale:+this._runConfig.maxStageScale,flashvars:x(this._runConfig.flashvars),stageScaleMode:this._runConfig.scaleMode,stageAlign:this._runConfig.stageAlign,stageColor:N(this._runConfig.bgcolor),runtimeFlags:{defaultSmoothBitmap:!!this._runConfig.smoothBitmaps,enableBlends:!!this._runConfig.enableBlends,enableFilters:!!this._runConfig.enableFilters}};return e.replace(/__LOADER_URL__/,n.loader).replace(/__GAME_CONFIG__/,JSON.stringify(JSON.stringify(r)))}_constructPlayer(){const t=this._root,e=document.createElement("iframe");e.style.display=this._runConfig.hideBeforeLoad?"none":"",this._gameFrame=e,t.appendChild(e),e.addEventListener("load",this._attachRuntimeEvents.bind(this),{once:!0}),e.addEventListener("error",this.onError),e.srcdoc=this._buildTemplate(e)}_configKey(t){const e=t.toLowerCase();return e in I?I[e]:Object.keys(U.BINDING_CONFIG).find(t=>t.toLowerCase()===e)}_mapAttrs(){const t=this.querySelectorAll("param"),e=this._runConfig;t.forEach(t=>{const n=this._configKey(t.name);n&&(e[n]=t.value)}),this.getAttributeNames().forEach(t=>{const n=this._configKey(t);n&&(e[n]=this.getAttribute(t))})}_loadGlobalConfig(){const t=window.AWAY_EMBED_CFG||{},e=U.BINDING_CONFIG;for(const[n,r]of Object.entries(t))n in e&&(this._runConfig[n]=r)}_setDefaults(){const t=U.BINDING_CONFIG;for(const e in t){if(t[e].required&&void 0===this._runConfig[e])throw`Parameter ${e} is required!`;void 0===this._runConfig[e]&&(this._runConfig[e]=t[e].default)}}_normalizeConfig(){const t=this._runConfig;t.runtimeBaseUrl=new URL(t.runtimeBaseUrl.replace(/\/?$/,"/"),document.baseURI).href,t.scaleMode=q[(""+t.scaleMode).toLowerCase()]||t.scaleMode,t.stageAlign&&(t.stageAlign=function(t){const e=t.toUpperCase();return(e.indexOf("T")>-1?"T":e.indexOf("B")>-1?"B":"")+(e.indexOf("L")>-1?"L":e.indexOf("R")>-1?"R":"")}(t.stageAlign)||void 0);for(const e of["autoplay","hideBeforeLoad","smoothBitmaps","enableBlends","enableFilters"])"string"==typeof t[e]&&(t[e]=!/^(false|0)$/i.test(t[e].trim()));"false"===t.splash&&(t.splash=!1),"false"===t.progress&&(t.progress=!1),t.bgcolor&&(t.backgroundColor=null===N(t.bgcolor)?t.bgcolor:"#"+t.bgcolor.replace("#",""))}_updateStyle(){this._style.textContent=`\n :host {\n display: inline-block;\n contain: content;\n width: ${P(this._runConfig.width)};\n height: ${P(this._runConfig.height)};\n }\n iframe {\n display: block;\n width: 100%;\n height: 100%;\n border: none;\n /* matches the frame's own document, or browsers make the frame opaque */\n color-scheme: light;\n }\n `}connectedCallback(){setTimeout(()=>{this._loaderHolder=this.querySelector("div.awayfl__loader"),this._loadGlobalConfig(),this._mapAttrs(),this._setDefaults(),this._normalizeConfig(),this._style=document.createElement("style"),this._updateStyle(),this._root.appendChild(this._style),this._constructPlayer()})}disconnectedCallback(){this._dropPlayer()}attributeChangedCallback(t,e,n){if(this.isConnected)return"src"===t&&this._player?(this._dropPlayer(),this._runConfig.src=n,void this._constructPlayer()):void("width"!==t&&"height"!==t||!this._style||(this._runConfig[t]=n,this._updateStyle()))}}U.BINDING_CONFIG={version:{required:!1,default:"latest"},runtimeBaseUrl:{required:!1,default:B},src:{required:!0},width:{required:!1,default:550},height:{required:!1,default:400},onLoad:{required:!1},onProgress:{required:!1},onError:{required:!1},scaleMode:{required:!1,default:"showAll"},stageAlign:{required:!1},autoplay:{required:!1,default:!0},hideBeforeLoad:{required:!1,default:!1},maxStageScale:{required:!1,default:void 0},backgroundColor:{required:!1},bgcolor:{required:!1},flashvars:{required:!1},splash:{required:!1},progress:{required:!1,default:j},smoothBitmaps:{required:!1,default:!1},enableBlends:{required:!1,default:!1},enableFilters:{required:!1,default:!1}},customElements.get("awayfl-player")||customElements.define("awayfl-player",U);const k="0.1.5",G=window;function M(t){G.AWAY_EMBED_CFG=Object.assign(G.AWAY_EMBED_CFG||{},t)}function R(t,e){const n=Object.getOwnPropertyDescriptor(window,t);!n||n.configurable?Object.defineProperty(window,t,{configurable:!0,enumerable:!0,get:()=>e,set:n=>{n!==e&&console.info(`[AwayFL] Ignoring the page's ${t}, as AwayFL provides it`)}}):G[t]=e}(G.swfobject||G.swfObject||G.SWFObject)&&console.info("[AwayFL] Replacing the page's SWFObject"),R("swfobject",F),R("swfObject",F),R("SWFObject",S),C(()=>setTimeout(()=>{!1!==(G.AWAY_EMBED_CFG||{}).autoUpgrade&&(c(),function(){let t=[];const e=()=>{const e=t;t=[],e.forEach(t=>t.isConnected&&c(t))};new MutationObserver(n=>{const r=!t.length;for(const e of n)e.addedNodes.forEach(e=>{e.nodeType===Node.ELEMENT_NODE&&t.push(e)});r&&t.length&&setTimeout(e)}).observe(document.documentElement,{childList:!0,subtree:!0})}())}));export{U as AwayPlayerComponent,S as SWFObject,k as VERSION,M as configure,F as swfObject,F as swfobject};
|
|
2
2
|
//# sourceMappingURL=embed.mjs.map
|