Skip to content

Commit 2fa010a

Browse files
committed
Web node custom memory in URL
1 parent d37b238 commit 2fa010a

File tree

4 files changed

+24
-10
lines changed

4 files changed

+24
-10
lines changed

frontend/httpd.conf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,6 @@ SSLProxyEngine On
231231

232232
# Cache rules
233233

234-
# Add cache for web node files
235-
; <FilesMatch "\.(js|wasm)$">
236-
; Header set Cache-Control "public, max-age=31536000, immutable"
237-
; </FilesMatch>
238-
239234
# REMOVE CACHE
240235
<IfModule mod_expires.c>
241236
ExpiresActive On

frontend/src/app/app.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@ export class AppComponent extends StoreDispatcher implements OnInit {
5959
}
6060

6161
goToWebNode(): void {
62-
this.router.navigate([Routes.LOADING_WEB_NODE]);
62+
this.router.navigate([Routes.LOADING_WEB_NODE], { queryParamsHandling: 'merge' });
6363
this.initAppFunctionalities();
6464
}
6565

6666
private initAppFunctionalities(): void {
6767
if (this.webNodeService.hasWebNodeConfig() && !this.webNodeService.isWebNodeLoaded()) {
68-
this.router.navigate([Routes.LOADING_WEB_NODE]);
68+
if (!window.location.href.includes(`/${Routes.LOADING_WEB_NODE}`)) {
69+
this.router.navigate([Routes.LOADING_WEB_NODE], { queryParamsHandling: 'preserve' });
70+
}
6971
}
7072
this.dispatch2(AppActions.init());
7173
if (!this.hideToolbar && !CONFIG.hideNodeStats) {

frontend/src/app/core/services/web-node.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export class WebNodeService {
2020

2121
readonly webnodeProgress$: BehaviorSubject<string> = new BehaviorSubject<string>('');
2222

23+
memory: WebAssembly.Memory;
24+
2325
constructor(private http: HttpClient) {
2426
FileProgressHelper.initDownloadProgress();
2527
const basex = base('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz');
@@ -54,7 +56,7 @@ export class WebNodeService {
5456
startWasm$(): Observable<any> {
5557
return of(any(window).webnode)
5658
.pipe(
57-
switchMap((wasm: any) => from(wasm.default()).pipe(map(() => wasm))),
59+
switchMap((wasm: any) => from(wasm.default(undefined, this.memory)).pipe(map(() => wasm))),
5860
switchMap((wasm) => {
5961
this.webnodeProgress$.next('Loaded');
6062
return from(wasm.run(this.webNodeKeyPair.privateKey));

frontend/src/app/features/webnode/webnode.component.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
22
import { WebNodeInitializationComponent } from '@app/features/webnode/web-node-initialization/web-node-initialization.component';
33
import { Platform } from '@angular/cdk/platform';
44
import { WebNodeNotSupportedComponent } from '@app/features/webnode/web-node-not-supported/web-node-not-supported.component';
5+
import { StoreDispatcher } from '@shared/base-classes/store-dispatcher.class';
6+
import { getMergedRoute, MergedRoute } from '@openmina/shared';
7+
import { filter } from 'rxjs';
8+
import { WebNodeService } from '@core/services/web-node.service';
59

610
@Component({
711
selector: 'mina-webnode',
@@ -14,15 +18,26 @@ import { WebNodeNotSupportedComponent } from '@app/features/webnode/web-node-not
1418
styleUrl: './webnode.component.scss',
1519
changeDetection: ChangeDetectionStrategy.OnPush,
1620
})
17-
export class WebnodeComponent implements OnInit {
21+
export class WebnodeComponent extends StoreDispatcher implements OnInit {
1822

1923
supported: boolean = false;
2024
isPhone: boolean = false;
2125

22-
constructor(private platform: Platform) {}
26+
constructor(private platform: Platform,
27+
private webNodeService: WebNodeService) { super(); }
2328

2429
ngOnInit(): void {
2530
this.checkIfDeviceIsSupported();
31+
this.listenToRoute();
32+
}
33+
34+
private listenToRoute(): void {
35+
this.select(getMergedRoute, (route: MergedRoute) => {
36+
const initial = Number(route.queryParams['initial']);
37+
const maximum = Number(route.queryParams['maximum']);
38+
const shared = route.queryParams['shared'] === 'true';
39+
this.webNodeService.memory = new WebAssembly.Memory({ initial, maximum, shared });
40+
}, filter(Boolean));
2641
}
2742

2843
private checkIfDeviceIsSupported(): void {

0 commit comments

Comments
 (0)