diff --git a/include.xml b/include.xml index aa34cb10db..533fc2f083 100644 --- a/include.xml +++ b/include.xml @@ -95,12 +95,15 @@ - - - - - - + + + + + + + + + @@ -147,7 +150,7 @@ - + @@ -171,8 +174,8 @@ - - + + diff --git a/src/lime/math/RGBA.hx b/src/lime/math/RGBA.hx index ca4cfd8d82..7c813bc200 100644 --- a/src/lime/math/RGBA.hx +++ b/src/lime/math/RGBA.hx @@ -49,9 +49,6 @@ abstract RGBA(#if (flash && !lime_doc_gen) Int #else UInt #end) from Int to Int private static function __init__():Void { - #if (js && modular) - __initColors(); - #else __alpha16 = new UInt32Array(256); for (i in 0...256) @@ -70,33 +67,8 @@ abstract RGBA(#if (flash && !lime_doc_gen) Int #else UInt #end) from Int to Int { __clamp[i] = 0xFF; } - #end } - #if (js && modular) - private static function __initColors() - { - __alpha16 = new UInt32Array(256); - - for (i in 0...256) - { - __alpha16[i] = Math.ceil((i) * ((1 << 16) / 0xFF)); - } - - __clamp = new UInt8Array(0xFF + 0xFF); - - for (i in 0...0xFF) - { - __clamp[i] = i; - } - - for (i in 0xFF...(0xFF + 0xFF + 1)) - { - __clamp[i] = 0xFF; - } - } - #end - /** Creates a new RGBA instance @param rgba (Optional) An RGBA color value diff --git a/src/lime/system/System.hx b/src/lime/system/System.hx index d7b21a1490..4493fc4e3d 100644 --- a/src/lime/system/System.hx +++ b/src/lime/system/System.hx @@ -125,7 +125,7 @@ class System @:noCompletion private static var __userDirectory:String; #if (js && html5) - @:keep @:expose("lime.embed") + @:keep @:expose public static function embed(projectName:String, element:Dynamic, width:Null = null, height:Null = null, config:Dynamic = null):Void { if (__applicationEntryPoint == null) return; diff --git a/src/lime/tools/ModuleHelper.hx b/src/lime/tools/ModuleHelper.hx index 06067231e9..fff3a04d9d 100644 --- a/src/lime/tools/ModuleHelper.hx +++ b/src/lime/tools/ModuleHelper.hx @@ -69,7 +69,20 @@ class ModuleHelper for (haxelib in project.haxelibs) { - hxml += "\n-cp " + Haxelib.getPath(haxelib); + var libPath:String = Haxelib.getPath(haxelib); + var classPath:String = null; + var json:String = Path.combine(libPath, "haxelib.json"); + if (FileSystem.exists(json)) + try + { + classPath = haxe.Json.parse(File.getContent(json)).classPath; + } + catch (e:Dynamic) {} + + if (classPath != null) + libPath = Path.combine(libPath, classPath); + + hxml += "\n-cp " + libPath; } for (key in project.haxedefs.keys()) @@ -91,7 +104,11 @@ class ModuleHelper hxml += "\n-D html5"; hxml += "\n-D html"; + #if !haxe4 hxml += "\n--no-inline"; + #else + hxml += "\n-D no-inline"; + #end hxml += "\n-dce no"; hxml += "\n-js " + outputPath; diff --git a/src/lime/utils/AssetLibrary.hx b/src/lime/utils/AssetLibrary.hx index 782bd4a433..93ee1cf260 100644 --- a/src/lime/utils/AssetLibrary.hx +++ b/src/lime/utils/AssetLibrary.hx @@ -765,7 +765,7 @@ class AssetLibrary { classRef = Type.resolveClass(Reflect.field(asset, "className")); - #if (js && html5 && modular) + #if (js && html5 && lime_modular) if (classRef == null) { classRef = untyped $hx_exports[asset.className]; diff --git a/templates/html5/output.js b/templates/html5/output.js index e04a257441..48d5a8415f 100644 --- a/templates/html5/output.js +++ b/templates/html5/output.js @@ -1,4 +1,4 @@ -var $lime_init = (function ($hx_exports, $global) { "use strict"; var $hx_script = (function (exports, global) { ::SOURCE_FILE:: +"use strict"; var $hx_script = (function (exports) { ::SOURCE_FILE:: });::if false:: /* Don't insert or remove any line breaks in the code above this line! @@ -12,34 +12,41 @@ var $lime_init = (function ($hx_exports, $global) { "use strict"; var $hx_script to avoid it getting ignored in a // comment at the end of ::SOURCE_FILE::. */ ::end:: - if (typeof self !== "undefined" && self.constructor.name.includes("Worker")) { - // No need for exports in a worker context, just initialize statics. - $hx_script({}, $global); - } else { - $hx_exports.lime = $hx_exports.lime || {}; - $hx_exports.lime.$scripts = $hx_exports.lime.$scripts || {}; - $hx_exports.lime.$scripts["::APP_FILE::"] = $hx_script; - $hx_exports.lime.embed = function (projectName) { - var exports = {}; - var script = $hx_exports.lime.$scripts[projectName]; - if (!script) throw Error("Cannot find project name \"" + projectName + "\""); - script(exports, $global); - for (var key in exports) $hx_exports[key] = $hx_exports[key] || exports[key]; - var lime = exports.lime || window.lime; - if (lime && lime.embed && this !== lime.embed) lime.embed.apply(lime, arguments); - return exports; - }; - } +var $hx_exports = typeof exports !== "undefined" ? exports : typeof define === "function" && define.amd ? {} : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : this; +if (typeof self !== "undefined" && self.constructor.name.includes("Worker")) { + // No need for exports in a worker context, just initialize statics. + $hx_script({}); +} else { + $hx_exports.lime = $hx_exports.lime || {}; + $hx_exports.lime.$scripts = $hx_exports.lime.$scripts || {}; + $hx_exports.lime.$scripts["::APP_FILE::"] = $hx_script; + $hx_exports.lime.embed = function (projectName) { + var script = $hx_exports.lime.$scripts[projectName]; + if (!script) throw Error("Cannot find project name \"" + projectName + "\""); + script($hx_exports); + $hx_exports.lime.system?.System?.embed?.apply(lime, arguments); + return $hx_exports; + }; - if (typeof define === "function" && define.amd) { - define([], function () { return $hx_exports.lime; }); - define.__amd = define.amd; - define.amd = null; + 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'); } -}) -$lime_init(typeof exports !== "undefined" ? exports : typeof define === "function" && define.amd ? {} : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : this, -typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : this); + window.addEventListener ("load", function () { + const content = document.getElementById(::if LIB_OPENFL::"openfl-content"::else::"content"::end::); + if (content && content.childElementCount === 0) { + $hx_exports.lime.embed ("::APP_FILE::", content, ::WIN_WIDTH::, ::WIN_HEIGHT::); + } + }); +} + +if (typeof define === "function" && define.amd) { + define([], function () { return $hx_exports.lime; }); + define.__amd = define.amd; + define.amd = null; +} ::if embeddedLibraries::::foreach embeddedLibraries:: ::__current__::::end::::end:: diff --git a/templates/html5/template/index.html b/templates/html5/template/index.html index daac92480a..3719de96f3 100755 --- a/templates/html5/template/index.html +++ b/templates/html5/template/index.html @@ -16,14 +16,6 @@ ::end::::end:: - -