Compare commits
51 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6df468db4d | |||
| 5320b29eed | |||
| d5688df03f | |||
| e121c457af | |||
| 45d061f051 | |||
| d9a0353091 | |||
| 9622100513 | |||
| 55b97251a0 | |||
| 576200b489 | |||
| da7c0b1513 | |||
| f2d8191b0d | |||
| 3bd800d296 | |||
| 5e9570023b | |||
| 64d8f4a382 | |||
| de601111f9 | |||
| 5c83088633 | |||
| c73331bf6a | |||
| 9a1bbd40fb | |||
| 1861b3b818 | |||
| 99c4e2e31c | |||
| ec32c63b29 | |||
| 09f4a9a3ed | |||
| d86d40f90d | |||
| 7e32d63415 | |||
| 13f8d8bd7b | |||
| 473033ba7b | |||
| 5a4e6e6b37 | |||
| 3aae0c143c | |||
| e5c008887b | |||
| 9cd62be64d | |||
| c72e1294c6 | |||
| f4c1e4dedb | |||
| e2206e2ade | |||
| 7aa3b3612f | |||
| 5b6079eb85 | |||
| 15834f9059 | |||
| 26f44cecd6 | |||
| 5ccdddde63 | |||
| a0aef16192 | |||
| 8f7365e895 | |||
| 572b00877c | |||
| feb4465b5b | |||
| 27e4f4ed8d | |||
| 0e2e3d62ed | |||
| e8a227fa1d | |||
| b6ee882c2b | |||
| e07027130d | |||
| 66fce5effd | |||
| a9c133c19a | |||
| 2a4ce913d5 | |||
| b9f25ebf34 |
+2
-1
@@ -1 +1,2 @@
|
||||
* text eol=lf
|
||||
text eol=lf
|
||||
rom -text
|
||||
@@ -3,7 +3,7 @@ name: Build & Release
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
# - master
|
||||
- master
|
||||
tags:
|
||||
- v*
|
||||
pull_request:
|
||||
@@ -63,6 +63,7 @@ jobs:
|
||||
MACOS_CERT_PASSWORD: ${{ secrets.MACOS_CERT_PASSWORD }}
|
||||
- name: Set Windows signing certificate
|
||||
if: matrix.os == 'windows-latest'
|
||||
continue-on-error: true
|
||||
id: write_file
|
||||
uses: timheuer/base64-to-file@v1
|
||||
with:
|
||||
@@ -82,18 +83,12 @@ jobs:
|
||||
run: yarn
|
||||
- name: Make
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: yarn make
|
||||
run: yarn make --arch=all
|
||||
env:
|
||||
APPLE_ID: ${{ secrets.APPLE_ID }}
|
||||
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
|
||||
WINDOWS_CODESIGN_FILE: ${{ steps.write_file.outputs.filePath }}
|
||||
WINDOWS_CODESIGN_PASSWORD: ${{ secrets.WINDOWS_CODESIGN_PASSWORD }}
|
||||
- name: Make (ia32)
|
||||
if: matrix.os == 'windows-latest' && startsWith(github.ref, 'refs/tags/')
|
||||
run: yarn make -- --arch=ia32
|
||||
env:
|
||||
WINDOWS_CODESIGN_FILE: ${{ steps.write_file.outputs.filePath }}
|
||||
WINDOWS_CODESIGN_PASSWORD: ${{ secrets.WINDOWS_CODESIGN_PASSWORD }}
|
||||
# - name: Archive production artifacts
|
||||
# uses: actions/upload-artifact@v2
|
||||
# with:
|
||||
@@ -105,6 +100,7 @@ jobs:
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
draft: true
|
||||
files: |
|
||||
out/**/*.deb
|
||||
out/**/*.dmg
|
||||
|
||||
@@ -4,6 +4,8 @@ This app by <a href="https://www.felixrieseberg.com">Felix Rieseberg</a>. The re
|
||||
|
||||
**Emulator**: Basilisk II, a 68k Macintosh emulator, by [Christian Bauer et al](http://basilisk.cebix.net), modified and compiled [with Emscripten](https://jamesfriend.com.au/basilisk-ii-classic-mac-emulator-in-the-browser) by [James Friend](https://jamesfriend.com.au).
|
||||
|
||||
**Runtime**: The developers behind Electron, electron-forge, Chromium, Node.js.
|
||||
|
||||
**Installed software** from vintage computing archives: [WinWorldPC](https://winworldpc.com), [Macintosh Garden](https://macintoshgarden.org), and [Macintosh Repository](https://www.macintoshrepository.org/).
|
||||
|
||||
This software is not affiliated with nor authorized by Apple. It is provided for educational purposes only. This is an unstable toy and should not be expected to work properly.
|
||||
|
||||
@@ -8,11 +8,11 @@ This is Mac OS 8, running in an [Electron](https://electronjs.org/) app pretendi
|
||||
|
||||
| | Windows | macOS | Linux |
|
||||
|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| Standalone Download | 📦[Standalone, 32-bit](https://github.com/felixrieseberg/macintosh.js/releases/download/v1.0.0/macintosh.js-win32-x64-1.0.0.zip) <br /> 📦[Standalone, 64-bit](https://github.com/felixrieseberg/macintosh.js/releases/download/v1.0.0/macintosh.js-win32-ia32-1.0.0.zip) | 📦[Standalone](https://github.com/felixrieseberg/macintosh.js/releases/download/v1.0.0/macintosh.js-darwin-x64-1.0.0.zip) | |
|
||||
| Installer | 💽[Setup, 64-bit](https://github.com/felixrieseberg/macintosh.js/releases/download/v1.0.0/macintoshjs-1.0.0-setup-x64.exe) <br /> 💽[Setup, 32-bit](https://github.com/felixrieseberg/macintosh.js/releases/download/v1.0.0/macintoshjs-1.0.0-setup-ia32.exe) | | 💽[deb, 64-bit](https://github.com/felixrieseberg/macintosh.js/releases/download/v1.0.0/macintosh.js_1.0.0_amd64.deb) <br /> 💽[rpm, 64-bit](https://github.com/felixrieseberg/macintosh.js/releases/download/v1.0.0/macintosh.js-1.0.0-1.x86_64.rpm) |
|
||||
| Standalone Download | 📦[Standalone, 32-bit](https://github.com/felixrieseberg/macintosh.js/releases/download/v1.0.6/macintosh.js-win32-ia32-1.0.6.zip) <br /> 📦[Standalone, 64-bit](https://github.com/felixrieseberg/macintosh.js/releases/download/v1.0.6/macintosh.js-win32-x64-1.0.6.zip) | 📦[Standalone](https://github.com/felixrieseberg/macintosh.js/releases/download/v1.0.6/macintosh.js-darwin-x64-1.0.6.zip) | |
|
||||
| Installer | 💽[Setup, 64-bit](https://github.com/felixrieseberg/macintosh.js/releases/download/v1.0.6/macintoshjs-1.0.6-setup-x64.exe) <br /> 💽[Setup, 32-bit](https://github.com/felixrieseberg/macintosh.js/releases/download/v1.0.6/macintoshjs-1.0.6-setup-ia32.exe) | | 💽[deb, 64-bit](https://github.com/felixrieseberg/macintosh.js/releases/download/v1.0.6/macintosh.js_1.0.6_amd64.deb) <br /> 💽[rpm, 64-bit](https://github.com/felixrieseberg/macintosh.js/releases/download/v1.0.6/macintosh.js-1.0.6-1.x86_64.rpm) |
|
||||
|
||||
## Does it work?
|
||||
Yes! Quite well, actually - on macOS, Windows, and Linux. Bear in mind that this is written entirely in JavaScript, so please adjust your expectations. The virtual machine is emulating a 1991 Macintosh Quadra 900 with a Motorola CPU, which Apple used before switching to IBM's PowerPC architecture in the late 1990s.
|
||||
Yes! Quite well, actually - on macOS, Windows, and Linux. Bear in mind that this is written entirely in JavaScript, so please adjust your expectations. The virtual machine is emulating a 1991 Macintosh Quadra 900 with a Motorola CPU, which Apple used before switching to the PowerPC architecture (Apple/IBM/Motorola) in the mid 1990s.
|
||||
|
||||
## Should this have been a native app?
|
||||
Absolutely.
|
||||
@@ -30,6 +30,14 @@ Yes, you can. Click on the "Help" button at the bottom of the running app to see
|
||||
|
||||
No. For what it's worth, the web was quite different 30 years ago - and you wouldn't be able to open even Google. However, Internet Explorer and Netscape are installed, as is the "Web Sharing Server", if you want to play around a bit.
|
||||
|
||||
## Should I use this for [serious application]?
|
||||
|
||||
Probably not. This is a toy - it's not the best nor the most performant way to emulate an old Macintosh. It is, however, a quick and easy way to experience a bit of nostalgia if you're _not_ trying to do anything serious with it.
|
||||
|
||||
## Credits
|
||||
|
||||
Please check out the [CREDITS](CREDITS.md)! This app wouldn't be possible without the hard work of [Christian Bauer](https://www.cebix.net/) and [James Friend](https://jamesfriend.com.au/), who did everything that seems like computing magic here.
|
||||
|
||||
## License
|
||||
|
||||
This project is provided for educational purposes only. It is not affiliated with and has
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+9
-1
@@ -75,7 +75,15 @@ module.exports = {
|
||||
},
|
||||
{
|
||||
name: '@electron-forge/maker-deb',
|
||||
platforms: ['linux']
|
||||
platforms: ['linux'],
|
||||
options: {
|
||||
maintainer: 'Felix Rieseberg',
|
||||
homepage: 'https://github.com/felixrieseberg/macintosh.js',
|
||||
categories: [
|
||||
'Education',
|
||||
],
|
||||
icon: path.resolve(__dirname, 'assets', 'icon.png')
|
||||
}
|
||||
},
|
||||
{
|
||||
name: '@electron-forge/maker-rpm',
|
||||
|
||||
+8
-8
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "macintosh.js",
|
||||
"productName": "macintosh.js",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"description": "Macintosh's System 8 in an Electron app. I'm sorry.",
|
||||
"main": "src/main/index.js",
|
||||
"scripts": {
|
||||
@@ -23,14 +23,14 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"electron-squirrel-startup": "^1.0.0",
|
||||
"update-electron-app": "^1.5.0"
|
||||
"update-electron-app": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@electron-forge/cli": "6.0.0-beta.52",
|
||||
"@electron-forge/maker-deb": "6.0.0-beta.52",
|
||||
"@electron-forge/maker-rpm": "6.0.0-beta.52",
|
||||
"@electron-forge/maker-squirrel": "6.0.0-beta.52",
|
||||
"@electron-forge/maker-zip": "6.0.0-beta.52",
|
||||
"electron": "10.0.0-beta.12"
|
||||
"@electron-forge/cli": "6.0.0-beta.54",
|
||||
"@electron-forge/maker-deb": "6.0.0-beta.54",
|
||||
"@electron-forge/maker-rpm": "6.0.0-beta.54",
|
||||
"@electron-forge/maker-squirrel": "6.0.0-beta.54",
|
||||
"@electron-forge/maker-zip": "6.0.0-beta.54",
|
||||
"electron": "11.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { error } = require("console");
|
||||
|
||||
const homeDir = require("os").homedir();
|
||||
const macDir = path.join(homeDir, "macintosh.js");
|
||||
@@ -10,7 +9,25 @@ const macintoshCopyPath = path.join(__dirname, "user_files");
|
||||
let userDataPath;
|
||||
|
||||
function getUserDataDiskPath() {
|
||||
return path.join(userDataPath, 'disk');
|
||||
return path.join(userDataPath, "disk");
|
||||
}
|
||||
|
||||
// File type utilities
|
||||
|
||||
function isFile(v = "") {
|
||||
return fs.statSync(path.join(macDir, v)).isFile();
|
||||
}
|
||||
|
||||
function isHiddenFile(filename = '') {
|
||||
return filename.startsWith('.');
|
||||
}
|
||||
|
||||
function isCDImage(filename = '') {
|
||||
return filename.endsWith('.iso') || filename.endsWith('.toast');
|
||||
}
|
||||
|
||||
function isDiskImage(filename = '') {
|
||||
return filename.endsWith('.img') || filename.endsWith('.dsk');
|
||||
}
|
||||
|
||||
function cleanupCopyPath() {
|
||||
@@ -32,101 +49,101 @@ function getUserDataDiskImage() {
|
||||
}
|
||||
|
||||
const diskImageUserPath = getUserDataDiskPath();
|
||||
const diskImagePath = path.join(__dirname, 'disk');
|
||||
const diskImagePath = path.join(__dirname, "disk");
|
||||
|
||||
// If there's a disk image, move it over
|
||||
if (fs.existsSync(diskImageUserPath)) {
|
||||
// Delete a possible basilisk disk image
|
||||
if (fs.existsSync(diskImagePath)) {
|
||||
console.log(`Disk image ${diskImageUserPath} exists, deleting ${diskImagePath}`);
|
||||
fs.unlinkSync(diskImagePath);
|
||||
if (!fs.existsSync(diskImageUserPath)) {
|
||||
try {
|
||||
fs.renameSync(diskImagePath, diskImageUserPath);
|
||||
} catch (error) {
|
||||
// This is _probably_ a permissions thing, let's copy the file
|
||||
fs.copyFileSync(diskImagePath, diskImageUserPath);
|
||||
}
|
||||
|
||||
fs.renameSync(diskImageUserPath, diskImagePath);
|
||||
} else {
|
||||
console.log(`getUserDataDiskImage: No image in user data dir, not doing anything`);
|
||||
console.log(
|
||||
`getUserDataDiskImage: Image in user data dir, not doing anything`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function addAutoloader(module) {
|
||||
const copyFilesAtPath = function (sourcePath) {
|
||||
try {
|
||||
const absoluteSourcePath = path.join(macDir, sourcePath);
|
||||
const absoluteTargetPath = path.join(macintoshCopyPath, sourcePath);
|
||||
const targetPath = `/macintosh.js${sourcePath ? `/${sourcePath}` : ""}`;
|
||||
const files = fs.readdirSync(absoluteSourcePath).filter((v) => {
|
||||
// Remove iso and img files
|
||||
return !v.endsWith(".iso") && !v.endsWith(".img");
|
||||
});
|
||||
// Taken a given path, it'll look at all the files in there,
|
||||
// copy them over to the basilisk folder, and then add them
|
||||
// to MEMFS
|
||||
function preloadFilesAtPath(module, initalSourcePath) {
|
||||
try {
|
||||
const sourcePath = path.join(macDir, initalSourcePath);
|
||||
const targetPath = `/macintosh.js${
|
||||
initalSourcePath ? `/${initalSourcePath}` : ""
|
||||
}`;
|
||||
const files = fs.readdirSync(sourcePath).filter((v) => {
|
||||
// Remove hidden, iso, and img files
|
||||
return !isHiddenFile(v) && !isDiskImage(v) && !isCDImage(v);
|
||||
});
|
||||
|
||||
(files || []).forEach((fileName) => {
|
||||
try {
|
||||
// If not, let's move on
|
||||
const fileSourcePath = path.join(absoluteSourcePath, fileName);
|
||||
const copyPath = path.join(absoluteTargetPath, fileName);
|
||||
const relativeSourcePath = `${
|
||||
sourcePath ? `${sourcePath}/` : ""
|
||||
}${fileName}`;
|
||||
const fileUrl = `user_files/${relativeSourcePath}`;
|
||||
(files || []).forEach((fileName) => {
|
||||
try {
|
||||
// If not, let's move on
|
||||
const fileSourcePath = path.join(sourcePath, fileName);
|
||||
const relativeSourcePath = `${
|
||||
initalSourcePath ? `${initalSourcePath}/` : ""
|
||||
}${fileName}`;
|
||||
|
||||
// Check if directory
|
||||
if (fs.statSync(fileSourcePath).isDirectory()) {
|
||||
if (!fs.existsSync(copyPath)) {
|
||||
fs.mkdirSync(copyPath);
|
||||
}
|
||||
|
||||
try {
|
||||
const virtualDirPath = `${targetPath}/${fileName}`;
|
||||
module.FS.mkdir(virtualDirPath);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
copyFilesAtPath(relativeSourcePath);
|
||||
return;
|
||||
// Check if directory
|
||||
if (fs.statSync(fileSourcePath).isDirectory()) {
|
||||
try {
|
||||
const virtualDirPath = `${targetPath}/${fileName}`;
|
||||
module.FS.mkdir(virtualDirPath);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
// We copy the files over and then add them as preload
|
||||
console.log(`loadDatafiles: Adding ${fileName}`);
|
||||
fs.copyFileSync(fileSourcePath, copyPath);
|
||||
|
||||
module.FS_createPreloadedFile(
|
||||
targetPath,
|
||||
fileName,
|
||||
fileUrl,
|
||||
true,
|
||||
true
|
||||
);
|
||||
} catch (error) {
|
||||
postMessage("showMessageBoxSync", {
|
||||
type: "error",
|
||||
title: "Could not transfer file",
|
||||
message: `We tried to transfer ${fileName} to the virtual machine, but failed. The error was: ${error}`,
|
||||
});
|
||||
|
||||
console.error(`loadDatafiles: Failed to preload ${fileName}`, error);
|
||||
preloadFilesAtPath(module, relativeSourcePath);
|
||||
return;
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
postMessage("showMessageBoxSync", {
|
||||
type: "error",
|
||||
title: "Could not transfer files",
|
||||
message: `We tried to transfer files to the virtual machine, but failed. The error was: ${error}`,
|
||||
});
|
||||
|
||||
console.error(`loadDatafiles: Failed to copyFilesAtPath`, error);
|
||||
}
|
||||
};
|
||||
createPreloadedFile(module, {
|
||||
parent: targetPath,
|
||||
name: fileName,
|
||||
url: fileSourcePath,
|
||||
});
|
||||
} catch (error) {
|
||||
postMessage("showMessageBoxSync", {
|
||||
type: "error",
|
||||
title: "Could not transfer file",
|
||||
message: `We tried to transfer ${fileName} to the virtual machine, but failed. The error was: ${error}`,
|
||||
});
|
||||
|
||||
const loadDatafiles = function () {
|
||||
module.autoloadFiles.forEach((filepath) => {
|
||||
const parent = `/`;
|
||||
const name = path.basename(filepath);
|
||||
|
||||
console.log(`Adding preload file`, { parent, name, url: filepath });
|
||||
|
||||
module.FS_createPreloadedFile(parent, name, filepath, true, true);
|
||||
console.error(
|
||||
`preloadFilesAtPath: Failed to preload ${fileName}`,
|
||||
error
|
||||
);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
postMessage("showMessageBoxSync", {
|
||||
type: "error",
|
||||
title: "Could not transfer files",
|
||||
message: `We tried to transfer files to the virtual machine, but failed. The error was: ${error}`,
|
||||
});
|
||||
|
||||
console.error(`preloadFilesAtPath: Failed to preloadFilesAtPath`, error);
|
||||
}
|
||||
}
|
||||
|
||||
function createPreloadedFile(module, options) {
|
||||
const parent = options.parent || `/`;
|
||||
const name = options.name || path.basename(options.url);
|
||||
const url = options.url;
|
||||
|
||||
console.log(`Adding preload file`, { parent, name, url });
|
||||
module.FS_createPreloadedFile(parent, name, url, true, true);
|
||||
}
|
||||
|
||||
function addAutoloader(module) {
|
||||
const loadDatafiles = function () {
|
||||
module.autoloadFiles.forEach(({ url, name }) =>
|
||||
createPreloadedFile(module, { url, name })
|
||||
);
|
||||
|
||||
// If the user has a macintosh.js dir, we'll copy over user
|
||||
// data
|
||||
@@ -134,7 +151,8 @@ function addAutoloader(module) {
|
||||
return;
|
||||
}
|
||||
|
||||
copyFilesAtPath("");
|
||||
// Load user files
|
||||
preloadFilesAtPath(module, "");
|
||||
};
|
||||
|
||||
if (module.autoloadFiles) {
|
||||
@@ -178,22 +196,23 @@ function writeSafely(filePath, fileData) {
|
||||
});
|
||||
}
|
||||
|
||||
function getPrefs(userImages = []) {
|
||||
function writePrefs(userImages = []) {
|
||||
try {
|
||||
const prefsTemplatePath = path.join(__dirname, "prefs_template");
|
||||
const prefsPath = path.join(__dirname, "prefs");
|
||||
const prefsPath = path.join(userDataPath, "prefs");
|
||||
|
||||
let prefs = fs.readFileSync(prefsTemplatePath, { encoding: "utf-8" });
|
||||
|
||||
// Replace line endings, just in case
|
||||
prefs = prefs.replaceAll('\r\n', '\n');
|
||||
prefs = prefs.replaceAll("\r\n", "\n");
|
||||
|
||||
if (userImages && userImages.length > 0) {
|
||||
console.log(`getPrefs: Found ${userImages.length} user images`);
|
||||
userImages.forEach((file) => {
|
||||
if (file.endsWith(".iso")) {
|
||||
prefs += `\ncdrom ${file}`;
|
||||
} else if (file.endsWith(".img")) {
|
||||
prefs += `\ndisk ${file}`;
|
||||
console.log(`writePrefs: Found ${userImages.length} user images`);
|
||||
userImages.forEach(({ name }) => {
|
||||
if (isCDImage(name)) {
|
||||
prefs += `\ncdrom ${name}`;
|
||||
} else if (isDiskImage(name)) {
|
||||
prefs += `\ndisk ${name}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -202,81 +221,60 @@ function getPrefs(userImages = []) {
|
||||
|
||||
fs.writeFileSync(prefsPath, prefs);
|
||||
} catch (error) {
|
||||
console.error(`getPrefs: Failed to set prefs`, error);
|
||||
console.error(`writePrefs: Failed to set prefs`, error);
|
||||
}
|
||||
|
||||
return "prefs";
|
||||
}
|
||||
|
||||
function isMacDirFileOfType(extension = "", v = "") {
|
||||
const isType = v.endsWith(`.${extension}`);
|
||||
const isMatch = isType && fs.statSync(path.join(macDir, v)).isFile();
|
||||
|
||||
console.log(`isMacDirFileOfType: ${v} is file and ${extension}: ${isMatch}`);
|
||||
return isMatch;
|
||||
}
|
||||
|
||||
function copyUserImages() {
|
||||
function getUserImages() {
|
||||
const result = [];
|
||||
|
||||
try {
|
||||
// No need if the macDir doesn't exist
|
||||
if (!fs.existsSync(macDir)) {
|
||||
console.log(`autoMountImageFiles: ${macDir} does not exist, exit`);
|
||||
console.log(`getUserImages: ${macDir} does not exist, exit`);
|
||||
return result;
|
||||
}
|
||||
|
||||
const macDirFiles = fs.readdirSync(macDir);
|
||||
const imgFiles = macDirFiles.filter((v) => isMacDirFileOfType("img", v));
|
||||
const isoFiles = macDirFiles.filter((v) => isMacDirFileOfType("iso", v));
|
||||
const imgFiles = macDirFiles.filter((v) => isFile(v) && isDiskImage(v));
|
||||
const isoFiles = macDirFiles.filter((v) => isFile(v) && isCDImage(v));
|
||||
const isoImgFiles = [...isoFiles, ...imgFiles];
|
||||
|
||||
console.log(`copyUserImages: iso and img files`, isoImgFiles);
|
||||
console.log(`getUserImages: iso and img files`, isoImgFiles);
|
||||
|
||||
isoImgFiles.forEach((fileName, i) => {
|
||||
const sourcePath = path.join(macDir, fileName);
|
||||
const url = path.join(macDir, fileName);
|
||||
const sanitizedFileName = `user_image_${i}_${fileName.replace(
|
||||
/[^\w\s\.]/gi,
|
||||
""
|
||||
)}`;
|
||||
const targetPath = path.join(__dirname, sanitizedFileName);
|
||||
|
||||
if (fs.existsSync(targetPath)) {
|
||||
const sourceStat = fs.statSync(sourcePath);
|
||||
const targetStat = fs.statSync(targetPath);
|
||||
|
||||
// Copy if the length is different
|
||||
if (sourceStat.size !== targetStat.size) {
|
||||
fs.copyFileSync(sourcePath, targetPath);
|
||||
} else {
|
||||
console.log(
|
||||
`autoMountImageFiles: ${sourcePath} already exists in ${targetPath}, not copying`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
fs.copyFileSync(sourcePath, targetPath);
|
||||
}
|
||||
|
||||
console.log(`Copied over ${targetPath}`);
|
||||
result.push(sanitizedFileName);
|
||||
});
|
||||
|
||||
// Delete all old files
|
||||
const imagesCopyFiles = fs.readdirSync(__dirname);
|
||||
imagesCopyFiles.forEach((v) => {
|
||||
if (v.startsWith("user_image_") && !result.includes(v)) {
|
||||
fs.unlinkSync(path.join(__dirname, v));
|
||||
}
|
||||
result.push({ url, name: sanitizedFileName });
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`copyUserImages: Encountered error`, error);
|
||||
console.error(`getUserImages: Encountered error`, error);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function getAutoLoadFiles(userImages = []) {
|
||||
const autoLoadFiles = ["disk", "rom", "prefs", ...userImages];
|
||||
const autoLoadFiles = [
|
||||
{
|
||||
name: "disk",
|
||||
url: path.join(userDataPath, "disk"),
|
||||
},
|
||||
{
|
||||
name: "rom",
|
||||
url: path.join(__dirname, "rom"),
|
||||
},
|
||||
{
|
||||
name: "prefs",
|
||||
url: path.join(userDataPath, "prefs"),
|
||||
},
|
||||
...userImages,
|
||||
];
|
||||
|
||||
return autoLoadFiles;
|
||||
}
|
||||
|
||||
@@ -358,7 +356,6 @@ self.onmessage = async function (msg) {
|
||||
if (msg && msg.data === "disk_save") {
|
||||
const diskData = Module.FS.readFile("/disk");
|
||||
const diskPath = getUserDataDiskPath();
|
||||
const basiliskDiskPath = path.join(__dirname, 'disk');
|
||||
|
||||
// I wish we could do this with promises, but OOM crashes kill that idea
|
||||
try {
|
||||
@@ -369,14 +366,6 @@ self.onmessage = async function (msg) {
|
||||
console.error(`Failed to write disk`, error);
|
||||
}
|
||||
|
||||
try {
|
||||
if (fs.existsSync(basiliskDiskPath) && !(Module && Module.isDevMode)) {
|
||||
fs.unlinkSync(basiliskDiskPath);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to delete ${basiliskDiskPath}`);
|
||||
}
|
||||
|
||||
// Now, user files
|
||||
console.log(`Saving user files`);
|
||||
await saveFilesInPath("/macintosh.js");
|
||||
@@ -479,14 +468,23 @@ function startEmulator(parentConfig) {
|
||||
|
||||
let AudioConfig = null;
|
||||
let AudioBufferQueue = [];
|
||||
const userImages = copyUserImages();
|
||||
|
||||
// Check for user images
|
||||
const userImages = getUserImages();
|
||||
|
||||
// Write prefs to user data dir
|
||||
writePrefs(userImages);
|
||||
|
||||
// Assemble preload files
|
||||
const autoloadFiles = getAutoLoadFiles(userImages);
|
||||
|
||||
// Set arguments
|
||||
const arguments = ["--config", "prefs"];
|
||||
|
||||
Module = {
|
||||
autoloadFiles: getAutoLoadFiles(userImages),
|
||||
|
||||
userImages: userImages,
|
||||
|
||||
arguments: ["--config", getPrefs(userImages)],
|
||||
autoloadFiles,
|
||||
userImages,
|
||||
arguments,
|
||||
canvas: null,
|
||||
|
||||
blit: function blit(bufPtr, width, height, depth, usingPalette) {
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
const { app } = require("electron");
|
||||
|
||||
function setupUpdates() {
|
||||
if (app.isPackaged) {
|
||||
if (app.isPackaged && process.platform !== "linux") {
|
||||
require("update-electron-app")({
|
||||
repo: "felixrieseberg/macintosh.js",
|
||||
updateInterval: "1 hour",
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
const { shell, ipcRenderer } = require("electron");
|
||||
const path = require("path");
|
||||
const { versions } = require("process");
|
||||
|
||||
const { getAppVersion } = require("./ipc.js");
|
||||
const { getAppVersion } = require("./ipc");
|
||||
|
||||
async function credits() {
|
||||
license.onclick = () => {
|
||||
|
||||
@@ -43,8 +43,9 @@ function tryToSendInput() {
|
||||
switch (inputEvent.type) {
|
||||
case "mousemove":
|
||||
hasMouseMove = true;
|
||||
mouseMoveX += inputEvent.dx;
|
||||
mouseMoveY += inputEvent.dy;
|
||||
// Make change according to https://github.com/felixrieseberg/macintosh.js/issues/6#issuecomment-665981700
|
||||
mouseMoveX = inputEvent.dx;
|
||||
mouseMoveY = inputEvent.dy;
|
||||
break;
|
||||
case "mousedown":
|
||||
case "mouseup":
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
cursor: none;
|
||||
}
|
||||
|
||||
canvas {
|
||||
border-top-left-radius: 10px;
|
||||
border-top-right-radius: 10px;
|
||||
border-bottom-left-radius: 9px;
|
||||
border-bottom-right-radius: 9px;
|
||||
}
|
||||
|
||||
.controls {
|
||||
text-align: center;
|
||||
margin-top: 5px;
|
||||
|
||||
Reference in New Issue
Block a user