@adriansteffan/reactive 0.0.17 → 0.0.19
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/bin/setup.js +13 -1
- package/dist/mod-BlYvqdtq.js +71352 -0
- package/dist/mod.d.ts +13 -1
- package/dist/reactive.es.js +14 -70864
- package/dist/reactive.umd.js +32 -32
- package/dist/style.css +1 -1
- package/dist/web-EvjUSKrQ.js +435 -0
- package/package.json +4 -1
- package/src/components/enterfullscreen.tsx +43 -0
- package/src/components/exitfullscreen.tsx +23 -0
- package/src/components/experiment.tsx +4 -0
- package/src/components/upload.tsx +223 -12
- package/src/mod.tsx +4 -2
- package/src/utils/common.ts +4 -0
- package/template/.dockerignore +3 -0
- package/template/README.md +159 -30
- package/template/capacitor.config.ts +15 -0
- package/template/electron/main.js +131 -0
- package/template/electron/preload.js +9 -0
- package/template/electron.vite.config.js +45 -0
- package/template/package-lock.json +8333 -2677
- package/template/package.json +56 -2
- package/template/{vite.config.ts → shared.vite.config.js} +4 -7
- package/template/src/App.tsx +4 -0
- package/template/tsconfig.json +1 -1
- package/template/tsconfig.node.json +3 -2
- package/template/vite.config.js +11 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { app, BrowserWindow, ipcMain } from 'electron';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
|
|
6
|
+
const curfilename = fileURLToPath(import.meta.url);
|
|
7
|
+
const curdirname = path.dirname(curfilename);
|
|
8
|
+
|
|
9
|
+
function createWindow() {
|
|
10
|
+
const mainWindow = new BrowserWindow({
|
|
11
|
+
width: 800,
|
|
12
|
+
height: 600,
|
|
13
|
+
webPreferences: {
|
|
14
|
+
preload: path.join(curdirname, '../preload/preload.cjs'),
|
|
15
|
+
nodeIntegration: true,
|
|
16
|
+
webSecurity: true,
|
|
17
|
+
contextIsolation: true,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
if (process.env.NODE_ENV === 'development') {
|
|
22
|
+
mainWindow.loadURL('http://localhost:5173/');
|
|
23
|
+
mainWindow.webContents.openDevTools();
|
|
24
|
+
} else {
|
|
25
|
+
mainWindow.loadFile(path.join(curdirname, '../../dist/index.html'));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const getAppPath = () => {
|
|
30
|
+
if (app.isPackaged) {
|
|
31
|
+
return path.dirname(app.getPath('exe'));
|
|
32
|
+
} else {
|
|
33
|
+
return path.join(__dirname, '../..');
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const ensureDataDirExists = () => {
|
|
38
|
+
const dataPath = path.join(getAppPath(), 'data');
|
|
39
|
+
if (!fs.existsSync(dataPath)) {
|
|
40
|
+
fs.mkdirSync(dataPath, { recursive: true });
|
|
41
|
+
}
|
|
42
|
+
return dataPath;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const ensureDirectoryExists = (relativePath) => {
|
|
46
|
+
const basePath = ensureDataDirExists();
|
|
47
|
+
const fullPath = path.join(basePath, ...relativePath.split('/'));
|
|
48
|
+
if (!fs.existsSync(fullPath)) {
|
|
49
|
+
fs.mkdirSync(fullPath, { recursive: true });
|
|
50
|
+
}
|
|
51
|
+
return fullPath;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
function setupIPC() {
|
|
55
|
+
ipcMain.handle('directory-exists', async (event, { path: dirPath }) => {
|
|
56
|
+
try {
|
|
57
|
+
const basePath = ensureDataDirExists();
|
|
58
|
+
const fullPath = path.join(basePath, dirPath);
|
|
59
|
+
const exists = fs.existsSync(fullPath);
|
|
60
|
+
return { success: true, exists };
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error('Error checking directory:', error);
|
|
63
|
+
return { success: false, error: error.message };
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
ipcMain.handle('create-directory', async (event, { path: dirPath }) => {
|
|
68
|
+
try {
|
|
69
|
+
const fullPath = ensureDirectoryExists(dirPath);
|
|
70
|
+
return { success: true, path: fullPath };
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.error('Error creating directory:', error);
|
|
73
|
+
return { success: false, error: error.message };
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Handle saving a file
|
|
78
|
+
ipcMain.handle('save-file', async (event, { filename, data, directory }) => {
|
|
79
|
+
try {
|
|
80
|
+
// Create the directory if it doesn't exist
|
|
81
|
+
const dirPath = directory ? ensureDirectoryExists(directory) : ensureDataDirExists();
|
|
82
|
+
const filePath = path.join(dirPath, filename);
|
|
83
|
+
fs.writeFileSync(filePath, data);
|
|
84
|
+
return { success: true, path: filePath };
|
|
85
|
+
} catch (error) {
|
|
86
|
+
console.error('Error saving file:', error);
|
|
87
|
+
return { success: false, error: error.message };
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Handle reading a file
|
|
92
|
+
ipcMain.handle('read-file', async (event, { filename }) => {
|
|
93
|
+
try {
|
|
94
|
+
const dataPath = ensureDataDirExists();
|
|
95
|
+
const filePath = path.join(dataPath, filename);
|
|
96
|
+
if (!fs.existsSync(filePath)) {
|
|
97
|
+
return { success: false, error: 'File does not exist' };
|
|
98
|
+
}
|
|
99
|
+
const data = fs.readFileSync(filePath, 'utf8');
|
|
100
|
+
return { success: true, data };
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.error('Error reading file:', error);
|
|
103
|
+
return { success: false, error: error.message };
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Handle listing files in the data directory
|
|
108
|
+
ipcMain.handle('list-files', async () => {
|
|
109
|
+
try {
|
|
110
|
+
const dataPath = ensureDataDirExists();
|
|
111
|
+
const files = fs.readdirSync(dataPath);
|
|
112
|
+
return { success: true, files };
|
|
113
|
+
} catch (error) {
|
|
114
|
+
console.error('Error listing files:', error);
|
|
115
|
+
return { success: false, error: error.message };
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
app.whenReady().then(() => {
|
|
121
|
+
setupIPC();
|
|
122
|
+
createWindow();
|
|
123
|
+
|
|
124
|
+
app.on('activate', function () {
|
|
125
|
+
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
app.on('window-all-closed', function () {
|
|
130
|
+
if (process.platform !== 'darwin') app.quit();
|
|
131
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { contextBridge, ipcRenderer } from 'electron';
|
|
2
|
+
|
|
3
|
+
contextBridge.exposeInMainWorld('electronAPI', {
|
|
4
|
+
directoryExists: (path) => ipcRenderer.invoke('directory-exists', { path }),
|
|
5
|
+
createDirectory: (path) => ipcRenderer.invoke('create-directory', { path }),
|
|
6
|
+
saveFile: (filename, data, directory) => ipcRenderer.invoke('save-file', { filename, data, directory }),
|
|
7
|
+
readFile: (filename) => ipcRenderer.invoke('read-file', { filename }),
|
|
8
|
+
listFiles: () => ipcRenderer.invoke('list-files'),
|
|
9
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// electron.vite.config.js
|
|
2
|
+
import { defineConfig } from 'electron-vite';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { sharedConfig } from './shared.vite.config.js';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
|
|
10
|
+
export default defineConfig({
|
|
11
|
+
main: {
|
|
12
|
+
build: {
|
|
13
|
+
outDir: 'dist-electron/main',
|
|
14
|
+
rollupOptions: {
|
|
15
|
+
input: {
|
|
16
|
+
index: path.resolve(__dirname, 'electron/main.js'),
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
preload: {
|
|
22
|
+
build: {
|
|
23
|
+
outDir: 'dist-electron/preload',
|
|
24
|
+
lib: {
|
|
25
|
+
entry: path.resolve(__dirname, 'electron/preload.js'),
|
|
26
|
+
formats: ['cjs']
|
|
27
|
+
},
|
|
28
|
+
rollupOptions: {
|
|
29
|
+
external: ['electron']
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
renderer: {
|
|
34
|
+
...sharedConfig,
|
|
35
|
+
root: path.resolve(__dirname, '.'),
|
|
36
|
+
build: {
|
|
37
|
+
outDir: 'dist',
|
|
38
|
+
rollupOptions: {
|
|
39
|
+
input: {
|
|
40
|
+
index: path.resolve(__dirname, 'index.html'),
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
});
|