Skip to content

Commit

Permalink
add Main entry point for boilerplate player
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-bateman committed Jul 8, 2021
1 parent 42ba921 commit 57ec83a
Show file tree
Hide file tree
Showing 18 changed files with 1,368 additions and 123 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Build and Release Folders
bin/
node_modules/
dist/
bundle/
Expand Down
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Build and Release Folders
bin/
node_modules/
src/
template/

# Dev files
npm-debug.log
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
85 changes: 85 additions & 0 deletions awayfl.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
const path = require('path');

module.exports = {


// all props prefixed with "rt_" will be added to config that is inserted in html

//------------------------------------------------------
// global config - same for all swf-files:
//------------------------------------------------------

debugConfig: false, // log config in build process
rt_showFPS: false, // show fps display - always false in prod
cacheBuster: true, // add cachebuster to urls - always false in prod
allowURLSearchParams: true, // allow changing config via url-params - always false in prod
split: false, // create own folder for each file - only available in prod

entryName: "Main", // name of webpack-entry - must be set for each config (use package.main ?)
entryPath: "./src/Main.ts", // path to webpack-entry - must be set for each config (use package.main ?)

buildinsPath: path.join(__dirname, "builtins"), // path to buildins - must be set when amv2 will be used
indexTemplate: path.join(__dirname, "template", "index_template.html"), // path to game-html template - must be set
gameTemplate: path.join(__dirname, "template", "game_template.html"), // path to index-html template - must be set
loaderTemplate: path.join(__dirname, "template", "loader.js"), // path to loader.js - must be set

//-------------------------------------------------------------------------
// default config for this game - can be overwritten for every file-config:
//-------------------------------------------------------------------------

rt_debug: true, // disable JS blobind - always false in prod
rt_title: "Main", // title of game - should be overwritten for each file-config, but also available for index
rt_filename: "", // filename of game - no extension - must be set for each config
rt_splash: "todo.jpg", // path to splash-image - with extension
rt_start: null, // path to start-image - with extension - optional - if present, loader wait for user input to start the game
rt_width: 1024, // width of preloader screen (todo: grab this from splashimage ?)
rt_height: 768, // height of preloader screen (todo: grab this from splashimage ?)
rt_x: 0, // x offset of stage (either absolute px value, or string with percentage of window.innerWidth (0-100))
rt_y: 0, // y offset of stage (either absolute px value, or string with percentage of window.innerHeight (0-100))
rt_w: "100%", // width of stage (either absolute px value, or string with percentage of window.innerWidth (0-100))
rt_h: "100%", // height of stage (either absolute px value, or string with percentage of window.innerHeight (0-100))

rt_stageScaleMode:null, // allowed values: EXACT_FIT noBorder noScale showAll
rt_stageAlign:null, // allowed values: B BL BR L R T TL TR

rt_progressParserWeigth: 1, // weight of parser in reporter - can be ommited or set to 0 aswell

// properties for progress bar
rt_progress: {
direction: "lr", // lr, td
back: "#130d02", // #000
line: "#f29f01", // "#00ff00",
rect: [0.25, 0.77, 0.5, 0.01], // values are percentage of width / height
},

rt_box2dVersion: 'none', // box2d version: none, legacy, new, custom (external implementation)
// list of file-configs.
// each file-config is a object that must provide:
// - rt_title
// - rt_filename (no extension)
// it can overwrite other config props aswell
fileconfigs: [
{
rt_title: "Bacon_Ipsem",
rt_filename: "Bacon_Ipsem",
rt_stageScaleMode: "showAll",
},
{
rt_showFPS: true,
rt_title: "BasicAS3Tests_FP30",
rt_filename: "BasicAS3Tests_FP30",
rt_stageScaleMode: "showAll",
},
{
rt_title: "text_test",
rt_filename: "text_test",
rt_stageScaleMode: "showAll",
}
],

resources: ["template/fonts.swf"], // list of urls to preload (fonts) - relative to project folder

assets:[

],
};
37 changes: 23 additions & 14 deletions copyVersionToIndex.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
"use strict";
exports.__esModule = true;
var fs = require("fs");
var path = require("path");


// read in the /index.ts
// read in the ts-file at filePath

// use regex to find a console log for printing the version and update it for the new version

// update /index.ts with the new content
// update ts-file at filePath with the new content

console.log("update src/index.ts with version:", process.env.npm_package_version);
//console.log(process.env.npm_package_version);
//console.log(process.env.INIT_CWD);
const args = process.argv.slice(2);
if (!args[0]) {
console.log("copyVersionToIndex - no path was provided")
}
let filePath = path.join(process.env.INIT_CWD, args[0]);

fs.readFile("./index.ts", 'utf8', function(err, data) {
if (err) throw err;
var re = /(.*[a-zA-Z]\s\-\s)(.*)(\"\)\;.*)/;
//console.log("before", data)
data = data.replace(re, "$1"+process.env.npm_package_version+"$3");//#BUILD_VIA_NPM_VERSION_PATCH_TO_DISPLAY_VERSION_HERE#", process.env.npm_package_version);
//console.log("after", data)
fs.writeFile("./index.ts", data, function(err) {
if (err) throw err;
console.log("Updated ./index.ts with inserted version ", process.env.npm_package_version);
});
});
console.log("update ", filePath, " with version:", process.env.npm_package_version);

fs.readFile(filePath, 'utf8', function (err, data) {
if (err) throw err;
var re = /(.*[a-zA-Z0-9]\s\-\s)(.*)(\"\)\;.*)/;
//console.log("before", data)
data = data.replace(re, "$1" + process.env.npm_package_version + "$3");//#BUILD_VIA_NPM_VERSION_PATCH_TO_DISPLAY_VERSION_HERE#", process.env.npm_package_version);
//console.log("after", data)
fs.writeFile(filePath, data, function (err) {
if (err) throw err;
console.log("Updated ", filePath, " with inserted version ", process.env.npm_package_version);
});
});
4 changes: 1 addition & 3 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@


console.debug("AwayFL - AwayFL-Player - 0.2.29");
console.debug("AwayFL-Player - 0.2.29");

export {AVMPlayer} from "./lib/AVMPlayer";
export {AVM1Player} from "./lib/AVM1Player";
Expand Down
170 changes: 101 additions & 69 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,71 +1,103 @@
{
"name": "@awayfl/awayfl-player",
"version": "0.2.29",
"description": "Flash Player emulator for executing SWF files (published for FP versions 6 and up) in javascript",
"main": "bundle/awayfl-player.umd.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"url": "http://www.away3d.com",
"author": "Rob Bateman",
"repository": {
"type": "git",
"url": "git+https://github.com/awayfl/awayfl-player.git"
},
"scripts": {
"rimraf": "rimraf",
"rollup": "rollup -c",
"uglifyjs": "uglifyjs ./bundle/awayfl-player.umd.js -o ./bundle/awayfl-player.umd.min.js --source-map \"content='./bundle/awayfl-player.umd.js.map'\" --mangle",
"tsc": "tsc",
"tsc:build": "npm run tsc || exit 0",
"clean": "npm cache clean && npm run rimraf -- node_modules dist bundle",
"clean:dist": "npm run rimraf -- dist bundle",
"watch": "npm run tsc -- --w",
"prebuild": "npm run clean:dist",
"build": "npm run tsc:build && npm run rollup && npm run uglifyjs",
"copyVersionToIndex": "node ./copyVersionToIndex && git add ./index.ts && git commit -m \"update version number in index.ts\"",
"version": "npm run copyVersionToIndex && npm run build",
"postversion": "git push && git push --tags && npm publish"
},
"keywords": [
"AwayJS",
"WebGL",
"2D",
"3D",
"graphics"
],
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/awayfl/awayfl-player/issues"
},
"homepage": "https://github.com/awayfl/awayfl-player#readme",
"peerDependencies": {
"@awayfl/avm1": "^0.2.0",
"@awayfl/avm2": "^0.2.0",
"@awayfl/playerglobal": "^0.2.0",
"@awayfl/swf-loader": "^0.4.0",
"@awayjs/core": "^0.9.0",
"@awayjs/scene": "^0.13.0",
"tslib": "^1.9.0"
},
"devDependencies": {
"@awayfl/avm1": "^0.2.0",
"@awayfl/avm2": "^0.2.0",
"@awayfl/playerglobal": "^0.2.0",
"@awayfl/swf-loader": "^0.4.0",
"@awayjs/core": "^0.9.0",
"@awayjs/graphics": "^0.5.0",
"@awayjs/materials": "^0.6.0",
"@awayjs/renderer": "^0.11.0",
"@awayjs/scene": "^0.13.0",
"@awayjs/stage": "^0.11.0",
"@awayjs/view": "^0.6.0",
"rimraf": "^2.5.2",
"rollup": "^0.57.1",
"rollup-plugin-commonjs": "^9.1.0",
"rollup-plugin-includepaths": "^0.2.1",
"rollup-plugin-node-resolve": "^3.3.0",
"tslib": "^1.9.0",
"typescript": "^3.7.3",
"uglify-js": "^3.0.15"
}
"name": "@awayfl/awayfl-player",
"version": "0.2.29",
"description": "Flash Player emulator for executing SWF files (published for FP versions 6 and up) in javascript",
"main": "bundle/awayfl-player.umd.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"url": "http://www.away3d.com",
"author": "Rob Bateman",
"scripts": {
"rimraf": "rimraf",
"rollup": "rollup -c",
"tsc": "tsc",
"tsc:build": "npm run tsc || exit 0",
"webpack": "webpack",
"clean": "npm cache clean && npm run rimraf -- node_modules bin",
"clean:bin": "npm run rimraf -- bin",
"preclean:install": "npm run clean",
"clean:install": "npm set progress=false && npm install",
"preclean:start": "npm run clean",
"clean:start": "npm start",
"watch": "npm run watch:dev",
"watch:dev": "npm run build:dev -- --watch",
"watch:dev:hmr": "npm run watch:dev -- --hot",
"watch:test": "npm run test -- --auto-watch --no-single-run",
"watch:prod": "npm run build:prod -- --watch",
"build": "npm run build:dev",
"prebuild:dev": "npm run clean:bin",
"build:dev": "webpack --config webpack.config.js --progress",
"prebuild:prod": "npm run clean:bin",
"build:prod": "webpack --config webpack.config.js --progress --env.prod",
"server": "npm run server:dev",
"server:dev": "webpack-dev-server --config webpack.config.js --progress --watch",
"server:dev:hmr": "npm run server:dev -- --hot",
"server:prod": "http-server bin --cors",
"start": "npm run server:dev",
"start:hmr": "npm run server:dev:hmr",
"yarnImport": "npm run rimraf -- yarn.lock && yarn import && git add ./yarn.lock && git commit -m \"update yarn.lock file\" || exit 0",
"copyVersionToIndex": "node ./copyVersionToIndex.js ./index.ts && git add ./index.ts && git commit -m \"update version number in index.ts\"",
"version": "npm run yarnImport && npm run copyVersionToIndex && npm run tsc:build && npm run rollup",
"postversion": "git push && git push --tags && npm publish"
},
"keywords": [
"AwayFL",
"Flash",
"Emulator",
"2D",
"Graphics",
"WebGL",
"Typescript"
],
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/awayfl/awayfl-player/issues"
},
"homepage": "https://github.com/awayfl/awayfl-player#readme",
"peerDependencies": {
"@awayfl/avm1": "^0.2.0",
"@awayfl/avm2": "^0.2.0",
"@awayfl/playerglobal": "^0.2.0",
"@awayfl/swf-loader": "^0.4.0",
"@awayjs/core": "^0.9.0",
"@awayjs/graphics": "^0.5.0",
"@awayjs/materials": "^0.6.0",
"@awayjs/renderer": "^0.11.0",
"@awayjs/scene": "^0.13.0",
"@awayjs/stage": "^0.11.0",
"@awayjs/view": "^0.6.0",
"tslib": "^1.9.0"
},
"devDependencies": {
"@awayfl/avm1": "^0.2.0",
"@awayfl/avm2": "^0.2.0",
"@awayfl/playerglobal": "^0.2.0",
"@awayfl/swf-loader": "^0.4.0",
"@awayjs/core": "^0.9.0",
"@awayjs/graphics": "^0.5.0",
"@awayjs/materials": "^0.6.0",
"@awayjs/renderer": "^0.11.0",
"@awayjs/scene": "^0.13.0",
"@awayjs/stage": "^0.11.0",
"@awayjs/view": "^0.6.0",
"@rollup/plugin-commonjs": "^18.0.0",
"@rollup/plugin-node-resolve": "^11.2.1",
"babel-core": "^6.26.3",
"copy-webpack-plugin": "^5.1.1",
"fs": "^0.0.1-security",
"html-webpack-plugin": "^4.2.0",
"path": "^0.12.7",
"rimraf": "^3.0.2",
"rollup": "^2.45.2",
"rollup-plugin-gzip": "^2.5.0",
"rollup-plugin-terser": "^7.0.2",
"terser-webpack-plugin": "^2.3.5",
"ts-loader": "^6.2.2",
"tslib": "^1.9.0",
"typescript": "^3.8.3",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3",
"webpack-merge": "^4.2.2"
}
}
Loading

0 comments on commit 57ec83a

Please sign in to comment.