Skip to content

Commit 95257dc

Browse files
committed
build fixes: enable __dirname, fix native extension loading, turn off npm-rebuild
remove unused, work on cleanup on shutdown
1 parent 8aa82b2 commit 95257dc

File tree

6 files changed

+257
-224
lines changed

6 files changed

+257
-224
lines changed
Binary file not shown.

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"dependencies": {
2323
"@fortawesome/fontawesome-free": "^5.15.4",
2424
"@shoelace-style/shoelace": "~2.15.1",
25-
"@webrecorder/wabac": "^2.23.2",
2625
"@types/webtorrent": "^0.110.0",
26+
"@webrecorder/wabac": "^2.23.2",
2727
"bulma": "^0.9.3",
2828
"create-torrent": "^6.1.0",
2929
"electron-log": "^4.4.1",
@@ -43,7 +43,7 @@
4343
"split.js": "^1.6.4",
4444
"stream-browserify": "^3.0.0",
4545
"tsconfig-paths-webpack-plugin": "^4.1.0",
46-
"webtorrent": "^2.6.7"
46+
"webtorrent": "^2.6.8"
4747
},
4848
"devDependencies": {
4949
"@playwright/test": "^1.52.0",
@@ -76,7 +76,7 @@
7676
"ts-lit-plugin": "^2.0.0-pre.1",
7777
"ts-loader": "^9.4.4",
7878
"typescript": "^5.2.2",
79-
"webpack": "^5.91.0",
79+
"webpack": "^5.99.9",
8080
"webpack-cli": "^5.1.4",
8181
"webpack-dev-server": "^5.0.4",
8282
"webpack-merge": "^5.10.0"
@@ -123,10 +123,11 @@
123123
"extraMetadata": {
124124
"main": "dist/electron.js"
125125
},
126+
"npmRebuild": false,
126127
"files": [
127-
"!**/node_modules/**/*",
128+
"!**node_modules/**/*",
128129
"dist/*.js",
129-
"dist/prebuilds/${platform}-${arch}/*",
130+
"!dist/node_modules*.js",
130131
"dist/build/*",
131132
"ui.js",
132133
"sw.js",
@@ -160,7 +161,7 @@
160161
"extraResources": [
161162
"plugins-mac"
162163
],
163-
"singleArchFiles": "{dist/prebuilds,dist/prebuilds/**}"
164+
"singleArchFiles": "{dist/prebuilds,dist/prebuilds/**,node_modules/**/prebuilds/**}"
164165
},
165166
"linux": {
166167
"category": "Archiving;Utility;",

src/chooser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ export class Chooser extends LitElement {
303303
type="text"
304304
name="filename"
305305
id="filename"
306-
pattern="((file|http|https|ipfs|s3)://.*.(warc|warc.gz|zip|wacz|wacz.zip|har|json|cdx|cdxj)([?#].*)?)|(googledrive://.+)|(ssb://.+)"
306+
pattern="((file|http|https|ipfs|s3)://.*.(warc|warc.gz|zip|wacz|wacz.zip|har|json|cdx|cdxj)([?#].*)?)|(googledrive://.+)|(ssb://.+)|(magnet:.+)"
307307
.value="${this.fileDisplayName}"
308308
@input="${this.onInput}"
309309
autocomplete="off"

src/electron-replay-app.ts

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class ElectronReplayApp {
9090
get mainWindowWebPreferences() {
9191
return {
9292
plugins: true,
93-
preload: path.join(__dirname, "preload.js"),
93+
preload: path.join(this.appPath, "preload.js"),
9494
nativeWindowOpen: true,
9595
contextIsolation: true,
9696
enableRemoteModule: false,
@@ -120,7 +120,6 @@ class ElectronReplayApp {
120120
}
121121

122122
console.log("app path", this.appPath);
123-
console.log("dir name", __dirname);
124123
console.log("proj path", this.projPath);
125124

126125
console.log("app data", app.getPath("appData"));
@@ -180,10 +179,31 @@ class ElectronReplayApp {
180179
void app.whenReady().then(() => this.onAppReady());
181180

182181
// Quit when all windows are closed.
183-
app.on("window-all-closed", function () {
184-
// On macOS it is common for applications and their menu bar
185-
// to stay active until the user quits explicitly with Cmd + Q
186-
//if (process.platform !== 'darwin')
182+
app.on("window-all-closed", async () => {
183+
if (this.client) {
184+
//console.log("closing all torrents", this.client.torrents.length);
185+
// try {
186+
// await Promise.allSettled(
187+
// this.client.torrents.map(
188+
// async (x) =>
189+
// new Promise<void>(
190+
// (resolve) => () => x.destroy({}, () => resolve()),
191+
// ),
192+
// ),
193+
// );
194+
// } catch (e) {
195+
// // ignore
196+
// }
197+
// await Promise.race([
198+
// new Promise((resolve) => setTimeout(resolve, 10000)),
199+
// new Promise<void>((resolve) => () => {
200+
// this.client!.destroy(() => {
201+
// console.log("wt closed!");
202+
// resolve();
203+
// });
204+
// }),
205+
// ]);
206+
}
187207
app.quit();
188208
});
189209
}
@@ -488,7 +508,16 @@ class ElectronReplayApp {
488508

489509
async doHandleBT(request: Request) {
490510
if (!this.client) {
491-
this.client = new WebTorrent({ peerId, utp: false });
511+
const downloads = path.join(app.getPath("downloads"), "rwp-torrents");
512+
console.log("downloads", downloads);
513+
this.client = new WebTorrent({
514+
peerId,
515+
//@ts-expect-error destoryStoreOnDestory not in type
516+
destroyStoreOnDestroy: true,
517+
path: downloads,
518+
});
519+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
520+
console.log((this.client as any).utp);
492521
}
493522

494523
// special ping from wabac.js to ensure the scheme works

webpack.config.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,15 @@ const electronMainConfig = (/*env, argv*/) => {
6565
filename: "[name].js",
6666
},
6767
node: {
68-
__dirname: false,
69-
__filename: false,
68+
__dirname: true,
69+
__filename: true,
7070
},
7171
plugins: [
7272
new webpack.DefinePlugin({
7373
__HELPER_PROXY__: JSON.stringify(HELPER_PROXY),
7474
}),
7575
new webpack.BannerPlugin(BANNER_TEXT),
76-
new CopyPlugin({
77-
patterns: [{ from: "build/extra_prebuilds/", to: "prebuilds" }],
78-
}),
7976
],
80-
resolve: {
81-
alias: {
82-
bufferutil: path.join(
83-
__dirname,
84-
"./node_modules/bufferutil/fallback.js",
85-
),
86-
},
87-
},
8877
};
8978
return merge(tsConfig, config);
9079
};

0 commit comments

Comments
 (0)