janela 0.18.0 → 0.19.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/templates/main.ts CHANGED
@@ -9,8 +9,27 @@
9
9
  // against it; see `janela init --template vue`.
10
10
 
11
11
  import type { JanelaApp } from "janela/host";
12
+ import { menuItem, menuSeparator, submenu, predefined } from "janela/host";
12
13
 
13
14
  export function setup(app: JanelaApp): void {
15
+ // A menu bar. Items carry their own handlers — there are no ids to declare
16
+ // or match — and `predefined` is the platform's own behaviour, callable like
17
+ // any other function.
18
+ //
19
+ // On macOS the standard submenus (App, Edit, View, Window) are kept around
20
+ // whatever you declare here, so this adds File without costing the app ⌘Q or
21
+ // ⌘V. Windows and Linux need no such floor: their editing keys belong to the
22
+ // webview, and Alt+F4 to the window manager.
23
+ app.setMenu([
24
+ submenu("File", [
25
+ menuItem("Say hello", "CmdOrCtrl+G", () => {
26
+ console.log("[host] hello from the menu");
27
+ }),
28
+ menuSeparator(),
29
+ menuItem("Close", "CmdOrCtrl+W", () => predefined.close()),
30
+ ]),
31
+ ]);
32
+
14
33
  app.command("greet", (args) => {
15
34
  const a = args as { name: string };
16
35
  return "Hello, " + a.name + "! You've been greeted from a native TypeScript binary.";
@@ -0,0 +1,7 @@
1
+ /// <reference types="vite/client" />
2
+ //
3
+ // Declares the modules Vite lets you import that TypeScript otherwise knows
4
+ // nothing about — `./styles.css` most immediately, plus `import.meta.env` and
5
+ // asset imports. Without it a side-effect CSS import is an error in any editor
6
+ // running `noUncheckedSideEffectImports` (TypeScript 5.6+), which is exactly
7
+ // what a red squiggle on line 1 of main.ts turns out to be.
@@ -10,6 +10,7 @@
10
10
  // returns `null`; every command answers the page's promise with a value.
11
11
 
12
12
  import type { JanelaApp } from "janela/host";
13
+ import { menuItem, menuSeparator, submenu, predefined } from "janela/host";
13
14
 
14
15
  /** Every command this app answers. Declared once; the page checks against it. */
15
16
  export type AppCommands = {
@@ -30,6 +31,24 @@ export type App = JanelaApp<AppCommands, AppEvents>;
30
31
  // name must be one of the declared ones, `args` is inferred from it, and the
31
32
  // return value has to match.
32
33
  export function setup(app: App): void {
34
+ // A menu bar. Items carry their own handlers — there are no ids to declare
35
+ // or match — and `predefined` is the platform's own behaviour, callable like
36
+ // any other function.
37
+ //
38
+ // On macOS the standard submenus (App, Edit, View, Window) are kept around
39
+ // whatever you declare here, so this adds File without costing the app ⌘Q or
40
+ // ⌘V. Windows and Linux need no such floor: their editing keys belong to the
41
+ // webview, and Alt+F4 to the window manager.
42
+ app.setMenu([
43
+ submenu("File", [
44
+ menuItem("Say hello", "CmdOrCtrl+G", () => {
45
+ console.log("[host] hello from the menu");
46
+ }),
47
+ menuSeparator(),
48
+ menuItem("Close", "CmdOrCtrl+W", () => predefined.close()),
49
+ ]),
50
+ ]);
51
+
33
52
  app.command("greet", (args) => {
34
53
  return "Hello, " + args.name + "! You've been greeted from a native TypeScript binary.";
35
54
  });
@@ -18,6 +18,7 @@
18
18
  "verbatimModuleSyntax": true
19
19
  },
20
20
  "include": [
21
+ "src/**/*.d.ts",
21
22
  "src/**/*.ts",
22
23
  "src/**/*.tsx",
23
24
  "src-host/**/*.ts"
@@ -0,0 +1,7 @@
1
+ /// <reference types="vite/client" />
2
+ //
3
+ // Declares the modules Vite lets you import that TypeScript otherwise knows
4
+ // nothing about — `./styles.css` most immediately, plus `import.meta.env` and
5
+ // asset imports. Without it a side-effect CSS import is an error in any editor
6
+ // running `noUncheckedSideEffectImports` (TypeScript 5.6+), which is exactly
7
+ // what a red squiggle on line 1 of main.ts turns out to be.
@@ -10,6 +10,7 @@
10
10
  // returns `null`; every command answers the page's promise with a value.
11
11
 
12
12
  import type { JanelaApp } from "janela/host";
13
+ import { menuItem, menuSeparator, submenu, predefined } from "janela/host";
13
14
 
14
15
  /** Every command this app answers. Declared once; the page checks against it. */
15
16
  export type AppCommands = {
@@ -30,6 +31,24 @@ export type App = JanelaApp<AppCommands, AppEvents>;
30
31
  // name must be one of the declared ones, `args` is inferred from it, and the
31
32
  // return value has to match.
32
33
  export function setup(app: App): void {
34
+ // A menu bar. Items carry their own handlers — there are no ids to declare
35
+ // or match — and `predefined` is the platform's own behaviour, callable like
36
+ // any other function.
37
+ //
38
+ // On macOS the standard submenus (App, Edit, View, Window) are kept around
39
+ // whatever you declare here, so this adds File without costing the app ⌘Q or
40
+ // ⌘V. Windows and Linux need no such floor: their editing keys belong to the
41
+ // webview, and Alt+F4 to the window manager.
42
+ app.setMenu([
43
+ submenu("File", [
44
+ menuItem("Say hello", "CmdOrCtrl+G", () => {
45
+ console.log("[host] hello from the menu");
46
+ }),
47
+ menuSeparator(),
48
+ menuItem("Close", "CmdOrCtrl+W", () => predefined.close()),
49
+ ]),
50
+ ]);
51
+
33
52
  app.command("greet", (args) => {
34
53
  return "Hello, " + args.name + "! You've been greeted from a native TypeScript binary.";
35
54
  });
@@ -19,6 +19,7 @@
19
19
  "verbatimModuleSyntax": true
20
20
  },
21
21
  "include": [
22
+ "src/**/*.d.ts",
22
23
  "src/**/*.ts",
23
24
  "src/**/*.tsx",
24
25
  "src-host/**/*.ts"
@@ -0,0 +1,7 @@
1
+ /// <reference types="vite/client" />
2
+ //
3
+ // Declares the modules Vite lets you import that TypeScript otherwise knows
4
+ // nothing about — `./styles.css` most immediately, plus `import.meta.env` and
5
+ // asset imports. Without it a side-effect CSS import is an error in any editor
6
+ // running `noUncheckedSideEffectImports` (TypeScript 5.6+), which is exactly
7
+ // what a red squiggle on line 1 of main.ts turns out to be.
@@ -10,6 +10,7 @@
10
10
  // returns `null`; every command answers the page's promise with a value.
11
11
 
12
12
  import type { JanelaApp } from "janela/host";
13
+ import { menuItem, menuSeparator, submenu, predefined } from "janela/host";
13
14
 
14
15
  /** Every command this app answers. Declared once; the page checks against it. */
15
16
  export type AppCommands = {
@@ -30,6 +31,24 @@ export type App = JanelaApp<AppCommands, AppEvents>;
30
31
  // name must be one of the declared ones, `args` is inferred from it, and the
31
32
  // return value has to match.
32
33
  export function setup(app: App): void {
34
+ // A menu bar. Items carry their own handlers — there are no ids to declare
35
+ // or match — and `predefined` is the platform's own behaviour, callable like
36
+ // any other function.
37
+ //
38
+ // On macOS the standard submenus (App, Edit, View, Window) are kept around
39
+ // whatever you declare here, so this adds File without costing the app ⌘Q or
40
+ // ⌘V. Windows and Linux need no such floor: their editing keys belong to the
41
+ // webview, and Alt+F4 to the window manager.
42
+ app.setMenu([
43
+ submenu("File", [
44
+ menuItem("Say hello", "CmdOrCtrl+G", () => {
45
+ console.log("[host] hello from the menu");
46
+ }),
47
+ menuSeparator(),
48
+ menuItem("Close", "CmdOrCtrl+W", () => predefined.close()),
49
+ ]),
50
+ ]);
51
+
33
52
  app.command("greet", (args) => {
34
53
  return "Hello, " + args.name + "! You've been greeted from a native TypeScript binary.";
35
54
  });
@@ -16,6 +16,7 @@
16
16
  "verbatimModuleSyntax": true
17
17
  },
18
18
  "include": [
19
+ "src/**/*.d.ts",
19
20
  "src/**/*.ts",
20
21
  "src/**/*.svelte",
21
22
  "src-host/**/*.ts"
@@ -0,0 +1,7 @@
1
+ /// <reference types="vite/client" />
2
+ //
3
+ // Declares the modules Vite lets you import that TypeScript otherwise knows
4
+ // nothing about — `./styles.css` most immediately, plus `import.meta.env` and
5
+ // asset imports. Without it a side-effect CSS import is an error in any editor
6
+ // running `noUncheckedSideEffectImports` (TypeScript 5.6+), which is exactly
7
+ // what a red squiggle on line 1 of main.ts turns out to be.
@@ -10,6 +10,7 @@
10
10
  // returns `null`; every command answers the page's promise with a value.
11
11
 
12
12
  import type { JanelaApp } from "janela/host";
13
+ import { menuItem, menuSeparator, submenu, predefined } from "janela/host";
13
14
 
14
15
  /** Every command this app answers. Declared once; the page checks against it. */
15
16
  export type AppCommands = {
@@ -30,6 +31,24 @@ export type App = JanelaApp<AppCommands, AppEvents>;
30
31
  // name must be one of the declared ones, `args` is inferred from it, and the
31
32
  // return value has to match.
32
33
  export function setup(app: App): void {
34
+ // A menu bar. Items carry their own handlers — there are no ids to declare
35
+ // or match — and `predefined` is the platform's own behaviour, callable like
36
+ // any other function.
37
+ //
38
+ // On macOS the standard submenus (App, Edit, View, Window) are kept around
39
+ // whatever you declare here, so this adds File without costing the app ⌘Q or
40
+ // ⌘V. Windows and Linux need no such floor: their editing keys belong to the
41
+ // webview, and Alt+F4 to the window manager.
42
+ app.setMenu([
43
+ submenu("File", [
44
+ menuItem("Say hello", "CmdOrCtrl+G", () => {
45
+ console.log("[host] hello from the menu");
46
+ }),
47
+ menuSeparator(),
48
+ menuItem("Close", "CmdOrCtrl+W", () => predefined.close()),
49
+ ]),
50
+ ]);
51
+
33
52
  app.command("greet", (args) => {
34
53
  return "Hello, " + args.name + "! You've been greeted from a native TypeScript binary.";
35
54
  });
@@ -16,6 +16,7 @@
16
16
  "verbatimModuleSyntax": true
17
17
  },
18
18
  "include": [
19
+ "src/**/*.d.ts",
19
20
  "src/**/*.ts",
20
21
  "src/**/*.vue",
21
22
  "src-host/**/*.ts"