docs-combiner 0.0.1 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli.js CHANGED
@@ -1,13 +1,31 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { spawn } = require('child_process');
3
+ const spawn = require('cross-spawn');
4
4
  const electron = require('electron');
5
5
  const path = require('path');
6
6
 
7
+ // require('electron') returns the path to Electron's executable from node_modules/electron
8
+ // On Windows: .../node_modules/electron/dist/electron.exe
9
+ // On macOS: .../node_modules/electron/dist/Electron.app/Contents/MacOS/Electron
10
+ // On Linux: .../node_modules/electron/dist/electron
11
+ const electronPath = electron;
12
+
13
+ // Path to the app directory (where package.json and dist/ are located)
14
+ // When installed via npx, __dirname points to the installed package location
7
15
  const appPath = path.join(__dirname);
8
- const child = spawn(electron, [appPath], { stdio: 'inherit' });
16
+
17
+ // Use cross-spawn for cross-platform compatibility
18
+ // cross-spawn correctly handles Windows paths, .exe extensions, and spaces in paths
19
+ const child = spawn(electronPath, [appPath], {
20
+ stdio: 'inherit'
21
+ });
22
+
23
+ child.on('error', (err) => {
24
+ console.error('Failed to start Electron:', err.message);
25
+ process.exit(1);
26
+ });
9
27
 
10
28
  child.on('close', (code) => {
11
- process.exit(code);
29
+ process.exit(code || 0);
12
30
  });
13
31
 
package/dist/index.html CHANGED
@@ -1,11 +1,56 @@
1
1
  <!DOCTYPE html>
2
- <html>
2
+ <html style="background-color: #ffffff; color: #000000;">
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
5
  <title>Docs Combiner</title>
6
+ <style>
7
+ /* Set theme styles immediately to prevent white flash */
8
+ /* Default to light theme, then switch to dark if needed */
9
+ html {
10
+ background-color: #ffffff !important;
11
+ color: #000000 !important;
12
+ }
13
+ html[data-theme="dark"] {
14
+ background-color: #121212 !important;
15
+ color: #ffffff !important;
16
+ }
17
+ body {
18
+ margin: 0;
19
+ padding: 0;
20
+ background-color: inherit !important;
21
+ color: inherit !important;
22
+ }
23
+ #root {
24
+ background-color: inherit !important;
25
+ color: inherit !important;
26
+ min-height: 100vh;
27
+ width: 100vw;
28
+ height: 100vh;
29
+ margin: 0;
30
+ padding: 0;
31
+ }
32
+ </style>
33
+ <script>
34
+ // Execute immediately, before any rendering
35
+ (function() {
36
+ try {
37
+ const savedTheme = localStorage.getItem('themeMode');
38
+ const isDark = savedTheme === 'dark';
39
+ if (isDark) {
40
+ document.documentElement.setAttribute('data-theme', 'dark');
41
+ document.documentElement.style.setProperty('background-color', '#121212', 'important');
42
+ document.documentElement.style.setProperty('color', '#ffffff', 'important');
43
+ } else {
44
+ document.documentElement.removeAttribute('data-theme');
45
+ document.documentElement.style.setProperty('background-color', '#ffffff', 'important');
46
+ document.documentElement.style.setProperty('color', '#000000', 'important');
47
+ }
48
+ } catch(e) {}
49
+ })();
50
+ </script>
6
51
  <script defer src="./renderer.js"></script></head>
7
- <body>
8
- <div id="root"></div>
52
+ <body style="background-color: inherit; color: inherit;">
53
+ <div id="root" style="background-color: inherit; color: inherit;"></div>
9
54
  <!-- Webpack will inject the bundle here -->
10
55
  </body>
11
56
  </html>
package/dist/main.js CHANGED
@@ -48,9 +48,23 @@ const fs = __importStar(require("fs"));
48
48
  const http = __importStar(require("http"));
49
49
  const url = __importStar(require("url"));
50
50
  function createWindow() {
51
+ // Try to read theme preference from localStorage file
52
+ // In Electron, localStorage is stored in a specific location
53
+ let backgroundColor = '#ffffff'; // Default light theme
54
+ try {
55
+ const userDataPath = electron_1.app.getPath('userData');
56
+ // Electron stores localStorage in Local Storage file
57
+ // For now, we'll default to light and let preload handle it
58
+ // But we can try to read from the actual localStorage file if needed
59
+ }
60
+ catch (e) {
61
+ // Use default
62
+ }
51
63
  const mainWindow = new electron_1.BrowserWindow({
52
64
  width: 1000,
53
65
  height: 800,
66
+ backgroundColor: '#121212', // Set to dark by default, will be corrected by preload if light
67
+ show: false, // Don't show until ready to prevent flash
54
68
  webPreferences: {
55
69
  preload: path.join(__dirname, 'preload.js'),
56
70
  nodeIntegration: false,
@@ -58,6 +72,25 @@ function createWindow() {
58
72
  sandbox: false
59
73
  },
60
74
  });
75
+ // Show window only after page is ready to prevent white flash
76
+ mainWindow.webContents.once('did-finish-load', () => {
77
+ // Ensure theme is applied before showing
78
+ mainWindow.webContents.executeJavaScript(`
79
+ (function() {
80
+ const savedTheme = localStorage.getItem('themeMode');
81
+ const isDark = savedTheme === 'dark';
82
+ const bgColor = isDark ? '#121212' : '#ffffff';
83
+ document.documentElement.style.setProperty('background-color', bgColor, 'important');
84
+ document.body.style.setProperty('background-color', bgColor, 'important');
85
+ const root = document.getElementById('root');
86
+ if (root) root.style.setProperty('background-color', bgColor, 'important');
87
+ })();
88
+ `).then(() => {
89
+ mainWindow.show();
90
+ }).catch(() => {
91
+ mainWindow.show();
92
+ });
93
+ });
61
94
  // We need to point to the webpack output html
62
95
  mainWindow.loadFile(path.join(__dirname, 'index.html'));
63
96
  // DevTools disabled by default as requested
@@ -147,6 +180,33 @@ electron_1.app.whenReady().then(() => {
147
180
  electron_1.ipcMain.handle('open-external', (event, url) => __awaiter(void 0, void 0, void 0, function* () {
148
181
  yield electron_1.shell.openExternal(url);
149
182
  }));
183
+ electron_1.ipcMain.handle('log', (event, level, ...args) => __awaiter(void 0, void 0, void 0, function* () {
184
+ const timestamp = new Date().toISOString();
185
+ const message = args.map(arg => {
186
+ if (typeof arg === 'object') {
187
+ try {
188
+ return JSON.stringify(arg, null, 2);
189
+ }
190
+ catch (_a) {
191
+ return String(arg);
192
+ }
193
+ }
194
+ return String(arg);
195
+ }).join(' ');
196
+ const formattedMessage = `[${timestamp}] ${message}`;
197
+ switch (level) {
198
+ case 'log':
199
+ case 'info':
200
+ console.log(formattedMessage);
201
+ break;
202
+ case 'warn':
203
+ console.warn(formattedMessage);
204
+ break;
205
+ case 'error':
206
+ console.error(formattedMessage);
207
+ break;
208
+ }
209
+ }));
150
210
  createWindow();
151
211
  electron_1.app.on('activate', function () {
152
212
  if (electron_1.BrowserWindow.getAllWindows().length === 0)
package/dist/preload.js CHANGED
@@ -1,6 +1,52 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const electron_1 = require("electron");
4
+ // Set theme immediately before React loads to prevent white flash
5
+ // This runs in Electron's preload context, before the page loads
6
+ (function () {
7
+ // Use DOMContentLoaded to ensure DOM is ready, but execute as early as possible
8
+ const applyTheme = () => {
9
+ try {
10
+ const savedTheme = localStorage.getItem('themeMode');
11
+ const isDark = savedTheme === 'dark';
12
+ const bgColor = isDark ? '#121212' : '#ffffff';
13
+ const textColor = isDark ? '#ffffff' : '#000000';
14
+ // Set data-theme attribute for CSS fallback
15
+ if (isDark) {
16
+ document.documentElement.setAttribute('data-theme', 'dark');
17
+ }
18
+ else {
19
+ document.documentElement.removeAttribute('data-theme');
20
+ }
21
+ // Set inline styles with !important for highest priority
22
+ document.documentElement.style.setProperty('background-color', bgColor, 'important');
23
+ document.documentElement.style.setProperty('color', textColor, 'important');
24
+ // Set body styles when available
25
+ if (document.body) {
26
+ document.body.style.setProperty('background-color', bgColor, 'important');
27
+ document.body.style.setProperty('color', textColor, 'important');
28
+ }
29
+ // Set root element styles when available (for lock screen)
30
+ const root = document.getElementById('root');
31
+ if (root) {
32
+ root.style.setProperty('background-color', bgColor, 'important');
33
+ root.style.setProperty('color', textColor, 'important');
34
+ }
35
+ }
36
+ catch (e) {
37
+ // Ignore errors if localStorage is not available yet
38
+ }
39
+ };
40
+ // Try immediately, and also on DOMContentLoaded as fallback
41
+ if (document.readyState === 'loading') {
42
+ document.addEventListener('DOMContentLoaded', applyTheme);
43
+ }
44
+ else {
45
+ applyTheme();
46
+ }
47
+ // Also try immediately (in case DOM is already ready)
48
+ applyTheme();
49
+ })();
4
50
  electron_1.contextBridge.exposeInMainWorld('electronAPI', {
5
51
  // Add any specific API requirements here if needed
6
52
  // For now, standard browser fetch works for many things, but if we need
@@ -10,4 +56,5 @@ electron_1.contextBridge.exposeInMainWorld('electronAPI', {
10
56
  loadConfig: () => electron_1.ipcRenderer.invoke('load-config'),
11
57
  startAuth: (clientId) => electron_1.ipcRenderer.invoke('start-auth', clientId),
12
58
  openExternal: (url) => electron_1.ipcRenderer.invoke('open-external', url),
59
+ log: (level, ...args) => electron_1.ipcRenderer.invoke('log', level, ...args),
13
60
  });