@moonbase.sh/electron 0.0.0 → 0.1.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.
@@ -0,0 +1,29 @@
1
+ // Boots the activation UI as the module's own window: the page is the panel, and
2
+ // the window is resized to fit each screen.
3
+ ;(async () => {
4
+ const bridge = window.moonbaseUi
5
+ const invoke = (command, args = {}) => bridge.invoke(command, args)
6
+ const config = await invoke('ui_config')
7
+ document.title = config.windowTitle || config.productName
8
+ if (config.reduceMotion) document.body.classList.add('reduce-motion')
9
+
10
+ let ready = false
11
+ const ui = createActivationUI({
12
+ root: document.getElementById('app'),
13
+ config,
14
+ invoke,
15
+ mode: 'window',
16
+ async onHeight(height) {
17
+ if (ready) return invoke('ui_resize', { height })
18
+ ready = true
19
+ const opened = await invoke('ui_ready', { height })
20
+ if (opened?.screen) ui.show(opened.screen)
21
+ },
22
+ })
23
+ bridge.onPush((name, payload) => ui[name]?.(payload))
24
+
25
+ document.addEventListener('keydown', (event) => {
26
+ if (event.key === 'Escape' && ui.canClose()) invoke('close_ui')
27
+ })
28
+ ui.start()
29
+ })()
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ // src/uiPreload.ts
4
+ var import_electron = require("electron");
5
+ import_electron.contextBridge.exposeInMainWorld("moonbaseUi", {
6
+ async invoke(command, args = {}) {
7
+ const outcome = await import_electron.ipcRenderer.invoke("moonbase:ui", command, args);
8
+ if (!outcome.ok)
9
+ throw outcome.error;
10
+ return outcome.value;
11
+ },
12
+ onPush(callback) {
13
+ import_electron.ipcRenderer.on("moonbase:push", (_event, name, payload) => callback(name, payload));
14
+ }
15
+ });
package/package.json CHANGED
@@ -1,7 +1,75 @@
1
1
  {
2
2
  "name": "@moonbase.sh/electron",
3
- "version": "0.0.0",
4
- "description": "Placeholder for Moonbase licensing for Electron apps. The first release is 0.1.0.",
3
+ "type": "module",
4
+ "version": "0.1.0",
5
+ "description": "Moonbase.sh licensing for Electron apps, with a finished activation UI",
5
6
  "author": "Tobias Lønnerød Madsen <m@dsen.tv>",
6
- "license": "MIT"
7
- }
7
+ "license": "MIT",
8
+ "sideEffects": false,
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
19
+ },
20
+ "./preload": {
21
+ "import": {
22
+ "types": "./dist/preload.d.ts",
23
+ "default": "./dist/preload.js"
24
+ },
25
+ "require": {
26
+ "types": "./dist/preload.d.cts",
27
+ "default": "./dist/preload.cjs"
28
+ }
29
+ },
30
+ "./package.json": "./package.json"
31
+ },
32
+ "main": "./dist/index.cjs",
33
+ "module": "./dist/index.js",
34
+ "types": "./dist/index.d.ts",
35
+ "typesVersions": {
36
+ "*": {
37
+ "preload": [
38
+ "./dist/preload.d.ts"
39
+ ]
40
+ }
41
+ },
42
+ "files": [
43
+ "dist/**"
44
+ ],
45
+ "engines": {
46
+ "node": ">=18.0.0"
47
+ },
48
+ "peerDependencies": {
49
+ "electron": ">=30"
50
+ },
51
+ "dependencies": {
52
+ "@moonbase.sh/licensing": "3.4.0"
53
+ },
54
+ "devDependencies": {
55
+ "@types/jsonwebtoken": "^9.0.9",
56
+ "@types/node": "^18.19.50",
57
+ "cross-fetch": "^3.1.5",
58
+ "electron": "^39.8.10",
59
+ "jsonwebtoken": "^9.0.2",
60
+ "rimraf": "^5.0.10",
61
+ "tsup": "^8.5.0",
62
+ "typescript": "~5.8.3",
63
+ "vitest": "^2.1.4"
64
+ },
65
+ "scripts": {
66
+ "build": "rimraf dist && tsup",
67
+ "dev": "tsup --watch",
68
+ "type-check": "tsc --noEmit -p tsconfig.typecheck.json",
69
+ "lint": "eslint . --cache --cache-location node_modules/.cache/eslint/ --cache-strategy content",
70
+ "lint:fix": "eslint . --cache --cache-location node_modules/.cache/eslint/ --cache-strategy content --fix",
71
+ "test": "vitest run",
72
+ "test:watch": "vitest",
73
+ "test:integration": "TEST_INTEGRATION=true vitest run"
74
+ }
75
+ }