Skip to content

Commit e165709

Browse files
committed
Fetches iso from github on prod builds
1 parent 4d194e9 commit e165709

File tree

7 files changed

+30
-9
lines changed

7 files changed

+30
-9
lines changed

.github/workflows/deploy.yml

-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ jobs:
2424
- name: Install NPM Dependencies
2525
run: npm ci
2626

27-
- name: Download ISO
28-
run: wget https://spacestation13.github.io/dm-playground-linux/rootfs.iso9660 -O public/lib/rootfs.iso
29-
3027
- name: Build project
3128
run: npx ng build --base-href /dm-playground/
3229

angular.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@
8888
"development": {
8989
"optimization": false,
9090
"extractLicenses": false,
91-
"sourceMap": true
91+
"sourceMap": true,
92+
"fileReplacements": [
93+
{
94+
"replace": "src/environments/environment.ts",
95+
"with": "src/environments/environment.development.ts"
96+
}
97+
]
9298
}
9399
},
94100
"defaultConfiguration": "production"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const environment = {
2+
isoUrl: './lib/rootfs.iso',
3+
};

src/environments/environment.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const environment = {
2+
isoUrl: 'https://spacestation13.github.io/dm-playground-linux/rootfs.iso9660',
3+
};

src/utils/literalConstants.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const isoUrlSearchParameter = 'isoUrl';

src/vm/emulator.service.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { EventEmitter, Injectable, Output } from '@angular/core';
22
import type { WorkerMsgWithoutCID, WorkerResponseMsg } from './emulator.worker';
3+
import { environment } from '../environments/environment';
4+
import { isoUrlSearchParameter } from '../utils/literalConstants';
35

46
const encoder = new TextEncoder();
57

@@ -16,11 +18,20 @@ export class EmulatorService {
1618
@Output()
1719
public receivedOutputController = new EventEmitter<string>();
1820

19-
private worker = new Worker(new URL('./emulator.worker', import.meta.url));
21+
private worker;
2022

2123
private asyncCallbacks = new Map<number, Function>();
2224

2325
constructor() {
26+
interface FakeWorker {
27+
new (url: URL): Worker;
28+
}
29+
const Worker = function (url: URL) {
30+
url.searchParams.set(isoUrlSearchParameter, environment.isoUrl);
31+
return new window.Worker(url);
32+
} as unknown as FakeWorker;
33+
this.worker = new Worker(new URL('./emulator.worker', import.meta.url));
34+
2435
this.worker.onmessage = (event: MessageEvent<WorkerResponseMsg>) => {
2536
let e = event.data;
2637
if ('event' in e) {

src/vm/emulator.worker.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/// <reference lib="webworker" />
22

3-
// @ts-ignore
4-
import { dynamic_import } from '../utils/misc';
3+
import { isoUrlSearchParameter } from '../utils/literalConstants';
54

6-
await dynamic_import('./lib/libv86.js');
5+
importScripts('./lib/libv86.js');
76

87
interface MsgSendTerminal {
98
command: 'sendTerminal';
@@ -73,6 +72,7 @@ export type WorkerEventResponseMsg =
7372
data: void;
7473
};
7574

75+
const parameters = new URLSearchParams(location.search);
7676
const emulator = new V86({
7777
//Emulator binaries
7878
wasm_path: 'lib/v86.wasm',
@@ -131,7 +131,7 @@ const emulator = new V86({
131131
url: 'https://raw.githubusercontent.com/copy/v86/master/bios/vgabios.bin',
132132
},
133133
cdrom: {
134-
url: './lib/rootfs.iso', //TODO: Use github url
134+
url: parameters.get(isoUrlSearchParameter),
135135
},
136136
hda: null,
137137
hdb: null,

0 commit comments

Comments
 (0)