@gtkx/cli 2.0.0-beta.6 → 2.0.0-beta.8

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.
Files changed (205) hide show
  1. package/README.md +43 -40
  2. package/dist/cli.js +1 -1
  3. package/dist/cli.js.map +1 -1
  4. package/dist/codegen/freshness.d.ts.map +1 -1
  5. package/dist/codegen/freshness.js +5 -1
  6. package/dist/codegen/freshness.js.map +1 -1
  7. package/dist/commands/deploy.d.ts +4 -0
  8. package/dist/commands/deploy.d.ts.map +1 -1
  9. package/dist/commands/deploy.js +6 -0
  10. package/dist/commands/deploy.js.map +1 -1
  11. package/dist/deploy/download.d.ts +7 -3
  12. package/dist/deploy/download.d.ts.map +1 -1
  13. package/dist/deploy/download.js +19 -15
  14. package/dist/deploy/download.js.map +1 -1
  15. package/dist/deploy/native-addon.d.ts +5 -0
  16. package/dist/deploy/native-addon.d.ts.map +1 -0
  17. package/dist/deploy/native-addon.js +134 -0
  18. package/dist/deploy/native-addon.js.map +1 -0
  19. package/dist/deploy/node-runtime/download.js +2 -2
  20. package/dist/deploy/node-runtime/download.js.map +1 -1
  21. package/dist/deploy/node-runtime/elf.d.ts +3 -1
  22. package/dist/deploy/node-runtime/elf.d.ts.map +1 -1
  23. package/dist/deploy/node-runtime/elf.js +3 -1
  24. package/dist/deploy/node-runtime/elf.js.map +1 -1
  25. package/dist/deploy/node-runtime/index.d.ts.map +1 -1
  26. package/dist/deploy/node-runtime/index.js +14 -2
  27. package/dist/deploy/node-runtime/index.js.map +1 -1
  28. package/dist/deploy/payload/stage.d.ts +2 -1
  29. package/dist/deploy/payload/stage.d.ts.map +1 -1
  30. package/dist/deploy/payload/stage.js +22 -2
  31. package/dist/deploy/payload/stage.js.map +1 -1
  32. package/dist/deploy/run-deploy.d.ts +1 -0
  33. package/dist/deploy/run-deploy.d.ts.map +1 -1
  34. package/dist/deploy/run-deploy.js +135 -79
  35. package/dist/deploy/run-deploy.js.map +1 -1
  36. package/dist/deploy/settings/arch.d.ts +9 -3
  37. package/dist/deploy/settings/arch.d.ts.map +1 -1
  38. package/dist/deploy/settings/arch.js +27 -6
  39. package/dist/deploy/settings/arch.js.map +1 -1
  40. package/dist/deploy/settings/index.d.ts +2 -1
  41. package/dist/deploy/settings/index.d.ts.map +1 -1
  42. package/dist/deploy/settings/index.js +2 -1
  43. package/dist/deploy/settings/index.js.map +1 -1
  44. package/dist/deploy/settings/libraries.d.ts.map +1 -1
  45. package/dist/deploy/settings/libraries.js +2 -1
  46. package/dist/deploy/settings/libraries.js.map +1 -1
  47. package/dist/deploy/settings/paths.d.ts +2 -1
  48. package/dist/deploy/settings/paths.d.ts.map +1 -1
  49. package/dist/deploy/settings/paths.js +6 -5
  50. package/dist/deploy/settings/paths.js.map +1 -1
  51. package/dist/deploy/targets/appimage.d.ts.map +1 -1
  52. package/dist/deploy/targets/appimage.js +1 -0
  53. package/dist/deploy/targets/appimage.js.map +1 -1
  54. package/dist/deploy/targets/flatpak-pnpm.js +4 -4
  55. package/dist/deploy/targets/flatpak-pnpm.js.map +1 -1
  56. package/dist/deploy/targets/flatpak-source.d.ts.map +1 -1
  57. package/dist/deploy/targets/flatpak-source.js +2 -0
  58. package/dist/deploy/targets/flatpak-source.js.map +1 -1
  59. package/dist/deploy/targets/flatpak.d.ts.map +1 -1
  60. package/dist/deploy/targets/flatpak.js +1 -0
  61. package/dist/deploy/targets/flatpak.js.map +1 -1
  62. package/dist/deploy/targets/nfpm-target.d.ts.map +1 -1
  63. package/dist/deploy/targets/nfpm-target.js +1 -0
  64. package/dist/deploy/targets/nfpm-target.js.map +1 -1
  65. package/dist/deploy/types.d.ts +4 -2
  66. package/dist/deploy/types.d.ts.map +1 -1
  67. package/dist/deploy/types.js.map +1 -1
  68. package/dist/deploy/vendored/appimagetool.js +2 -2
  69. package/dist/deploy/vendored/appimagetool.js.map +1 -1
  70. package/dist/deploy/vendored/nfpm.js +1 -1
  71. package/dist/deploy/vendored/nfpm.js.map +1 -1
  72. package/dist/dev/font-dir.d.ts +3 -0
  73. package/dist/dev/font-dir.d.ts.map +1 -0
  74. package/dist/dev/font-dir.js +9 -0
  75. package/dist/dev/font-dir.js.map +1 -0
  76. package/dist/dev/runner-main.d.ts.map +1 -1
  77. package/dist/dev/runner-main.js +2 -0
  78. package/dist/dev/runner-main.js.map +1 -1
  79. package/dist/dev/runner.d.ts.map +1 -1
  80. package/dist/dev/runner.js +19 -6
  81. package/dist/dev/runner.js.map +1 -1
  82. package/dist/internal/agent-rules.d.ts.map +1 -1
  83. package/dist/internal/agent-rules.js +6 -2
  84. package/dist/internal/agent-rules.js.map +1 -1
  85. package/dist/internal/banner.d.ts.map +1 -1
  86. package/dist/internal/banner.js +3 -0
  87. package/dist/internal/banner.js.map +1 -1
  88. package/dist/internal/font-path.d.ts +4 -0
  89. package/dist/internal/font-path.d.ts.map +1 -0
  90. package/dist/internal/font-path.js +12 -0
  91. package/dist/internal/font-path.js.map +1 -0
  92. package/dist/internal/font-staging.d.ts +6 -0
  93. package/dist/internal/font-staging.d.ts.map +1 -0
  94. package/dist/internal/font-staging.js +92 -0
  95. package/dist/internal/font-staging.js.map +1 -0
  96. package/dist/internal/source-imports.d.ts +2 -1
  97. package/dist/internal/source-imports.d.ts.map +1 -1
  98. package/dist/internal/source-imports.js +8 -3
  99. package/dist/internal/source-imports.js.map +1 -1
  100. package/dist/internal/xdg-banner.d.ts +4 -0
  101. package/dist/internal/xdg-banner.d.ts.map +1 -0
  102. package/dist/internal/xdg-banner.js +11 -0
  103. package/dist/internal/xdg-banner.js.map +1 -0
  104. package/dist/internal/xdg-data-dirs.d.ts +2 -1
  105. package/dist/internal/xdg-data-dirs.d.ts.map +1 -1
  106. package/dist/internal/xdg-data-dirs.js +1 -1
  107. package/dist/internal/xdg-data-dirs.js.map +1 -1
  108. package/dist/settings/schema.d.ts.map +1 -1
  109. package/dist/settings/schema.js +1 -6
  110. package/dist/settings/schema.js.map +1 -1
  111. package/dist/vite-plugins/asset-extensions.d.ts.map +1 -1
  112. package/dist/vite-plugins/asset-extensions.js +2 -0
  113. package/dist/vite-plugins/asset-extensions.js.map +1 -1
  114. package/dist/vite-plugins/asset-imports.d.ts.map +1 -1
  115. package/dist/vite-plugins/asset-imports.js +7 -2
  116. package/dist/vite-plugins/asset-imports.js.map +1 -1
  117. package/dist/vite-plugins/asset-specifier.d.ts +5 -1
  118. package/dist/vite-plugins/asset-specifier.d.ts.map +1 -1
  119. package/dist/vite-plugins/asset-specifier.js +10 -1
  120. package/dist/vite-plugins/asset-specifier.js.map +1 -1
  121. package/dist/vite-plugins/css.d.ts.map +1 -1
  122. package/dist/vite-plugins/css.js +3 -2
  123. package/dist/vite-plugins/css.js.map +1 -1
  124. package/dist/vite-plugins/font-name.d.ts +3 -0
  125. package/dist/vite-plugins/font-name.d.ts.map +1 -0
  126. package/dist/vite-plugins/font-name.js +406 -0
  127. package/dist/vite-plugins/font-name.js.map +1 -0
  128. package/dist/vite-plugins/font-worker-env.d.ts +4 -0
  129. package/dist/vite-plugins/font-worker-env.d.ts.map +1 -0
  130. package/dist/vite-plugins/font-worker-env.js +19 -0
  131. package/dist/vite-plugins/font-worker-env.js.map +1 -0
  132. package/dist/vite-plugins/font.d.ts +4 -0
  133. package/dist/vite-plugins/font.d.ts.map +1 -0
  134. package/dist/vite-plugins/font.js +99 -0
  135. package/dist/vite-plugins/font.js.map +1 -0
  136. package/dist/vite-plugins/icons.d.ts.map +1 -1
  137. package/dist/vite-plugins/icons.js +5 -10
  138. package/dist/vite-plugins/icons.js.map +1 -1
  139. package/dist/vite-plugins/index.d.ts.map +1 -1
  140. package/dist/vite-plugins/index.js +2 -0
  141. package/dist/vite-plugins/index.js.map +1 -1
  142. package/dist/vite-plugins/react-compiler.js +2 -2
  143. package/dist/vite-plugins/react-compiler.js.map +1 -1
  144. package/dist/vite-plugins/resources.js +3 -3
  145. package/dist/vite-plugins/resources.js.map +1 -1
  146. package/dist/vite-plugins/settings-worker-env.js +2 -2
  147. package/dist/vite-plugins/settings-worker-env.js.map +1 -1
  148. package/dist/vite-plugins/store-links.d.ts.map +1 -1
  149. package/dist/vite-plugins/store-links.js +2 -1
  150. package/dist/vite-plugins/store-links.js.map +1 -1
  151. package/dist/vite-plugins/undeclared-library.js +5 -5
  152. package/dist/vite-plugins/undeclared-library.js.map +1 -1
  153. package/dist/vitest-plugin.d.ts.map +1 -1
  154. package/dist/vitest-plugin.js +2 -0
  155. package/dist/vitest-plugin.js.map +1 -1
  156. package/env.d.ts +9 -0
  157. package/package.json +17 -15
  158. package/src/cli.ts +1 -1
  159. package/src/codegen/freshness.ts +5 -1
  160. package/src/commands/deploy.ts +6 -0
  161. package/src/deploy/download.ts +33 -17
  162. package/src/deploy/native-addon.ts +183 -0
  163. package/src/deploy/node-runtime/download.ts +2 -2
  164. package/src/deploy/node-runtime/elf.ts +4 -1
  165. package/src/deploy/node-runtime/index.ts +24 -4
  166. package/src/deploy/payload/stage.ts +34 -2
  167. package/src/deploy/run-deploy.ts +203 -93
  168. package/src/deploy/settings/arch.ts +40 -8
  169. package/src/deploy/settings/index.ts +4 -1
  170. package/src/deploy/settings/libraries.ts +2 -1
  171. package/src/deploy/settings/paths.ts +8 -6
  172. package/src/deploy/targets/appimage.ts +1 -0
  173. package/src/deploy/targets/flatpak-pnpm.ts +4 -4
  174. package/src/deploy/targets/flatpak-source.ts +2 -0
  175. package/src/deploy/targets/flatpak.ts +1 -0
  176. package/src/deploy/targets/nfpm-target.ts +1 -0
  177. package/src/deploy/types.ts +4 -1
  178. package/src/deploy/vendored/appimagetool.ts +2 -2
  179. package/src/deploy/vendored/nfpm.ts +1 -1
  180. package/src/dev/font-dir.ts +11 -0
  181. package/src/dev/runner-main.ts +2 -0
  182. package/src/dev/runner.ts +24 -6
  183. package/src/internal/agent-rules.ts +6 -2
  184. package/src/internal/banner.ts +4 -0
  185. package/src/internal/font-path.ts +15 -0
  186. package/src/internal/font-staging.ts +129 -0
  187. package/src/internal/source-imports.ts +18 -3
  188. package/src/internal/xdg-banner.ts +13 -0
  189. package/src/internal/xdg-data-dirs.ts +1 -1
  190. package/src/settings/schema.ts +1 -8
  191. package/src/vite-plugins/asset-extensions.ts +2 -0
  192. package/src/vite-plugins/asset-imports.ts +9 -1
  193. package/src/vite-plugins/asset-specifier.ts +17 -0
  194. package/src/vite-plugins/css.ts +4 -2
  195. package/src/vite-plugins/font-name.ts +582 -0
  196. package/src/vite-plugins/font-worker-env.ts +25 -0
  197. package/src/vite-plugins/font.ts +165 -0
  198. package/src/vite-plugins/icons.ts +6 -12
  199. package/src/vite-plugins/index.ts +2 -0
  200. package/src/vite-plugins/react-compiler.ts +2 -2
  201. package/src/vite-plugins/resources.ts +3 -3
  202. package/src/vite-plugins/settings-worker-env.ts +2 -2
  203. package/src/vite-plugins/store-links.ts +2 -1
  204. package/src/vite-plugins/undeclared-library.ts +5 -5
  205. package/src/vitest-plugin.ts +2 -0
@@ -0,0 +1,165 @@
1
+ import type { Plugin, Rollup } from "vite";
2
+ import { readFileSync } from "node:fs";
3
+ import { parseSync } from "vite";
4
+ import type { AssetEmitter } from "./asset-emitter.js";
5
+ import { prependBanner } from "../internal/banner.js";
6
+ import { fontFileName, FONTS_DIR } from "../internal/font-path.js";
7
+ import { stagedFontStatus } from "../internal/font-staging.js";
8
+ import { sourceLanguage } from "../internal/source-imports.js";
9
+ import { xdgDataDirsBanner } from "../internal/xdg-banner.js";
10
+ import { parseFontSpecifier } from "./asset-specifier.js";
11
+ import { fontFamilyNames } from "./font-name.js";
12
+ import { stripQuery } from "./strip-query.js";
13
+ import { createVirtualNamespace } from "./virtual-module.js";
14
+
15
+ type PluginState = {
16
+ isBuild: boolean;
17
+ root: string;
18
+ emitted: Set<string>;
19
+ importers: Map<string, string>;
20
+ };
21
+
22
+ type ResolveContext = Parameters<typeof resolveToVirtual>[0];
23
+ type ResolveRequest = Parameters<typeof resolveToVirtual>[1];
24
+
25
+ type RetainedFontModuleId = {
26
+ id: string;
27
+ moduleSideEffects: true;
28
+ };
29
+
30
+ type LoadContext = AssetEmitter & {
31
+ addWatchFile: (file: string) => void;
32
+ error: (message: string) => never;
33
+ };
34
+
35
+ const VIRTUAL_PREFIX = "\0gtkx-font:";
36
+ const { isVirtual, fromVirtualId, resolveToVirtual } = createVirtualNamespace(VIRTUAL_PREFIX);
37
+
38
+ const unreadableFontError = (filePath: string): string =>
39
+ `Cannot read a font family name from ${filePath}; ?font expects a TrueType, OpenType, ` +
40
+ "TrueType Collection, WOFF, or WOFF2 font";
41
+
42
+ const unstagedFontError = (filePath: string, importer: string): string =>
43
+ `${filePath} was not staged before the toolkit started, so ${importer} would resolve its family to a ` +
44
+ "fallback font. Fonts are staged from ?font imports found in source files under the project root; move " +
45
+ "the import there, or restart to pick it up.";
46
+
47
+ const resolveFontId = async (
48
+ ctx: ResolveContext,
49
+ state: PluginState,
50
+ request: ResolveRequest,
51
+ ): Promise<RetainedFontModuleId | undefined> => {
52
+ if (parseFontSpecifier(request.source) === null) {
53
+ return undefined;
54
+ }
55
+
56
+ const virtualId = await resolveToVirtual(ctx, request);
57
+
58
+ if (virtualId === undefined) {
59
+ return undefined;
60
+ }
61
+
62
+ state.importers.set(virtualId, request.importer ?? state.root);
63
+
64
+ return { id: virtualId, moduleSideEffects: true };
65
+ };
66
+
67
+ const emitFont = (ctx: LoadContext, state: PluginState, filePath: string, content: Buffer): void => {
68
+ const fileName = `${FONTS_DIR}/${fontFileName(filePath, content)}`;
69
+
70
+ if (state.emitted.has(fileName)) {
71
+ return;
72
+ }
73
+
74
+ state.emitted.add(fileName);
75
+ ctx.emitFile({ type: "asset", fileName, source: content });
76
+ };
77
+
78
+ const loadFontModule = (ctx: LoadContext, state: PluginState, id: string): string | undefined => {
79
+ if (!isVirtual(id)) {
80
+ return undefined;
81
+ }
82
+
83
+ const filePath = stripQuery(fromVirtualId(id));
84
+ const content = readFileSync(filePath);
85
+ const [family] = fontFamilyNames(content);
86
+
87
+ if (family === undefined) {
88
+ return ctx.error(unreadableFontError(filePath));
89
+ }
90
+
91
+ ctx.addWatchFile(filePath);
92
+
93
+ if (state.isBuild) {
94
+ emitFont(ctx, state, filePath, content);
95
+ } else if (stagedFontStatus(filePath, content) === "absent") {
96
+ return ctx.error(unstagedFontError(filePath, state.importers.get(id) ?? state.root));
97
+ }
98
+
99
+ return `export default ${JSON.stringify(family)};`;
100
+ };
101
+
102
+ const hasSideEffectFontImport = (code: string, id: string): boolean => {
103
+ const lang = sourceLanguage(stripQuery(id));
104
+
105
+ if (lang === undefined || !code.includes("?font")) {
106
+ return false;
107
+ }
108
+
109
+ const parsed = parseSync(id, code, { lang });
110
+
111
+ if (parsed.errors.length > 0) {
112
+ return false;
113
+ }
114
+
115
+ return parsed.module.staticImports.some(
116
+ (statement) => statement.entries.length === 0 && parseFontSpecifier(statement.moduleRequest.value) !== null,
117
+ );
118
+ };
119
+
120
+ const retainSideEffectFontImport = (
121
+ code: string,
122
+ id: string,
123
+ ): { code: string; moduleSideEffects: true } | null =>
124
+ hasSideEffectFontImport(code, id)
125
+ ? { code, moduleSideEffects: true }
126
+ : null;
127
+
128
+ const fontBanner = (state: PluginState) => (chunk: Rollup.RenderedChunk): string =>
129
+ state.emitted.size === 0 ? "" : xdgDataDirsBanner(chunk);
130
+
131
+ function gtkxFont(): Plugin {
132
+ const state: PluginState = { isBuild: false, root: "", emitted: new Set(), importers: new Map() };
133
+
134
+ return {
135
+ name: "gtkx:font",
136
+ enforce: "pre",
137
+
138
+ configResolved(config) {
139
+ state.isBuild = config.command === "build";
140
+ state.root = config.root;
141
+ },
142
+
143
+ resolveId(source, importer, options) {
144
+ return resolveFontId(this, state, { source, importer, options });
145
+ },
146
+
147
+ load(id) {
148
+ return loadFontModule(this, state, id);
149
+ },
150
+
151
+ transform(code, id) {
152
+ return retainSideEffectFontImport(code, id);
153
+ },
154
+
155
+ outputOptions(options) {
156
+ if (!state.isBuild) {
157
+ return;
158
+ }
159
+
160
+ return prependBanner(options, fontBanner(state));
161
+ },
162
+ };
163
+ }
164
+
165
+ export { gtkxFont };
@@ -1,17 +1,18 @@
1
1
  import type { ConfigLoader } from "@gtkx/config";
2
- import type { Plugin, Rollup, UserConfig } from "vite";
3
- import { createConfigLoader } from "@gtkx/config/internal";
2
+ import type { Plugin, UserConfig } from "vite";
3
+ import { createConfigLoader, viteProjectRoot } from "@gtkx/config/internal";
4
4
  import { info } from "@gtkx/utils";
5
5
  import { readFileSync } from "node:fs";
6
6
  import { join } from "node:path";
7
7
  import type { AssetEmitter } from "./asset-emitter.js";
8
- import { outputRootUrlExpression, prependBanner } from "../internal/banner.js";
8
+ import { prependBanner } from "../internal/banner.js";
9
9
  import {
10
10
  relativeIconPath,
11
11
  resolveApplicationIcon,
12
12
  type ResolvedApplicationIcon,
13
13
  } from "../internal/icon-path.js";
14
14
  import { type ListedFile, listFilesRecursive } from "../internal/list-files.js";
15
+ import { xdgDataDirsBanner } from "../internal/xdg-banner.js";
15
16
 
16
17
  type PluginState = {
17
18
  applicationId: string;
@@ -20,13 +21,6 @@ type PluginState = {
20
21
 
21
22
  const ICONS_DIR = "icons";
22
23
 
23
- const xdgEnvBanner = (chunk: Rollup.RenderedChunk): string => [
24
- "globalThis.process.env.XDG_DATA_DIRS = [",
25
- ` ${outputRootUrlExpression(chunk)},`,
26
- " globalThis.process.env.XDG_DATA_DIRS || \"/usr/local/share:/usr/share\",",
27
- "].join(\":\");",
28
- ].join("\n");
29
-
30
24
  const findIconFiles = (state: PluginState): ListedFile[] => {
31
25
  if (state.source.kind === "theme") {
32
26
  return listFilesRecursive(state.source.path);
@@ -43,7 +37,7 @@ const findIconFiles = (state: PluginState): ListedFile[] => {
43
37
  };
44
38
 
45
39
  const applyUserConfig = async (state: PluginState, config: UserConfig, loadConfig: ConfigLoader): Promise<void> => {
46
- const { config: gtkxConfig, root } = await loadConfig.load(config.root ?? process.cwd());
40
+ const { config: gtkxConfig, root } = await loadConfig.load(viteProjectRoot(config));
47
41
  state.applicationId = gtkxConfig.applicationId;
48
42
  state.source = resolveApplicationIcon(root, gtkxConfig.applicationId, gtkxConfig.applicationIcon);
49
43
  };
@@ -78,7 +72,7 @@ function gtkxIcons(loadConfig: ConfigLoader = createConfigLoader()): Plugin {
78
72
  return;
79
73
  }
80
74
 
81
- return prependBanner(options, xdgEnvBanner);
75
+ return prependBanner(options, xdgDataDirsBanner);
82
76
  },
83
77
 
84
78
  buildEnd() {
@@ -5,6 +5,7 @@ import type { BuildManifestCollector } from "../internal/build-manifest.js";
5
5
  import { gtkxAssetImports } from "./asset-imports.js";
6
6
  import { gtkxBuiltUrl } from "./built-url.js";
7
7
  import { gtkxCss } from "./css.js";
8
+ import { gtkxFont } from "./font.js";
8
9
  import { type CatalogWriteListener, gtkxI18n } from "./i18n.js";
9
10
  import { gtkxIcons } from "./icons.js";
10
11
  import { gtkxReactCompiler } from "./react-compiler.js";
@@ -53,6 +54,7 @@ const gtkxVitePlugins = (options: GtkxVitePluginOptions = {}): Plugin[] => {
53
54
  gtkxIcons(loadConfig),
54
55
  gtkxAssetImports(),
55
56
  gtkxBuiltUrl(),
57
+ gtkxFont(),
56
58
  gtkxResources(loadConfig, entryPath),
57
59
  gtkxCss(),
58
60
  gtkxReactCompiler(loadConfig),
@@ -3,7 +3,7 @@ import type { ResolvedReactCompilerOptions } from "@gtkx/config/internal";
3
3
  import type { Plugin, ResolvedConfig, UserConfig } from "vite";
4
4
  import { transformAsync } from "@babel/core";
5
5
  import babelPresetTypescriptNs from "@babel/preset-typescript";
6
- import { createConfigLoader } from "@gtkx/config/internal";
6
+ import { createConfigLoader, viteProjectRoot } from "@gtkx/config/internal";
7
7
  import babelPluginReactCompilerNs from "babel-plugin-react-compiler";
8
8
 
9
9
  type ReactCompilerState = {
@@ -62,7 +62,7 @@ function gtkxReactCompiler(loadConfig: ConfigLoader = createConfigLoader()): Plu
62
62
  enforce: "pre",
63
63
 
64
64
  async config(config: UserConfig) {
65
- const resolved = await loadConfig.resolve(config.root ?? process.cwd());
65
+ const resolved = await loadConfig.resolve(viteProjectRoot(config));
66
66
  state.options = resolved.reactCompiler;
67
67
  },
68
68
 
@@ -1,6 +1,6 @@
1
1
  import type { ConfigLoader } from "@gtkx/config";
2
2
  import type { ModuleNode, Plugin, ResolvedConfig, Rolldown, UserConfig, ViteDevServer } from "vite";
3
- import { createConfigLoader, resourceBasePath } from "@gtkx/config/internal";
3
+ import { createConfigLoader, resourceBasePath, viteProjectRoot } from "@gtkx/config/internal";
4
4
  import { error, info, isPathInside, isRecord, sortStrings, toPosixPath } from "@gtkx/utils";
5
5
  import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
6
6
  import { basename, dirname, extname, isAbsolute, join, posix, relative, sep } from "node:path";
@@ -1283,7 +1283,7 @@ const reconcileImporter = async (ctx: ResolveContext, state: PluginState, id: st
1283
1283
  };
1284
1284
 
1285
1285
  const resolveResourceConfig = async (state: PluginState, config: UserConfig, loadConfig: ConfigLoader) => {
1286
- const loaded = await loadConfig.load(config.root ?? process.cwd());
1286
+ const loaded = await loadConfig.load(viteProjectRoot(config));
1287
1287
  state.prefix = resourceBasePath(loaded.config.applicationId);
1288
1288
  state.root = loaded.root;
1289
1289
 
@@ -1383,7 +1383,7 @@ const rejectInvalidSpecifier = (source: string): void => {
1383
1383
  if (isBareRelativeAsset(source)) {
1384
1384
  throw new Error(
1385
1385
  `${JSON.stringify(source)} must choose ?resource for a GResource, ?icon for a themed icon, ` +
1386
- "or ?url for an emitted file",
1386
+ "?font for a bundled font, or ?url for an emitted file",
1387
1387
  );
1388
1388
  }
1389
1389
  };
@@ -1,6 +1,6 @@
1
1
  import type { UserConfig } from "vite";
2
2
  import type { Plugin } from "vitest/config";
3
- import { createConfigLoader } from "@gtkx/config/internal";
3
+ import { createConfigLoader, viteProjectRoot } from "@gtkx/config/internal";
4
4
  import { prependSchemaDir, stageAndCompileProjectSchemas } from "../settings/schema.js";
5
5
 
6
6
  function gtkxSettingsWorkerEnv(configFile?: string): Plugin {
@@ -11,7 +11,7 @@ function gtkxSettingsWorkerEnv(configFile?: string): Plugin {
11
11
  enforce: "pre",
12
12
 
13
13
  async config(config: UserConfig) {
14
- const loaded = await loadConfig.load(config.root ?? process.cwd());
14
+ const loaded = await loadConfig.load(viteProjectRoot(config));
15
15
  const dir = stageAndCompileProjectSchemas(loaded.root);
16
16
 
17
17
  if (dir === null) {
@@ -1,5 +1,6 @@
1
1
  import type { Plugin, UserConfig } from "vite";
2
2
  import { ensureStoreLinks } from "@gtkx/codegen/internal";
3
+ import { viteProjectRoot } from "@gtkx/config/internal";
3
4
 
4
5
  const GENERATED_MODULE_PREFIX = /^@gtkx\/(?:gi\/|jsx(?:\/|$))/;
5
6
 
@@ -11,7 +12,7 @@ function gtkxStoreLinks(): Plugin {
11
12
  enforce: "pre",
12
13
 
13
14
  config(config: UserConfig) {
14
- state.root = config.root ?? process.cwd();
15
+ state.root = viteProjectRoot(config);
15
16
  },
16
17
 
17
18
  resolveId(source) {
@@ -2,7 +2,7 @@ import type { StoreOptions } from "@gtkx/codegen";
2
2
  import type { ConfigLoader } from "@gtkx/config";
3
3
  import type { Plugin, UserConfig } from "vite";
4
4
  import { discoverGirNamespaces, resolveGirPath, resolveStore } from "@gtkx/codegen";
5
- import { createConfigLoader } from "@gtkx/config/internal";
5
+ import { createConfigLoader, viteProjectRoot } from "@gtkx/config/internal";
6
6
  import { existsSync, readFileSync } from "node:fs";
7
7
  import { join } from "node:path";
8
8
 
@@ -20,7 +20,7 @@ type GeneratedModule = {
20
20
  };
21
21
 
22
22
  const GENERATED_MODULE_PATTERN = /^@gtkx\/(gi|jsx)\/([a-z0-9]+)$/;
23
- const DEFAULT_LIBRARY_NAMESPACES: Set<string> = new Set(["gtk", "adw"]);
23
+ const DEFAULT_LIBRARY_NAMESPACES: Set<string> = new Set(["adw", "gtk"]);
24
24
 
25
25
  const girSearchPaths = async (state: PluginState): Promise<string[]> => {
26
26
  if (state.girPath === null) {
@@ -88,7 +88,7 @@ const undeclaredLibraryError = (source: string, namespace: string, girPath: stri
88
88
  return new Error(
89
89
  `Cannot resolve "${source}": the binding store has no "${namespace}" module, and no ` +
90
90
  `GIR data for it was found in [${girPath.join(", ")}]. If "${namespace}" is a library, install ` +
91
- "its gobject-introspection data package. Gtk-4.0 and Adw-1 are bound by default; add only other " +
91
+ "its gobject-introspection data package. Adw-1 is bound by default and pulls in Gtk-4.0; add only other " +
92
92
  "GIR identifiers to `libraries` in gtkx.config.ts. Otherwise run gtkx codegen to regenerate the store.",
93
93
  );
94
94
  }
@@ -96,7 +96,7 @@ const undeclaredLibraryError = (source: string, namespace: string, girPath: stri
96
96
  if (DEFAULT_LIBRARY_NAMESPACES.has(namespace)) {
97
97
  return new Error(
98
98
  `Cannot resolve "${source}": the "${identifier}" bindings have not been generated. ` +
99
- "The Gtk and Adwaita namespaces are bound by default; run gtkx dev or gtkx build again.",
99
+ "The Adwaita and GTK namespaces are generated implicitly; run gtkx dev or gtkx build again.",
100
100
  );
101
101
  }
102
102
 
@@ -129,7 +129,7 @@ function gtkxUndeclaredLibrary(loadConfig: ConfigLoader = createConfigLoader()):
129
129
  enforce: "pre",
130
130
 
131
131
  config(config: UserConfig) {
132
- state.root = config.root ?? process.cwd();
132
+ state.root = viteProjectRoot(config);
133
133
  },
134
134
 
135
135
  async resolveId(source, importer, options) {
@@ -1,6 +1,7 @@
1
1
  import type { Plugin } from "vite";
2
2
  import gtkxVitest, { type PluginOptions } from "@gtkx/vitest";
3
3
  import { gtkxEnsureStore } from "./vite-plugins/ensure-store.js";
4
+ import { gtkxFontWorkerEnv } from "./vite-plugins/font-worker-env.js";
4
5
  import { gtkxVitePlugins } from "./vite-plugins/index.js";
5
6
  import { gtkxSettingsWorkerEnv } from "./vite-plugins/settings-worker-env.js";
6
7
 
@@ -15,6 +16,7 @@ const gtkx = (options: PluginOptions = {}): Plugin[] => [
15
16
  gtkxEnsureStore(options.configFile),
16
17
  ...gtkxVitePlugins({ configFile: options.configFile }),
17
18
  gtkxSettingsWorkerEnv(options.configFile),
19
+ gtkxFontWorkerEnv(options.configFile),
18
20
  gtkxVitest(options),
19
21
  ];
20
22