@swf2es/player-hosts 0.1.1 → 0.1.2
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.
|
@@ -65,7 +65,7 @@ import { xmlClass } from "./globals/XML.js";
|
|
|
65
65
|
import { xmlNodeClass, serialize as xmlString } from "./globals/XMLNode.js";
|
|
66
66
|
import { xmlSocketClass } from "./globals/XMLSocket.js";
|
|
67
67
|
import { Avm1Input } from "./input.js";
|
|
68
|
-
import { MovieLoads } from "./loads.js";
|
|
68
|
+
import { MovieLoads, queryVariables } from "./loads.js";
|
|
69
69
|
import { Avm1Net, textFor } from "./net.js";
|
|
70
70
|
import { asciiLower, atPath, childByName, pathOf, under } from "./paths.js";
|
|
71
71
|
import { ActionQueue, BLOCK, CONSTRUCT, CONSTRUCTION, FRAME, HALT, INIT, INITIALIZE, METHOD, NORMAL, Queued, } from "./queue.js";
|
|
@@ -209,6 +209,8 @@ export class Avm1 {
|
|
|
209
209
|
/** The focus, what Tab moves it through and Selection's listeners. */
|
|
210
210
|
focusTracker = new FocusTracker(this);
|
|
211
211
|
url;
|
|
212
|
+
/** The page's flashvars for the main SWF's root. */
|
|
213
|
+
parameters;
|
|
212
214
|
storage;
|
|
213
215
|
/** SharedObject's writes of what its scripts changed, as the player goes: none before attach. */
|
|
214
216
|
sharedObjects = null;
|
|
@@ -231,6 +233,7 @@ export class Avm1 {
|
|
|
231
233
|
this.onUncaught = options.onUncaught ?? ((error) => console.error(error));
|
|
232
234
|
this.fileHost = options.fileHost === undefined ? browserFileHost() : options.fileHost;
|
|
233
235
|
this.url = options.url ?? "";
|
|
236
|
+
this.parameters = options.parameters ?? {};
|
|
234
237
|
this.localConnections = options.localConnections ?? new LocalConnections();
|
|
235
238
|
this.storage = options.storage ?? defaultStorage();
|
|
236
239
|
this.net = new Avm1Net(options.fetch ?? null, options.socket ?? null, options.base ?? this.url, options.sendToUrl ?? true);
|
|
@@ -399,6 +402,17 @@ export class Avm1 {
|
|
|
399
402
|
realm.global.define("TextSnapshot", textSnapshotClass(realm), avm1.DONT_ENUM);
|
|
400
403
|
this.adopt(main);
|
|
401
404
|
this.made(root);
|
|
405
|
+
// Its parameters, as Flash defines them on the root before the first frame's actions run.
|
|
406
|
+
const face = root.avm1;
|
|
407
|
+
if (face !== null) {
|
|
408
|
+
const parameters = new Map(queryVariables(this.url));
|
|
409
|
+
for (const [name, value] of Object.entries(this.parameters)) {
|
|
410
|
+
parameters.set(name, String(value));
|
|
411
|
+
}
|
|
412
|
+
for (const [name, value] of parameters) {
|
|
413
|
+
face.define(name, textFor(value, this.swfVersion), 0);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
402
416
|
}
|
|
403
417
|
/** A SWF's timelines told to this: their clips are made and play through it from now on. */
|
|
404
418
|
adopt(swf) {
|
|
@@ -53,11 +53,11 @@ async function arrive(result, decode) {
|
|
|
53
53
|
return { type: "swf", swf, library, size: bytes.length, status };
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
|
-
* A URL's query as a
|
|
56
|
+
* A URL's query as a SWF's root gets it, each name a variable, as
|
|
57
57
|
* Ruffle's movie_loader_complete defines a movie's parameters: decoded,
|
|
58
58
|
* `+` a space, a name without `=` an empty value.
|
|
59
59
|
*/
|
|
60
|
-
function queryVariables(url) {
|
|
60
|
+
export function queryVariables(url) {
|
|
61
61
|
const path = url.split("#", 1)[0];
|
|
62
62
|
const at = path.indexOf("?");
|
|
63
63
|
if (at < 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swf2es/player-hosts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Optional Node and WebSocket transports, worker threads, an IndexedDB module cache and precompiled modules for the swf2es player",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"swf",
|
|
@@ -60,6 +60,6 @@
|
|
|
60
60
|
"LICENSE.third-party"
|
|
61
61
|
],
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@swf2es/player": "0.1.
|
|
63
|
+
"@swf2es/player": "0.1.2"
|
|
64
64
|
}
|
|
65
65
|
}
|