diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f28a60d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+_test_files
+node_modules
+package-lock.json
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index 2ef16f2..be20a15 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,9 +1,9 @@
MIT License
-Copyright (c) 2017-2023 Marc Robledo
+Copyright (c) 2017-2024 Marc Robledo
This project incorporates components from Octicons
-(https://github.com/primer/octicons/) Copyright (c) 2023 GitHub Inc.,
+(https://github.com/primer/octicons/) Copyright (c) 2024 GitHub Inc.,
also released under MIT license.
Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/README.md b/README.md
index f1e6b7e..27afa0c 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
# Rom Patcher JS
-A ROM patcher made in HTML5.
+A ROM patcher made in Javascript.
**Features:**
* Supported formats:
@@ -16,10 +16,35 @@ A ROM patcher made in HTML5.
* can remove headers before patching
* unzips files automatically
* made in Vanilla JS
-* can be run in any modern web browser, including mobile
+* can be run in any modern web browser (including mobile) and Node.js
+* can be customized and embeded into your website for a custom patcher
+
+## Embedding Rom Patcher JS in your site
+Modders and hackers can embed Rom Patcher JS in their websites to provide an online ROM patcher for their patches, allowing users to patch ROMs without downloading any files.
+- File [`index_template.html`](https://github.com/marcrobledo/RomPatcher.js/blob/master/index_template.html) includes a simple working example
+- Read [the wiki](https://github.com/marcrobledo/RomPatcher.js/wiki) for more detailed instructions
+
+
+
+## Using Rom Patcher JS in Node CLI
+Install dependencies:
+> npm install
+
+Patch a ROM:
+> node index.js patch "my_rom.bin" "my_patch.ips"
+
+Create a patch:
+> node index.js create "original_rom.bin" modified_rom.bin"
+
+Show all options:
+> node index.js patch --help
+> node index.js create --help
+
+
+
## Known sites that use Rom Patcher JS
* [Romhacking.net](https://www.romhacking.net/)
* [Smash Remix](https://smash64.online/remix/)
@@ -27,3 +52,9 @@ A ROM patcher made in HTML5.
* [Rocket Edition](https://rocket-edition.com/download/)
* [SnapCameraPreservation](https://snapchatreverse.jaku.tv/snap/)
* [Pokemon Clover](https://poclo.net/download)
+
+
+
+## Resources used
+* [zip.js](https://gildas-lormeau.github.io/zip.js/) by Gildas Lormeau
+* [Octicons](https://primer.style/octicons/) by GitHub Inc.
diff --git a/_cache_service_worker.js b/_cache_service_worker.js
index a10b242..9a836dd 100644
--- a/_cache_service_worker.js
+++ b/_cache_service_worker.js
@@ -1,54 +1,53 @@
/*
- Cache Service Worker template by mrc 2019
- mostly based in:
- https://github.com/GoogleChrome/samples/blob/gh-pages/service-worker/basic/service-worker.js
- https://github.com/chriscoyier/Simple-Offline-Site/blob/master/js/service-worker.js
- https://gist.github.com/kosamari/7c5d1e8449b2fbc97d372675f16b566e
+ Cache Service Worker for Rom Patcher JS by Marc Robledo
+ https://github.com/marcrobledo/RomPatcher.js
- Note for GitHub Pages:
- there can be an unexpected behaviour (cache not updating) when site is accessed from
- https://user.github.io/repo/ (without index.html) in some browsers (Firefox)
- use absolute paths if hosted in GitHub Pages in order to avoid it
- also invoke sw with an absolute path:
- navigator.serviceWorker.register('/repo/_cache_service_worker.js', {scope: '/repo/'})
+ Used to cache the webapp files for offline use
*/
-var PRECACHE_ID='rom-patcher-js';
-var PRECACHE_VERSION='v291';
-var PRECACHE_URLS=[
- '/RomPatcher.js/','/RomPatcher.js/index.html',
+var PRECACHE_ID = 'rom-patcher-js';
+var PRECACHE_VERSION = 'v30beta1';
+var PRECACHE_URLS = [
+ '/RomPatcher.js/', '/RomPatcher.js/index.html',
'/RomPatcher.js/manifest.json',
- '/RomPatcher.js/style/app_icon_16.png',
- '/RomPatcher.js/style/app_icon_114.png',
- '/RomPatcher.js/style/app_icon_144.png',
- '/RomPatcher.js/style/app_icon_192.png',
- '/RomPatcher.js/style/app_icon_maskable.png',
- '/RomPatcher.js/style/logo.png',
- '/RomPatcher.js/style/RomPatcher.css',
- '/RomPatcher.js/style/icon_close.svg',
- '/RomPatcher.js/style/icon_github.svg',
- '/RomPatcher.js/style/icon_heart.svg',
- '/RomPatcher.js/style/icon_settings.svg',
- '/RomPatcher.js/js/RomPatcher.js',
- '/RomPatcher.js/js/locale.js',
- '/RomPatcher.js/js/worker_apply.js',
- '/RomPatcher.js/js/worker_create.js',
- '/RomPatcher.js/js/worker_crc.js',
- '/RomPatcher.js/js/MarcFile.js',
- '/RomPatcher.js/js/crc.js',
- '/RomPatcher.js/js/zip.js/zip.js',
- '/RomPatcher.js/js/zip.js/z-worker.js',
- '/RomPatcher.js/js/zip.js/inflate.js',
- '/RomPatcher.js/js/formats/ips.js',
- '/RomPatcher.js/js/formats/ups.js',
- '/RomPatcher.js/js/formats/aps_n64.js',
- '/RomPatcher.js/js/formats/aps_gba.js',
- '/RomPatcher.js/js/formats/bps.js',
- '/RomPatcher.js/js/formats/rup.js',
- '/RomPatcher.js/js/formats/ppf.js',
- '/RomPatcher.js/js/formats/pmsr.js',
- '/RomPatcher.js/js/formats/vcdiff.js',
- '/RomPatcher.js/js/formats/zip.js'
+ /* Rom Patcher JS core (code) */
+ '/RomPatcher.js/rom-patcher-js/RomPatcher.js',
+ '/RomPatcher.js/rom-patcher-js/RomPatcher.webapp.js',
+ '/RomPatcher.js/rom-patcher-js/RomPatcher.webworker.apply.js',
+ '/RomPatcher.js/rom-patcher-js/RomPatcher.webworker.create.js',
+ '/RomPatcher.js/rom-patcher-js/RomPatcher.webworker.crc.js',
+ '/RomPatcher.js/rom-patcher-js/modules/BinFile.js',
+ '/RomPatcher.js/rom-patcher-js/modules/HashCalculator.js',
+ '/RomPatcher.js/rom-patcher-js/modules/RomPatcher.format.ips.js',
+ '/RomPatcher.js/rom-patcher-js/modules/RomPatcher.format.bps.js',
+ '/RomPatcher.js/rom-patcher-js/modules/RomPatcher.format.ups.js',
+ '/RomPatcher.js/rom-patcher-js/modules/RomPatcher.format.aps_n64.js',
+ '/RomPatcher.js/rom-patcher-js/modules/RomPatcher.format.aps_gba.js',
+ '/RomPatcher.js/rom-patcher-js/modules/RomPatcher.format.rup.js',
+ '/RomPatcher.js/rom-patcher-js/modules/RomPatcher.format.ppf.js',
+ '/RomPatcher.js/rom-patcher-js/modules/RomPatcher.format.pmsr.js',
+ '/RomPatcher.js/rom-patcher-js/modules/RomPatcher.format.vcdiff.js',
+ '/RomPatcher.js/rom-patcher-js/modules/zip.js/z-worker.js',
+ '/RomPatcher.js/rom-patcher-js/modules/zip.js/zip.min.js',
+ '/RomPatcher.js/rom-patcher-js/modules/zip.js/inflate.js',
+ /* Rom Patcher JS core (web assets) */
+ '/RomPatcher.js/rom-patcher-js/assets/icon_alert_orange.svg',
+ '/RomPatcher.js/rom-patcher-js/assets/icon_check_circle_green.svg',
+ '/RomPatcher.js/rom-patcher-js/assets/icon_upload.svg',
+ '/RomPatcher.js/rom-patcher-js/assets/icon_x_circle_red.svg',
+ /* webapp assets */
+ '/RomPatcher.js/webapp/webapp.js',
+ '/RomPatcher.js/webapp/style.css',
+ '/RomPatcher.js/webapp/app_icon_16.png',
+ '/RomPatcher.js/webapp/app_icon_114.png',
+ '/RomPatcher.js/webapp/app_icon_144.png',
+ '/RomPatcher.js/webapp/app_icon_192.png',
+ '/RomPatcher.js/webapp/app_icon_maskable.png',
+ '/RomPatcher.js/webapp/logo.png',
+ '/RomPatcher.js/webapp/icon_close.svg',
+ '/RomPatcher.js/webapp/icon_github.svg',
+ '/RomPatcher.js/webapp/icon_heart.svg',
+ '/RomPatcher.js/webapp/icon_settings.svg'
];
@@ -56,7 +55,7 @@ var PRECACHE_URLS=[
// install event (fired when sw is first installed): opens a new cache
self.addEventListener('install', evt => {
evt.waitUntil(
- caches.open('precache-'+PRECACHE_ID+'-'+PRECACHE_VERSION)
+ caches.open('precache-' + PRECACHE_ID + '-' + PRECACHE_VERSION)
.then(cache => cache.addAll(PRECACHE_URLS))
.then(self.skipWaiting())
);
@@ -67,10 +66,10 @@ self.addEventListener('install', evt => {
self.addEventListener('activate', evt => {
evt.waitUntil(
caches.keys().then(cacheNames => {
- return cacheNames.filter(cacheName => (cacheName.startsWith('precache-'+PRECACHE_ID+'-') && !cacheName.endsWith('-'+PRECACHE_VERSION)));
+ return cacheNames.filter(cacheName => (cacheName.startsWith('precache-' + PRECACHE_ID + '-') && !cacheName.endsWith('-' + PRECACHE_VERSION)));
}).then(cachesToDelete => {
return Promise.all(cachesToDelete.map(cacheToDelete => {
- console.log('delete '+cacheToDelete);
+ console.log('Delete cache: ' + cacheToDelete);
return caches.delete(cacheToDelete);
}));
}).then(() => self.clients.claim())
@@ -80,12 +79,12 @@ self.addEventListener('activate', evt => {
// fetch event (fired when requesting a resource): returns cached resource when possible
self.addEventListener('fetch', evt => {
- if(evt.request.url.startsWith(self.location.origin)){ //skip cross-origin requests
+ if (evt.request.url.startsWith(self.location.origin)) { //skip cross-origin requests
evt.respondWith(
caches.match(evt.request).then(cachedResource => {
if (cachedResource) {
return cachedResource;
- }else{
+ } else {
return fetch(evt.request);
}
})
diff --git a/index.html b/index.html
index 1f41641..82fc5b8 100644
--- a/index.html
+++ b/index.html
@@ -7,14 +7,14 @@
-
-
+
+
-
-
-
-
-
+
+
+
+
+
@@ -28,147 +28,132 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+