@gtkx/cli 1.6.0 → 2.0.0-beta.1

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 (186) hide show
  1. package/README.md +5 -5
  2. package/dist/codegen/freshness.d.ts.map +1 -1
  3. package/dist/codegen/freshness.js +45 -16
  4. package/dist/codegen/freshness.js.map +1 -1
  5. package/dist/codegen/reference.d.ts.map +1 -1
  6. package/dist/codegen/reference.js +1 -7
  7. package/dist/codegen/reference.js.map +1 -1
  8. package/dist/codegen/report.d.ts.map +1 -1
  9. package/dist/codegen/report.js +5 -16
  10. package/dist/codegen/report.js.map +1 -1
  11. package/dist/codegen/run-codegen.d.ts +3 -5
  12. package/dist/codegen/run-codegen.d.ts.map +1 -1
  13. package/dist/codegen/run-codegen.js +23 -100
  14. package/dist/codegen/run-codegen.js.map +1 -1
  15. package/dist/codegen/store-resolver.d.ts +0 -1
  16. package/dist/codegen/store-resolver.d.ts.map +1 -1
  17. package/dist/codegen/store-resolver.js +8 -17
  18. package/dist/codegen/store-resolver.js.map +1 -1
  19. package/dist/commands/docs.d.ts.map +1 -1
  20. package/dist/commands/docs.js +5 -15
  21. package/dist/commands/docs.js.map +1 -1
  22. package/dist/deploy/freedesktop/copyright.d.ts.map +1 -1
  23. package/dist/deploy/freedesktop/copyright.js +2 -13
  24. package/dist/deploy/freedesktop/copyright.js.map +1 -1
  25. package/dist/deploy/freedesktop/xml.d.ts.map +1 -1
  26. package/dist/deploy/freedesktop/xml.js +21 -25
  27. package/dist/deploy/freedesktop/xml.js.map +1 -1
  28. package/dist/deploy/node-runtime/license.d.ts.map +1 -1
  29. package/dist/deploy/node-runtime/license.js +2 -9
  30. package/dist/deploy/node-runtime/license.js.map +1 -1
  31. package/dist/deploy/notices/packages.d.ts.map +1 -1
  32. package/dist/deploy/notices/packages.js +3 -10
  33. package/dist/deploy/notices/packages.js.map +1 -1
  34. package/dist/deploy/payload/copy-tree.d.ts.map +1 -1
  35. package/dist/deploy/payload/copy-tree.js +3 -3
  36. package/dist/deploy/payload/copy-tree.js.map +1 -1
  37. package/dist/deploy/payload/stage.d.ts.map +1 -1
  38. package/dist/deploy/payload/stage.js +1 -3
  39. package/dist/deploy/payload/stage.js.map +1 -1
  40. package/dist/deploy/settings/build-manifest.d.ts.map +1 -1
  41. package/dist/deploy/settings/build-manifest.js +4 -15
  42. package/dist/deploy/settings/build-manifest.js.map +1 -1
  43. package/dist/deploy/settings/libraries.d.ts.map +1 -1
  44. package/dist/deploy/settings/libraries.js +2 -19
  45. package/dist/deploy/settings/libraries.js.map +1 -1
  46. package/dist/deploy/settings/paths.d.ts +1 -2
  47. package/dist/deploy/settings/paths.d.ts.map +1 -1
  48. package/dist/deploy/settings/paths.js +5 -15
  49. package/dist/deploy/settings/paths.js.map +1 -1
  50. package/dist/deploy/settings/screenshots.d.ts.map +1 -1
  51. package/dist/deploy/settings/screenshots.js +6 -31
  52. package/dist/deploy/settings/screenshots.js.map +1 -1
  53. package/dist/deploy/targets/flatpak-pnpm.js +4 -4
  54. package/dist/deploy/targets/flatpak-pnpm.js.map +1 -1
  55. package/dist/deploy/targets/flatpak-source.d.ts.map +1 -1
  56. package/dist/deploy/targets/flatpak-source.js +4 -4
  57. package/dist/deploy/targets/flatpak-source.js.map +1 -1
  58. package/dist/deploy/targets/flatpak-sources.js +1 -1
  59. package/dist/deploy/targets/flatpak-sources.js.map +1 -1
  60. package/dist/dev/runner-main.d.ts.map +1 -1
  61. package/dist/dev/runner-main.js +1 -2
  62. package/dist/dev/runner-main.js.map +1 -1
  63. package/dist/dev/schema-dir.d.ts +1 -1
  64. package/dist/dev/schema-dir.d.ts.map +1 -1
  65. package/dist/dev/schema-dir.js +2 -4
  66. package/dist/dev/schema-dir.js.map +1 -1
  67. package/dist/i18n/catalogs.d.ts.map +1 -1
  68. package/dist/i18n/catalogs.js +2 -1
  69. package/dist/i18n/catalogs.js.map +1 -1
  70. package/dist/i18n/metadata-templates.d.ts.map +1 -1
  71. package/dist/i18n/metadata-templates.js +2 -1
  72. package/dist/i18n/metadata-templates.js.map +1 -1
  73. package/dist/i18n/source-messages.d.ts +3 -21
  74. package/dist/i18n/source-messages.d.ts.map +1 -1
  75. package/dist/i18n/source-messages.js +66 -85
  76. package/dist/i18n/source-messages.js.map +1 -1
  77. package/dist/i18n/types.d.ts +6 -7
  78. package/dist/i18n/types.d.ts.map +1 -1
  79. package/dist/i18n/types.js +83 -96
  80. package/dist/i18n/types.js.map +1 -1
  81. package/dist/internal/docs-elements.js +2 -2
  82. package/dist/internal/docs-elements.js.map +1 -1
  83. package/dist/internal/icon-path.d.ts.map +1 -1
  84. package/dist/internal/icon-path.js +5 -16
  85. package/dist/internal/icon-path.js.map +1 -1
  86. package/dist/internal/source-imports.d.ts.map +1 -1
  87. package/dist/internal/source-imports.js +10 -41
  88. package/dist/internal/source-imports.js.map +1 -1
  89. package/dist/settings/render.d.ts +0 -1
  90. package/dist/settings/render.d.ts.map +1 -1
  91. package/dist/settings/render.js +1 -11
  92. package/dist/settings/render.js.map +1 -1
  93. package/dist/settings/schema.d.ts +2 -2
  94. package/dist/settings/schema.d.ts.map +1 -1
  95. package/dist/settings/schema.js +21 -62
  96. package/dist/settings/schema.js.map +1 -1
  97. package/dist/vite-plugins/asset-imports.d.ts +1 -2
  98. package/dist/vite-plugins/asset-imports.d.ts.map +1 -1
  99. package/dist/vite-plugins/asset-imports.js +19 -32
  100. package/dist/vite-plugins/asset-imports.js.map +1 -1
  101. package/dist/vite-plugins/asset-specifier.d.ts +1 -3
  102. package/dist/vite-plugins/asset-specifier.d.ts.map +1 -1
  103. package/dist/vite-plugins/asset-specifier.js +1 -4
  104. package/dist/vite-plugins/asset-specifier.js.map +1 -1
  105. package/dist/vite-plugins/i18n.d.ts.map +1 -1
  106. package/dist/vite-plugins/i18n.js +2 -1
  107. package/dist/vite-plugins/i18n.js.map +1 -1
  108. package/dist/vite-plugins/index.d.ts.map +1 -1
  109. package/dist/vite-plugins/index.js +2 -4
  110. package/dist/vite-plugins/index.js.map +1 -1
  111. package/dist/vite-plugins/resources.d.ts.map +1 -1
  112. package/dist/vite-plugins/resources.js +32 -97
  113. package/dist/vite-plugins/resources.js.map +1 -1
  114. package/dist/vite-plugins/settings-worker-env.d.ts.map +1 -1
  115. package/dist/vite-plugins/settings-worker-env.js +2 -4
  116. package/dist/vite-plugins/settings-worker-env.js.map +1 -1
  117. package/dist/vite-plugins/settings.d.ts +1 -2
  118. package/dist/vite-plugins/settings.d.ts.map +1 -1
  119. package/dist/vite-plugins/settings.js +8 -14
  120. package/dist/vite-plugins/settings.js.map +1 -1
  121. package/dist/vite-plugins/undeclared-library.d.ts.map +1 -1
  122. package/dist/vite-plugins/undeclared-library.js +10 -13
  123. package/dist/vite-plugins/undeclared-library.js.map +1 -1
  124. package/dist/vite-plugins/worker.d.ts.map +1 -1
  125. package/dist/vite-plugins/worker.js +0 -1
  126. package/dist/vite-plugins/worker.js.map +1 -1
  127. package/package.json +21 -15
  128. package/src/codegen/freshness.ts +66 -17
  129. package/src/codegen/reference.ts +1 -8
  130. package/src/codegen/report.ts +5 -21
  131. package/src/codegen/run-codegen.ts +28 -145
  132. package/src/codegen/store-resolver.ts +8 -24
  133. package/src/commands/docs.ts +5 -17
  134. package/src/deploy/freedesktop/copyright.ts +2 -14
  135. package/src/deploy/freedesktop/xml.ts +24 -32
  136. package/src/deploy/node-runtime/license.ts +2 -8
  137. package/src/deploy/notices/packages.ts +3 -11
  138. package/src/deploy/payload/copy-tree.ts +3 -4
  139. package/src/deploy/payload/stage.ts +2 -6
  140. package/src/deploy/settings/build-manifest.ts +4 -16
  141. package/src/deploy/settings/libraries.ts +1 -22
  142. package/src/deploy/settings/paths.ts +6 -16
  143. package/src/deploy/settings/screenshots.ts +8 -46
  144. package/src/deploy/targets/flatpak-pnpm.ts +4 -4
  145. package/src/deploy/targets/flatpak-source.ts +4 -4
  146. package/src/deploy/targets/flatpak-sources.ts +1 -1
  147. package/src/dev/runner-main.ts +1 -2
  148. package/src/dev/schema-dir.ts +2 -4
  149. package/src/i18n/catalogs.ts +2 -1
  150. package/src/i18n/metadata-templates.ts +2 -1
  151. package/src/i18n/source-messages.ts +77 -115
  152. package/src/i18n/types.ts +97 -131
  153. package/src/internal/docs-elements.ts +2 -2
  154. package/src/internal/icon-path.ts +6 -19
  155. package/src/internal/source-imports.ts +14 -50
  156. package/src/settings/render.ts +1 -13
  157. package/src/settings/schema.ts +19 -81
  158. package/src/vite-plugins/asset-imports.ts +20 -44
  159. package/src/vite-plugins/asset-specifier.ts +0 -5
  160. package/src/vite-plugins/i18n.ts +2 -1
  161. package/src/vite-plugins/index.ts +2 -4
  162. package/src/vite-plugins/resources.ts +37 -140
  163. package/src/vite-plugins/settings-worker-env.ts +2 -4
  164. package/src/vite-plugins/settings.ts +11 -20
  165. package/src/vite-plugins/undeclared-library.ts +14 -20
  166. package/src/vite-plugins/worker.ts +0 -1
  167. package/dist/i18n/binding-extractor.d.ts +0 -30
  168. package/dist/i18n/binding-extractor.d.ts.map +0 -1
  169. package/dist/i18n/binding-extractor.js +0 -1324
  170. package/dist/i18n/binding-extractor.js.map +0 -1
  171. package/dist/i18n/extractor-plugin.d.ts +0 -8
  172. package/dist/i18n/extractor-plugin.d.ts.map +0 -1
  173. package/dist/i18n/extractor-plugin.js +0 -247
  174. package/dist/i18n/extractor-plugin.js.map +0 -1
  175. package/dist/internal/data-dir.d.ts +0 -4
  176. package/dist/internal/data-dir.d.ts.map +0 -1
  177. package/dist/internal/data-dir.js +0 -52
  178. package/dist/internal/data-dir.js.map +0 -1
  179. package/dist/vite-plugins/animated.d.ts +0 -5
  180. package/dist/vite-plugins/animated.d.ts.map +0 -1
  181. package/dist/vite-plugins/animated.js +0 -325
  182. package/dist/vite-plugins/animated.js.map +0 -1
  183. package/src/i18n/binding-extractor.ts +0 -1969
  184. package/src/i18n/extractor-plugin.ts +0 -413
  185. package/src/internal/data-dir.ts +0 -70
  186. package/src/vite-plugins/animated.ts +0 -486
@@ -1,20 +1,17 @@
1
1
  import type { ConfigLoader } from "@gtkx/config";
2
2
  import type { ModuleNode, Plugin, ResolvedConfig, Rolldown, UserConfig, ViteDevServer } from "vite";
3
- import { createConfigLoader, resolveFuture, resourceBasePath } from "@gtkx/config/internal";
4
- import { error, info, isRecord, sortStrings } from "@gtkx/utils";
3
+ import { createConfigLoader, resourceBasePath } from "@gtkx/config/internal";
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";
7
7
  import { parseSync } from "vite";
8
- import { resolveDataDir } from "../internal/data-dir.js";
9
- import { type ListedFile, listFilesRecursive } from "../internal/list-files.js";
8
+ import { withExclusiveLoad } from "../internal/module-loads.js";
10
9
  import { runCliTool } from "../internal/run-cli-tool.js";
11
10
  import { parseRuntimeImportsIn, type SourceImport, sourceLanguage } from "../internal/source-imports.js";
12
11
  import { createRetainedStagingDir, type RetainedStagingDir, withStagingDir } from "../internal/staging-dir.js";
13
12
  import { ASSET_RE } from "./asset-extensions.js";
14
13
  import {
15
- DATA_PREFIX,
16
14
  isBareRelativeAsset,
17
- isDataAsset,
18
15
  parseIconSpecifier,
19
16
  parseResourceSpecifier,
20
17
  } from "./asset-specifier.js";
@@ -44,7 +41,6 @@ type PluginState = {
44
41
  prefix: string;
45
42
  root: string;
46
43
  isBuild: boolean;
47
- isV2: boolean;
48
44
  entries: Map<string, ResourceEntry>;
49
45
  bundledSpecifiers: Map<string, Set<string>>;
50
46
  moduleDependencies: Map<string, Set<string>>;
@@ -58,7 +54,6 @@ type PluginState = {
58
54
  devBundlePath: string;
59
55
  server: ViteDevServer | null;
60
56
  compiledSignature: string;
61
- dataDir: string | null;
62
57
  bundleReferenceId: string | null;
63
58
  iconOwners: Map<string, ResourceEntry>;
64
59
  };
@@ -118,7 +113,7 @@ type DerivedIconEntry = {
118
113
  resourcePath: string;
119
114
  };
120
115
 
121
- type LegacyResolveRequest = {
116
+ type ResolveRequest = {
122
117
  source: string;
123
118
  importer: string | undefined;
124
119
  options: Record<string, unknown> | undefined;
@@ -128,6 +123,7 @@ const RESOURCE_COMPILER = "glib-compile-resources";
128
123
  const MANIFEST_PREFIX = "/";
129
124
  const DEV_STAGING_PREFIX = "resources-dev";
130
125
  const MANIFEST_FILENAME = "package.json";
126
+ const DATA_PREFIX = "#data/";
131
127
  const BUNDLED_QUERY_MENTION_RE = /[?&](?:icon|resource)(?:[=&]|$)/;
132
128
  const ICON_EXTENSIONS: Set<string> = new Set([".png", ".svg", ".xpm"]);
133
129
 
@@ -164,16 +160,8 @@ const STOCK_ICON_CONTEXTS: Set<string> = new Set([
164
160
  const ICON_SIZE_RE = /^([1-9]\d*)x\1(?:@[1-9]\d*)?$/;
165
161
  const RESERVED_ICON_NAMES: Set<string> = new Set(["", ".", ".."]);
166
162
 
167
- const toForwardSlashes = (value: string): string => value.replaceAll(/[/\\]/g, "/");
168
-
169
- const isWithin = (root: string, path: string): boolean => {
170
- const rel = relative(root, path);
171
-
172
- return rel.length > 0 && !isAbsolute(rel) && rel !== ".." && !rel.startsWith(`..${sep}`);
173
- };
174
-
175
163
  const isDependencyFile = (root: string, path: string): boolean =>
176
- isWithin(root, path) && relative(root, path).split(sep).includes("node_modules");
164
+ isPathInside(root, path) && relative(root, path).split(sep).includes("node_modules");
177
165
 
178
166
  const packageIdentityIn = (dir: string): string | null => {
179
167
  try {
@@ -216,17 +204,17 @@ const validateResourcePath = (resourcePath: string): string => {
216
204
  };
217
205
 
218
206
  const derivedResourcePath = (state: PluginState, sourcePath: string): string => {
219
- if (isWithin(state.root, sourcePath) && !isDependencyFile(state.root, sourcePath)) {
220
- return validateResourcePath(`${state.prefix}/${toForwardSlashes(relative(state.root, sourcePath))}`);
207
+ if (isPathInside(state.root, sourcePath) && !isDependencyFile(state.root, sourcePath)) {
208
+ return validateResourcePath(`${state.prefix}/${toPosixPath(relative(state.root, sourcePath))}`);
221
209
  }
222
210
 
223
211
  const owner = packageForFile(sourcePath);
224
212
 
225
- if (owner === null || !isWithin(owner.dir, sourcePath)) {
213
+ if (owner === null || !isPathInside(owner.dir, sourcePath)) {
226
214
  throw new Error(`${sourcePath} is outside the application and does not belong to a named package`);
227
215
  }
228
216
 
229
- const packagePath = toForwardSlashes(relative(owner.dir, sourcePath));
217
+ const packagePath = toPosixPath(relative(owner.dir, sourcePath));
230
218
 
231
219
  return validateResourcePath(`${state.prefix}/${owner.name}/${packagePath}`);
232
220
  };
@@ -292,7 +280,7 @@ const iconLayoutInParts = (parts: string[], beforeIndex: number): string | null
292
280
  };
293
281
 
294
282
  const iconLayoutFromTree = (sourcePath: string): string | null => {
295
- const parts = toForwardSlashes(sourcePath).split("/");
283
+ const parts = toPosixPath(sourcePath).split("/");
296
284
 
297
285
  return iconLayoutInParts(parts, parts.length - 2);
298
286
  };
@@ -335,11 +323,10 @@ const hasSideEffectIconImport = (code: string, id: string): boolean => {
335
323
  };
336
324
 
337
325
  const retainSideEffectIconImport = (
338
- state: PluginState,
339
326
  code: string,
340
327
  id: string,
341
328
  ): { code: string; moduleSideEffects: true } | null =>
342
- state.isV2 && hasSideEffectIconImport(code, id)
329
+ hasSideEffectIconImport(code, id)
343
330
  ? { code, moduleSideEffects: true }
344
331
  : null;
345
332
 
@@ -430,20 +417,6 @@ const refreshRegisteredDevBundle = (state: PluginState): void => {
430
417
  }
431
418
  };
432
419
 
433
- const scanDataAssets = (dataDir: string): ListedFile[] => listFilesRecursive(dataDir, (name) => ASSET_RE.test(name));
434
-
435
- const primeLegacyDevBundle = (state: PluginState): void => {
436
- if (state.dataDir === null) {
437
- return;
438
- }
439
-
440
- for (const { absPath, rel } of scanDataAssets(state.dataDir)) {
441
- registerEntry(state, absPath, rel);
442
- }
443
-
444
- compileDevBundle(state);
445
- };
446
-
447
420
  const registerDevAsset = (state: PluginState): void => {
448
421
  if (entriesSignature(state) !== state.compiledSignature) {
449
422
  compileDevBundle(state);
@@ -490,7 +463,7 @@ const activateEntry = (state: PluginState, entry: ResourceEntry): ResourceEntry
490
463
  };
491
464
 
492
465
  const isDeclarativeImporter = (state: PluginState, importer: string | undefined): importer is string =>
493
- !state.isBuild && state.isV2 && importer !== undefined;
466
+ !state.isBuild && importer !== undefined;
494
467
 
495
468
  const setSourceAvailability = (state: PluginState, file: string, isAvailable: boolean): void => {
496
469
  if (isAvailable) {
@@ -713,26 +686,6 @@ const resolveIconEntry = async (
713
686
  };
714
687
  };
715
688
 
716
- const resolveLegacyAssetEntry = async (
717
- ctx: ResolveContext,
718
- state: PluginState,
719
- request: LegacyResolveRequest,
720
- ): Promise<ResourceEntry | undefined> => {
721
- const resolved = await ctx.resolve(request.source, request.importer, { ...request.options, skipSelf: true });
722
-
723
- if (!resolved || resolved.external) {
724
- return undefined;
725
- }
726
-
727
- const sourcePath = stripQuery(resolved.id);
728
-
729
- if (!isAbsolute(sourcePath)) {
730
- return undefined;
731
- }
732
-
733
- return registerEntry(state, sourcePath, request.source.slice(DATA_PREFIX.length));
734
- };
735
-
736
689
  const loadInitModule = (state: PluginState): string => {
737
690
  if (state.isBuild) {
738
691
  if (state.bundleReferenceId === null) {
@@ -831,8 +784,7 @@ const loadAssetModule = (state: PluginState, virtualId: string): string => {
831
784
  const { absPath, iconName, rel } = virtualAssetMetadata(virtualId);
832
785
  const resourcePath = validateResourcePath(rel);
833
786
  const { entry, isRegistered } = loadedResourceEntry(state, absPath, resourcePath);
834
- const uri = `resource://${entry.resourcePath}`;
835
- const defaultValue = iconName ?? (state.isV2 ? entry.resourcePath : uri);
787
+ const defaultValue = iconName ?? entry.resourcePath;
836
788
  compileLoadedDevAsset(state, isRegistered);
837
789
 
838
790
  return [
@@ -899,12 +851,12 @@ const isSourceModule = (file: string): boolean => sourceLanguage(file) !== undef
899
851
  const isBundledSource = (source: string): boolean =>
900
852
  parseResourceSpecifier(source) !== null || parseIconSpecifier(source) !== null;
901
853
 
902
- const validateUnbundledV2Source = (source: string): void => {
854
+ const validateUnbundledSource = (source: string): void => {
903
855
  if (isLegacyDataSpecifier(source)) {
904
856
  throw new Error(`${JSON.stringify(source)} uses the legacy #data asset form`);
905
857
  }
906
858
 
907
- rejectInvalidV2Specifier(source);
859
+ rejectInvalidSpecifier(source);
908
860
  };
909
861
 
910
862
  const resolvedModuleDependency = async (
@@ -916,7 +868,7 @@ const resolvedModuleDependency = async (
916
868
  return null;
917
869
  }
918
870
 
919
- validateUnbundledV2Source(source);
871
+ validateUnbundledSource(source);
920
872
  const resolved = await ctx.resolve(source, importer, { skipSelf: true });
921
873
 
922
874
  if (resolved === null) {
@@ -952,7 +904,7 @@ const importerReconciliation = async (
952
904
  const file = stripQuery(id);
953
905
  const key = importerKey(file);
954
906
 
955
- if (!state.isV2 || state.isBuild || !isSourceModule(file)) {
907
+ if (state.isBuild || !isSourceModule(file)) {
956
908
  return null;
957
909
  }
958
910
 
@@ -1171,35 +1123,16 @@ const forgetImporterDeclarations = (state: PluginState, importer: string): void
1171
1123
  state.declaredIcons.delete(importer);
1172
1124
  };
1173
1125
 
1174
- const cloneStringSetMap = (source: Map<string, Set<string>>): Map<string, Set<string>> => {
1175
- const clone: Map<string, Set<string>> = new Map();
1176
-
1177
- for (const [key, values] of source) {
1178
- clone.set(key, new Set(values));
1179
- }
1180
-
1181
- return clone;
1182
- };
1183
-
1184
- const cloneDeclarationMap = (
1185
- source: Map<string, Map<string, ResourceEntry>>,
1186
- ): Map<string, Map<string, ResourceEntry>> => {
1187
- const clone: Map<string, Map<string, ResourceEntry>> = new Map();
1188
-
1189
- for (const [key, declarations] of source) {
1190
- clone.set(key, new Map(declarations));
1191
- }
1192
-
1193
- return clone;
1194
- };
1126
+ const cloneMapValues = <Value>(source: Map<string, Value>, clone: (value: Value) => Value): Map<string, Value> =>
1127
+ new Map([...source].map(([key, value]) => [key, clone(value)]));
1195
1128
 
1196
1129
  const reconciliationCandidate = (state: PluginState): PluginState => ({
1197
1130
  ...state,
1198
- bundledSpecifiers: cloneStringSetMap(state.bundledSpecifiers),
1199
- moduleDependencies: cloneStringSetMap(state.moduleDependencies),
1200
- prunedDependencies: cloneStringSetMap(state.prunedDependencies),
1201
- declaredEntries: cloneDeclarationMap(state.declaredEntries),
1202
- declaredIcons: cloneDeclarationMap(state.declaredIcons),
1131
+ bundledSpecifiers: cloneMapValues(state.bundledSpecifiers, (values) => new Set(values)),
1132
+ moduleDependencies: cloneMapValues(state.moduleDependencies, (values) => new Set(values)),
1133
+ prunedDependencies: cloneMapValues(state.prunedDependencies, (values) => new Set(values)),
1134
+ declaredEntries: cloneMapValues(state.declaredEntries, (entries) => new Map(entries)),
1135
+ declaredIcons: cloneMapValues(state.declaredIcons, (entries) => new Map(entries)),
1203
1136
  missingSourcePaths: new Set(state.missingSourcePaths),
1204
1137
  });
1205
1138
 
@@ -1333,7 +1266,7 @@ const commitReconciliation = (state: PluginState, candidate: PluginState): void
1333
1266
  state.iconOwners = candidate.iconOwners;
1334
1267
  };
1335
1268
 
1336
- const reconcileV2Importer = async (ctx: ResolveContext, state: PluginState, id: string): Promise<void> => {
1269
+ const reconcileImporter = async (ctx: ResolveContext, state: PluginState, id: string): Promise<void> => {
1337
1270
  const reconciliation = await importerReconciliation(ctx, state, id);
1338
1271
 
1339
1272
  if (reconciliation === null) {
@@ -1353,7 +1286,6 @@ const resolveResourceConfig = async (state: PluginState, config: UserConfig, loa
1353
1286
  const loaded = await loadConfig.load(config.root ?? process.cwd());
1354
1287
  state.prefix = resourceBasePath(loaded.config.applicationId);
1355
1288
  state.root = loaded.root;
1356
- state.isV2 = resolveFuture(loaded.config.future).isResourceImported;
1357
1289
 
1358
1290
  return {
1359
1291
  assetsInclude: [ASSET_RE],
@@ -1423,14 +1355,6 @@ const attachResourceWatcher = (state: PluginState, server: ViteDevServer): void
1423
1355
  const applyResolvedConfig = (state: PluginState, config: ResolvedConfig): void => {
1424
1356
  state.isBuild = config.command === "build";
1425
1357
  state.root = config.root;
1426
- state.dataDir = null;
1427
-
1428
- if (state.isBuild || state.isV2) {
1429
- return;
1430
- }
1431
-
1432
- const relativeDataDir = resolveDataDir(config.root);
1433
- state.dataDir = relativeDataDir === null ? null : join(config.root, relativeDataDir);
1434
1358
  };
1435
1359
 
1436
1360
  const loadResourceModule = (state: PluginState, id: string): string | undefined => {
@@ -1448,7 +1372,7 @@ const loadResourceModule = (state: PluginState, id: string): string | undefined
1448
1372
  const isLegacyDataSpecifier = (source: string): boolean =>
1449
1373
  source.startsWith(DATA_PREFIX) && ASSET_RE.test(stripQuery(source));
1450
1374
 
1451
- const rejectInvalidV2Specifier = (source: string): void => {
1375
+ const rejectInvalidSpecifier = (source: string): void => {
1452
1376
  if (BUNDLED_QUERY_MENTION_RE.test(source)) {
1453
1377
  throw new Error(
1454
1378
  `${JSON.stringify(source)} is not a valid bundled asset import; use ?resource, ` +
@@ -1467,7 +1391,7 @@ const rejectInvalidV2Specifier = (source: string): void => {
1467
1391
  const resolveExplicitResourceId = async (
1468
1392
  ctx: ResolveContext,
1469
1393
  state: PluginState,
1470
- request: LegacyResolveRequest,
1394
+ request: ResolveRequest,
1471
1395
  ): Promise<string | undefined> => {
1472
1396
  const specifier = parseResourceSpecifier(request.source);
1473
1397
 
@@ -1488,7 +1412,7 @@ const resolveExplicitResourceId = async (
1488
1412
  const resolveIconResourceId = async (
1489
1413
  ctx: ResolveContext,
1490
1414
  state: PluginState,
1491
- request: LegacyResolveRequest,
1415
+ request: ResolveRequest,
1492
1416
  ): Promise<RetainedIconModuleId | undefined> => {
1493
1417
  const specifier = parseIconSpecifier(request.source);
1494
1418
 
@@ -1508,10 +1432,10 @@ const resolveIconResourceId = async (
1508
1432
  : { id: virtualIconId(resolved), moduleSideEffects: true };
1509
1433
  };
1510
1434
 
1511
- const resolveV2ResourceId = async (
1435
+ const resolveBundledResourceId = async (
1512
1436
  ctx: ResolveContext,
1513
1437
  state: PluginState,
1514
- request: LegacyResolveRequest,
1438
+ request: ResolveRequest,
1515
1439
  ): Promise<ResourceModuleId | undefined> => {
1516
1440
  if (isLegacyDataSpecifier(request.source)) {
1517
1441
  throw new Error(
@@ -1534,46 +1458,21 @@ const resolveV2ResourceId = async (
1534
1458
  return resolved;
1535
1459
  }
1536
1460
 
1537
- rejectInvalidV2Specifier(request.source);
1461
+ rejectInvalidSpecifier(request.source);
1538
1462
 
1539
1463
  return undefined;
1540
1464
  };
1541
1465
 
1542
- const resolveLegacyResourceId = async (
1543
- ctx: ResolveContext,
1544
- state: PluginState,
1545
- request: LegacyResolveRequest,
1546
- ): Promise<string | undefined> => {
1547
- if (BUNDLED_QUERY_MENTION_RE.test(request.source)) {
1548
- throw new Error(`${JSON.stringify(request.source)} requires future.v2ResourceImports`);
1549
- }
1550
-
1551
- if (!isDataAsset(request.source)) {
1552
- return undefined;
1553
- }
1554
-
1555
- const entry = await resolveLegacyAssetEntry(ctx, state, request);
1556
-
1557
- return entry === undefined ? undefined : virtualAssetId(entry);
1558
- };
1559
-
1560
1466
  const resolveResourceId = (
1561
1467
  ctx: ResolveContext,
1562
1468
  state: PluginState,
1563
- request: LegacyResolveRequest,
1469
+ request: ResolveRequest,
1564
1470
  ): Promise<ResourceModuleId | undefined> => {
1565
1471
  if (request.source === VIRTUAL_INIT) {
1566
1472
  return Promise.resolve(VIRTUAL_INIT);
1567
1473
  }
1568
1474
 
1569
- return state.isV2
1570
- ? resolveV2ResourceId(ctx, state, request)
1571
- : resolveLegacyResourceId(ctx, state, request);
1572
- };
1573
-
1574
- const configureResourceServer = (state: PluginState, server: ViteDevServer): void => {
1575
- attachResourceWatcher(state, server);
1576
- primeLegacyDevBundle(state);
1475
+ return resolveBundledResourceId(ctx, state, request);
1577
1476
  };
1578
1477
 
1579
1478
  const createResourcesPlugin = (state: PluginState, loadConfig: ConfigLoader): Plugin => ({
@@ -1588,7 +1487,7 @@ const createResourcesPlugin = (state: PluginState, loadConfig: ConfigLoader): Pl
1588
1487
  },
1589
1488
 
1590
1489
  configureServer: (server) => {
1591
- configureResourceServer(state, server);
1490
+ attachResourceWatcher(state, server);
1592
1491
  },
1593
1492
 
1594
1493
  buildStart() {
@@ -1610,9 +1509,9 @@ const createResourcesPlugin = (state: PluginState, loadConfig: ConfigLoader): Pl
1610
1509
  },
1611
1510
 
1612
1511
  async transform(code, id) {
1613
- await reconcileV2Importer(this, state, id);
1512
+ await withExclusiveLoad(state, () => reconcileImporter(this, state, id));
1614
1513
 
1615
- return retainSideEffectIconImport(state, code, id);
1514
+ return retainSideEffectIconImport(code, id);
1616
1515
  },
1617
1516
 
1618
1517
  generateBundle(_options, bundle) {
@@ -1629,7 +1528,6 @@ function gtkxResources(loadConfig: ConfigLoader = createConfigLoader(), entryPat
1629
1528
  prefix: "",
1630
1529
  root: "",
1631
1530
  isBuild: false,
1632
- isV2: false,
1633
1531
  entries: new Map(),
1634
1532
  bundledSpecifiers: new Map(),
1635
1533
  moduleDependencies: new Map(),
@@ -1643,7 +1541,6 @@ function gtkxResources(loadConfig: ConfigLoader = createConfigLoader(), entryPat
1643
1541
  devBundlePath: "",
1644
1542
  server: null,
1645
1543
  compiledSignature: "",
1646
- dataDir: null,
1647
1544
  bundleReferenceId: null,
1648
1545
  iconOwners: new Map(),
1649
1546
  };
@@ -1,7 +1,6 @@
1
1
  import type { UserConfig } from "vite";
2
2
  import type { Plugin } from "vitest/config";
3
- import { createConfigLoader, resolveFuture } from "@gtkx/config/internal";
4
- import { resolveDataDir } from "../internal/data-dir.js";
3
+ import { createConfigLoader } from "@gtkx/config/internal";
5
4
  import { prependSchemaDir, stageAndCompileProjectSchemas } from "../settings/schema.js";
6
5
 
7
6
  function gtkxSettingsWorkerEnv(): Plugin {
@@ -13,8 +12,7 @@ function gtkxSettingsWorkerEnv(): Plugin {
13
12
 
14
13
  async config(config: UserConfig) {
15
14
  const loaded = await loadConfig.load(config.root ?? process.cwd());
16
- const dataDir = resolveFuture(loaded.config.future).isResourceImported ? null : resolveDataDir(loaded.root);
17
- const dir = stageAndCompileProjectSchemas(loaded.root, dataDir);
15
+ const dir = stageAndCompileProjectSchemas(loaded.root);
18
16
 
19
17
  if (dir === null) {
20
18
  return;
@@ -1,13 +1,10 @@
1
- import type { ConfigLoader } from "@gtkx/config";
2
- import type { ModuleNode, Plugin, ResolvedConfig, UserConfig, ViteDevServer } from "vite";
3
- import { resolveFuture } from "@gtkx/config/internal";
1
+ import type { ModuleNode, Plugin, ResolvedConfig, ViteDevServer } from "vite";
4
2
  import { error, errorMessage, info, sortStrings } from "@gtkx/utils";
5
3
  import { readFileSync } from "node:fs";
6
4
  import { basename, join } from "node:path";
7
5
  import type { BuildManifestCollector } from "../internal/build-manifest.js";
8
6
  import type { AssetEmitter } from "./asset-emitter.js";
9
7
  import { prependBanner } from "../internal/banner.js";
10
- import { resolveDataDir } from "../internal/data-dir.js";
11
8
  import { createRetainedStagingDir, type RetainedStagingDir, withStagingDir } from "../internal/staging-dir.js";
12
9
  import { compileSchemas } from "../settings/compile.js";
13
10
  import { parseSchemaXml, SchemaParseError } from "../settings/parser.js";
@@ -25,8 +22,6 @@ import { createVirtualNamespace } from "./virtual-module.js";
25
22
  type PluginState = {
26
23
  schemaDir: RetainedStagingDir;
27
24
  rootDir: string | null;
28
- dataDir: string | null;
29
- isV2ResourceImports: boolean;
30
25
  isBuild: boolean;
31
26
  schemaEnvTimer: ReturnType<typeof setTimeout> | null;
32
27
  trackedSchemas: Map<string, string>;
@@ -81,7 +76,7 @@ const syncSchemaEnv = (state: PluginState): void => {
81
76
  }
82
77
 
83
78
  try {
84
- emitSchemaEnv(state.rootDir, state.dataDir, state.isV2ResourceImports);
79
+ emitSchemaEnv(state.rootDir);
85
80
  } catch (error_) {
86
81
  error(`Failed to generate GSettings schema types: ${errorMessage(error_)}`);
87
82
  }
@@ -105,12 +100,6 @@ const scheduleSchemaEnvSync = (state: PluginState): void => {
105
100
  }, SCHEMA_ENV_DEBOUNCE_MS);
106
101
  };
107
102
 
108
- const applyUserConfig = async (state: PluginState, config: UserConfig, loadConfig: ConfigLoader): Promise<void> => {
109
- const loaded = await loadConfig.load(config.root ?? process.cwd());
110
- state.isV2ResourceImports = resolveFuture(loaded.config.future).isResourceImported;
111
- state.dataDir = state.isV2ResourceImports ? null : resolveDataDir(loaded.root);
112
- };
113
-
114
103
  const applyResolvedConfig = (state: PluginState, config: ResolvedConfig): void => {
115
104
  state.isBuild = config.command === "build";
116
105
  state.rootDir = typeof config.root === "string" ? config.root : null;
@@ -173,6 +162,12 @@ const compileBuildSchemas = (schemaFiles: string[]): Buffer =>
173
162
  return readFileSync(join(dir, "gschemas.compiled"));
174
163
  });
175
164
 
165
+ const rejectLegacySchemaSpecifier = (source: string): void => {
166
+ if (source.startsWith("#data/")) {
167
+ throw new Error(`${JSON.stringify(source)} uses the legacy #data schema form`);
168
+ }
169
+ };
170
+
176
171
  const buildSchemaPaths = (rootDir: string, schemaFiles: string[]): string[] =>
177
172
  schemaFiles.map((filePath) => {
178
173
  const rel = projectRelativeSchemaPath(rootDir, filePath);
@@ -262,12 +257,10 @@ const watchSchemaFiles = (state: PluginState, server: ViteDevServer): void => {
262
257
  server.watcher.on("unlink", refreshSchemaTypes);
263
258
  };
264
259
 
265
- function gtkxSettings(loadConfig: ConfigLoader, buildManifest?: BuildManifestCollector): Plugin {
260
+ function gtkxSettings(buildManifest?: BuildManifestCollector): Plugin {
266
261
  const state: PluginState = {
267
262
  schemaDir: createRetainedStagingDir(SCHEMA_STAGING_PREFIX),
268
263
  rootDir: null,
269
- dataDir: null,
270
- isV2ResourceImports: false,
271
264
  isBuild: false,
272
265
  schemaEnvTimer: null,
273
266
  trackedSchemas: new Map(),
@@ -278,10 +271,6 @@ function gtkxSettings(loadConfig: ConfigLoader, buildManifest?: BuildManifestCol
278
271
  name: "gtkx:settings",
279
272
  enforce: "pre",
280
273
 
281
- async config(config: UserConfig) {
282
- await applyUserConfig(state, config, loadConfig);
283
- },
284
-
285
274
  configResolved(config) {
286
275
  applyResolvedConfig(state, config);
287
276
  },
@@ -303,6 +292,8 @@ function gtkxSettings(loadConfig: ConfigLoader, buildManifest?: BuildManifestCol
303
292
  return;
304
293
  }
305
294
 
295
+ rejectLegacySchemaSpecifier(source);
296
+
306
297
  return resolveToVirtual(this, { source, importer, options });
307
298
  },
308
299
 
@@ -15,11 +15,12 @@ type PluginState = {
15
15
  type GeneratedModule = {
16
16
  source: string;
17
17
  kind: string;
18
- namespace: string | null;
18
+ namespace: string;
19
19
  importer: string;
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
24
 
24
25
  const girSearchPaths = async (state: PluginState): Promise<string[]> => {
25
26
  if (state.girPath === null) {
@@ -36,10 +37,6 @@ const findGirIdentifier = (girPath: string[], namespace: string): string | undef
36
37
  discoverGirNamespaces(girPath).find((identifier) => getNamespace(identifier) === namespace);
37
38
 
38
39
  const parseGeneratedModule = (source: string, importer: string | undefined): GeneratedModule | null => {
39
- if (source === "@gtkx/jsx") {
40
- return { source, kind: "jsx", namespace: null, importer: importer ?? "the project's sources" };
41
- }
42
-
43
40
  const matched = GENERATED_MODULE_PATTERN.exec(source);
44
41
  const kind = matched?.[1];
45
42
  const namespace = matched?.[2];
@@ -74,7 +71,7 @@ const hasStoreModule = (storeDir: string, exportKey: string): boolean => {
74
71
  };
75
72
 
76
73
  const unreachableStoreError = (generated: GeneratedModule, options: StoreOptions): Error => {
77
- const provided = generated.namespace === null ? "its index module" : `"${generated.namespace}"`;
74
+ const provided = `"${generated.namespace}"`;
78
75
 
79
76
  return new Error(
80
77
  `Cannot resolve "${generated.source}": the generated store in ${options.storeDir} does provide ` +
@@ -84,21 +81,22 @@ const unreachableStoreError = (generated: GeneratedModule, options: StoreOptions
84
81
  );
85
82
  };
86
83
 
87
- const missingIndexError = (generated: GeneratedModule): Error =>
88
- new Error(
89
- `Cannot resolve "${generated.source}": the binding store has no index module. ` +
90
- "Run gtkx codegen to regenerate the store.",
91
- );
92
-
93
84
  const undeclaredLibraryError = (source: string, namespace: string, girPath: string[]): Error => {
94
85
  const identifier = findGirIdentifier(girPath, namespace);
95
86
 
96
87
  if (identifier === undefined) {
97
88
  return new Error(
98
89
  `Cannot resolve "${source}": the binding store has no "${namespace}" module, and no ` +
99
- `GIR data for it was found in [${girPath.join(", ")}]. If "${namespace}" is a library, ` +
100
- "install its gobject-introspection data package and add its GIR identifier to `libraries` in " +
101
- "gtkx.config.ts. Otherwise run gtkx codegen to regenerate the store.",
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 " +
92
+ "GIR identifiers to `libraries` in gtkx.config.ts. Otherwise run gtkx codegen to regenerate the store.",
93
+ );
94
+ }
95
+
96
+ if (DEFAULT_LIBRARY_NAMESPACES.has(namespace)) {
97
+ return new Error(
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.",
102
100
  );
103
101
  }
104
102
 
@@ -110,16 +108,12 @@ const undeclaredLibraryError = (source: string, namespace: string, girPath: stri
110
108
 
111
109
  const unresolvedModuleError = async (state: PluginState, generated: GeneratedModule): Promise<Error> => {
112
110
  const options = getStoreOptions(state.root, generated.kind);
113
- const exportKey = generated.namespace === null ? "." : `./${generated.namespace}`;
111
+ const exportKey = `./${generated.namespace}`;
114
112
 
115
113
  if (options !== null && hasStoreModule(options.storeDir, exportKey)) {
116
114
  return unreachableStoreError(generated, options);
117
115
  }
118
116
 
119
- if (generated.namespace === null) {
120
- return missingIndexError(generated);
121
- }
122
-
123
117
  return undeclaredLibraryError(generated.source, generated.namespace, await girSearchPaths(state));
124
118
  };
125
119
 
@@ -56,7 +56,6 @@ const NON_CODE = new RegExp(
56
56
  const WORKER_DIR = "workers";
57
57
 
58
58
  const SUGGESTED_EXTENSIONS: Record<string, string[]> = {
59
- ".cjs": [".cts"],
60
59
  ".js": [".ts", ".tsx"],
61
60
  ".jsx": [".tsx"],
62
61
  ".mjs": [".mts"],
@@ -1,30 +0,0 @@
1
- type ScopeInfo = {
2
- defaultNs?: string;
3
- keyPrefix?: string;
4
- namespaces?: string[];
5
- };
6
- type ExtractedCall = {
7
- info: ScopeInfo;
8
- key: string;
9
- };
10
- type ExtractedMessage = {
11
- defaultValue: string;
12
- explicitDefault: boolean;
13
- key: string;
14
- location: {
15
- column?: number;
16
- file: string;
17
- line?: number;
18
- };
19
- ns?: string;
20
- };
21
- type BindingExtraction = {
22
- blockedGetFixedT: Set<string>;
23
- calls: Map<string, ExtractedCall>;
24
- errors: string[];
25
- messages: ExtractedMessage[];
26
- trans: Map<string, ScopeInfo | null>;
27
- };
28
- declare const extractBindings: (code: string, path: string) => Promise<BindingExtraction>;
29
- export { type BindingExtraction, type ScopeInfo, extractBindings };
30
- //# sourceMappingURL=binding-extractor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"binding-extractor.d.ts","sourceRoot":"","sources":["../../src/i18n/binding-extractor.ts"],"names":[],"mappings":"AAgBA,KAAK,SAAS,GAAG;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAiBF,KAAK,aAAa,GAAG;IACjB,IAAI,EAAE,SAAS,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,OAAO,CAAC;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE;QACN,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,EAAE,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACrB,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAClC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC,CAAC;CACxC,CAAC;AAslBF,QAAA,MAAM,eAAe,GAAU,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,OAAO,CAAC,iBAAiB,CA6BpF,CAAC;AAiwCF,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,SAAS,EAAE,eAAe,EAAE,CAAC"}