Skip to content

Commit

Permalink
cleaned up webworker implementation.
Browse files Browse the repository at this point in the history
Now it’s vite ready.

Signed-off-by: Dave Shanley <dave@quobix.com>
  • Loading branch information
daveshanley committed Jun 21, 2023
1 parent d3c80fb commit 0e3e6a2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
1 change: 0 additions & 1 deletion ui/src/components/transaction/transaction-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {WiretapCurrentSpec, WiretapFiltersKey, WiretapLinkCacheStore, WiretapLoc
import {AreFiltersActive, WiretapFilters} from "@/model/controls";
import {TransactionLinkCache} from "@/model/link_cache";
import {GetBagManager} from "@pb33f/saddlebag";
import {ViolationViewComponent} from "@/components/violation/violation";
import dividerCss from "@/components/divider.css";

@customElement('http-transaction-container')
Expand Down
9 changes: 0 additions & 9 deletions ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,3 @@ import './wiretap';
import {setBasePath} from '@shoelace-style/shoelace/dist/utilities/base-path.js';
//setBasePath('/shoelace');
setBasePath('/assets/shoelace');

export const workerFactory = (workerScript: URL, workerOptions: WorkerOptions) => () =>
new Worker(workerScript, workerOptions);

export const linkCacheFactory = workerFactory(new URL('./workers/link_cache_worker.ts', import.meta.url), {
type: 'module',
});


9 changes: 5 additions & 4 deletions ui/src/model/link_cache.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {Bag, GetBagManager} from "@pb33f/saddlebag";
import {WiretapControls, WiretapFilters} from "@/model/controls";
import {linkCacheFactory} from "@/index";
// @ts-ignore
import LinkCacheWorker from "@/workers/link_cache_worker?worker";
import {WiretapFilters} from "@/model/controls";

import {
WiretapFiltersKey,
WiretapFiltersStore,
WiretapHttpTransactionStore, WiretapLinkCacheKey,
WiretapLinkCacheStore,
WiretapLocalStorage
} from "@/model/constants";
import {HttpTransaction, HttpTransactionBase, HttpTransactionLink} from "@/model/http_transaction";
import localforage from "localforage";
Expand All @@ -29,7 +30,7 @@ export class TransactionLinkCache {
this._state = new Map<string, Map<string, HttpTransactionLink[]>>();

// create a new linkCacheWorker
this._linkCacheWorker = linkCacheFactory();
this._linkCacheWorker = new LinkCacheWorker();

// get transaction store
this._httpTransactionStore =
Expand Down
4 changes: 2 additions & 2 deletions ui/src/workers/link_cache_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ function update(keyword: string,

// check transactions for keyword
transactions.forEach((transaction) => {
const querySegments = transaction.queryString.split('&')
for (let i = 0; i < querySegments.length; i++) {
const querySegments = transaction.queryString?.split('&')
for (let i = 0; i < querySegments?.length; i++) {
const segment = querySegments[i];
const keyVal = segment.split('=')
if (keyVal.length === 2) {
Expand Down

0 comments on commit 0e3e6a2

Please sign in to comment.