@awayfl/awayfl-player 0.2.36 → 0.2.37

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/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- console.debug("AwayFL-Player - 0.2.36");
1
+ console.debug("AwayFL-Player - 0.2.37");
2
2
  export { AVMPlayer } from "./lib/AVMPlayer";
3
3
  export { AVM1Player } from "./lib/AVM1Player";
4
4
  export { AVM2Player } from "./lib/AVM2Player";
package/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- console.debug("AwayFL-Player - 0.2.36");
1
+ console.debug("AwayFL-Player - 0.2.37");
2
2
 
3
3
  export {AVMPlayer} from "./lib/AVMPlayer";
4
4
  export {AVM1Player} from "./lib/AVM1Player";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awayfl/awayfl-player",
3
- "version": "0.2.36",
3
+ "version": "0.2.37",
4
4
  "description": "Flash Player emulator for executing SWF files (published for FP versions 6 and up) in javascript",
5
5
  "main": "bundle/awayfl-player.umd.js",
6
6
  "module": "dist/index.js",
package/webpack.config.js CHANGED
@@ -47,16 +47,21 @@ module.exports = (env = {}) => {
47
47
  filename: 'js/[name].js'
48
48
  },
49
49
  resolve: {
50
+ alias: {},
50
51
  // Add `.ts` and `.tsx` as a resolvable extension.
51
52
  extensions: ['.webpack.js', '.web.js', '.js', '.ts', '.tsx']
52
53
  },
53
54
  module: {
54
55
  rules: [
55
- // all files with a `.ts` or `.tsx` extension will be handled by `awesome-typescript-loader`
56
- { test: /\.ts(x?)/, exclude: /node_modules/, loader: tsloader, options: { experimentalWatchApi: true} },
57
-
58
- // all files with a `.js` or `.jsx` extension will be handled by `source-map-loader`
59
- //{ test: /\.js(x?)/, loader: require.resolve('source-map-loader') }
56
+ {
57
+ test: /\.ts(x?)/,
58
+ exclude: /node_modules/,
59
+ loader: tsloader,
60
+ options: {
61
+ experimentalWatchApi: true,
62
+ transpileOnly: true
63
+ }
64
+ },
60
65
  ]
61
66
  },
62
67
  plugins: plugins,
@@ -71,26 +76,28 @@ module.exports = (env = {}) => {
71
76
  },
72
77
  devServer: {
73
78
  client: {
74
- progress: true,
79
+ progress: true, // wp5
75
80
  }
76
81
  },
77
-
78
-
79
82
  }
80
83
 
81
84
  const dev = {
85
+ target: 'web',
82
86
  mode: "development",// wp4
83
- devtool: 'source-map',
84
- //devtool: 'cheap-module-eval-source-map',//use this option for recompiling libs
87
+ //devtool: 'source-map',
88
+ devtool: 'cheap-module-source-map',//use this option for recompiling libs
85
89
  devServer: {
86
- //contentBase: path.join(process.cwd(), "src"),
87
90
  static: {
88
91
  publicPath: "/",
89
92
  },
90
93
  open: false,
94
+ hot: false,
95
+ watchFiles: ['src/**/*.*'],
91
96
  client: {
92
97
  progress: true,
93
- }
98
+ },
99
+ allowedHosts: "all",
100
+ port: 80,
94
101
  },
95
102
  optimization: {
96
103
  //minimize: false // wp4
@@ -176,33 +183,49 @@ const processConfig = (config, rootPath, CopyWebPackPlugin, HTMLWebPackPlugin, B
176
183
 
177
184
  swfPath = path.join(rootPath, "src", "assets", configForHTML.filename + ".swf");
178
185
  if (!fs.existsSync(swfPath)) {
179
- throw ("invalid filename path for fileconfig " + configForHTML.filename);
186
+ throw new Error("invalid filename path for fileconfig " + configForHTML.filename);
180
187
  }
181
188
  stats = fs.statSync(swfPath);
182
189
  filesize = stats["size"];
183
190
  if (!fs.existsSync(path.join(rootPath, "src", "assets", configForHTML.splash))) {
184
- throw ("invalid splashscreen path for fileconfig " + configForHTML.splash);
191
+ throw new Error("invalid splashscreen path for fileconfig " + configForHTML.splash);
185
192
  }
193
+
186
194
  plugins.push(new CopyWebPackPlugin({
187
195
  patterns: [
188
196
  { from: swfPath, to: outputPath + "assets" },
189
197
  ],
190
198
  }));
199
+
191
200
  plugins.push(new CopyWebPackPlugin({
192
201
  patterns: [
193
202
  { from: path.join(rootPath, "src", "assets", configForHTML.splash), to: outputPath + "assets" },
194
203
  ],
195
204
  }));
196
205
 
197
- // optional copy startscreen:
206
+ // optional copy loading image:
207
+
208
+ if (configForHTML.loading) {
209
+ if (!fs.existsSync(path.join(rootPath, "src", "assets", configForHTML.loading.image))) {
210
+ throw ("invalid loading image path for fileconfig " + configForHTML.loading.image);
211
+ }
212
+ plugins.push(new CopyWebPackPlugin({
213
+ patterns: [
214
+ { from: path.join(rootPath, "src", "assets", configForHTML.loading.image), to: outputPath + "assets" },
215
+ ],
216
+ }));
217
+ }
218
+
219
+
220
+ // optional copy start image:
198
221
 
199
222
  if (configForHTML.start) {
200
- if (!fs.existsSync(path.join(rootPath, "src", "assets", configForHTML.start))) {
201
- throw ("invalid startscreen path for fileconfig " + configForHTML.start);
223
+ if (!fs.existsSync(path.join(rootPath, "src", "assets", configForHTML.start.image))) {
224
+ throw ("invalid start image path for fileconfig " + configForHTML.start.image);
202
225
  }
203
226
  plugins.push(new CopyWebPackPlugin({
204
227
  patterns: [
205
- { from: path.join(rootPath, "src", "assets", configForHTML.start), to: outputPath + "assets" },
228
+ { from: path.join(rootPath, "src", "assets", configForHTML.start.image), to: outputPath + "assets" },
206
229
  ],
207
230
  }));
208
231
  }
@@ -222,7 +245,7 @@ const processConfig = (config, rootPath, CopyWebPackPlugin, HTMLWebPackPlugin, B
222
245
  if (!res_filesize) {
223
246
  // only need to copy if it has not yet been done
224
247
  if (!fs.existsSync(res_path)) {
225
- throw ("invalid filename path for resource " + res_path);
248
+ throw new Error("invalid filename path for resource " + res_path);
226
249
  }
227
250
  plugins.push(new CopyWebPackPlugin({
228
251
  patterns: [
@@ -247,7 +270,7 @@ const processConfig = (config, rootPath, CopyWebPackPlugin, HTMLWebPackPlugin, B
247
270
 
248
271
  // extension is missing = is folder
249
272
  if (!fs.existsSync(res_path)) {
250
- throw ("invalid filename path for asset " + res_path);
273
+ throw new Error("invalid filename path for asset " + res_path);
251
274
  }
252
275
 
253
276
  let folder = fs.lstatSync(res_path).isDirectory();
@@ -272,8 +295,11 @@ const processConfig = (config, rootPath, CopyWebPackPlugin, HTMLWebPackPlugin, B
272
295
  if (configForHTML.splash)
273
296
  configForHTML.splash = "assets/" + configForHTML.splash;
274
297
 
298
+ if (configForHTML.loading)
299
+ configForHTML.loading.image = "assets/" + configForHTML.loading.image;
300
+
275
301
  if (configForHTML.start)
276
- configForHTML.start = "assets/" + configForHTML.start;
302
+ configForHTML.start.image = "assets/" + configForHTML.start.image;
277
303
 
278
304
 
279
305
  var runtimePath = "js/" + config.entryName + ".js";
@@ -309,8 +335,27 @@ const processConfig = (config, rootPath, CopyWebPackPlugin, HTMLWebPackPlugin, B
309
335
 
310
336
  // code to overwrite config by URLSearchParams
311
337
  if (config.allowURLSearchParams) {
312
- jsStringForHTML += "const q = new URLSearchParams(location.search);\n";
313
- jsStringForHTML += "for (let key of q.keys()){ config[key] = q.get(key);};\n";
338
+ jsStringForHTML += `const q = new URLSearchParams(location.search);
339
+
340
+ for (let key of q.keys()){
341
+ let value = q.get(key);
342
+
343
+ if (value.includes("<boolean>") || value.includes("<bool>")) {
344
+ let valueWithoutClass = value.replace(/<boolean>/g,'').replace(/<bool>/g,'').toLowerCase();
345
+ if (["true", "t", "1"].includes(valueWithoutClass)) config[key] = true;
346
+ else if (["false", "f", "0"].includes(valueWithoutClass)) config[key] = false;
347
+ else console.warn("Unable to cast URLSearchParam '" + key + "'='" + valueWithoutClass + "' as boolean");
348
+ } else if (value.includes("<int>") || value.includes("<integer>") || value.includes("<number>")) {
349
+ let valueWithoutClass = value.replace(/<int>/g,'').replace(/<integer>/g,'').replace(/<number>/g,'');
350
+ config[key] = parseInt(valueWithoutClass, 10);
351
+ } else {
352
+ // treat this as string
353
+ config[key] = q.get(key);
354
+ }
355
+
356
+ // console.log({key, value, result: config[key]});
357
+ };
358
+ `;
314
359
  }
315
360
 
316
361
  // add cachebuster
@@ -324,7 +369,7 @@ const processConfig = (config, rootPath, CopyWebPackPlugin, HTMLWebPackPlugin, B
324
369
  var htmlOutputPath = (config.split ? folderName + "/" : "") + (config.split ? "index.html" : folderName + ".html");
325
370
  gameURLS[fileConfig.rt_filename] = {
326
371
  path: htmlOutputPath,
327
- name: configForHTML.title
372
+ name: configForHTML.title,
328
373
  };
329
374
 
330
375
  var htmlSourcePath = getConfigProp(fileConfig, config, "gameTemplate");
@@ -373,7 +418,7 @@ const processConfig = (config, rootPath, CopyWebPackPlugin, HTMLWebPackPlugin, B
373
418
 
374
419
  plugins.push({
375
420
  apply: function (compiler) {
376
- compiler.plugin('done', function (compilation) {
421
+ compiler.hooks.afterEmit.tap('MyPlugin', function (compilation) {
377
422
  console.log("copy build to game-folders");
378
423
  for (var i = 0; i < config.fileconfigs.length; i++) {
379
424
  copyRecursiveSync(fs, path, path.join(rootPath, "bin", "js"), path.join(rootPath, "bin", config.fileconfigs[i].rt_filename, "js"));
@@ -394,6 +439,7 @@ var getConfigProp = function (fileconfig, config, name) {
394
439
  };
395
440
 
396
441
  // get a config for a game-file.
442
+ // this filters out all props that are not prefixed by "rt_"
397
443
  // also takes care that it uses props from global-config if file-config does not provide it
398
444
  // this can probably be done better and cleaner
399
445
  // but for now it should do the job