Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots πŸ“–

fix: critical review fixes β€” double shadow DOM, blur persistence, chunking, WASM gitignore

Luis Ortiz528112a6afdf
diff --git a/.gitignore b/.gitignore
index eb8d214..8ad14b9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ docs/
.claude/
mockups/
.worktrees/
+public/transformers/
diff --git a/package.json b/package.json
index b4368d3..23fa8a5 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,8 @@
"lint": "biome check .",
"lint:fix": "biome check --write .",
"format": "biome format --write .",
- "prepare": "husky"
+ "prepare": "husky",
+ "postinstall": "mkdir -p public/transformers && cp node_modules/onnxruntime-web/dist/*.wasm public/transformers/ 2>/dev/null || true"
},
"keywords": [],
"author": "",
diff --git a/public/transformers/ort-wasm-simd-threaded.asyncify.wasm b/public/transformers/ort-wasm-simd-threaded.asyncify.wasm
deleted file mode 100644
index 3b9f738..0000000
Binary files a/public/transformers/ort-wasm-simd-threaded.asyncify.wasm and /dev/null differ
diff --git a/public/transformers/ort-wasm-simd-threaded.jsep.wasm b/public/transformers/ort-wasm-simd-threaded.jsep.wasm
deleted file mode 100644
index 5fc5039..0000000
Binary files a/public/transformers/ort-wasm-simd-threaded.jsep.wasm and /dev/null differ
diff --git a/public/transformers/ort-wasm-simd-threaded.jspi.wasm b/public/transformers/ort-wasm-simd-threaded.jspi.wasm
deleted file mode 100644
index 0062598..0000000
Binary files a/public/transformers/ort-wasm-simd-threaded.jspi.wasm and /dev/null differ
diff --git a/public/transformers/ort-wasm-simd-threaded.wasm b/public/transformers/ort-wasm-simd-threaded.wasm
deleted file mode 100644
index 35254ce..0000000
Binary files a/public/transformers/ort-wasm-simd-threaded.wasm and /dev/null differ
diff --git a/src/core/blur/manager.ts b/src/core/blur/manager.ts
index b6c10ae..86ceaf9 100644
--- a/src/core/blur/manager.ts
+++ b/src/core/blur/manager.ts
@@ -70,7 +70,7 @@ export class BlurManager {
private onDone = (() => {
this.panel?.unmount();
this.panel = null;
- this.scanner.stop();
+ this.scanner.detach();
this.picker.stop();
document.removeEventListener('mimik-blur:update-presets', this.onUpdatePresets);
document.removeEventListener('mimik-blur:start-picker', this.onStartPicker);
diff --git a/src/core/blur/panel.ts b/src/core/blur/panel.ts
index b02c2bc..7eda7ff 100644
--- a/src/core/blur/panel.ts
+++ b/src/core/blur/panel.ts
@@ -256,15 +256,7 @@ export class BlurPanel {
mount() {
if (!customElements.get(PANEL_TAG)) {
- customElements.define(
- PANEL_TAG,
- class extends HTMLElement {
- constructor() {
- super();
- this.attachShadow({ mode: 'closed' });
- }
- },
- );
+ customElements.define(PANEL_TAG, class extends HTMLElement {});
}
this.host = document.createElement(PANEL_TAG);
diff --git a/src/core/blur/scanner.ts b/src/core/blur/scanner.ts
index 96eaf3c..7eae739 100644
--- a/src/core/blur/scanner.ts
+++ b/src/core/blur/scanner.ts
@@ -31,10 +31,14 @@ export class BlurScanner {
}
stop() {
+ this.detach();
+ this.unblurAll();
+ }
+
+ detach() {
this.observer?.disconnect();
this.observer = null;
if (this.debounceTimer) clearTimeout(this.debounceTimer);
- this.unblurAll();
}
private getActivePatterns(): RegExp[] {
diff --git a/src/entrypoints/background/index.ts b/src/entrypoints/background/index.ts
index ef8f467..0533e08 100644
--- a/src/entrypoints/background/index.ts
+++ b/src/entrypoints/background/index.ts
@@ -11,8 +11,6 @@ import { registerNavigationListeners } from './navigation';
import { handleCaptureStep, handleFinalizeInputStep, handleUpdateInputStep } from './step-pipeline';
import { broadcastStartCapture, broadcastStopCapture, showNotificationOnTab } from './tab-manager';
-let offscreenReady = false;
-
async function ensureOffscreen() {
const contexts = await chrome.offscreen.getContexts({
contextTypes: ['OFFSCREEN_DOCUMENT' as chrome.offscreen.ContextType],
@@ -225,10 +223,7 @@ export default defineBackground(() => {
});
chrome.runtime.onMessage.addListener((msg, _sender, sendResponse) => {
- if (msg.type === 'offscreen:ready') {
- offscreenReady = true;
- return false;
- }
+ if (msg.type === 'offscreen:ready') return false;
if (msg.type === 'BLUR_AI_DETECT') {
ensureOffscreen()
diff --git a/src/entrypoints/content.ts b/src/entrypoints/content.ts
index e1a1225..9a65306 100644
--- a/src/entrypoints/content.ts
+++ b/src/entrypoints/content.ts
@@ -87,6 +87,8 @@ export default defineContentScript({
const blurManager = new BlurManager();
guideMe.start();
const handleTabMessage = createTabMessageHandler(session, guideMe);
+ const isTopFrame = window.self === window.top;
+ let removeBlurListener: (() => void) | null = null;
document.addEventListener(CLEANUP_EVENT, () => {
session.dispose();
@@ -99,9 +101,6 @@ export default defineContentScript({
window.addEventListener('beforeunload', () => session.stop());
browser.runtime.onMessage.addListener(handleTabMessage);
syncWithBackground(session);
-
- const isTopFrame = window.self === window.top;
- let removeBlurListener: (() => void) | null = null;
if (isTopFrame) {
const blurHandler = (changes: Record<string, { newValue?: unknown }>) => {
if (!('mimikBlurMode' in changes)) return;
diff --git a/src/entrypoints/offscreen/main.ts b/src/entrypoints/offscreen/main.ts
index eee3336..5ee801d 100644
--- a/src/entrypoints/offscreen/main.ts
+++ b/src/entrypoints/offscreen/main.ts
@@ -90,6 +90,20 @@ function postProcess(tokens: TokenResult[], originalText: string): Entity[] {
return entities;
}
+const CHUNK_SIZE = 2000;
+const CHUNK_OVERLAP = 150;
+
+function chunkText(text: string): string[] {
+ if (text.length <= CHUNK_SIZE) return [text];
+ const chunks: string[] = [];
+ let offset = 0;
+ while (offset < text.length) {
+ chunks.push(text.slice(offset, offset + CHUNK_SIZE));
+ offset += CHUNK_SIZE - CHUNK_OVERLAP;
+ }
+ return chunks;
+}
+
async function detect(text: string): Promise<{ entities: Entity[] }> {
if (!ner) {
const init = await initModel();
@@ -97,9 +111,23 @@ async function detect(text: string): Promise<{ entities: Entity[] }> {
}
try {
- const results = await ner!(text, { ignore_labels: ['O'] });
- const tokens = (Array.isArray(results) ? results : [results]) as unknown as TokenResult[];
- return { entities: postProcess(tokens, text) };
+ const chunks = chunkText(text);
+ const allEntities: Entity[] = [];
+ const seen = new Set<string>();
+
+ for (const chunk of chunks) {
+ const results = await ner!(chunk, { ignore_labels: ['O'] });
+ const tokens = (Array.isArray(results) ? results : [results]) as unknown as TokenResult[];
+ for (const entity of postProcess(tokens, text)) {
+ const key = `${entity.text}:${entity.label}`;
+ if (!seen.has(key)) {
+ seen.add(key);
+ allEntities.push(entity);
+ }
+ }
+ }
+
+ return { entities: allEntities };
} catch {
return { entities: [] };
}