mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-11 04:19:26 -07:00
Compare commits
3 Commits
windows-qo
...
v0.12.0-be
| Author | SHA1 | Date | |
|---|---|---|---|
| f79e6bde3b | |||
| bd5275fbf8 | |||
| 3281a7b39e |
3
bun.lock
3
bun.lock
@@ -12,6 +12,7 @@
|
|||||||
"commander": "^14.0.3",
|
"commander": "^14.0.3",
|
||||||
"hono": "^4.12.7",
|
"hono": "^4.12.7",
|
||||||
"jsonc-parser": "^3.3.1",
|
"jsonc-parser": "^3.3.1",
|
||||||
|
"koffi": "^2.15.6",
|
||||||
"libsql": "^0.5.22",
|
"libsql": "^0.5.22",
|
||||||
"ws": "^8.19.0",
|
"ws": "^8.19.0",
|
||||||
},
|
},
|
||||||
@@ -478,6 +479,8 @@
|
|||||||
|
|
||||||
"keyv": ["keyv@4.5.4", "", { "dependencies": { "json-buffer": "3.0.1" } }, "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw=="],
|
"keyv": ["keyv@4.5.4", "", { "dependencies": { "json-buffer": "3.0.1" } }, "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw=="],
|
||||||
|
|
||||||
|
"koffi": ["koffi@2.15.6", "", {}, "sha512-WQBpM5uo74UQ17UpsFN+PUOrQQg4/nYdey4SGVluQun2drYYfePziLLWdSmFb4wSdWlJC1aimXQnjhPCheRKuw=="],
|
||||||
|
|
||||||
"lazy-val": ["lazy-val@1.0.5", "", {}, "sha512-0/BnGCCfyUMkBpeDgWihanIAF9JmZhHBgUhEqzvf+adhNGLoP6TaiI5oF8oyb3I45P+PcnrqihSf01M0l0G5+Q=="],
|
"lazy-val": ["lazy-val@1.0.5", "", {}, "sha512-0/BnGCCfyUMkBpeDgWihanIAF9JmZhHBgUhEqzvf+adhNGLoP6TaiI5oF8oyb3I45P+PcnrqihSf01M0l0G5+Q=="],
|
||||||
|
|
||||||
"libsql": ["libsql@0.5.28", "", { "dependencies": { "@neon-rs/load": "^0.0.4", "detect-libc": "2.0.2" }, "optionalDependencies": { "@libsql/darwin-arm64": "0.5.28", "@libsql/darwin-x64": "0.5.28", "@libsql/linux-arm-gnueabihf": "0.5.28", "@libsql/linux-arm-musleabihf": "0.5.28", "@libsql/linux-arm64-gnu": "0.5.28", "@libsql/linux-arm64-musl": "0.5.28", "@libsql/linux-x64-gnu": "0.5.28", "@libsql/linux-x64-musl": "0.5.28", "@libsql/win32-x64-msvc": "0.5.28" }, "os": [ "linux", "win32", "darwin", ], "cpu": [ "arm", "x64", "arm64", ] }, "sha512-wKqx9FgtPcKHdPfR/Kfm0gejsnbuf8zV+ESPmltFvsq5uXwdeN9fsWn611DmqrdXj1e94NkARcMA2f1syiAqOg=="],
|
"libsql": ["libsql@0.5.28", "", { "dependencies": { "@neon-rs/load": "^0.0.4", "detect-libc": "2.0.2" }, "optionalDependencies": { "@libsql/darwin-arm64": "0.5.28", "@libsql/darwin-x64": "0.5.28", "@libsql/linux-arm-gnueabihf": "0.5.28", "@libsql/linux-arm-musleabihf": "0.5.28", "@libsql/linux-arm64-gnu": "0.5.28", "@libsql/linux-arm64-musl": "0.5.28", "@libsql/linux-x64-gnu": "0.5.28", "@libsql/linux-x64-musl": "0.5.28", "@libsql/win32-x64-msvc": "0.5.28" }, "os": [ "linux", "win32", "darwin", ], "cpu": [ "arm", "x64", "arm64", ] }, "sha512-wKqx9FgtPcKHdPfR/Kfm0gejsnbuf8zV+ESPmltFvsq5uXwdeN9fsWn611DmqrdXj1e94NkARcMA2f1syiAqOg=="],
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "subminer",
|
"name": "subminer",
|
||||||
"productName": "SubMiner",
|
"productName": "SubMiner",
|
||||||
"desktopName": "SubMiner.desktop",
|
"desktopName": "SubMiner.desktop",
|
||||||
"version": "0.12.0-beta.1",
|
"version": "0.12.0-beta.2",
|
||||||
"description": "All-in-one sentence mining overlay with AnkiConnect and dictionary integration",
|
"description": "All-in-one sentence mining overlay with AnkiConnect and dictionary integration",
|
||||||
"packageManager": "bun@1.3.5",
|
"packageManager": "bun@1.3.5",
|
||||||
"main": "dist/main-entry.js",
|
"main": "dist/main-entry.js",
|
||||||
|
|||||||
@@ -2,6 +2,23 @@ import assert from 'node:assert/strict';
|
|||||||
import test from 'node:test';
|
import test from 'node:test';
|
||||||
import { initializeOverlayAnkiIntegration, initializeOverlayRuntime } from './overlay-runtime-init';
|
import { initializeOverlayAnkiIntegration, initializeOverlayRuntime } from './overlay-runtime-init';
|
||||||
|
|
||||||
|
function withPlatform(platform: NodeJS.Platform, run: () => void): void {
|
||||||
|
const originalPlatform = process.platform;
|
||||||
|
Object.defineProperty(process, 'platform', {
|
||||||
|
value: platform,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
run();
|
||||||
|
} finally {
|
||||||
|
Object.defineProperty(process, 'platform', {
|
||||||
|
value: originalPlatform,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
test('initializeOverlayRuntime skips Anki integration when ankiConnect.enabled is false', () => {
|
test('initializeOverlayRuntime skips Anki integration when ankiConnect.enabled is false', () => {
|
||||||
let createdIntegrations = 0;
|
let createdIntegrations = 0;
|
||||||
let startedIntegrations = 0;
|
let startedIntegrations = 0;
|
||||||
@@ -548,59 +565,61 @@ test('initializeOverlayRuntime hides overlay windows when tracker loses the targ
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('initializeOverlayRuntime preserves visible overlay on Windows tracker loss when target is not minimized', () => {
|
test('initializeOverlayRuntime preserves visible overlay on Windows tracker loss when target is not minimized', () => {
|
||||||
const calls: string[] = [];
|
withPlatform('win32', () => {
|
||||||
const tracker = {
|
const calls: string[] = [];
|
||||||
onGeometryChange: null as ((...args: unknown[]) => void) | null,
|
const tracker = {
|
||||||
onWindowFound: null as ((...args: unknown[]) => void) | null,
|
onGeometryChange: null as ((...args: unknown[]) => void) | null,
|
||||||
onWindowLost: null as (() => void) | null,
|
onWindowFound: null as ((...args: unknown[]) => void) | null,
|
||||||
onWindowFocusChange: null as ((focused: boolean) => void) | null,
|
onWindowLost: null as (() => void) | null,
|
||||||
isTargetWindowMinimized: () => false,
|
onWindowFocusChange: null as ((focused: boolean) => void) | null,
|
||||||
start: () => {},
|
isTargetWindowMinimized: () => false,
|
||||||
};
|
start: () => {},
|
||||||
const overlayWindows = [
|
};
|
||||||
{
|
const overlayWindows = [
|
||||||
hide: () => calls.push('hide-visible'),
|
{
|
||||||
},
|
hide: () => calls.push('hide-visible'),
|
||||||
];
|
},
|
||||||
|
];
|
||||||
|
|
||||||
initializeOverlayRuntime({
|
initializeOverlayRuntime({
|
||||||
backendOverride: null,
|
backendOverride: null,
|
||||||
createMainWindow: () => {},
|
createMainWindow: () => {},
|
||||||
registerGlobalShortcuts: () => {},
|
registerGlobalShortcuts: () => {},
|
||||||
updateVisibleOverlayBounds: () => {},
|
updateVisibleOverlayBounds: () => {},
|
||||||
isVisibleOverlayVisible: () => true,
|
isVisibleOverlayVisible: () => true,
|
||||||
updateVisibleOverlayVisibility: () => {
|
updateVisibleOverlayVisibility: () => {
|
||||||
calls.push('update-visible');
|
calls.push('update-visible');
|
||||||
},
|
},
|
||||||
refreshCurrentSubtitle: () => {},
|
refreshCurrentSubtitle: () => {},
|
||||||
getOverlayWindows: () => overlayWindows as never,
|
getOverlayWindows: () => overlayWindows as never,
|
||||||
syncOverlayShortcuts: () => {
|
syncOverlayShortcuts: () => {
|
||||||
calls.push('sync-shortcuts');
|
calls.push('sync-shortcuts');
|
||||||
},
|
},
|
||||||
setWindowTracker: () => {},
|
setWindowTracker: () => {},
|
||||||
getMpvSocketPath: () => '/tmp/mpv.sock',
|
getMpvSocketPath: () => '/tmp/mpv.sock',
|
||||||
createWindowTracker: () => tracker as never,
|
createWindowTracker: () => tracker as never,
|
||||||
getResolvedConfig: () => ({
|
getResolvedConfig: () => ({
|
||||||
ankiConnect: { enabled: false } as never,
|
ankiConnect: { enabled: false } as never,
|
||||||
}),
|
}),
|
||||||
getSubtitleTimingTracker: () => null,
|
getSubtitleTimingTracker: () => null,
|
||||||
getMpvClient: () => null,
|
getMpvClient: () => null,
|
||||||
getRuntimeOptionsManager: () => null,
|
getRuntimeOptionsManager: () => null,
|
||||||
setAnkiIntegration: () => {},
|
setAnkiIntegration: () => {},
|
||||||
showDesktopNotification: () => {},
|
showDesktopNotification: () => {},
|
||||||
createFieldGroupingCallback: () => async () => ({
|
createFieldGroupingCallback: () => async () => ({
|
||||||
keepNoteId: 1,
|
keepNoteId: 1,
|
||||||
deleteNoteId: 2,
|
deleteNoteId: 2,
|
||||||
deleteDuplicate: false,
|
deleteDuplicate: false,
|
||||||
cancelled: false,
|
cancelled: false,
|
||||||
}),
|
}),
|
||||||
getKnownWordCacheStatePath: () => '/tmp/known-words-cache.json',
|
getKnownWordCacheStatePath: () => '/tmp/known-words-cache.json',
|
||||||
|
});
|
||||||
|
|
||||||
|
calls.length = 0;
|
||||||
|
tracker.onWindowLost?.();
|
||||||
|
|
||||||
|
assert.deepEqual(calls, ['sync-shortcuts']);
|
||||||
});
|
});
|
||||||
|
|
||||||
calls.length = 0;
|
|
||||||
tracker.onWindowLost?.();
|
|
||||||
|
|
||||||
assert.deepEqual(calls, ['sync-shortcuts']);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('initializeOverlayRuntime restores overlay bounds and visibility when tracker finds the target window again', () => {
|
test('initializeOverlayRuntime restores overlay bounds and visibility when tracker finds the target window again', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user