Skip to content

Commit

Permalink
improve library output (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
emma-sg committed Jan 4, 2024
1 parent 69342a7 commit 554c69e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 10 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"homepage": "https://replayweb.page/",
"author": "Webrecorder Software",
"license": "AGPL-3.0-or-later",
"types": "dist/index.d.ts",
"types": "dist/ui.d.ts",
"main": "ui.js",
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.4",
"@shoelace-style/shoelace": "^2.8.0",
Expand Down
3 changes: 3 additions & 0 deletions src/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ interface Window {
types: { description: string; accept: Record<string, string[]> }[];
}) => Promise<[FileSystemFileHandle]>;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
declare type TODOFixMe = any;
12 changes: 5 additions & 7 deletions src/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ import type { PageEntry } from "./pageentry";
// ===========================================================================
class Pages extends LitElement {
@property({ type: Array })
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO fixme
filteredPages: any[] = [];
filteredPages: TODOFixMe[] = [];

@property({ type: Array })
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO fixme
sortedPages: any[] = [];
sortedPages: TODOFixMe[] = [];

@property({ type: String })
query = "";
Expand Down Expand Up @@ -163,11 +161,11 @@ class Pages extends LitElement {
this.sortKey = "date";
this.sortDesc = true;
}
const sorter = this.renderRoot.querySelector("wr-sorter") as Sorter;
const sorter = this.renderRoot.querySelector("wr-sorter") as Sorter<
typeof this.filteredPages
>;
if (sorter) {
// @ts-expect-error - TS2339 - Property 'sortKey' does not exist on type 'Sorter'.
sorter.sortKey = this.sortKey;
// @ts-expect-error - TS2339 - Property 'sortDesc' does not exist on type 'Sorter'.
sorter.sortDesc = this.sortDesc;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sorter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import fasSortDown from "@fortawesome/fontawesome-free/svgs/solid/sort-down.svg"
import fasSortUp from "@fortawesome/fontawesome-free/svgs/solid/sort-up.svg";

// ===========================================================================
class Sorter<T> extends LitElement {
class Sorter<T = unknown> extends LitElement {
@property({ attribute: false })
sortedData: T[] = [];

Expand Down
34 changes: 33 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,36 @@ const browserConfig = (/*env, argv*/) => {
return merge(tsConfig, config);
};

module.exports = [browserConfig, electronMainConfig, electronPreloadConfig];
const libraryConfig = (/*env, argv*/) => {
const browserConf = browserConfig();
return {
...browserConf,
plugins: [
new webpack.NormalModuleReplacementPlugin(/^node:*/, (resource) => {
switch (resource.request) {
case "node:stream":
resource.request = "stream-browserify";
break;
}
}),
new webpack.ProvidePlugin({
process: "process/browser",
}),
new MiniCssExtractPlugin(),
new webpack.DefinePlugin({
__SW_NAME__: JSON.stringify("sw.js"),
__HELPER_PROXY__: JSON.stringify(HELPER_PROXY),
__GDRIVE_CLIENT_ID__: JSON.stringify(GDRIVE_CLIENT_ID),
__VERSION__: JSON.stringify(package_json.version),
}),
new webpack.BannerPlugin(BANNER_TEXT),
],
};
};

module.exports = [
browserConfig,
electronMainConfig,
electronPreloadConfig,
libraryConfig,
];

0 comments on commit 554c69e

Please sign in to comment.