@xwiki/cristal-electron-main 0.9.0 → 0.11.0
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/CHANGELOG.md +25 -0
- package/dist/index.cjs +31 -2
- package/package.json +8 -9
- package/src/index.ts +7 -2
- package/src/mainWindow.ts +3 -4
- package/src/reload.ts +28 -0
- package/src/security-restrictions.ts +7 -1
- package/tsconfig.json +17 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xwiki/cristal-electron-main",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"license": "LGPL 2.1",
|
|
5
5
|
"author": "XWiki Org Community <contact@xwiki.org>",
|
|
6
6
|
"homepage": "https://cristal.xwiki.org/",
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"url": "https://jira.xwiki.org/projects/CRISTAL/"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"electron": "31.
|
|
17
|
-
"@xwiki/cristal-browser-electron": "0.
|
|
18
|
-
"@xwiki/cristal-electron-storage": "0.
|
|
16
|
+
"electron": "31.7.1",
|
|
17
|
+
"@xwiki/cristal-browser-electron": "0.11.0",
|
|
18
|
+
"@xwiki/cristal-electron-storage": "0.11.0",
|
|
19
|
+
"@xwiki/cristal-electron-authentication-xwiki-main": "0.11.0"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
|
-
"@types/node": "
|
|
22
|
-
"cross-env": "7.0.3"
|
|
23
|
-
"rimraf": "5.0.7"
|
|
22
|
+
"@types/node": "22.7.7",
|
|
23
|
+
"cross-env": "7.0.3"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "tsc --project tsconfig.json && vite build",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"electron": "echo 'no task'",
|
|
29
29
|
"lint": "eslint \"./src/**/*.{ts,tsx}\" --max-warnings=0",
|
|
30
30
|
"linux": "echo 'no task'",
|
|
31
|
-
"package": "echo 'no task'"
|
|
32
|
-
"test": "echo 'no test'"
|
|
31
|
+
"package": "echo 'no task'"
|
|
33
32
|
}
|
|
34
33
|
}
|
package/src/index.ts
CHANGED
|
@@ -26,6 +26,8 @@ import { platform } from "node:process";
|
|
|
26
26
|
import load from "@xwiki/cristal-electron-storage/main";
|
|
27
27
|
// @ts-expect-error shouldn't happen but we need to generate the types for the whole project once.
|
|
28
28
|
import loadBrowser from "@xwiki/cristal-browser-electron/main";
|
|
29
|
+
import { load as loadAuthentication } from "@xwiki/cristal-electron-authentication-xwiki-main";
|
|
30
|
+
import { loadFile } from "./reload";
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
33
|
* Prevent electron from running multiple instances.
|
|
@@ -58,7 +60,10 @@ app
|
|
|
58
60
|
.whenReady()
|
|
59
61
|
.then(() => {
|
|
60
62
|
load();
|
|
61
|
-
restoreOrCreateWindow().then((w) =>
|
|
63
|
+
restoreOrCreateWindow().then((w) => {
|
|
64
|
+
loadBrowser(w);
|
|
65
|
+
loadAuthentication(w, loadFile);
|
|
66
|
+
});
|
|
62
67
|
/**
|
|
63
68
|
* @see https://www.electronjs.org/docs/latest/api/app#event-activate-macos Event: 'activate'.
|
|
64
69
|
*/
|
|
@@ -110,7 +115,7 @@ if (import.meta.env.PROD) {
|
|
|
110
115
|
* @see https://github.com/electron/electron/issues/38829
|
|
111
116
|
* Potentially it may be fixed by this https://github.com/electron/electron/pull/37535
|
|
112
117
|
*/
|
|
113
|
-
// eslint-disable-next-line @typescript-eslint/no-
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
114
119
|
require("electron-updater").autoUpdater.checkForUpdatesAndNotify(),
|
|
115
120
|
)
|
|
116
121
|
.catch((e) => console.error("Failed check and install updates:", e));
|
package/src/mainWindow.ts
CHANGED
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import { app, BrowserWindow, shell } from "electron";
|
|
22
|
-
import { join
|
|
22
|
+
import { join } from "node:path";
|
|
23
|
+
import { loadFile } from "./reload";
|
|
23
24
|
|
|
24
25
|
async function createWindow() {
|
|
25
26
|
const browserWindow = new BrowserWindow({
|
|
@@ -80,9 +81,7 @@ async function createWindow() {
|
|
|
80
81
|
* @see https://github.com/nodejs/node/issues/12682
|
|
81
82
|
* @see https://github.com/electron/electron/issues/6869
|
|
82
83
|
*/
|
|
83
|
-
await
|
|
84
|
-
resolve(app.getAppPath(), "./renderer/dist/index.html"),
|
|
85
|
-
);
|
|
84
|
+
await loadFile(browserWindow);
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
return browserWindow;
|
package/src/reload.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* See the LICENSE file distributed with this work for additional
|
|
3
|
+
* information regarding copyright ownership.
|
|
4
|
+
*
|
|
5
|
+
* This is free software; you can redistribute it and/or modify it
|
|
6
|
+
* under the terms of the GNU Lesser General Public License as
|
|
7
|
+
* published by the Free Software Foundation; either version 2.1 of
|
|
8
|
+
* the License, or (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This software is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13
|
+
* Lesser General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Lesser General Public
|
|
16
|
+
* License along with this software; if not, write to the Free
|
|
17
|
+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
18
|
+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { app, BrowserWindow } from "electron";
|
|
22
|
+
import { resolve } from "node:path";
|
|
23
|
+
|
|
24
|
+
function loadFile(win: BrowserWindow) {
|
|
25
|
+
return win.loadFile(resolve(app.getAppPath(), "./renderer/dist/index.html"));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { loadFile };
|
|
@@ -34,11 +34,17 @@ type Permission = Parameters<
|
|
|
34
34
|
*
|
|
35
35
|
* In development mode you need allow open `VITE_DEV_SERVER_URL`.
|
|
36
36
|
*/
|
|
37
|
-
const ALLOWED_ORIGINS_AND_PERMISSIONS
|
|
37
|
+
const ALLOWED_ORIGINS_AND_PERMISSIONS: Map<string, Set<Permission>> = new Map<
|
|
38
|
+
string,
|
|
39
|
+
Set<Permission>
|
|
40
|
+
>(
|
|
38
41
|
import.meta.env.DEV && import.meta.env.VITE_DEV_SERVER_URL
|
|
39
42
|
? [[new URL(import.meta.env.VITE_DEV_SERVER_URL).origin, new Set()]]
|
|
40
43
|
: [],
|
|
41
44
|
);
|
|
45
|
+
// TODO: CRISTAL-253 replace this hardcoded mapping with list of values drawn
|
|
46
|
+
// from the configuration.
|
|
47
|
+
ALLOWED_ORIGINS_AND_PERMISSIONS.set("http://localhost:15680", new Set());
|
|
42
48
|
|
|
43
49
|
/**
|
|
44
50
|
* A list of origins that you allow open IN BROWSER.
|
package/tsconfig.json
CHANGED
|
@@ -5,15 +5,28 @@
|
|
|
5
5
|
"target": "esnext",
|
|
6
6
|
"sourceMap": false,
|
|
7
7
|
"moduleResolution": "Node",
|
|
8
|
+
"experimentalDecorators": true,
|
|
9
|
+
"emitDecoratorMetadata": true,
|
|
8
10
|
"skipLibCheck": true,
|
|
9
11
|
"strict": true,
|
|
10
12
|
"isolatedModules": true,
|
|
11
|
-
"types": [
|
|
13
|
+
"types": [
|
|
14
|
+
"node",
|
|
15
|
+
"vite/client"
|
|
16
|
+
],
|
|
12
17
|
"baseUrl": ".",
|
|
13
18
|
"paths": {
|
|
14
|
-
"/@/*": [
|
|
19
|
+
"/@/*": [
|
|
20
|
+
"./src/*"
|
|
21
|
+
]
|
|
15
22
|
}
|
|
16
23
|
},
|
|
17
|
-
"include": [
|
|
18
|
-
|
|
24
|
+
"include": [
|
|
25
|
+
"src/**/*.ts",
|
|
26
|
+
"../types/**/*.d.ts"
|
|
27
|
+
],
|
|
28
|
+
"exclude": [
|
|
29
|
+
"**/*.spec.ts",
|
|
30
|
+
"**/*.test.ts"
|
|
31
|
+
]
|
|
19
32
|
}
|