Skip to content

Commit 11f7e24

Browse files
v9.6.0 (#740)
* Go 1.18 and custom elements (#739) * rename html generated files * bump required go version to 1.18 * update dependencies * rename attributes() to getAttributes() * rename Mounted() to IsMounted() * bump go version in ci * rename dispatcher() to getDispatcher() * rename children() to getChildren * rename context() to getContext * rename parent() to getParent() * Create html.go * createElement now also takes namespace * html element mount * move html attribute logic * change replace logi * add js value delete and equal * html element update * attributes unit tests * html element implementation complete * event handler unit tests * fix wasm test * fix unit tests * fix test 2 * Update state_test.go * benchmark element * generate html * Revert "generate html" This reverts commit bcb4414. * rename element.selfClosing * rename element.parentElem * rename elem.disp * rename elem.jsvalue * use attributes in element * elem uses eventHandlers * change getAttributes and getEventHandlers return values * refactor elem mount/dismount * refactor element update * refactor element remove child at * cleanup element * move element.go to html.go * add on method to html elements * fix gen typo * replace interface{} by any * update deps * customizable element contructor and test * bump go version doc to 1.18 * cleanup * cleanup * optimize html convert * rename customizable by elem * Revert "rename customizable by elem" This reverts commit 613e0b8. * Revert "Revert "rename customizable by elem"" This reverts commit da43f0d. * Revert "optimize html convert" This reverts commit 77cb2b3. * Revert "Revert "optimize html convert"" This reverts commit ec0bfc4. * better html write optimization * rename SelfClosingElem to ElemSelfClosing * generate docs * Update attribute.go * Update app.wasm * revert Mounted name change * generate doc * fix format typo * Update attribute.go * optimize filter ui (#736) * cleanup * cleanup code * Update html.go * Update component.go * Fix for attr names "accept-charset" and "http-equiv" (#748) * Fixing invalid double set charset meta headers (#750) * Refactor component events (#751) * add onLifecyleEvent to UI interface * refactor app update * refactor app install change * refactor resize * refactor nav * rename onLifecycleEvent to onComponentEvent * Refactor engine (#752) * enginex dispatcher implementation * fix tests * engineX client/server dispatcher * enginex cleanup * frame backoff * init and start once * use engine x * rename enginex to engine + unit tests * try preventComponentUpdate * Update component.go * add remove component update * Revert "add remove component update" This reverts commit 185f470. * context prevent update * allow prevent update override * limit frame backoff * Wasm download progress (#754) * display download progress * inititalize progress * Update shell.go * Revert "Update shell.go" This reverts commit 99625f5. * Update component.go * fix unit test * Update component.go * V9.6 fixes (#755) * call on component update after root update * no emit when handling js event * test ordering updates * reverse update order * avoid updating multiple time a component * no panic when mounting mounted element * remove ordering * simplify * restore mount guard * Update component.go * Update engine.go * Update engine.go * Update component.go * Update component.go * try fix * Update engine.go * try update optimization * optimize update * use emit back in js event * cleanlup * Improve loader (#756) * Customize loading label * Allow to custom http header to guess wasm size * Update http.go * fix loading header * update loading * Customizable service worker (#757) * export appworkerjs template * allow http handler to change app worker template * fix wasm tests * Update static-resources.md Co-authored-by: Hans Raaf <[email protected]>
1 parent 2c1f1d9 commit 11f7e24

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+70325
-66568
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- name: Setup Go
1111
uses: actions/setup-go@v2
1212
with:
13-
go-version: "1.17"
13+
go-version: "1.18"
1414
- name: Checkout Code
1515
uses: actions/checkout@v2
1616
- name: Vet
@@ -23,7 +23,7 @@ jobs:
2323
- name: Setup Go
2424
uses: actions/setup-go@v2
2525
with:
26-
go-version: "1.17"
26+
go-version: "1.18"
2727
- name: Checkout Code
2828
uses: actions/checkout@v2
2929
- name: Run Unit Tests
@@ -36,7 +36,7 @@ jobs:
3636
- name: Setup Go
3737
uses: actions/setup-go@v2
3838
with:
39-
go-version: "1.17"
39+
go-version: "1.18"
4040
- name: Checkout Code
4141
uses: actions/checkout@v2
4242
- name: Install WASM Browser Test

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ An app created with go-app can out of the box **run in its own window**, **suppo
2929

3030
**go-app** requirements:
3131

32-
- [Go 1.17](https://golang.org/doc/go1.17) or newer
32+
- [Go 1.18](https://golang.org/doc/go1.17) or newer
3333
- [Go module](https://github.com/golang/go/wiki/Modules)
3434

3535
```sh

docs/actions.html

Lines changed: 108 additions & 109 deletions
Large diffs are not rendered by default.

docs/app-worker.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const cacheName = "app-" + "5b5659f9412858d9a889d51820887845d1eff4de";
2-
const resourcesToCache = ["/app.css","/app.js","/manifest.webmanifest","https://storage.googleapis.com/murlok-github/icon-192.png","/wasm_exec.js","/","/web/css/prism.css","/web/css/docs.css","https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500\u0026display=swap","/web/documents/updates.md","/web/app.wasm","https://storage.googleapis.com/murlok-github/icon-512.png","/web/js/prism.js","/web/documents/what-is-go-app.md","/web/documents/home.md","/web/documents/home-next.md"];
1+
const cacheName = "app-" + "99744976a78f1c0e6202f9856d65e47589cb83ca";
2+
const resourcesToCache = ["/","/app.css","/app.js","/manifest.webmanifest","/wasm_exec.js","/web/app.wasm","/web/css/docs.css","/web/css/prism.css","/web/documents/home-next.md","/web/documents/home.md","/web/documents/updates.md","/web/documents/what-is-go-app.md","/web/js/prism.js","https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500\u0026display=swap","https://storage.googleapis.com/murlok-github/icon-192.png","https://storage.googleapis.com/murlok-github/icon-512.png"];
33

44
self.addEventListener("install", (event) => {
5-
console.log("installing app worker 5b5659f9412858d9a889d51820887845d1eff4de");
5+
console.log("installing app worker 99744976a78f1c0e6202f9856d65e47589cb83ca");
66

77
event.waitUntil(
88
caches
@@ -28,7 +28,7 @@ self.addEventListener("activate", (event) => {
2828
);
2929
})
3030
);
31-
console.log("app worker 5b5659f9412858d9a889d51820887845d1eff4de is activated");
31+
console.log("app worker 99744976a78f1c0e6202f9856d65e47589cb83ca is activated");
3232
});
3333

3434
self.addEventListener("fetch", (event) => {

docs/app.js

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ var goappNav = function () {};
55
var goappOnUpdate = function () {};
66
var goappOnAppInstallChange = function () {};
77

8-
const goappEnv = {"GOAPP_INTERNAL_URLS":"null","GOAPP_ROOT_PREFIX":"","GOAPP_STATIC_RESOURCES_URL":"","GOAPP_VERSION":"5b5659f9412858d9a889d51820887845d1eff4de"};
8+
const goappEnv = {"GOAPP_INTERNAL_URLS":"null","GOAPP_ROOT_PREFIX":"","GOAPP_STATIC_RESOURCES_URL":"","GOAPP_VERSION":"99744976a78f1c0e6202f9856d65e47589cb83ca"};
9+
const goappWasmContentLengthHeader = "";
910

1011
let goappServiceWorkerRegistration;
1112
let deferredPrompt = null;
@@ -202,16 +203,22 @@ async function goappInitWebAssembly() {
202203
}
203204

204205
try {
205-
const go = new Go();
206+
const loaderIcon = document.getElementById("app-wasm-loader-icon");
207+
loaderIcon.className = "goapp-logo";
208+
209+
const loaderLabel = document.getElementById("app-wasm-loader-label");
210+
const loadingLabel = loaderLabel.innerText;
211+
const showProgress = (progress) => {
212+
loaderLabel.innerText = loadingLabel.replace("{progress}", progress);
213+
};
214+
showProgress(0);
206215

216+
const go = new Go();
207217
const wasm = await instantiateStreaming(
208-
fetch("/web/app.wasm"),
218+
fetchWithProgress("/web/app.wasm", showProgress),
209219
go.importObject
210220
);
211221

212-
const loaderIcon = document.getElementById("app-wasm-loader-icon");
213-
loaderIcon.className = "goapp-logo";
214-
215222
go.run(wasm.instance);
216223
} catch (err) {
217224
const loaderIcon = document.getElementById("app-wasm-loader-icon");
@@ -229,3 +236,55 @@ function goappCanLoadWebAssembly() {
229236
navigator.userAgent
230237
);
231238
}
239+
240+
async function fetchWithProgress(url, progess) {
241+
const response = await fetch(url);
242+
243+
let contentLength;
244+
try {
245+
contentLength = response.headers.get(goappWasmContentLengthHeader);
246+
} catch {}
247+
if (!goappWasmContentLengthHeader || !contentLength) {
248+
contentLength = response.headers.get("Content-Length");
249+
}
250+
251+
const total = parseInt(contentLength, 10);
252+
let loaded = 0;
253+
254+
const progressHandler = function (loaded, total) {
255+
progess(Math.round((loaded * 100) / total));
256+
};
257+
258+
var res = new Response(
259+
new ReadableStream(
260+
{
261+
async start(controller) {
262+
var reader = response.body.getReader();
263+
for (;;) {
264+
var { done, value } = await reader.read();
265+
266+
if (done) {
267+
progressHandler(total, total);
268+
break;
269+
}
270+
271+
loaded += value.byteLength;
272+
progressHandler(loaded, total);
273+
controller.enqueue(value);
274+
}
275+
controller.close();
276+
},
277+
},
278+
{
279+
status: response.status,
280+
statusText: response.statusText,
281+
}
282+
)
283+
);
284+
285+
for (var pair of response.headers.entries()) {
286+
res.headers.set(pair[0], pair[1]);
287+
}
288+
289+
return res;
290+
}

0 commit comments

Comments
 (0)