Skip to content
Permalink
Browse files

fix(publish): index.html: use contentLength instead of totalByteLength

  • Loading branch information...
yyc-git committed Mar 19, 2019
1 parent 5e052b5 commit 201e5da62d0c75312a5068d856a71f1bb1115ef2
@@ -169,10 +169,6 @@
window.onload = function () {
var totalWDBByteLength = $totalWDBByteLength;
var totalByteLength = totalWDBByteLength;
if (
AssetTool.isSupportStreamLoad()
) {
@@ -187,7 +183,7 @@
function (totalLoadedByteLength, contentLength, wdbPath) {
AssetTool.showOrCreateLoadingInfo(
totalLoadedByteLength,
totalByteLength
contentLength
);
},
function (state, gameObject) {
@@ -182,9 +182,6 @@ <h1 id="detect" style="display: none">your browser not support sharedArrayBuffer
}
var totalWDBByteLength = $totalWDBByteLength;
var totalByteLength = totalWDBByteLength;
if (
AssetTool.isSupportStreamLoad()
) {
@@ -199,7 +196,7 @@ <h1 id="detect" style="display: none">your browser not support sharedArrayBuffer
function (totalLoadedByteLength, contentLength, wdbPath) {
AssetTool.showOrCreateLoadingInfo(
totalLoadedByteLength,
totalByteLength
contentLength
);
},
function (state, gameObject) {
@@ -9,7 +9,7 @@ module LoadData = {
response
|> Fetch.Response.text
|> then_(jsStr => {
zip |. Zip.write("wd.js", `str(jsStr));
zip->(Zip.write("wd.js", `str(jsStr)));

useWorker ?
fetchFunc(. "./publish/wd.render.worker.js")
@@ -18,7 +18,7 @@ module LoadData = {
|> Fetch.Response.text
|> then_(jsStr => {
zip
|. Zip.write("wd.render.worker.js", `str(jsStr));
->(Zip.write("wd.render.worker.js", `str(jsStr)));

resolve(zip);
})
@@ -27,15 +27,6 @@ module LoadData = {
})
);

let _replaceIndexHtml = (indexHtmlStr, sceneGraphArrayBuffer) =>
indexHtmlStr
|> Js.String.replaceByRe(
[%re {|/\$totalWDBByteLength/img|}],
sceneGraphArrayBuffer
|> Js.Typed_array.ArrayBuffer.byteLength
|> Js.Int.toString,
);

let loadAndWriteIndexHtmlData =
(useWorker, sceneGraphArrayBuffer, fetchFunc, zip) =>
fetchFunc(.
@@ -45,12 +36,7 @@ module LoadData = {
response
|> Fetch.Response.text
|> then_(htmlStr =>
zip
|. Zip.write(
"index.html",
`str(_replaceIndexHtml(htmlStr, sceneGraphArrayBuffer)),
)
|> resolve
zip->(Zip.write("index.html", `str(htmlStr))) |> resolve
)
);

@@ -62,13 +48,15 @@ module LoadData = {
|> Fetch.Response.arrayBuffer
|> then_(arrayBuffer =>
zip
|. Zip.write(
~options=Options.makeWriteOptions(~binary=true, ()),
{j|res/loading/$name|j},
`trustme(
arrayBuffer |> TypeArrayType.newBlobFromArrayBuffer,
),
)
->(
Zip.write(
~options=Options.makeWriteOptions(~binary=true, ()),
{j|res/loading/$name|j},
`trustme(
arrayBuffer |> TypeArrayType.newBlobFromArrayBuffer,
),
)
)
|> resolve
)
)
@@ -121,8 +109,7 @@ module LoadData = {
response
|> Fetch.Response.text
|> then_(str =>
zip
|. Zip.write({j|config/$targetFileNamePath|j}, `str(str))
zip->(Zip.write({j|config/$targetFileNamePath|j}, `str(str)))
|> resolve
)
)
@@ -300,15 +287,17 @@ module Publish = {
|> _loadData(useWorker, sceneGraphArrayBuffer, fetchFunc)
|> WonderBsMost.Most.tap(zip =>
zip
|. Zip.write(
~options=Options.makeWriteOptions(~binary=true, ()),
"Scene.wdb",
`trustme(
sceneGraphArrayBuffer
|> TypeArrayType.newBlobFromArrayBuffer,
),
)
|. Zip.generateAsyncBlob(Zip.makeAsyncBlobOptions())
->(
Zip.write(
~options=Options.makeWriteOptions(~binary=true, ()),
"Scene.wdb",
`trustme(
sceneGraphArrayBuffer
|> TypeArrayType.newBlobFromArrayBuffer,
),
)
)
->(Zip.generateAsyncBlob(Zip.makeAsyncBlobOptions()))
|> Js.Promise.then_(content =>
FileSaver.saveAs(content, zipName ++ ".zip")
|> Js.Promise.resolve

0 comments on commit 201e5da

Please sign in to comment.
You can’t perform that action at this time.