Skip to content

Commit

Permalink
update go-app
Browse files Browse the repository at this point in the history
  • Loading branch information
lu4p committed Dec 30, 2020
1 parent aaabeb6 commit 267435a
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 52 deletions.
8 changes: 4 additions & 4 deletions docs/app-worker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const cacheName = "app-" + "1d803cfd4223967be62c5c3408633d866795bf4f";
const cacheName = "app-" + "91e7989a230f05103fe4e93dc2e57405536cff69";

self.addEventListener("install", event => {
console.log("installing app worker 1d803cfd4223967be62c5c3408633d866795bf4f");
console.log("installing app worker 91e7989a230f05103fe4e93dc2e57405536cff69");
self.skipWaiting();

event.waitUntil(
Expand All @@ -10,7 +10,7 @@ self.addEventListener("install", event => {
"/astextract",
"/astextract/app.css",
"/astextract/app.js",
"/astextract/manifest.json",
"/astextract/manifest.webmanifest",
"/astextract/wasm_exec.js",
"/astextract/web/app.wasm",
"https://storage.googleapis.com/murlok-github/icon-192.png",
Expand All @@ -34,7 +34,7 @@ self.addEventListener("activate", event => {
);
})
);
console.log("app worker 1d803cfd4223967be62c5c3408633d866795bf4f is activated");
console.log("app worker 91e7989a230f05103fe4e93dc2e57405536cff69 is activated");
});

self.addEventListener("fetch", event => {
Expand Down
97 changes: 97 additions & 0 deletions docs/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,100 @@
height: 18px;
margin-right: 12px;
}

/*------------------------------------------------------------------------------
Shell
------------------------------------------------------------------------------*/
.goapp-shell,
.goapp-shell-layout,
.goapp-shell-overlay-menu {
width: 100%;
height: 100%;
max-width: 100%;
max-height: 100%;
overflow: hidden;
pointer-events: none;
}

.goapp-shell {
position: fixed;
top: 0;
left: 0;
-webkit-text-size-adjust: 100%;
-moz-text-size-adjust: 100%;
text-size-adjust: 100%;
}

.goapp-shell-layout {
position: relative;
display: flex;
}

.goapp-shell-item {
max-height: 100%;
overflow-x: hidden;
overflow-y: auto;
}

.goapp-shell-menu-button,
.goapp-shell-item > *,
.goapp-shell-overlay-menu > * {
pointer-events: auto;
}

.goapp-shell-menu-button {
position: absolute;
top: 0;
left: 0;
margin: 0;
padding: 0;
border: none;
outline: none;
background-color: transparent;
color: currentColor;
}

.goapp-shell-menu-button-default {
font-size: 24px;
padding: 12px 18px;
color: currentColor;
}

.goapp-shell-menu-button-default:hover {
color: dodgerblue;
cursor: pointer;
}

.goapp-shell-overlay-menu {
position: absolute;
top: 0;
left: 0;
}

/*------------------------------------------------------------------------------
Stack
------------------------------------------------------------------------------*/
.goapp-stack {
position: relative;
display: flex;
}

/*------------------------------------------------------------------------------
Flow
------------------------------------------------------------------------------*/
.goapp-flow {
position: relative;
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: stretch;
width: 100%;
max-width: 100%;
margin: 0;
padding: 0;
}

.goapp-flow-item {
flex-grow: 0;
flex-shrink: 1;
}
2 changes: 1 addition & 1 deletion docs/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if ("serviceWorker" in navigator) {
// -----------------------------------------------------------------------------
// Init progressive app
// -----------------------------------------------------------------------------
const goappEnv = {"GOAPP_ROOT_PREFIX":"/astextract","GOAPP_STATIC_RESOURCES_URL":"/astextract","GOAPP_VERSION":"1d803cfd4223967be62c5c3408633d866795bf4f"};
const goappEnv = {"GOAPP_ROOT_PREFIX":"/astextract","GOAPP_STATIC_RESOURCES_URL":"/astextract","GOAPP_VERSION":"91e7989a230f05103fe4e93dc2e57405536cff69"};

function goappGetenv(k) {
return goappEnv[k];
Expand Down
10 changes: 5 additions & 5 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
<head>
<meta charset="UTF-8">
<meta httpequiv="Content-Type" content="text/html; charset=utf-8">
<meta name="author" content="lu4p">
<meta content="lu4p" name="author">
<meta name="description" content>
<meta name="keywords" content>
<meta name="theme-color" content="#ffffff">
<meta content="#ffffff" name="theme-color">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0, viewport-fit=cover">
<title>
astextract
</title>
<link type="image/png" href="https://storage.googleapis.com/murlok-github/icon-192.png" rel="icon">
<link rel="icon" type="image/png" href="https://storage.googleapis.com/murlok-github/icon-192.png">
<link href="https://storage.googleapis.com/murlok-github/icon-192.png" rel="apple-touch-icon">
<link rel="manifest" href="/astextract/manifest.json">
<link rel="manifest" href="/astextract/manifest.webmanifest">
<link type="text/css" rel="stylesheet" href="/astextract/app.css">
<script defer src="/astextract/wasm_exec.js"></script>
<script src="/astextract/wasm_exec.js" defer></script>
<script defer src="/astextract/app.js"></script>
<link type="text/css" rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre.min.css">
</head>
Expand Down
21 changes: 21 additions & 0 deletions docs/manifest.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"short_name": "astextract",
"name": "astextract",
"icons": [
{
"src": "https://storage.googleapis.com/murlok-github/icon-192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "https://storage.googleapis.com/murlok-github/icon-512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"scope": "/astextract/",
"start_url": "/astextract/",
"background_color": "#2d2c2c",
"theme_color": "#ffffff",
"display": "standalone"
}
59 changes: 28 additions & 31 deletions docs/wasm_exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
}

if (!global.fs && global.require) {
global.fs = require("fs");
const fs = require("fs");
if (Object.keys(fs) !== 0) {
global.fs = fs;
}
}

const enosys = () => {
Expand Down Expand Up @@ -172,37 +175,19 @@
const storeValue = (addr, v) => {
const nanHead = 0x7FF80000;

if (typeof v === "number") {
if (typeof v === "number" && v !== 0) {
if (isNaN(v)) {
this.mem.setUint32(addr + 4, nanHead, true);
this.mem.setUint32(addr, 0, true);
return;
}
if (v === 0) {
this.mem.setUint32(addr + 4, nanHead, true);
this.mem.setUint32(addr, 1, true);
return;
}
this.mem.setFloat64(addr, v, true);
return;
}

switch (v) {
case undefined:
this.mem.setFloat64(addr, 0, true);
return;
case null:
this.mem.setUint32(addr + 4, nanHead, true);
this.mem.setUint32(addr, 2, true);
return;
case true:
this.mem.setUint32(addr + 4, nanHead, true);
this.mem.setUint32(addr, 3, true);
return;
case false:
this.mem.setUint32(addr + 4, nanHead, true);
this.mem.setUint32(addr, 4, true);
return;
if (v === undefined) {
this.mem.setFloat64(addr, 0, true);
return;
}

let id = this._ids.get(v);
Expand All @@ -216,8 +201,13 @@
this._ids.set(v, id);
}
this._goRefCounts[id]++;
let typeFlag = 1;
let typeFlag = 0;
switch (typeof v) {
case "object":
if (v !== null) {
typeFlag = 1;
}
break;
case "string":
typeFlag = 2;
break;
Expand Down Expand Up @@ -440,14 +430,14 @@

// func valueInstanceOf(v ref, t ref) bool
"syscall/js.valueInstanceOf": (sp) => {
this.mem.setUint8(sp + 24, loadValue(sp + 8) instanceof loadValue(sp + 16));
this.mem.setUint8(sp + 24, (loadValue(sp + 8) instanceof loadValue(sp + 16)) ? 1 : 0);
},

// func copyBytesToGo(dst []byte, src ref) (int, bool)
"syscall/js.copyBytesToGo": (sp) => {
const dst = loadSlice(sp + 8);
const src = loadValue(sp + 32);
if (!(src instanceof Uint8Array)) {
if (!(src instanceof Uint8Array || src instanceof Uint8ClampedArray)) {
this.mem.setUint8(sp + 48, 0);
return;
}
Expand All @@ -461,7 +451,7 @@
"syscall/js.copyBytesToJS": (sp) => {
const dst = loadValue(sp + 8);
const src = loadSlice(sp + 16);
if (!(dst instanceof Uint8Array)) {
if (!(dst instanceof Uint8Array || dst instanceof Uint8ClampedArray)) {
this.mem.setUint8(sp + 48, 0);
return;
}
Expand Down Expand Up @@ -490,10 +480,17 @@
global,
this,
];
this._goRefCounts = []; // number of references that Go has to a JS value, indexed by reference id
this._ids = new Map(); // mapping from JS values to reference ids
this._idPool = []; // unused ids that have been garbage collected
this.exited = false; // whether the Go program has exited
this._goRefCounts = new Array(this._values.length).fill(Infinity); // number of references that Go has to a JS value, indexed by reference id
this._ids = new Map([ // mapping from JS values to reference ids
[0, 1],
[null, 2],
[true, 3],
[false, 4],
[global, 5],
[this, 6],
]);
this._idPool = []; // unused ids that have been garbage collected
this.exited = false; // whether the Go program has exited

// Pass command line arguments and environment variables to WebAssembly by writing them to the linear memory.
let offset = 4096;
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/lu4p/astextract
go 1.14

require (
github.com/maxence-charriere/go-app/v7 v7.0.5
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/maxence-charriere/go-app/v7 v7.0.7
github.com/rogpeppe/go-internal v1.6.2
)
31 changes: 21 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,28 +1,39 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gomarkdown/markdown v0.0.0-20201030010234-8ba61b39d0e4/go.mod h1:aii0r/K0ZnHv7G0KF7xy1v0A7s2Ljrb5byB7MO5p6TU=
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/maxence-charriere/go-app/v7 v7.0.3 h1:E4vvR/Sv2dfcsAswfp/ZmdFIAhqMUpvMeYxNLPKkKBc=
github.com/maxence-charriere/go-app/v7 v7.0.3/go.mod h1:JTs+/Taw1Qz+NDOQsA0mQS0QuoEtD7kZuSpviWRKsjk=
github.com/maxence-charriere/go-app/v7 v7.0.5 h1:Wpmb0a+hfrWpTtNr7bwBaHCP594ppUU9EbBk0Ek768A=
github.com/maxence-charriere/go-app/v7 v7.0.5/go.mod h1:j8bnGsqvzQzpRztKvueLenqcOitefjvoMXAyW6hVp0k=
github.com/maxence-charriere/go-app/v7 v7.0.7 h1:u0rAVQiZHSIkOwEZbNDjRQBeCV0n+X52J9EbgDpMBhU=
github.com/maxence-charriere/go-app/v7 v7.0.7/go.mod h1:3S3cKNiz6/ib081vPTkM+WOuIIK7qtq+7wtHFX9/Svw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.6.2 h1:aIihoIOHCiLZHxyoNQ+ABL4NKhFTgKLBdMLyEAh98m0=
github.com/rogpeppe/go-internal v1.6.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/dl v0.0.0-20190829154251-82a15e2f2ead/go.mod h1:IUMfjQLJQd4UTqG1Z90tenwKoCX93Gn3MAQJMOSBsDQ=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0 h1:0vLT13EuvQ0hNvakwLuFZ/jYrLp5F3kcWHXdRggjCE8=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 comments on commit 267435a

Please sign in to comment.