Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

An experimental repository for developing libraries and web tools necessary to use pure Go to compile a PWA web app via WASM.

License

NotificationsYou must be signed in to change notification settings

hollowaykeanho/ExperimentingGoWASM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

banner

This is the principle repository for (Holloway) Chew, Kean Ho's experimentationto develop a pure Go web application supportingProgressive Web Application offlinemode alongside using pure Go to develop web application entirely.

Experiemntation Goals

The goal of unifying web application development for client-side rendering usinga proper programming language likeGo has been aspired butlow implementations due to little efforts. That's why the primary goal is to:

  1. Develop the foundational Go library so that the customers (Go web developer)to deploy web app.
    1. ☑️ - Power on withExperimentingGoWASM Go workspace withvendor/hestiaGo andvendor/presentoGo packages.
    2. ☑️ - Develop Monteur's test, build, package, and releaserecipes for GoWASM.
    3. Develop baseline foundation for using GoWASM.
    4. ☑️ - Develop<body> manipulations directly in GoWASM(output).
    5. ☑️ - Develop<body> manipulations directly in GoWASM (input).
    6. ☑️ - Develop<body> manipulations directly in GoWASM(event-driven).
    7. ☑️ Explore and conclude the necessity of usingTinyGo.
  2. Develop client-side rendering capability usingHugo forcost reduction between the server sides and the end-user sides.
    1. ☑️ - Power on with Presento Theme with NoCSS but renderingcapabilities.
    2. ☑️ - Develop necessary partial functions to isolate Hugo's riskyfunctions and also to prevent supply-chain vendor locked-in wheneverpossible.
    3. ☑️ - Develop plain HTML+Javascript pages necessary to bring upGo-WASM.
    4. ☑️ - Power on Go-WASM+HTML+Javascript on Hugo.
    5. ☑️ - Deploy Gunzip against Go-WASM to reduce its size withMonteur.
    6. ☑ - Develop necessary foundation for Go-WASM client-side rendering.
  3. Develop the necessary CSS/Sass frontend rendering libraries to keep thefoundation reasonably and visually appealing at minimum.
    1. ☑️ - Analyize (1) and (2) to see exactly where to develop theCSS/Sass and why. Make sure it's documentable.
    2. ☑ - Develop the core component to render the page without devicescreen locking.
  4. Use scalable tools that can roll out updates for multiple technologiesmodularly and without much fears.
    1. ☑️ - deployed ZORALab's Monteur to manage the repositorysystematically, customizable at scale.
    2. ☑️ - deployed Hugo Themes module to manage Hugo specific andscalable setup.

3rd-Party Dependencies

Here are the list of 3rd-party dependencies used so far:

  1. ZORALab's Monteur -https://monteur.zoralab.com
  2. Go -https://go.dev
  3. Hugo -https://gohugo.io/
  4. GolangCI-Lint -https://golangci-lint.run/
  5. TinyGo -https://tinygo.org/docs/guides/webassembly/

About GZip Output Files

After decent research, it was found that many network CDN and load balancerservice providers (e.g. CloudFlare) automatically serves the content incompressed mode with GZip or Brotil (seehttps://support.cloudflare.com/hc/en-us/articles/200168396-Does-Cloudflare-compress-resources-).

For self-hosting CDN servers like Nginx or Apache, they already are servingcompression executions when enabled(see:https://docs.nginx.com/nginx/admin-guide/web-server/compression/).

Hence, there is no need to worry about manual compression.

Deployment Requirements

To determine where pure-Go WASM rendering to serve, a detailed scan throughof how consumption behavior affects the web technologies and how it serves.

Web Format Availability

Here, we look into what and how consumptions influences the web languages:

Available FormatsCaused ByContent ByDesigned ByBehavior By
html,css,jsnormal usehtmlcssjs
html,cssjs-blockhtmlcsscss
html,cssad-blockhtmlcsscss
html,jsReact-typehtmljsjs
html,jsAngular-typehtmljsjs
jssingle-pagejsjsjs
htmlbaremetalhtml

Conclusion for Designing Pure-Go WASM Library

  1. The UI library must be capable of generating its necessary HTML content codes.
  2. The UI library must be capable of generating its necessary CSS styling codes.
    1. The CSS codes MUST be flexible for various deployments notably as:
      1. inline HTML
      2. ascss file (external)
      3. insidejs
      4. as inlinecss (inside HTML)
      5. js rendering codes.
  3. The content codes must be flexible enough to store in bothhtml andjs formats.
  4. the behavior part is split into 2 parts:
    1. UI related behavior (e.g. bouncing, dancing, etc) shall be handled solelybycss.
    2. Data processing or routing (e.g. trigger loading screen, transmittingsubmission to server, etc) should be solely handled byjs.
  5. The UI library MUST leverage the compiler's unused code shedding capability forany of the user choice of output.

UI Tech Availability

Here, we look into different UI tech availability for rendering the a display output:

TechnologiesSource
vanilla webhttps://html.spec.whatwg.org/#introduction
qthttps://doc.qt.io/qt-6/wasm.html
wailshttps://wails.io/
lorcahttps://github.com/zserge/lorca
pwahttps://web.dev/progressive-web-apps/
webviewhttps://github.com/webview/webview
seedhttps://github.com/qlova/seed
qt (Go)https://github.com/therecipe/qt
tcellhttps://github.com/gdamore/tcell

Conclusion:

  1. The UI packageMUST leave room for horizontal scaling outside ofweb technologies alone.
  2. The packageMUST be a factory of similar design to generate thetechnology specific codes while allowing the compiler to shed unusedones seamlessly.

Rendering Devices

Here, we look into different devices rendering the same content page:

TechnologiesTypeDisplay Size (width x height)Pixel DensitySource
Apple Watch 6 (40mm)Wearables162px x 197px2https://www.webmobilefirst.com/en/devices/apple-watch-serie-6/
Apple iPhone SE (2018)Mobile320px x 568px2https://www.webmobilefirst.com/en/devices/apple-iphone-se/
Apple iPhone 5sMobile320px x 568px2https://www.webmobilefirst.com/en/devices/apple-iphone-5s/
Sony Experia XZMobile320px x 640px3https://www.webmobilefirst.com/en/devices/sony-xperia-xz/
Huawei Mate 10 LiteMobile360px x 720px3https://www.webmobilefirst.com/en/devices/huawei-mate-10-lite/
Samsung Galaxy S22 UltraMobile360px x 772px4https://www.webmobilefirst.com/en/devices/samsung-galaxy-s22-ultra-2022/
Samsung Galaxy Ultra 22+Mobile360px x 780px3https://www.webmobilefirst.com/en/devices/samsung-galaxy-s22-plus-2022/
Honor 9xMobile360px x 780px3https://www.webmobilefirst.com/en/devices/honor-9x/
Huawei Mate 30Mobile360px x 780px3https://www.webmobilefirst.com/en/devices/huawei-mate-30/
Huawei P30 ProMobile360px x 780px3https://www.webmobilefirst.com/en/devices/huawei-p30-pro/
Google Pixel 6 ProMobile360px x 780px4https://www.webmobilefirst.com/en/devices/google-pixel-6-pro/
Xiaomi 12Mobile360px x 800px3https://www.webmobilefirst.com/en/devices/xiaomi-12-2022/
Xiaomi 11iMobile360px x 800px3https://www.webmobilefirst.com/en/devices/xiaomi-mi-11i/
Generic Android PhoneMobile360px x 800px2https://www.webmobilefirst.com/en/devices/non-branded-android-smartphone/
Apple iPhone 7Mobile375px x 667px2https://www.webmobilefirst.com/en/devices/apple-iphone-7/
iPhone 13 Mini (2021)Mobile375px x 812px3https://www.webmobilefirst.com/en/devices/apple-iphone-13-mini-2021/
Huawei Mate 30 ProMobile392px x 800px3https://www.webmobilefirst.com/en/devices/huawei-mate-30-pro/
Apple iPhone 7 PlusMobile414px x 736px3https://www.webmobilefirst.com/en/devices/apple-iphone-7-plus/
Samsung Galaxy Note20 UltraMobile414px x 883px3.5https://www.webmobilefirst.com/en/devices/samsung-galaxy-note20-ultra/
Apple iPhone XS MaxMobile414px x 896px3https://www.webmobilefirst.com/en/devices/apple-iphone-xs-max/
A4 (72 DPI)Paper595px x 842px1https://www.a4-size.com/a4-size-in-pixels/
US Letter (72 DPI)Paper612px x 792px1https://papersizes.online/paper-size/letter/pixels/
Samsung Galaxy Fold (2019)Mobile768px x 1076px2https://www.webmobilefirst.com/en/devices/samsung-galaxy-fold/
A4 (96 DPI)Paper794px x 1123px1https://www.a4-size.com/a4-size-in-pixels/
US Letter (96 DPI)Paper816px x 1056px1https://papersizes.online/paper-size/letter/pixels/
US Letter (100 DPI)Paper850px x 1100px1https://papersizes.online/paper-size/letter/pixels/
Samsung Galaxy Fold (2020)Mobile884px x 1104px2https://www.webmobilefirst.com/en/devices/samsung-galaxy-fold2/
US Letter (120 DPI)Paper1020px x 1320px1https://papersizes.online/paper-size/letter/pixels/
Amazon Fire 7 (2017)Tablet1024px x 600px1http://responsivechecker.net/device/fire-7-2017
Samsung Galaxy Tab S3 9.7Tablet1024px x 768px2http://responsivechecker.net/device/galaxy-tab-s3-9-7
Apple iPad Mini 4Tablet1024px x 768px2http://responsivechecker.net/device/ipad-mini-4
Microsoft Surface DuoMobile1114px x 705px2.5https://www.webmobilefirst.com/en/devices/microsoft-surface-duo/
Apple iPad 4Tablet1180px x 820px2https://www.webmobilefirst.com/en/devices/apple-ipad-air-4/
A4 (150 DPI)Paper1240px x 1754px1https://www.a4-size.com/a4-size-in-pixels/
US Letter (150 DPI)Paper1275px x 1650px1https://papersizes.online/paper-size/letter/pixels/
Amazon Fire HD 10 (2017)Tablet1280px x 800px2http://responsivechecker.net/device/fire-hd-10-2017
Macbook Air 2020 13"Laptop1280px x 800px2https://www.webmobilefirst.com/en/devices/macbook-air/
iPad ProTablet1366px x 1024px2http://responsivechecker.net/device/ipad-pro/
iPad Pro 12.9"Tablet1366px x 1024px2http://responsivechecker.net/device/ipad-pro-12-9
US Letter (200 DPI)Paper1700px x 2200px1https://papersizes.online/paper-size/letter/pixels/
Macbook ProLaptop1728px x 1117px2https://www.webmobilefirst.com/en/devices/apple-macbook-pro-16-2021/
Samsung Smart TV NEO QLED 4k 55"TV1920px x 1080px2https://www.webmobilefirst.com/en/devices/samsung-smart-tv-neo-qled-4k-55/
iMac 24" 2021Desktop2048px x 1152px2https://www.webmobilefirst.com/en/devices/apple-imac-24-inch-2021/
US Letter (250 DPI)Paper2125px x 2750px1https://papersizes.online/paper-size/letter/pixels/
A4 (300 DPI)Paper2480px x 3508px1https://www.a4-size.com/a4-size-in-pixels/
US Letter (300 DPI)Paper2550px x 3300px1https://papersizes.online/paper-size/letter/pixels/
A4 (600 DPI)Paper4961px x 7016px1https://www.a4-size.com/a4-size-in-pixels/
US Letter (600 DPI)Paper5100px x 6600px1https://papersizes.online/paper-size/letter/pixels/
A4 (720 DPI)Paper5953px x 8419px1https://www.a4-size.com/a4-size-in-pixels/
A4 (1200 DPI)Paper9922px x 14032px1https://www.a4-size.com/a4-size-in-pixels/
US Letter (1200 DPI)Paper10200px x 13200px1https://papersizes.online/paper-size/letter/pixels/

Conclusion:

  1. UI library web rendering SHALL NOT DEPENDS on device-orientedmedia query breakpoint.
  2. Any media querySHALL be oriented to the design module with itsown definitions of breakpoint indepnendent of device dimension.
  3. As the hardware industry rolls out odd screen sizes,there is aneed to develop a new approach to avoid breakpoint dimension wheneverpossible.
  4. All media tags (e.g. images, videos, etc) shall have pixel densityawareness.

Critical Issues

Here are the tracking issues critical to the research success:

  1. Tinygo WASM Memory Leak (first detected after implementing Chain kernelexample) -tinygo-org/tinygo#1140
  2. Go WASI Implementation (first detected near experimentation conclusion)

(1) Utilize Local CI - Monteur

The FIRST technology chosen wasZORALab's Monteurto manage the repository development continuously and controls with confidenceswhen deploying the repository in a decentralized manner.

The first step you need to do would be installing Monteur as per instructed intheir official website.

Once themonteur program is available, proceed to your own copy and perform:

$ monteur setup

Monteur shall setup all the repository's dependencies and configurationsseamlessly. Repeat thismonteur setup command whenever there is an update fromMonteur Setup Job recipes OR something went wrong with the current setup inyour repository.

(2) Local Development

The second step is to bring up your local development. Monteur setup localfilesystem inside the repository. Hence, whenever you open a new terminal towanting to develop this repository, simply do the following:

$source .monteurFS/config/main

Once done, the terminal you're in is now configured to be repository specific.You're now ready to develop the repository. All instructions beyond this stepassumes you always this step.

NOTE

Whenever you find any software that is missing in action, you're likelyforgotten this step.

(3) Local Hosting Hugo

The SECOND technology selected washugo for simple static site generations.The repository is designed in a way that it can operate in offline or badconnectivity environments. To do that, execute:

.configs/hugo/server.cmd

Once done, please visit the URL site presented in the terminal. The defaultis:http://localhost:8080

If you need to work on something else, you need to setup a new terminal again.

(4) GoWASM Go Workspace

The THIRD technologies selected werego andgolangci-lint for theirsimplicity and portability sake. In order to work on the Go project, you needto open a new terminal, perform the Step (2) for it, and then change directoryintowasmExpGo. That is the root location of the Go source codes and itsworkspace.

cd wasmExpGo

While the workspace is for this repository, the file structures are arrangedinto 3 different Gomodules:wasmExpGo,hestiaGo, andpresentoGo. Theminimal file structure is as follows:

.├── app│   └── wasm│       └── main.go├── go.mod├── hestiaGo│   ├── go.mod│   └── version.go└── presentoGo    ├── go.mod    └── version.go

Each module has its specific roles to prevent vendor locked-in threat whilemaintaining Go's quality in package modularlities. They key roles are:

  1. wasmExpGo - the repository specific packages.
  2. hestiaGo - the common library packages that will be upstreamed to:https://github.com/ZORALab/Hestia
  3. presentoGo - the frontend UI rendering packages that will be upstreamed to:https://github.com/ZORALab/Presento

To prevent supply-chain nightmare from affecting any project,go.mod plays acritical role here to make sure all the source codes know where to find thepackages.

Generally speaking, all import statementsSHALL use thereplace clauseto denote its sourcing navigations. Here is a simple example:

// Copyright 2022 "Holloway" Chew, Kean Ho <hollowaykeanho@gmail.com>//// Permission is hereby granted, free of charge, to any person obtaining a copy// of this software and associated documentation files (the "Software"), to// deal in the Software without restriction, including without limitation the// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or// sell copies of the Software, and to permit persons to whom the Software is// furnished to do so, subject to the following conditions://// The above copyright notice and this permission notice shall be included in// all copies or substantial portions of the Software.//// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER// DEALINGS IN THE SOFTWARE.package mainimport ("fmt""hestiaGo""presentoGo")func main() {fmt.Printf("Hello World\n")fmt.Printf("Hestia Version: %s\n", hestiaGo.VERSION)fmt.Printf("Presento Version: %s\n", presentoGo.VERSION)}

Notice that bothhestiaGo andpresentoGo are not imported usinggithub.com/hollowaykeanho/.... Instead, they are using their navigator.

Then inwasmExpGo'sgo.mod, it has replace clauses as follows:

module github.com/hollowaykeanho/ExperimentingGoWASM/wasmExpGogo 1.18replace (github.com/hollowaykeanho/ExperimentingGoWASM/wasmExpGo => ./hestiaGo => ./hestiaGopresentoGo => ./presentoGowasmExpGo => ./)

Themodule clause remains as default since we want to maintaingo getcapability. However, in source codes, we usewasmExpGo instead just like theother 2.

Then, in each 3rd-party libraries, their modules are in accordance to theirrespectivego.mod settings:

module https://github.com/ZORALab/Hestia/hestiaGogo 1.18replace (github.com/ZORALab/Hestia/hestiaGo => ./hestiaGo => ./)

(5) Testing Go Workspace

With Monteur Test CI Job made available, given the correct recipe, Monteurcan perform either pinpoint or recursive testing against Go packges. All theuser needs to do is:

$ monteur test

And then all the necessary result data files are generated into the packagedirectory itself.

(6) Building Go WASM

With Monteur Build CI Job made available, given the correct recipe, Monteurcan peform percise Go build in a reproducible manner. All the user needs to dois:

$ monteur build

(7) Package Go WASM

With Monteur Package CI Job made available, given the correct recipe, Monteurcan peform proper packaging in a reproducible manner. All the user needs to dois:

$ monteur package

(8) Release to Hugo

With Monteur Release CI Job made available, given the correct recipe, Monteurcan peform proper manage the Go WASM systematically. All the user needs to dois:

$ monteur release

At this point, Go development is considered completed.

(9) Compose Static Site Generations

With Monteur Compose CI Job made available, given the correct recipe, Monteurcan properly compose Hugo's website artifact for web publications. All the userneeds to do is:

$ monteur compose

At this point, Hugo development is considered completed.

(10) Publish the Static Site Artifact

With Monteur Publish CI Job made available, given the correct recipe, Monteurcan properly publish the composed website artifact to the public. All the userneeds to do is:

$ monteur publish

At this point, the development is considered deployed.

License

The repository is licensed under MIT License.

About

An experimental repository for developing libraries and web tools necessary to use pure Go to compile a PWA web app via WASM.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp