Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion hxformat.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
{
"excludes": [
"\\templates",
"/templates",
"\\project",
"/project"
],
"lineEnds": {
"leftCurly": "both",
"rightCurly": "both"
"rightCurly": "both",
"objectLiteralCurly": {
"leftCurly": "after"
}
},
"sameLine": {
"ifBody": "same",
Expand Down
14 changes: 13 additions & 1 deletion src/lime/tools/HXProject.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1143,10 +1143,21 @@ class HXProject extends Script
{
if (StringTools.startsWith(haxeflag, "-lib"))
{
Reflect.setField(context, "LIB_" + StringTools.formatUppercaseVariable(haxeflag.substr(5)), "true");
var haxelibName = StringTools.formatUppercaseVariable(haxeflag.substr(5));
Reflect.setField(context, "LIB_" + haxelibName, "true");
try
{
Reflect.setField(context, "LIB_" + haxelibName + "_PATH", Haxelib.getPath(new Haxelib(haxelibName)));
}
catch(e: Dynamic) {}
}
}

for (flag in targetFlags.keys())
{
Reflect.setField(context, "FLAG_" + StringTools.formatUppercaseVariable(flag), targetFlags.get(flag));
}

context.assets = new Array<Dynamic>();

for (asset in assets)
Expand Down Expand Up @@ -1346,6 +1357,7 @@ class HXProject extends Script
// #end

Reflect.setField(context, "LIB_" + StringTools.formatUppercaseVariable(haxelib.name), true);
Reflect.setField(context, "LIB_" + StringTools.formatUppercaseVariable(haxelib.name) + "_PATH", Haxelib.getPath(haxelib));

if (name == "nme")
{
Expand Down
60 changes: 60 additions & 0 deletions src/lime/tools/ObjectHelper.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package lime.tools;

class ObjectHelper
{
public static function formatForDisplay(object:Dynamic):String
{
var keys = Reflect.fields(object);
keys.sort(Reflect.compare);
var lines = [];
for (key in keys)
{
lines.push('${key}: ${Reflect.field(object, key)}');
}
return lines.join("\n");
}

public static function formatJson(obj:Dynamic, indent:Int = 2):String
{
return prettyJson(obj, 0, indent);
}

private static function prettyJson(value:Dynamic, level:Int, indent:Int):String
{
var isOfType = #if (haxe_ver >= 4.2) Std.isOfType #else Std.is #end;
var pad = StringTools.lpad("", " ", level * indent);
var nextPad = StringTools.lpad("", " ", (level + 1) * indent);

// Primitive types
if (value == null) return "null";
if (isOfType(value, Bool) || isOfType(value, Int) || isOfType(value, Float)) return Std.string(value);
if (isOfType(value, String)) return '"' + StringTools.replace(value, '"', '\\"') + '"';

// Enums
var e = Type.getEnum(value);
if (e != null) return '"' + Type.enumConstructor(value) + '"';

// Arrays
if (isOfType(value, Array))
{
var arr:Array<Dynamic> = cast value;
var items = arr.map(function(v) return prettyJson(v, level + 1, indent));
return "[\n" + nextPad + items.join(",\n" + nextPad) + "\n" + pad + "]";
}

// Objects
var fields = Reflect.fields(value);
fields.sort(Reflect.compare);
if (fields.length > 0)
{
var pairs = fields.map(function(f)
{
var v = Reflect.field(value, f);
return '"' + f + '": ' + prettyJson(v, level + 1, indent);
});
return "{\n" + nextPad + pairs.join(",\n" + nextPad) + "\n" + pad + "}";
}

return '"<unknown>"';
}
}
45 changes: 45 additions & 0 deletions templates/html5/npm/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="utf-8">

<title>::APP_TITLE::</title>

<meta id="viewport" name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="mobile-web-app-capable" content="yes">

::if favicons::::foreach (favicons)::
<link rel="::__current__.rel::" type="::__current__.type::" href="::__current__.href::">::end::::end::

::if linkedLibraries::::foreach (linkedLibraries)::
<script type="text/javascript" src="::__current__::"></script>::end::::end::
<script type="text/javascript" src="./::APP_FILE::.js"></script>

<script>
window.addEventListener ("touchmove", function (event) { event.preventDefault (); }, { capture: false, passive: false });
if (typeof window.devicePixelRatio != 'undefined' && window.devicePixelRatio > 2) {
var meta = document.getElementById ("viewport");
meta.setAttribute ('content', 'width=device-width, initial-scale=' + (2 / window.devicePixelRatio) + ', user-scalable=no');
}
</script>

<style>
html,body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
#content { ::if (WIN_BACKGROUND)::background: #000000; ::end::width: ::if (WIN_RESIZABLE)::100%::elseif (WIN_WIDTH > 0)::::WIN_WIDTH::px::else::100%::end::; height: ::if (WIN_RESIZABLE)::100%::elseif (WIN_WIDTH > 0)::::WIN_HEIGHT::px::else::100%::end::; }
::foreach assets::::if (type == "font")::::if (cssFontFace)::::cssFontFace::::end::::end::::end::
</style>

</head>
<body>
::foreach assets::::if (type == "font")::
<span style="font-family: ::id::"> </span>::end::::end::

<div id="content"></div>

<script type="text/javascript">
lime.embed ("::APP_FILE::", "content", ::WIN_WIDTH::, ::WIN_HEIGHT::);
</script>

</body>
</html>
28 changes: 9 additions & 19 deletions templates/html5/npm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,15 @@
"name": "::META_PACKAGE::",
"version": "::META_VERSION::",
"private": true,
"devDependencies": {
"haxe": "^5.0.10",
"haxe-loader": "^0.10.0",
"uglifyjs-webpack-plugin": "^1.3.0",
"webpack": "^4.20.2",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.9",
"webpack-merge": "^4.1.4"
},
"haxeDependencies": {
"haxe": "3.4.7"
},
"scripts": {
"build": "npm run build:prod",
"build:dev": "webpack --config webpack.dev.js",
"build:prod": "webpack --config webpack.prod.js",
"start": "npm run start:dev",
"start:dev": "webpack-dev-server --open --config webpack.dev.js",
"start:prod": "webpack-dev-server --open --config webpack.prod.js"
"lime:preupdate": "",
"lime:update": "",
"lime:prebuild": "",
"lime:build": "vite build",
"lime:run": "vite preview ::if (FLAG_PORT != null)::-p ::FLAG_PORT::::end:: ::if (FLAG_NOLAUNCH != null)::::else::--open::end::",
"lime:test": "vite ::if (FLAG_PORT != null)::-p ::FLAG_PORT::::end:: ::if (FLAG_NOLAUNCH != null)::::else::--open::end::"
},
"dependencies": {}
"devDependencies": {
"vite": "^8.0.0"
}
}
3 changes: 3 additions & 0 deletions templates/html5/npm/vite.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
publicDir: "bin"
};
20 changes: 0 additions & 20 deletions templates/html5/npm/webpack.common.js

This file was deleted.

10 changes: 0 additions & 10 deletions templates/html5/npm/webpack.dev.js

This file was deleted.

17 changes: 0 additions & 17 deletions templates/html5/npm/webpack.prod.js

This file was deleted.

60 changes: 36 additions & 24 deletions tools/CommandLineTools.hx
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,7 @@ class CommandLineTools
publishProject();

case "installer", "copy-if-newer":

// deprecated?
// deprecated?

default:
Log.error("'" + command + "' is not a valid command");
Expand Down Expand Up @@ -511,7 +510,7 @@ class CommandLineTools
case LINUX:
var arguments = Sys.args();

if (System.hostArchitecture == ARMV7 )
if (System.hostArchitecture == ARMV7)
{
untyped $loader.path = $array(path + "LinuxArm/", $loader.path);
}
Expand Down Expand Up @@ -600,19 +599,16 @@ class CommandLineTools
platform = new AndroidPlatform(command, project, targetFlags);

case BLACKBERRY:

// platform = new BlackBerryPlatform (command, project, targetFlags);
// platform = new BlackBerryPlatform (command, project, targetFlags);

case IOS:
platform = new IOSPlatform(command, project, targetFlags);

case TIZEN:

// platform = new TizenPlatform (command, project, targetFlags);
// platform = new TizenPlatform (command, project, targetFlags);

case WEBOS:

// platform = new WebOSPlatform (command, project, targetFlags);
// platform = new WebOSPlatform (command, project, targetFlags);

case WINDOWS:
platform = new WindowsPlatform(command, project, targetFlags);
Expand Down Expand Up @@ -788,14 +784,22 @@ class CommandLineTools
{
var commands = [

"config" => "Display or set command-line configuration values", "create" => "Create a new project or extension using templates",
"clean" => "Clean the specified project and target", "update" => "Copy assets for the specified project and target",
"build" => "Compile and package for the specified project and target", "run" => "Install and run for the specified project and target",
"test" => "Update, build and run in one command", "help" => "Show this information",
"trace" => "Trace output for the specifed project and target", "deploy" => "Archive and upload builds",
"display" => "Display information for the specified project and target", "rebuild" => "Recompile native binaries for libraries",
"install" => "Install a library from haxelib, plus dependencies", "remove" => "Remove a library from haxelib",
"upgrade" => "Upgrade a library from haxelib", "setup" => "Setup " + defaultLibraryName + " or a specific platform"
"config" => "Display or set command-line configuration values",
"create" => "Create a new project or extension using templates",
"clean" => "Clean the specified project and target",
"update" => "Copy assets for the specified project and target",
"build" => "Compile and package for the specified project and target",
"run" => "Install and run for the specified project and target",
"test" => "Update, build and run in one command",
"help" => "Show this information",
"trace" => "Trace output for the specifed project and target",
"deploy" => "Archive and upload builds",
"display" => "Display information for the specified project and target",
"rebuild" => "Recompile native binaries for libraries",
"install" => "Install a library from haxelib, plus dependencies",
"remove" => "Remove a library from haxelib",
"upgrade" => "Upgrade a library from haxelib",
"setup" => "Setup " + defaultLibraryName + " or a specific platform"

];

Expand Down Expand Up @@ -1102,6 +1106,8 @@ class CommandLineTools
Log.println("");
Log.println(" \x1b[3m(no option)\x1b[0m -- Display HXML build arguments");
Log.println(" \x1b[1m--output-file\x1b[0m -- Display the output file for the project");
Log.println(" \x1b[1m--template-context\x1b[0m -- Display variables in the current template context");
Log.println(" \x1b[1m--template-context --json\x1b[0m -- Display variables in the current template context in JSON format");
}
}
}
Expand Down Expand Up @@ -1841,7 +1847,9 @@ class CommandLineTools

var projectDirectory = Path.directory(projectFile);
var localRepository = Path.combine(projectDirectory, ".haxelib");
if (FileSystem.exists(localRepository) && FileSystem.isDirectory(localRepository) && StringTools.startsWith(path, localRepository))
if (FileSystem.exists(localRepository)
&& FileSystem.isDirectory(localRepository)
&& StringTools.startsWith(path, localRepository))
{
args.push("-nolocalrepocheck");
}
Expand Down Expand Up @@ -2244,17 +2252,21 @@ class CommandLineTools
{
targetFlags.set("help", "");
}
else if (argument == "--output-file")
{
targetFlags.set("output-file", "");
}
else if (argument.substr(0, 1) == "-")
{
if (argument == "-dce" || argument.substr(1, 1) == "-")
if (argument == "-dce")
{
overrides.haxeflags.push(argument);
catchHaxeFlag = true;
}
else if (argument.length > 2 && argument.substr(1, 1) == "-")
{
targetFlags.set(argument.substr(2), "");

// TODO: Should this be more selective?
overrides.haxeflags.push(argument);

if (argument == "--remap" || argument == "--connect" || argument == "-dce")
if (argument == "--remap" || argument == "--connect")
{
catchHaxeFlag = true;
}
Expand Down
Loading
Loading