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
21 changes: 12 additions & 9 deletions include.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,15 @@

<dependency name="extension-api" path="dependencies/extension-api" if="android" />

<dependency path="dependencies/howler.min.js" if="html5 howlerjs" embed="true" />
<dependency path="dependencies/pako.min.js" if="html5" embed="true" allow-web-workers="true" />
<dependency path="dependencies/lzma_worker-min.js" if="html5" embed="true" />
<dependency path="dependencies/FileSaver.min.js" if="html5" embed="true" />
<dependency path="dependencies/webgl-debug.js" if="html5 webgl-debug" embed="true" />
<dependency path="dependencies/stats.min.js" if="html5 stats" embed="true" />
<set name="embed-js" value="false" if="lime-modular" />
<set name="embed-js" value="true" unless="lime-modular" />
<dependency path="dependencies/howler.min.js" if="html5 howlerjs" embed="${embed-js}" />
<dependency path="dependencies/pako.min.js" if="html5" embed="${embed-js}" allow-web-workers="true" />
<dependency path="dependencies/lzma_worker-min.js" if="html5" embed="${embed-js}" />
<dependency path="dependencies/FileSaver.min.js" if="html5" embed="${embed-js}" />
<dependency path="dependencies/webgl-debug.js" if="html5 webgl-debug" embed="${embed-js}" />
<dependency path="dependencies/stats.min.js" if="html5 stats" embed="${embed-js}" />
<unset name="embed-js" />

<dependency path="dependencies/angle/d3dcompiler_47.dll" if="windows angle" unless="static_link" />
<dependency path="dependencies/angle/libegl.dll" if="windows angle" unless="static_link" />
Expand Down Expand Up @@ -147,7 +150,7 @@
<class name="js.Promise" />
<class name="js.RegExp" />
<class name="js.Selection" />
<class name="js.XMLSocket" />
<class name="js.XMLSocket" if="${${haxe_ver} < 4}" />
<class name="EReg" />
<class name="HxOverrides" />
<class name="List" />
Expand All @@ -171,8 +174,8 @@

<module name="${lime-module-name}" if="html5" unless="exclude-lime-module">

<source path="" package="lime" exclude="lime._backend.*|lime.project.*|lime.tools.*|lime.net.*|lime.graphics.console.*|lime.text.harfbuzz.*" />
<source path="" package="lime" include="lime._backend.html5" />
<source path="src" package="lime" exclude="lime._internal.backend.*|lime.project.*|lime.tools.*|lime.net.*|lime.graphics.console.*|lime.text.harfbuzz.*" />
<source path="src" package="lime" include="lime._internal.backend.html5" />

<class name="lime.net.HTTPRequest" />

Expand Down
28 changes: 0 additions & 28 deletions src/lime/math/RGBA.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/lime/system/System.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Int> = null, height:Null<Int> = null, config:Dynamic = null):Void
{
if (__applicationEntryPoint == null) return;
Expand Down
19 changes: 18 additions & 1 deletion src/lime/tools/ModuleHelper.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/lime/utils/AssetLibrary.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
59 changes: 33 additions & 26 deletions templates/html5/output.js
Original file line number Diff line number Diff line change
@@ -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!
Expand All @@ -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::
Expand Down
14 changes: 1 addition & 13 deletions templates/html5/template/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@
<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::; }
Expand All @@ -37,9 +29,5 @@

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

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

</body>
</html>
</html>