Skip to content

Commit 0a76a52

Browse files
authored
Merge pull request #2 from onyxdevs/cursor/implement-mac-desktop-application-1815
Implement mac desktop application
2 parents 7f7a75a + ae274ae commit 0a76a52

38 files changed

Lines changed: 5546 additions & 170 deletions

.prettierrc

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
{
2-
"semi": true,
3-
"trailingComma": "es5",
4-
"singleQuote": true,
5-
"printWidth": 100,
2+
"printWidth": 120,
63
"tabWidth": 4,
74
"useTabs": false,
8-
"bracketSpacing": true,
9-
"arrowParens": "always",
10-
"endOfLine": "lf"
5+
"semi": true,
6+
"singleQuote": true,
7+
"trailingComma": "all",
8+
"overrides": [
9+
{
10+
"files": "*.yaml",
11+
"options": {
12+
"tabWidth": 4
13+
}
14+
},
15+
{
16+
"files": "*.yml",
17+
"options": {
18+
"tabWidth": 4
19+
}
20+
}
21+
]
1122
}

.yarn/install-state.gz

129 KB
Binary file not shown.

eslint.config.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,53 @@ module.exports = [
180180
},
181181
},
182182
{
183+
// Browser/Renderer JavaScript files (Electron renderer process)
184+
files: ['packages/mac/src/renderer/**/*.js'],
185+
languageOptions: {
186+
ecmaVersion: 2020,
187+
sourceType: 'script', // Renderer files use script mode
188+
globals: {
189+
// Browser globals
190+
window: 'readonly',
191+
document: 'readonly',
192+
console: 'readonly',
193+
setTimeout: 'readonly',
194+
clearTimeout: 'readonly',
195+
setInterval: 'readonly',
196+
clearInterval: 'readonly',
197+
alert: 'readonly',
198+
confirm: 'readonly',
199+
prompt: 'readonly',
200+
// DOM globals
201+
Element: 'readonly',
202+
HTMLElement: 'readonly',
203+
Event: 'readonly',
204+
MouseEvent: 'readonly',
205+
KeyboardEvent: 'readonly',
206+
// Additional browser APIs
207+
fetch: 'readonly',
208+
localStorage: 'readonly',
209+
sessionStorage: 'readonly',
210+
},
211+
},
212+
plugins: {
213+
prettier,
214+
},
215+
rules: {
216+
'prettier/prettier': [
217+
'error',
218+
{
219+
tabWidth: 4,
220+
},
221+
],
222+
// Relax some rules for renderer files
223+
'no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
224+
},
225+
},
226+
{
227+
// Node.js JavaScript files
183228
files: ['**/*.js', '**/*.mjs', '**/*.cjs'],
229+
ignores: ['packages/mac/src/renderer/**/*.js'], // Exclude renderer files
184230
languageOptions: {
185231
ecmaVersion: 2020,
186232
sourceType: 'module',

jest.config.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ module.exports = {
4545
],
4646

4747
// Global settings
48-
collectCoverageFrom: [
49-
'packages/*/src/**/*.ts',
50-
'!packages/*/src/**/*.d.ts',
51-
'!packages/*/src/**/index.ts',
52-
],
48+
collectCoverageFrom: ['packages/*/src/**/*.ts', '!packages/*/src/**/*.d.ts', '!packages/*/src/**/index.ts'],
5349

5450
coverageDirectory: 'coverage',
5551
coverageReporters: ['text', 'lcov', 'html'],

packages/cli/__tests__/commands/convert-command.test.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,10 @@ describe('ConvertCommandCreator', () => {
3737

3838
// Setup mocks
3939
const { SubtitleProcessor, ConfigManager } = require('@subzilla/core');
40-
const mockProcessFile = jest
41-
.fn<() => Promise<{ outputPath: string; backupPath: string }>>()
42-
.mockResolvedValue({
43-
outputPath: '/mock/output.srt',
44-
backupPath: '/mock/backup.srt',
45-
});
40+
const mockProcessFile = jest.fn<() => Promise<{ outputPath: string; backupPath: string }>>().mockResolvedValue({
41+
outputPath: '/mock/output.srt',
42+
backupPath: '/mock/backup.srt',
43+
});
4644

4745
(SubtitleProcessor as any).mockImplementation(() => ({
4846
processFile: mockProcessFile,
@@ -152,7 +150,7 @@ describe('ConvertCommandCreator', () => {
152150
html: true,
153151
colors: true,
154152
}),
155-
})
153+
}),
156154
);
157155
});
158156

@@ -169,7 +167,7 @@ describe('ConvertCommandCreator', () => {
169167
expect.objectContaining({
170168
retryCount: 3,
171169
retryDelay: 2000,
172-
})
170+
}),
173171
);
174172
});
175173

@@ -190,7 +188,7 @@ describe('ConvertCommandCreator', () => {
190188
overwriteInput: true,
191189
overwriteExisting: true,
192190
overwriteBackup: false,
193-
})
191+
}),
194192
);
195193
});
196194

@@ -213,7 +211,7 @@ describe('ConvertCommandCreator', () => {
213211
expect.objectContaining({
214212
backupOriginal: true,
215213
bom: false,
216-
})
214+
}),
217215
);
218216
});
219217

@@ -242,7 +240,7 @@ describe('ConvertCommandCreator', () => {
242240
'🧬 Output options:',
243241
expect.objectContaining({
244242
lineEndings: 'lf',
245-
})
243+
}),
246244
);
247245
});
248246
});

packages/cli/src/commands/batch-command.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,11 @@ export class BatchCommandCreator extends BaseCommandCreator<IBatchCommandOptions
2424
common: {
2525
strip: createStripOptions(options, config),
2626
backupOriginal: options.backup ?? config.output?.createBackup,
27-
overwriteBackup:
28-
options.overwriteBackup ?? config.output?.overwriteBackup,
27+
overwriteBackup: options.overwriteBackup ?? config.output?.overwriteBackup,
2928
bom: options.bom ?? config.output?.bom,
3029
lineEndings: options.lineEndings ?? config.output?.lineEndings,
3130
overwriteInput: options.overwriteInput ?? config.output?.overwriteInput,
32-
overwriteExisting:
33-
options.overwriteExisting ?? config.output?.overwriteExisting,
31+
overwriteExisting: options.overwriteExisting ?? config.output?.overwriteExisting,
3432
retryCount: options.retryCount
3533
? parseInt(options.retryCount, 10)
3634
: config.batch?.retryCount,
@@ -43,19 +41,11 @@ export class BatchCommandCreator extends BaseCommandCreator<IBatchCommandOptions
4341
outputDir: options.outputDir ?? config.output?.directory,
4442
recursive: options.recursive ?? config.batch?.recursive ?? false,
4543
parallel: options.parallel ?? config.batch?.parallel ?? false,
46-
skipExisting:
47-
options.skipExisting ?? config.batch?.skipExisting ?? false,
48-
maxDepth: options.maxDepth
49-
? parseInt(options.maxDepth, 10)
50-
: config.batch?.maxDepth,
51-
includeDirectories:
52-
options.includeDirs ?? config.batch?.includeDirectories,
53-
excludeDirectories:
54-
options.excludeDirs ?? config.batch?.excludeDirectories,
55-
preserveStructure:
56-
options.preserveStructure ??
57-
config.batch?.preserveStructure ??
58-
false,
44+
skipExisting: options.skipExisting ?? config.batch?.skipExisting ?? false,
45+
maxDepth: options.maxDepth ? parseInt(options.maxDepth, 10) : config.batch?.maxDepth,
46+
includeDirectories: options.includeDirs ?? config.batch?.includeDirectories,
47+
excludeDirectories: options.excludeDirs ?? config.batch?.excludeDirectories,
48+
preserveStructure: options.preserveStructure ?? config.batch?.preserveStructure ?? false,
5949
chunkSize: options.chunkSize ?? config.batch?.chunkSize,
6050
},
6151
};

packages/cli/src/commands/convert-command.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,9 @@ export class ConvertCommandCreator extends BaseCommandCreator<IConvertCommandOpt
2727
bom: options.bom ?? config.output?.bom,
2828
lineEndings: options.lineEndings ?? config.output?.lineEndings,
2929
overwriteInput: options.overwriteInput ?? config.output?.overwriteInput,
30-
overwriteExisting:
31-
options.overwriteExisting ?? config.output?.overwriteExisting,
32-
retryCount: options.retryCount
33-
? parseInt(options.retryCount, 10)
34-
: config.batch?.retryCount,
35-
retryDelay: options.retryDelay
36-
? parseInt(options.retryDelay, 10)
37-
: config.batch?.retryDelay,
30+
overwriteExisting: options.overwriteExisting ?? config.output?.overwriteExisting,
31+
retryCount: options.retryCount ? parseInt(options.retryCount, 10) : config.batch?.retryCount,
32+
retryDelay: options.retryDelay ? parseInt(options.retryDelay, 10) : config.batch?.retryDelay,
3833
};
3934

4035
console.log('🧬 Output options:', outputOptions);
@@ -45,9 +40,7 @@ export class ConvertCommandCreator extends BaseCommandCreator<IConvertCommandOpt
4540

4641
console.log('✨ Conversion successful!');
4742
console.log(`Input file: ${inputFile}`);
48-
console.log(
49-
`Output file: ${options.output || this.getDefaultOutputPath(inputFile)}`
50-
);
43+
console.log(`Output file: ${options.output || this.getDefaultOutputPath(inputFile)}`);
5144

5245
if (options.backup || config.output?.createBackup) {
5346
console.log(`Backup file: ${inputFile}.bak`);

packages/cli/src/commands/info-command.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,15 @@ export class InfoCommandCreator extends BaseCommandCreator<IInfoCommandOptions>
2929
const fileBuffer = await fs.readFile(inputFile);
3030

3131
// Detect encoding
32-
const detectedEncoding =
33-
await EncodingDetectionService.detectEncoding(inputFile);
32+
const detectedEncoding = await EncodingDetectionService.detectEncoding(inputFile);
3433

3534
// Check for BOM
3635
const hasBOM = fileBuffer.slice(0, 3).equals(Buffer.from([0xef, 0xbb, 0xbf]));
3736

3837
// Count lines and entries
3938
const content = fileBuffer.toString(detectedEncoding as NodeJS.BufferEncoding);
4039
const lines = content.split(/\r?\n/);
41-
const entries = content
42-
.split(/\r?\n\r?\n/)
43-
.filter((entry) => entry.trim()).length;
40+
const entries = content.split(/\r?\n\r?\n/).filter((entry) => entry.trim()).length;
4441

4542
// Detect line endings
4643
const hasCarriageReturn = content.includes('\r\n');
@@ -63,10 +60,7 @@ export class InfoCommandCreator extends BaseCommandCreator<IInfoCommandOptions>
6360
console.log(` • Total Lines: ${chalk.yellow(lines.length)}`);
6461
console.log(` • Subtitle Entries: ${chalk.yellow(entries)}`);
6562
} catch (error) {
66-
console.error(
67-
chalk.red('❌ Error analyzing subtitle file:'),
68-
(error as Error).message
69-
);
63+
console.error(chalk.red('❌ Error analyzing subtitle file:'), (error as Error).message);
7064
process.exit(1);
7165
}
7266
},

packages/cli/src/utils/strip-options.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { IStripOptions, IStripCommandOptions, IConfig } from '@subzilla/types';
22

3-
export function createStripOptions(
4-
options: IStripCommandOptions,
5-
config: IConfig
6-
): IStripOptions | undefined {
3+
export function createStripOptions(options: IStripCommandOptions, config: IConfig): IStripOptions | undefined {
74
const stripOptions: IStripOptions = options.stripAll
85
? {
96
html: true,

packages/core/__tests__/EncodingConversionService.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ describe('EncodingConversionService', () => {
5252
const content = 'Smart quotes: "Hello"';
5353
// Create buffer with Windows-1252 specific characters
5454
const buffer = Buffer.from([
55-
0x53, 0x6d, 0x61, 0x72, 0x74, 0x20, 0x71, 0x75, 0x6f, 0x74, 0x65, 0x73, 0x3a, 0x20,
56-
0x93, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x94,
55+
0x53, 0x6d, 0x61, 0x72, 0x74, 0x20, 0x71, 0x75, 0x6f, 0x74, 0x65, 0x73, 0x3a, 0x20, 0x93, 0x48, 0x65,
56+
0x6c, 0x6c, 0x6f, 0x94,
5757
]);
5858

5959
const result = EncodingConversionService.convertToUtf8(buffer, 'windows-1252');

0 commit comments

Comments
 (0)