Skip to content

Commit

Permalink
update to wabac.js 2.20.0-beta.4
Browse files Browse the repository at this point in the history
add new file.path lookup via contextBridge
  • Loading branch information
ikreymer committed Oct 14, 2024
1 parent f64a6c8 commit 224a4d0
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.4",
"@shoelace-style/shoelace": "~2.15.1",
"@webrecorder/wabac": "^2.20.0-beta.3",
"@webrecorder/wabac": "^2.20.0-beta.4",
"bulma": "^0.9.3",
"electron-log": "^4.4.1",
"electron-updater": "^6.3.2",
Expand Down
12 changes: 11 additions & 1 deletion src/chooser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ import fasUpload from "@fortawesome/fontawesome-free/svgs/solid/upload.svg";
import { customElement, property } from "lit/decorators.js";

export interface FileWithPath extends File {
readonly path: string;
path: string;
}

declare let window: Window & {
electron?: {
getPath: (file: File) => string;
};
};

// ===========================================================================
@customElement("wr-chooser")
export class Chooser extends LitElement {
Expand Down Expand Up @@ -89,6 +95,10 @@ export class Chooser extends LitElement {
setFile(file: FileWithPath) {
this.file = file;
// file.path only available in electron app
if (IS_APP && window.electron?.getPath) {
this.file.path = window.electron.getPath(this.file);
}

this.fileDisplayName = "file://" + (file.path || file.name);
}

Expand Down
11 changes: 8 additions & 3 deletions src/electron-preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
import { CollectionLoader } from "@webrecorder/wabac/swlib";
import { type IpcRendererEvent } from "electron";

const { ipcRenderer, contextBridge } = require("electron");

contextBridge.exposeInMainWorld("electron", { IS_APP: true });
const { ipcRenderer, contextBridge, webUtils } = require("electron");

contextBridge.exposeInMainWorld("electron", {
IS_APP: true,
getPath(file: File) {
return webUtils.getPathForFile(file);
},
});

const dbs = {};

Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type URLResource = {
export type Page = URLResource;

export type ItemType = {
filename: string;
filename?: string;
sourceUrl: string;
replayPrefix: string;
apiPrefix: string;
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const browserConfig = (env, argv) => {
},
entry,
optimization,
devtool: argv.mode === "production" ? undefined : "source-map",
//devtool: argv.mode === "production" ? undefined : "source-map",
output: {
path: path.join(__dirname),
filename: "[name].js",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1021,10 +1021,10 @@
resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-2.0.5.tgz#325db42395cd49fe6c14057f9a900e427df8810e"
integrity sha512-lqaoKnRYBdo1UgDX8uF24AfGMifWK19TxPmM5FHc2vAGxrJ/qtyUyFBWoY1tISZdelsQ5fBcOusifo5o5wSJxQ==

"@webrecorder/wabac@^2.20.0-beta.3":
version "2.20.0-beta.3"
resolved "https://registry.yarnpkg.com/@webrecorder/wabac/-/wabac-2.20.0-beta.3.tgz#034cd07078270537028104ba407ae5b7baa2dd20"
integrity sha512-/s98zVZFn8+0btTwsb2kRiwyfLZxPyWwKclsrpFQvyUCsvrQsTTKVbHTpictAlmyknOIdkrLqqWK4ScYTs39Xg==
"@webrecorder/wabac@^2.20.0-beta.4":
version "2.20.0-beta.4"
resolved "https://registry.yarnpkg.com/@webrecorder/wabac/-/wabac-2.20.0-beta.4.tgz#c60fcd00f449cca52ce1a0bef305a06922c9e3e8"
integrity sha512-enHYcZoqs7cOu2tdTqVeB/zB27uL4wmCMzvF55bJqdB8d5zgPpY+/fpRA3eLxGrPc0nFYAjsI/aNaa62FH7WKQ==
dependencies:
"@peculiar/asn1-ecc" "^2.3.4"
"@peculiar/asn1-schema" "^2.3.3"
Expand Down

0 comments on commit 224a4d0

Please sign in to comment.