Upgraded to js-dos v7 w/web workers

This commit is contained in:
Dustin Brett 2020-11-28 23:27:38 -08:00
parent c9796dfce2
commit 65118a266e
23 changed files with 6640 additions and 115 deletions

View File

@ -2,14 +2,14 @@
## High
- File Manager
- Explorer
- Filename should truncate when too long
- Focus
- Reopening app changes foreground id but not focus
- Icons
- Dragging should go in front of windows
- Files
- Uploaded files not working on subsequent loads
- Uploaded files not working on reload for PDF/ODT
- Windows
- Initial load maximized if dimensions > screen
@ -25,8 +25,6 @@
- Store icon positions
- Fix 3rd line truncation (hiding overflow cuts off shadow)
- Fix single long line not truncating
- DOS
- Run in web worker to stop animation blocking
- Focus
- Winamp titlebar not properly focused on load
- Files
@ -36,35 +34,24 @@
## Low
- Wallpaper
- Use brighter rainbow effect
- File Manager
- Resizable/sortable/scrollable columns
- Modified date/time
- Expandable tree-view of directories (List & Menu View)
- System
- Context menus on right click or touch hold
- Toolbar
- Back, Forward, Refresh & Home Buttons
- Toolbars
- Back, Forward, Refresh, Zoom & Home Buttons
- Address & Search Inputs
- Icons
- Switch to grid layout
- WebODF icon for doc types
- ClippyJS
- Clean up code and move to hooks
- System Tray
- Use battery icons from
- DOS
- Add buttons for virtual keyboard and saving
# Feedback
- Allow changing theme components to all Windows or all macOS (or Linux)
- iOS/iPad Safari issue with start button
- Improve UX/a11y to fit better into browser format
- Virtual keyboard for DOS on mobile/tablet
- Min/max/close are sometimes not doing the correct functions
- Key combos in DOS are being capture by browser/OS (Fullscreen?)
- Unfocus of start menu is inconsistent on Safari
- Dragging acts odd when Blog iframe is open
- iPhone 6 issues with clicking anything
- Blog iframe glitches out of window on Safari w/iPhone XS or lower
- Typing and resizing of 1 DOS window effects others
- Blog iframe glitches out of window on Safari
- Unfocus of start menu is inconsistent on Safari
- Mobile Safari issues with start button

View File

@ -13,12 +13,8 @@ const defaultDimensions = {
height: 400 + TITLEBAR_HEIGHT
};
const Dos: React.FC<AppComponent> = ({
args,
file: { url, name = '' } = {},
maximized
}) => {
const canvasRef = useRef<HTMLCanvasElement>(null);
const Dos: React.FC<AppComponent> = ({ file: { url } = {}, maximized }) => {
const containerRef = useRef<HTMLElement>(null);
const maximizedStyle = maximized
? getLockedAspectRatioDimensions(
defaultDimensions.width,
@ -26,16 +22,16 @@ const Dos: React.FC<AppComponent> = ({
)
: {};
useDos({ args, canvasRef, name, url });
useDos({ containerRef, url });
return (
<article className={styles.dos} style={maximizedStyle}>
<canvas
onTouchStart={focusClosestFocusableElementFromRef(canvasRef)}
onClick={focusClosestFocusableElementFromRef(canvasRef)}
ref={canvasRef}
/>
</article>
<article
className={styles.dos}
style={maximizedStyle}
onTouchStart={focusClosestFocusableElementFromRef(containerRef)}
onClick={focusClosestFocusableElementFromRef(containerRef)}
ref={containerRef}
/>
);
};

View File

@ -1,61 +1,33 @@
import type { DosCommandInterface } from 'js-dos/dist/typescript/js-dos-ci';
import type { DosMainFn, DosRuntime } from 'js-dos';
import type { WindowWithDosModule } from '@/types/components/Programs/dos';
import type {
DosCommandInterface,
WindowWithDosModules
} from '@/types/components/Programs/dos';
import { CNAME } from '@/utils/constants';
import { useEffect, useState } from 'react';
const dosOptions = {
wdosboxUrl: '/libs/wdosbox.js',
/* eslint @typescript-eslint/no-empty-function: off */
onprogress: () => {}
};
const useDos = ({
args,
canvasRef,
name,
containerRef,
url
}: {
args: URLSearchParams | undefined;
canvasRef: React.RefObject<HTMLCanvasElement>;
name: string;
containerRef: React.RefObject<HTMLElement>;
url?: string;
}): void => {
const [dosCi, setDosCi] = useState<DosCommandInterface | null>(null);
const loadMain = (main: DosMainFn, prependedArgs: string[] = []) => {
const loadArgs = args?.get('-c')
? args
?.getAll('-c')
.map((value) => ['-c', value])
.flat() || []
: ['-c', 'CLS'];
main([...prependedArgs, ...loadArgs]).then((value) => {
setDosCi(value);
});
};
const loadDos = ({ fs, main }: DosRuntime) => {
if (url) {
const appPath = name.replace(/ /g, '').substring(0, 8);
fs.extract(url, appPath).then(() =>
loadMain(main, ['-c', `CD ${appPath}`])
);
} else {
loadMain(main);
}
};
useEffect(() => {
const { current: canvasElement } = canvasRef as {
const { current: containerElement } = containerRef as {
current: HTMLCanvasElement;
};
const { Dos: DosModule } = window as WindowWithDosModule;
const DosWindow = window as WindowWithDosModules;
DosModule(canvasElement, {
autolock: !!args?.get('autolock'),
...dosOptions
}).then(loadDos);
/* eslint no-underscore-dangle: off */
DosWindow.__dirname = '';
DosWindow.emulators.pathPrefix = '/libs/js-dos/';
DosWindow.Dos(containerElement)
.run(url?.replace(`https://${CNAME}`, ''))
.then((ci: DosCommandInterface) => setDosCi(ci));
}, []);
useEffect(

6
package-lock.json generated
View File

@ -8838,9 +8838,9 @@
}
},
"js-dos": {
"version": "6.22.59",
"resolved": "https://registry.npmjs.org/js-dos/-/js-dos-6.22.59.tgz",
"integrity": "sha512-rlU1/Rcih2GsGC/FO4zzC8hrUv08aBlftMV6JrS2o4i1bern5kgSirKbxArQvif6CLI81WMrLZx68EZMhzTpBQ=="
"version": "7.0.0-beta.r24",
"resolved": "https://registry.npmjs.org/js-dos/-/js-dos-7.0.0-beta.r24.tgz",
"integrity": "sha512-bRWNKbPeh73m3x4LXz6gzV7Mp4tkPrNBTA5Pi+Be2+nCCzkGbsK4QKwkVhwmn8clwlGlSHn/F6hKi8D+49Pq2w=="
},
"js-tokens": {
"version": "4.0.0",

View File

@ -27,7 +27,7 @@
"color": "^3.1.3",
"framer-motion": "^2.9.4",
"ini": "^1.3.5",
"js-dos": "^6.22.59",
"js-dos": "^7.0.0-beta.r24",
"next": "^10.0.3",
"next-optimized-images": "^3.0.0-canary.10",
"react": "^17.0.1",

View File

@ -1,3 +1,3 @@
[InternetShortcut]
URL=https://x.dustinbrett.com/?app=dos
URL=https://x.dustinbrett.com/libs/js-dos/dos.jsdos
IconFile=https://x.dustinbrett.com/icons/programs/dos.png

View File

@ -1,3 +1,3 @@
[InternetShortcut]
URL=https://x.dustinbrett.com/games/doom.jsdos?-c=DOOM.EXE
URL=https://x.dustinbrett.com/games/doom.jsdos
IconFile=https://x.dustinbrett.com/icons/games/doom.png

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
public/libs/js-dos/dos.jsdos Executable file

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

BIN
public/libs/js-dos/wworker.wasm Executable file

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -1,3 +1,3 @@
[InternetShortcut]
URL=https://x.dustinbrett.com/games/keen4.jsdos?-c=CD%20CKEEN4&-c=KEEN4E.EXE
URL=https://x.dustinbrett.com/games/keen4.jsdos
IconFile=https://x.dustinbrett.com/icons/games/keen.png

View File

@ -1,3 +1,3 @@
[InternetShortcut]
URL=https://x.dustinbrett.com/games/jazz.jsdos?-c=JAZZ.EXE
URL=https://x.dustinbrett.com/games/jazz.jsdos
IconFile=https://x.dustinbrett.com/icons/games/jazz.png

View File

@ -1 +1 @@
{"desktop":{"Blog.url":null,"DOS.url":null,"Doom.url":null,"Explorer.url":null},"docs":{"resume.pdf":null,"welcome.odt":null},"favicon.ico":null,"fonts":{"SF-Regular.woff2":null,"segmdl2.woff2":null,"segoeui.woff2":null},"games":{"doom.jsdos":null,"jazz.jsdos":null,"keen4.jsdos":null},"icons":{"files":{"js.svg":null,"pdf.svg":null,"unknown.svg":null},"games":{"doom.png":null,"jazz.png":null,"keen.png":null},"programs":{"blog.jpeg":null,"dos.png":null,"explorer.png":null,"webodf.png":null,"winamp.png":null}},"libs":{"pdf.worker.min.js":null,"vanta.waves.min.js":null,"wdosbox.js":null,"wdosbox.wasm.js":null,"webodf.js":null},"mp3":{"demo.mp3":null},"skins":{"SpyAMP_Pro.wsz":null},"start":{"Commander Keen.url":null,"Jazz Jackrabbit.url":null,"PDF.url":null,"WebODF.url":null,"Winamp.url":null}}
{"desktop":{"Blog.url":null,"DOS.url":null,"Doom.url":null,"Explorer.url":null},"docs":{"resume.pdf":null,"welcome.odt":null},"favicon.ico":null,"fonts":{"SF-Regular.woff2":null,"segmdl2.woff2":null,"segoeui.woff2":null},"games":{"doom.jsdos":null,"jazz.jsdos":null,"keen4.jsdos":null},"icons":{"files":{"js.svg":null,"pdf.svg":null,"unknown.svg":null},"games":{"doom.png":null,"jazz.png":null,"keen.png":null},"programs":{"blog.jpeg":null,"dos.png":null,"explorer.png":null,"webodf.png":null,"winamp.png":null}},"libs":{"js-dos":{"dos.jsdos":null,"js-dos.js":null,"wworker.js":null,"wworker.wasm":null},"pdf.worker.min.js":null,"vanta.waves.min.js":null,"webodf.js":null},"mp3":{"demo.mp3":null},"skins":{"SpyAMP_Pro.wsz":null},"start":{"Commander Keen.url":null,"Jazz Jackrabbit.url":null,"PDF.url":null,"WebODF.url":null,"Winamp.url":null}}

View File

@ -1 +1 @@
{"/desktop/Blog.url":{"size":122,"mtime":"2020-11-18T19:22:53.236Z"},"/desktop/DOS.url":{"size":119,"mtime":"2020-11-26T05:39:52.509Z"},"/desktop/Doom.url":{"size":137,"mtime":"2020-11-26T07:20:44.917Z"},"/desktop/Explorer.url":{"size":129,"mtime":"2020-11-18T19:22:53.236Z"},"/docs/resume.pdf":{"size":42924,"mtime":"2020-11-26T07:04:59.158Z"},"/docs/welcome.odt":{"size":135879,"mtime":"2020-11-18T19:22:53.238Z"},"/favicon.ico":{"size":7406,"mtime":"2020-11-18T19:22:53.238Z"},"/fonts/SF-Regular.woff2":{"size":75472,"mtime":"2020-11-18T19:22:53.239Z"},"/fonts/segmdl2.woff2":{"size":91172,"mtime":"2020-11-18T19:22:53.239Z"},"/fonts/segoeui.woff2":{"size":16048,"mtime":"2020-11-18T19:22:53.240Z"},"/games/doom.jsdos":{"size":2431248,"mtime":"2020-11-18T19:22:53.253Z"},"/games/jazz.jsdos":{"size":1432201,"mtime":"2020-11-26T07:25:19.656Z"},"/games/keen4.jsdos":{"size":556414,"mtime":"2020-11-18T19:22:53.256Z"},"/icons/files/js.svg":{"size":2464,"mtime":"2020-11-18T19:22:53.257Z"},"/icons/files/pdf.svg":{"size":2473,"mtime":"2020-11-26T06:05:43.579Z"},"/icons/files/unknown.svg":{"size":555,"mtime":"2020-11-18T19:22:53.257Z"},"/icons/games/doom.png":{"size":49765,"mtime":"2020-11-18T19:22:53.262Z"},"/icons/games/jazz.png":{"size":3085,"mtime":"2020-11-26T07:33:49.387Z"},"/icons/games/keen.png":{"size":33217,"mtime":"2020-11-18T19:22:53.262Z"},"/icons/programs/blog.jpeg":{"size":28723,"mtime":"2020-11-18T19:22:53.262Z"},"/icons/programs/dos.png":{"size":1290,"mtime":"2020-11-18T19:22:53.263Z"},"/icons/programs/explorer.png":{"size":17729,"mtime":"2020-11-18T19:22:53.263Z"},"/icons/programs/webodf.png":{"size":45927,"mtime":"2020-11-18T19:22:53.264Z"},"/icons/programs/winamp.png":{"size":18520,"mtime":"2020-11-18T19:22:53.264Z"},"/libs/pdf.worker.min.js":{"size":638935,"mtime":"2020-11-26T06:27:22.517Z"},"/libs/vanta.waves.min.js":{"size":20929,"mtime":"2020-11-18T19:22:53.264Z"},"/libs/wdosbox.js":{"size":189751,"mtime":"2020-11-18T19:22:53.265Z"},"/libs/wdosbox.wasm.js":{"size":1809269,"mtime":"2020-11-18T19:22:53.275Z"},"/libs/webodf.js":{"size":437819,"mtime":"2020-11-18T19:22:53.278Z"},"/mp3/demo.mp3":{"size":38912,"mtime":"2020-11-18T19:22:53.278Z"},"/skins/SpyAMP_Pro.wsz":{"size":214919,"mtime":"2020-11-18T19:22:53.280Z"},"/start/Commander Keen.url":{"size":155,"mtime":"2020-11-26T05:38:56.489Z"},"/start/Jazz Jackrabbit.url":{"size":137,"mtime":"2020-11-26T07:32:46.052Z"},"/start/PDF.url":{"size":116,"mtime":"2020-11-26T07:20:21.019Z"},"/start/WebODF.url":{"size":125,"mtime":"2020-11-26T07:19:53.651Z"},"/start/Winamp.url":{"size":125,"mtime":"2020-11-18T19:22:53.281Z"}}
{"/desktop/Blog.url":{"size":122,"mtime":"2020-11-18T19:22:53.236Z"},"/desktop/DOS.url":{"size":132,"mtime":"2020-11-29T06:57:52.249Z"},"/desktop/Doom.url":{"size":125,"mtime":"2020-11-29T06:57:48.705Z"},"/desktop/Explorer.url":{"size":129,"mtime":"2020-11-18T19:22:53.236Z"},"/docs/resume.pdf":{"size":42924,"mtime":"2020-11-26T07:04:59.158Z"},"/docs/welcome.odt":{"size":135879,"mtime":"2020-11-18T19:22:53.238Z"},"/favicon.ico":{"size":7406,"mtime":"2020-11-18T19:22:53.238Z"},"/fonts/SF-Regular.woff2":{"size":75472,"mtime":"2020-11-18T19:22:53.239Z"},"/fonts/segmdl2.woff2":{"size":91172,"mtime":"2020-11-18T19:22:53.239Z"},"/fonts/segoeui.woff2":{"size":16048,"mtime":"2020-11-18T19:22:53.240Z"},"/games/doom.jsdos":{"size":2456852,"mtime":"2020-11-29T06:18:29.419Z"},"/games/jazz.jsdos":{"size":1435554,"mtime":"2020-11-29T06:18:58.530Z"},"/games/keen4.jsdos":{"size":561552,"mtime":"2020-11-29T06:19:40.575Z"},"/icons/files/js.svg":{"size":2464,"mtime":"2020-11-18T19:22:53.257Z"},"/icons/files/pdf.svg":{"size":2473,"mtime":"2020-11-26T06:05:43.579Z"},"/icons/files/unknown.svg":{"size":555,"mtime":"2020-11-18T19:22:53.257Z"},"/icons/games/doom.png":{"size":49765,"mtime":"2020-11-18T19:22:53.262Z"},"/icons/games/jazz.png":{"size":3085,"mtime":"2020-11-26T07:33:49.387Z"},"/icons/games/keen.png":{"size":33217,"mtime":"2020-11-18T19:22:53.262Z"},"/icons/programs/blog.jpeg":{"size":28723,"mtime":"2020-11-18T19:22:53.262Z"},"/icons/programs/dos.png":{"size":1290,"mtime":"2020-11-18T19:22:53.263Z"},"/icons/programs/explorer.png":{"size":17729,"mtime":"2020-11-18T19:22:53.263Z"},"/icons/programs/webodf.png":{"size":45927,"mtime":"2020-11-18T19:22:53.264Z"},"/icons/programs/winamp.png":{"size":18520,"mtime":"2020-11-18T19:22:53.264Z"},"/libs/js-dos/dos.jsdos":{"size":4218,"mtime":"2020-11-29T06:56:56.908Z"},"/libs/js-dos/js-dos.js":{"size":310547,"mtime":"2020-11-29T04:52:51.784Z"},"/libs/js-dos/wworker.js":{"size":258575,"mtime":"2020-11-29T04:58:05.343Z"},"/libs/js-dos/wworker.wasm":{"size":1732076,"mtime":"2020-11-29T06:52:42.651Z"},"/libs/pdf.worker.min.js":{"size":638935,"mtime":"2020-11-26T06:27:22.517Z"},"/libs/vanta.waves.min.js":{"size":20929,"mtime":"2020-11-18T19:22:53.264Z"},"/libs/webodf.js":{"size":437819,"mtime":"2020-11-18T19:22:53.278Z"},"/mp3/demo.mp3":{"size":38912,"mtime":"2020-11-18T19:22:53.278Z"},"/skins/SpyAMP_Pro.wsz":{"size":214919,"mtime":"2020-11-18T19:22:53.280Z"},"/start/Commander Keen.url":{"size":126,"mtime":"2020-11-29T06:21:05.551Z"},"/start/Jazz Jackrabbit.url":{"size":125,"mtime":"2020-11-29T06:21:08.445Z"},"/start/PDF.url":{"size":116,"mtime":"2020-11-26T07:20:21.019Z"},"/start/WebODF.url":{"size":125,"mtime":"2020-11-26T07:19:53.651Z"},"/start/Winamp.url":{"size":125,"mtime":"2020-11-18T19:22:53.281Z"}}

View File

@ -12,4 +12,8 @@
border-radius: 0 0 2px 2px;
}
div {
display: none;
}
}

View File

@ -1,4 +1,10 @@
import type { DosFactory } from 'js-dos';
export type DosCommandInterface = {
exit: () => void;
};
export type WindowWithDosModule = Window &
typeof globalThis & { Dos: DosFactory };
export type WindowWithDosModules = Window &
typeof globalThis & {
__dirname: string;
Dos: any;
emulators: any;
};

View File

@ -18,3 +18,5 @@ export const ROOT_DIRECTORY = '/';
export const CLICK_DELAY_IN_MILLISECONDS = 300;
export const NEXT_CONTAINER_ID = '__next';
export const CNAME = 'x.dustinbrett.com';