Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
554f93ec
Commit
554f93ec
authored
Feb 01, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: move initial wasm into app
parent
79227021
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
8 deletions
+17
-8
index.html
web/index.html
+0
-6
App.tsx
web/src/App.tsx
+6
-2
global.d.ts
web/src/types/global.d.ts
+11
-0
No files found.
web/index.html
View file @
554f93ec
...
@@ -18,12 +18,6 @@
...
@@ -18,12 +18,6 @@
}
}
</script>
</script>
<script
src=
"wasm_exec.js"
></script>
<script
src=
"wasm_exec.js"
></script>
<script>
const
go
=
new
Go
();
WebAssembly
.
instantiateStreaming
(
fetch
(
"gomark.wasm"
),
go
.
importObject
).
then
((
result
)
=>
{
go
.
run
(
result
.
instance
);
});
</script>
</head>
</head>
<body>
<body>
<div
id=
"root"
></div>
<div
id=
"root"
></div>
...
...
web/src/App.tsx
View file @
554f93ec
...
@@ -26,16 +26,20 @@ const App = () => {
...
@@ -26,16 +26,20 @@ const App = () => {
},
[
systemStatus
.
host
]);
},
[
systemStatus
.
host
]);
useEffect
(()
=>
{
useEffect
(()
=>
{
const
initialGoWASMExec
=
async
()
=>
{
const
go
=
new
window
.
Go
();
const
result
=
await
WebAssembly
.
instantiateStreaming
(
fetch
(
"/gomark.wasm"
),
go
.
importObject
);
go
.
run
(
result
.
instance
);
};
const
initialState
=
async
()
=>
{
const
initialState
=
async
()
=>
{
try
{
try
{
await
userStore
.
fetchCurrentUser
();
await
userStore
.
fetchCurrentUser
();
}
catch
(
error
)
{
}
catch
(
error
)
{
// Do nothing.
// Do nothing.
}
}
setLoading
(
false
);
};
};
initialState
(
);
Promise
.
all
([
initialGoWASMExec
(),
initialState
()]).
then
(()
=>
setLoading
(
false
)
);
},
[]);
},
[]);
useEffect
(()
=>
{
useEffect
(()
=>
{
...
...
web/src/types/global.d.ts
View file @
554f93ec
import
{
Node
}
from
"./node"
;
import
{
Node
}
from
"./node"
;
declare
class
Go
{
argv
:
string
[];
env
:
{
[
envKey
:
string
]:
string
};
exit
:
(
code
:
number
)
=>
void
;
importObject
:
WebAssembly
.
Imports
;
exited
:
boolean
;
mem
:
DataView
;
run
(
instance
:
WebAssembly
.
Instance
):
Promise
<
void
>
;
}
declare
global
{
declare
global
{
interface
Window
{
interface
Window
{
Go
:
typeof
Go
;
parse
:
(
content
:
string
)
=>
Node
[];
parse
:
(
content
:
string
)
=>
Node
[];
restore
:
(
input
:
Node
[])
=>
string
;
restore
:
(
input
:
Node
[])
=>
string
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment