create-gtkx 1.6.0 → 2.0.0-beta.10

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.
@@ -3,21 +3,11 @@ import { defineConfig } from "@gtkx/config";
3
3
  export default defineConfig({
4
4
  applicationId: "<%= applicationId %>",
5
5
  applicationIcon: "data/icons",
6
- future: {
7
- v2ByteArrays: true,
8
- v2ValueReturns: true,
9
- v2FinishResults: true,
10
- v2InoutReturns: true,
11
- v2ResourceImports: true,
12
- v2DefaultLibraries: true,
13
- v2TreeShaking: true,
14
- },
15
6
  deploy: {
16
- name: "<%= title %>",
17
- summary: "A GTK4 application built with GTKX",
7
+ name: <%- sourceStringLiteral(displayName) %>,
8
+ summary: "A GNOME application built with GTKX",
18
9
  description: [
19
- "<%= title %> is a GTK4 and Adwaita application built with GTKX, which renders native GObject "
20
- + "widgets from React. Replace this paragraph with a description of what your application does.",
10
+ <%- sourceStringLiteral(`${displayName} is a GNOME application built with GTKX on Adwaita and GTK4, with native GObject widgets rendered from React. Replace this paragraph with a description of what your application does.`) %>,
21
11
  ],
22
12
  categories: ["Utility"],
23
13
  },
@@ -2,7 +2,7 @@
2
2
  "name": "<%= name %>",
3
3
  "version": "0.0.1",
4
4
  "private": true,
5
- "description": "A GTK4 application built with GTKX",
5
+ "description": "A GNOME application built with GTKX",
6
6
  "license": "MIT",
7
7
  <% if (developerEmail) { -%>
8
8
  "author": <%- sourceStringLiteral(`${developerName} <${developerEmail}>`) %>,
@@ -10,6 +10,9 @@
10
10
  "author": <%- sourceStringLiteral(developerName) %>,
11
11
  <% } -%>
12
12
  "type": "module",
13
+ "engines": {
14
+ "node": ">=26.7.0"
15
+ },
13
16
  "scripts": {
14
17
  "dev": "gtkx dev",
15
18
  "build": "gtkx build",
@@ -1,5 +1,6 @@
1
1
  import * as Gtk from "@gtkx/gi/gtk";
2
- import { GtkApplication, GtkApplicationWindow, GtkBox, GtkButton, GtkLabel } from "@gtkx/jsx/gtk";
2
+ import { AdwApplication, AdwApplicationWindow, AdwHeaderBar, AdwToolbarView } from "@gtkx/jsx/adw";
3
+ import { GtkBox, GtkButton, GtkLabel } from "@gtkx/jsx/gtk";
3
4
  import { quit } from "@gtkx/react";
4
5
  import { useState } from "react";
5
6
 
@@ -7,38 +8,40 @@ const MainWindow = () => {
7
8
  const [count, setCount] = useState(0);
8
9
 
9
10
  return (
10
- <GtkApplicationWindow
11
- title="<%= title %>"
11
+ <AdwApplicationWindow
12
+ title={<%- sourceStringLiteral(displayName) %>}
12
13
  defaultWidth={400}
13
14
  defaultHeight={300}
14
15
  onCloseRequest={quit}
15
16
  >
16
- <GtkBox
17
- orientation={Gtk.Orientation.VERTICAL}
18
- spacing={20}
19
- marginTop={40}
20
- marginBottom={40}
21
- marginStart={40}
22
- marginEnd={40}
23
- valign={Gtk.Align.CENTER}
24
- halign={Gtk.Align.CENTER}
25
- >
26
- <GtkLabel cssClasses={["title-1"]}>Welcome to GTKX!</GtkLabel>
27
- <GtkLabel cssClasses={["title-2"]}>Count: {count}</GtkLabel>
28
- <GtkButton
29
- label="Increment"
30
- onClicked={() => setCount((c) => c + 1)}
31
- cssClasses={["suggested-action", "pill"]}
32
- />
33
- </GtkBox>
34
- </GtkApplicationWindow>
17
+ <AdwToolbarView topBar={<AdwHeaderBar />}>
18
+ <GtkBox
19
+ orientation={Gtk.Orientation.VERTICAL}
20
+ spacing={20}
21
+ marginTop={40}
22
+ marginBottom={40}
23
+ marginStart={40}
24
+ marginEnd={40}
25
+ valign={Gtk.Align.CENTER}
26
+ halign={Gtk.Align.CENTER}
27
+ >
28
+ <GtkLabel cssClasses={["title-1"]}>Welcome to GTKX!</GtkLabel>
29
+ <GtkLabel cssClasses={["title-2"]}>Count: {count}</GtkLabel>
30
+ <GtkButton
31
+ label="Increment"
32
+ onClicked={() => setCount((c) => c + 1)}
33
+ cssClasses={["suggested-action", "pill"]}
34
+ />
35
+ </GtkBox>
36
+ </AdwToolbarView>
37
+ </AdwApplicationWindow>
35
38
  );
36
39
  };
37
40
 
38
41
  export const App = () => (
39
- <GtkApplication>
42
+ <AdwApplication>
40
43
  <MainWindow />
41
- </GtkApplication>
44
+ </AdwApplication>
42
45
  );
43
46
 
44
47
  export default App;
package/src/templates.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { sortStrings, sourceStringLiteral } from "@gtkx/utils";
1
+ import { sortStrings, sourceStringLiteral, toPosixPath } from "@gtkx/utils";
2
2
  import ejs from "ejs";
3
3
  import { readdirSync } from "node:fs";
4
4
  import { join } from "node:path";
@@ -6,7 +6,7 @@ import { join } from "node:path";
6
6
  type TemplateContext = {
7
7
  name: string;
8
8
  applicationId: string;
9
- title: string;
9
+ displayName: string;
10
10
  shouldIncludeTesting: boolean;
11
11
  isTypescript: boolean;
12
12
  importExtension: string;
@@ -14,20 +14,18 @@ type TemplateContext = {
14
14
  developerEmail: string | null;
15
15
  };
16
16
 
17
- const getTemplatesDir = (): string => {
18
- return join(import.meta.dirname, "templates");
19
- };
17
+ const TEMPLATES_DIR = join(import.meta.dirname, "templates");
20
18
 
21
19
  const listTemplates = (): string[] =>
22
20
  sortStrings(
23
- readdirSync(getTemplatesDir(), { recursive: true, withFileTypes: true })
21
+ readdirSync(TEMPLATES_DIR, { recursive: true, withFileTypes: true })
24
22
  .filter((entry) => entry.isFile())
25
23
  .map((entry) => join(entry.parentPath, entry.name))
26
- .map((absolute) => absolute.slice(getTemplatesDir().length + 1).replaceAll(/[/\\]/g, "/"))
24
+ .map((absolute) => toPosixPath(absolute.slice(TEMPLATES_DIR.length + 1)))
27
25
  .map((relative) => relative.replace(/\.ejs$/, "")),
28
26
  );
29
27
 
30
28
  const renderFile = async (templateName: string, context: TemplateContext): Promise<string> =>
31
- ejs.renderFile(join(getTemplatesDir(), `${templateName}.ejs`), { ...context, sourceStringLiteral });
29
+ ejs.renderFile(join(TEMPLATES_DIR, `${templateName}.ejs`), { ...context, sourceStringLiteral });
32
30
 
33
31
  export { listTemplates, renderFile, type TemplateContext };