@gtkx/config 2.0.0-beta.12 → 2.0.0-beta.13

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/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { type Config, defineConfig, type ElementConfigOptions, mergeConfig, type ResolvedConfig } from "./config.ts";
2
- export { type DeployDesktopActionOptions, type DeployExtraFileOptions, type DeployFileAssociationOptions, type DeployNodeOptions, type DeployReleaseOptions, type DeployScreenshotOptions, } from "./deploy.ts";
3
- export { type ConfigLoader, type LoadedConfig, loadConfig } from "./loader.ts";
1
+ export { type AgentsOptions, type ApplicationConfig, type Config, defineConfig, type DeprecationsOptions, type ElementConfigOptions, type ElementPropsExport, type ElementsOptions, type McpOptions, mergeConfig, type ModuleExport, type ReactCompilerOptions, type ResolvedConfig, } from "./config.ts";
2
+ export { type DeployAppImageOptions, type DeployAppImageSigningOptions, type DeployBrandingOptions, type DeployDebOptions, type DeployDebPackageRelationOptions, type DeployDebSigningOptions, type DeployDesktopActionOptions, type DeployDeveloperOptions, type DeployExtraFileOptions, type DeployFileAssociationOptions, type DeployFlatpakOptions, type DeployFlatpakSigningOptions, type DeployFlatpakSourceOptions, type DeployNodeOptions, type DeployOptions, type DeployPackageRelationOptions, type DeployRelationsOptions, type DeployReleaseOptions, type DeployRpmOptions, type DeployRpmSigningOptions, type DeployScreenshotOptions, type DeployScriptsOptions, type DeploySigningOptions, type DeployToolsOptions, } from "./deploy.ts";
3
+ export { type ConfigLoader, type LoadConfigOptions, type LoadedConfig, loadConfig } from "./loader.ts";
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,YAAY,EAAE,KAAK,oBAAoB,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AACrH,OAAO,EACH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 +1,4 @@
1
- export { defineConfig, mergeConfig } from "./config.js";
1
+ export { defineConfig, mergeConfig, } from "./config.js";
2
2
  export {} from "./deploy.js";
3
3
  export { loadConfig } from "./loader.js";
4
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,YAAY,EAA6B,WAAW,EAAuB,MAAM,aAAa,CAAC;AACrH,OAAO,EAON,MAAM,aAAa,CAAC;AACrB,OAAO,EAAwC,UAAU,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export { type Config, defineConfig, type ElementConfigOptions, mergeConfig, type ResolvedConfig } from \"./config.ts\";\nexport {\n type DeployDesktopActionOptions,\n type DeployExtraFileOptions,\n type DeployFileAssociationOptions,\n type DeployNodeOptions,\n type DeployReleaseOptions,\n type DeployScreenshotOptions,\n} from \"./deploy.ts\";\nexport { type ConfigLoader, type LoadedConfig, loadConfig } from \"./loader.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,YAAY,EAMZ,WAAW,GAId,MAAM,aAAa,CAAC;AACrB,OAAO,EAyBN,MAAM,aAAa,CAAC;AACrB,OAAO,EAAgE,UAAU,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export {\n type AgentsOptions,\n type ApplicationConfig,\n type Config,\n defineConfig,\n type DeprecationsOptions,\n type ElementConfigOptions,\n type ElementPropsExport,\n type ElementsOptions,\n type McpOptions,\n mergeConfig,\n type ModuleExport,\n type ReactCompilerOptions,\n type ResolvedConfig,\n} from \"./config.ts\";\nexport {\n type DeployAppImageOptions,\n type DeployAppImageSigningOptions,\n type DeployBrandingOptions,\n type DeployDebOptions,\n type DeployDebPackageRelationOptions,\n type DeployDebSigningOptions,\n type DeployDesktopActionOptions,\n type DeployDeveloperOptions,\n type DeployExtraFileOptions,\n type DeployFileAssociationOptions,\n type DeployFlatpakOptions,\n type DeployFlatpakSigningOptions,\n type DeployFlatpakSourceOptions,\n type DeployNodeOptions,\n type DeployOptions,\n type DeployPackageRelationOptions,\n type DeployRelationsOptions,\n type DeployReleaseOptions,\n type DeployRpmOptions,\n type DeployRpmSigningOptions,\n type DeployScreenshotOptions,\n type DeployScriptsOptions,\n type DeploySigningOptions,\n type DeployToolsOptions,\n} from \"./deploy.ts\";\nexport { type ConfigLoader, type LoadConfigOptions, type LoadedConfig, loadConfig } from \"./loader.ts\";\n"]}
@@ -2,7 +2,7 @@ export { configDependenciesFor, loadConfigModule } from "./config-dependencies.t
2
2
  export { createConfigReloader } from "./config-reloader.ts";
3
3
  export { configCandidatePaths } from "./config-source.ts";
4
4
  export type { McpSettings, ResolvedReactCompilerOptions } from "./config.ts";
5
- export { APPLICATION_ID_MAX_LENGTH, isAgentReferenceEnabled, isAgentRulesEnabled, isValidApplicationId, resolveAcceptedChildTypes, resolveElementComponents, resolveElementProps, resolveLazyElements, resolveMcpSettings, resolveOmittedProps, } from "./config.ts";
5
+ export { APPLICATION_ID_MAX_LENGTH, isAgentReferenceEnabled, isAgentRulesEnabled, isValidApplicationId, LIBRARY_APPLICATION_ID, resolveAcceptedChildTypes, resolveElementComponents, resolveElementProps, resolveLazyElements, resolveMcpSettings, resolveOmittedProps, } from "./config.ts";
6
6
  export { createConfigLoader } from "./loader.ts";
7
7
  export { assertSupportedNodeVersion, DEFAULT_NODE_VERSION, MINIMUM_NODE_VERSION } from "./node-version.ts";
8
8
  export { resourceBasePath } from "./resource-base-path.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAA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ist/internal.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export { configDependenciesFor, loadConfigModule } from "./config-dependencies.js";
2
2
  export { createConfigReloader } from "./config-reloader.js";
3
3
  export { configCandidatePaths } from "./config-source.js";
4
- export { APPLICATION_ID_MAX_LENGTH, isAgentReferenceEnabled, isAgentRulesEnabled, isValidApplicationId, resolveAcceptedChildTypes, resolveElementComponents, resolveElementProps, resolveLazyElements, resolveMcpSettings, resolveOmittedProps, } from "./config.js";
4
+ export { APPLICATION_ID_MAX_LENGTH, isAgentReferenceEnabled, isAgentRulesEnabled, isValidApplicationId, LIBRARY_APPLICATION_ID, resolveAcceptedChildTypes, resolveElementComponents, resolveElementProps, resolveLazyElements, resolveMcpSettings, resolveOmittedProps, } from "./config.js";
5
5
  export { createConfigLoader } from "./loader.js";
6
6
  export { assertSupportedNodeVersion, DEFAULT_NODE_VERSION, MINIMUM_NODE_VERSION } from "./node-version.js";
7
7
  export { resourceBasePath } from "./resource-base-path.js";
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EACH,yBAAyB,EACzB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,yBAAyB,EACzB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC3G,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["export { configDependenciesFor, loadConfigModule } from \"./config-dependencies.ts\";\nexport { createConfigReloader } from \"./config-reloader.ts\";\nexport { configCandidatePaths } from \"./config-source.ts\";\nexport type { McpSettings, ResolvedReactCompilerOptions } from \"./config.ts\";\nexport {\n APPLICATION_ID_MAX_LENGTH,\n isAgentReferenceEnabled,\n isAgentRulesEnabled,\n isValidApplicationId,\n resolveAcceptedChildTypes,\n resolveElementComponents,\n resolveElementProps,\n resolveLazyElements,\n resolveMcpSettings,\n resolveOmittedProps,\n} from \"./config.ts\";\nexport { createConfigLoader } from \"./loader.ts\";\nexport { assertSupportedNodeVersion, DEFAULT_NODE_VERSION, MINIMUM_NODE_VERSION } from \"./node-version.ts\";\nexport { resourceBasePath } from \"./resource-base-path.ts\";\nexport { viteProjectRoot } from \"./vite-root.ts\";\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EACH,yBAAyB,EACzB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC3G,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["export { configDependenciesFor, loadConfigModule } from \"./config-dependencies.ts\";\nexport { createConfigReloader } from \"./config-reloader.ts\";\nexport { configCandidatePaths } from \"./config-source.ts\";\nexport type { McpSettings, ResolvedReactCompilerOptions } from \"./config.ts\";\nexport {\n APPLICATION_ID_MAX_LENGTH,\n isAgentReferenceEnabled,\n isAgentRulesEnabled,\n isValidApplicationId,\n LIBRARY_APPLICATION_ID,\n resolveAcceptedChildTypes,\n resolveElementComponents,\n resolveElementProps,\n resolveLazyElements,\n resolveMcpSettings,\n resolveOmittedProps,\n} from \"./config.ts\";\nexport { createConfigLoader } from \"./loader.ts\";\nexport { assertSupportedNodeVersion, DEFAULT_NODE_VERSION, MINIMUM_NODE_VERSION } from \"./node-version.ts\";\nexport { resourceBasePath } from \"./resource-base-path.ts\";\nexport { viteProjectRoot } from \"./vite-root.ts\";\n"]}
package/dist/loader.d.ts CHANGED
@@ -1,12 +1,22 @@
1
- import { type Config, type ResolvedConfig } from "./config.ts";
1
+ import { type ApplicationConfig, type ResolvedConfig } from "./config.ts";
2
2
  /** Result of loading a project's `gtkx.config.ts` file. */
3
3
  type LoadedConfig = {
4
- /** The parsed and validated configuration. */
5
- config: Config;
6
- /** Absolute path of the configuration file that was loaded. */
4
+ /** The parsed and validated configuration, with the default application ID filled in when one stood in. */
5
+ config: ApplicationConfig;
6
+ /** Whether the configuration names its own `applicationId`, rather than a default standing in for it. */
7
+ isApplication: boolean;
8
+ /**
9
+ * Absolute path of the configuration file that was loaded, or of `gtkx.config.ts` in the project root
10
+ * when a default application ID stood in for a missing file.
11
+ */
7
12
  configFile: string;
8
13
  /** Absolute path of the project root the configuration was resolved against. */
9
14
  root: string;
15
+ /**
16
+ * The gettext domain: the `applicationId` production builds use, so a `$development` application ID
17
+ * shares the production catalogs.
18
+ */
19
+ translationDomain: string;
10
20
  };
11
21
  /** How a configuration file is read, shared by {@link loadConfig} and `createConfigLoader`. */
12
22
  type LoadConfigOptions = {
@@ -17,6 +27,12 @@ type LoadConfigOptions = {
17
27
  mode?: string | undefined;
18
28
  /** Whether to report graduated future flags; supervising processes can own these warnings. Defaults to true. */
19
29
  shouldWarnGraduatedFuture?: boolean | undefined;
30
+ /**
31
+ * Application ID for a project that is not an application, such as a component library running its
32
+ * tests: it stands in for a missing `applicationId`, and for a missing configuration file unless
33
+ * `configFile` names a file other than `gtkx.config.ts` in the project root.
34
+ */
35
+ defaultApplicationId?: string | undefined;
20
36
  } & Partial<Record<"configFile", string | undefined>>;
21
37
  /** Reads a project's configuration once per directory, caching what it loads and what it resolves. */
22
38
  type ConfigLoader = {
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,MAAM,EAAsC,KAAK,cAAc,EAAkB,MAAM,aAAa,CAAC;AAGnH,2DAA2D;AAC3D,KAAK,YAAY,GAAG;IAChB,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,+FAA+F;AAC/F,KAAK,iBAAiB,GAAG;IACrB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,gHAAgH;IAChH,yBAAyB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACnD,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;AAEtD,sGAAsG;AACtG,KAAK,YAAY,GAAG;IAChB,gGAAgG;IAChG,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IAC7C,yGAAyG;IACzG,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;CACrD,CAAC;AAwDF;;;;;GAKG;AACH,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AAC;AAgGF;;;;;GAKG;AACH,QAAA,MAAM,UAAU,QAAe,MAAM,YAAW,iBAAiB,KAAQ,OAAO,CAAC,YAAY,CA2D5F,CAAC;AAEF,QAAA,MAAM,kBAAkB,aAAa,iBAAiB,KAAQ,YAkB7D,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,iBAAiB,EAAE,CAAC"}
package/dist/loader.js CHANGED
@@ -1,21 +1,43 @@
1
1
  import { isPathInside, warn } from "@gtkx/utils";
2
2
  import { loadConfig as loadConfigFile } from "c12";
3
+ import { defu } from "defu";
3
4
  import { existsSync } from "node:fs";
4
5
  import { relative, resolve } from "node:path";
5
6
  import { addConfigSource, captureConfigDependencies, createConfigImporter, setConfigDependencies, } from "./config-dependencies.js";
6
- import { missingConfigFileError } from "./config-error.js";
7
- import { localConfigSourcePath } from "./config-source.js";
8
- import { graduatedFutureKeys, resolveConfig, validateConfig } from "./config.js";
7
+ import { isRecord, missingConfigFileError } from "./config-error.js";
8
+ import { configCandidatePaths, localConfigSourcePaths } from "./config-source.js";
9
+ import { graduatedFutureKeys, resolveConfig, validateConfig, } from "./config.js";
9
10
  import { assertSupportedNodeVersion } from "./node-version.js";
10
11
  const graduatedFutureWarnings = new Map();
12
+ const PRODUCTION_MODE = "production";
13
+ const EXTEND_KEY = "extends";
14
+ const DEFAULT_CONFIG_FILE_NAME = "gtkx.config.ts";
15
+ const recordOrEmpty = (value) => (isRecord(value) ? value : {});
16
+ const modeOverrides = (layer, mode) => ({
17
+ ...recordOrEmpty(layer[`$${mode}`]),
18
+ ...recordOrEmpty(recordOrEmpty(layer.$env)[mode]),
19
+ });
20
+ const configForMode = (layers, mode) => {
21
+ const merged = defu({}, ...layers.map((layer) => (mode ? defu(modeOverrides(layer, mode), layer) : layer)));
22
+ for (const key of Object.keys(merged)) {
23
+ if (key === EXTEND_KEY || key.startsWith("$")) {
24
+ Reflect.deleteProperty(merged, key);
25
+ }
26
+ }
27
+ return merged;
28
+ };
29
+ const productionApplicationId = (layers, config) => {
30
+ const { applicationId } = configForMode(layers, PRODUCTION_MODE);
31
+ return typeof applicationId === "string" ? applicationId : config.applicationId;
32
+ };
33
+ const withDefaultApplicationId = (config, applicationId) => applicationId === undefined || config.applicationId !== undefined ? config : { ...config, applicationId };
11
34
  const rejectMissingLocalConfig = (source, options) => {
12
- const path = localConfigSourcePath(source, options);
13
- if (path === undefined) {
14
- return;
35
+ const paths = localConfigSourcePaths(source, options);
36
+ for (const path of paths) {
37
+ addConfigSource(path);
15
38
  }
16
- addConfigSource(path);
17
- if (!existsSync(path)) {
18
- throw new Error(`Extended configuration does not exist at ${path}`);
39
+ if (paths.length > 0 && !paths.some((path) => existsSync(path))) {
40
+ throw new Error(`Extended configuration ${source} does not exist in ${options.cwd ?? process.cwd()}`);
19
41
  }
20
42
  };
21
43
  const withConfigDependencies = (dependencies, operation) => {
@@ -39,6 +61,9 @@ const selectedConfigFile = (root, configured) => {
39
61
  }
40
62
  return relative(root, path);
41
63
  };
64
+ const explicitConfigFile = (root, selected) => selected !== undefined && configCandidatePaths(root).find((path) => existsSync(path)) === resolve(root, selected)
65
+ ? undefined
66
+ : selected;
42
67
  const warnGraduatedFuture = (config, root) => {
43
68
  const keys = graduatedFutureKeys(config);
44
69
  const signature = keys.join(",");
@@ -58,37 +83,45 @@ const loadConfig = async (cwd, options = {}) => {
58
83
  assertSupportedNodeVersion();
59
84
  const searched = resolve(cwd);
60
85
  const requestedConfigFile = selectedConfigFile(searched, options.configFile);
86
+ const c12ConfigFile = explicitConfigFile(searched, requestedConfigFile);
61
87
  const captured = await captureConfigDependencies(() => loadConfigFile({
62
88
  name: "gtkx",
63
89
  cwd: searched,
64
90
  rcFile: false,
65
91
  globalRc: false,
66
92
  packageJson: false,
67
- omit$Keys: true,
93
+ envName: false,
68
94
  context: { mode: options.mode },
69
95
  jiti: createConfigImporter(),
70
96
  resolve: rejectMissingLocalConfig,
71
- ...(requestedConfigFile !== undefined && { configFile: requestedConfigFile }),
72
- ...(options.mode !== undefined && { envName: options.mode }),
97
+ ...(c12ConfigFile !== undefined && { configFile: c12ConfigFile }),
73
98
  }));
74
99
  const result = captured.value;
75
100
  const configFile = result.configFile;
76
101
  const root = result.cwd ?? searched;
77
102
  const layerFiles = (result.layers ?? []).flatMap((layer) => layer.configFile === undefined ? [] : [resolve(layer.cwd ?? root, layer.configFile)]);
78
103
  const dependencies = [...(configFile === undefined ? [] : [configFile]), ...layerFiles, ...captured.dependencies];
104
+ const foundConfigFile = configFile !== undefined && existsSync(resolve(searched, configFile)) ? configFile : undefined;
105
+ const isConfigFileOptional = options.defaultApplicationId !== undefined &&
106
+ (requestedConfigFile === undefined || requestedConfigFile === DEFAULT_CONFIG_FILE_NAME);
79
107
  return withConfigDependencies(dependencies, () => {
80
- if (configFile === undefined || !existsSync(resolve(searched, configFile))) {
108
+ if (foundConfigFile === undefined && !isConfigFileOptional) {
81
109
  throw missingConfigFileError(searched, requestedConfigFile);
82
110
  }
83
- const config = result.config;
84
- validateConfig(config, configFile);
111
+ const layers = (result.layers ?? []).flatMap((layer) => (isRecord(layer.config) ? [layer.config] : []));
112
+ const authored = configForMode(layers, options.mode ?? process.env.NODE_ENV);
113
+ const config = withDefaultApplicationId(authored, options.defaultApplicationId);
114
+ const loadedConfigFile = foundConfigFile ?? resolve(searched, DEFAULT_CONFIG_FILE_NAME);
115
+ validateConfig(config, loadedConfigFile);
85
116
  if (options.shouldWarnGraduatedFuture !== false) {
86
117
  warnGraduatedFuture(config, root);
87
118
  }
88
119
  const loaded = {
89
120
  config,
90
- configFile,
121
+ isApplication: authored.applicationId !== undefined,
122
+ configFile: loadedConfigFile,
91
123
  root,
124
+ translationDomain: productionApplicationId(layers, config),
92
125
  };
93
126
  setConfigDependencies(loaded, dependencies);
94
127
  return loaded;
@@ -100,8 +133,8 @@ const createConfigLoader = (options = {}) => {
100
133
  const resolved = new Map();
101
134
  const load = (cwd) => loaded.getOrInsertComputed(resolve(cwd), (root) => loadConfig(root, options));
102
135
  const resolveAt = async (root) => {
103
- const { config, root: configRoot } = await load(root);
104
- return resolveConfig(config, configRoot);
136
+ const { config, root: configRoot, translationDomain } = await load(root);
137
+ return resolveConfig(config, translationDomain, configRoot);
105
138
  };
106
139
  return {
107
140
  load,
@@ -1 +1 @@
1
- {"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,KAAK,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EACH,eAAe,EACf,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAgC,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAe,mBAAmB,EAAE,aAAa,EAAuB,cAAc,EAAE,MAAM,aAAa,CAAC;AACnH,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AA+B/D,MAAM,uBAAuB,GAAwB,IAAI,GAAG,EAAE,CAAC;AAE/D,MAAM,wBAAwB,GAAG,CAAC,MAAc,EAAE,OAAgC,EAAa,EAAE;IAC7F,MAAM,IAAI,GAAG,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEpD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACrB,OAAO;IACX,CAAC;IAED,eAAe,CAAC,IAAI,CAAC,CAAC;IAEtB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,4CAA4C,IAAI,EA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CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAElF,MAAM,SAAS,GAAG,KAAK,EAAE,IAAY,EAA2B,EAAE;QAC9D,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;QAEtD,OAAO,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC7C,CAAC,CAAC;IAEF,OAAO;QACH,IAAI;QACJ,OAAO,EAAE,CAAC,GAAW,EAA2B,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC;KAC3G,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAgE,CAAC","sourcesContent":["import { isPathInside, warn } from \"@gtkx/utils\";\nimport { loadConfig as loadConfigFile } from \"c12\";\nimport { existsSync } from \"node:fs\";\nimport { relative, resolve } from \"node:path\";\nimport {\n addConfigSource,\n captureConfigDependencies,\n createConfigImporter,\n setConfigDependencies,\n} from \"./config-dependencies.ts\";\nimport { missingConfigFileError } from \"./config-error.ts\";\nimport { type ConfigResolutionOptions, localConfigSourcePath } from \"./config-source.ts\";\nimport { type Config, graduatedFutureKeys, resolveConfig, type ResolvedConfig, validateConfig } from \"./config.ts\";\nimport { assertSupportedNodeVersion } from \"./node-version.ts\";\n\n/** Result of loading a project's `gtkx.config.ts` file. */\ntype LoadedConfig = {\n /** The parsed and validated configuration. */\n config: Config;\n /** Absolute path of the configuration file that was loaded. */\n configFile: string;\n /** Absolute path of the project root the configuration was resolved against. */\n root: string;\n};\n\n/** How a configuration file is read, shared by {@link loadConfig} and `createConfigLoader`. */\ntype LoadConfigOptions = {\n /**\n * Environment name such as `development`: the config's matching `$<mode>` block is layered over the\n * top-level values, and the name is passed to a config authored as a function.\n */\n mode?: string | undefined;\n /** Whether to report graduated future flags; supervising processes can own these warnings. Defaults to true. */\n shouldWarnGraduatedFuture?: boolean | undefined;\n} & Partial<Record<\"configFile\", string | undefined>>;\n\n/** Reads a project's configuration once per directory, caching what it loads and what it resolves. */\ntype ConfigLoader = {\n /** Loads the configuration file the given directory resolves to, as {@link loadConfig} does. */\n load: (cwd: string) => Promise<LoadedConfig>;\n /** Loads the configuration for the given directory and reduces it to what the build and the app need. */\n resolve: (cwd: string) => Promise<ResolvedConfig>;\n};\n\nconst graduatedFutureWarnings: Map<string, string> = new Map();\n\nconst rejectMissingLocalConfig = (source: string, options: ConfigResolutionOptions): undefined => {\n const path = localConfigSourcePath(source, options);\n\n if (path === undefined) {\n return;\n }\n\n addConfigSource(path);\n\n if (!existsSync(path)) {\n throw new Error(`Extended configuration does not exist at ${path}`);\n }\n};\n\nconst withConfigDependencies = <T>(dependencies: string[], operation: () => T): T => {\n try {\n return operation();\n } catch (error) {\n if (typeof error === \"object\" && error !== null) {\n setConfigDependencies(error, dependencies);\n }\n\n throw error;\n }\n};\n\nconst selectedConfigFile = (root: string, configured: string | undefined): string | undefined => {\n if (configured === undefined) {\n return undefined;\n }\n\n const path = resolve(root, configured);\n\n if (!isPathInside(root, path)) {\n throw new Error(`Configuration file ${configured} must be inside the project root ${root}`);\n }\n\n return relative(root, path);\n};\n\nconst warnGraduatedFuture = (config: unknown, root: string): void => {\n const keys = graduatedFutureKeys(config);\n const signature = keys.join(\",\");\n\n if (keys.length === 0 || graduatedFutureWarnings.get(root) === signature) {\n return;\n }\n\n graduatedFutureWarnings.set(root, signature);\n warn(`GTKX 2 ignores graduated future flags: ${keys.join(\", \")}. Remove them from gtkx.config.ts.`);\n};\n\n/**\n * Loads and validates the `gtkx.config.ts` file for a project.\n * @param cwd Directory the configuration file is looked up in; parent directories are not searched.\n * @param options Loading options, such as the environment mode whose overrides are applied.\n * @throws When that directory holds no configuration file, or when the configuration fails validation.\n */\nconst loadConfig = async (cwd: string, options: LoadConfigOptions = {}): Promise<LoadedConfig> => {\n assertSupportedNodeVersion();\n const searched = resolve(cwd);\n const requestedConfigFile = selectedConfigFile(searched, options.configFile);\n\n const captured = await captureConfigDependencies(() =>\n loadConfigFile<Config>({\n name: \"gtkx\",\n cwd: searched,\n rcFile: false,\n globalRc: false,\n packageJson: false,\n omit$Keys: true,\n context: { mode: options.mode },\n jiti: createConfigImporter(),\n resolve: rejectMissingLocalConfig,\n ...(requestedConfigFile !== undefined && { configFile: requestedConfigFile }),\n ...(options.mode !== undefined && { envName: options.mode }),\n }),\n );\n const result = captured.value;\n\n const configFile = result.configFile;\n const root = result.cwd ?? searched;\n const layerFiles = (result.layers ?? []).flatMap((layer) =>\n layer.configFile === undefined ? [] : [resolve(layer.cwd ?? root, layer.configFile)],\n );\n const dependencies = [...(configFile === undefined ? [] : [configFile]), ...layerFiles, ...captured.dependencies];\n\n return withConfigDependencies(dependencies, () => {\n if (configFile === undefined || !existsSync(resolve(searched, configFile))) {\n throw missingConfigFileError(searched, requestedConfigFile);\n }\n\n const config = result.config;\n validateConfig(config, configFile);\n if (options.shouldWarnGraduatedFuture !== false) {\n warnGraduatedFuture(config, root);\n }\n\n const loaded = {\n config,\n configFile,\n root,\n };\n setConfigDependencies(loaded, dependencies);\n\n return loaded;\n });\n};\n\nconst createConfigLoader = (options: LoadConfigOptions = {}): ConfigLoader => {\n assertSupportedNodeVersion();\n const loaded: Map<string, Promise<LoadedConfig>> = new Map();\n const resolved: Map<string, Promise<ResolvedConfig>> = new Map();\n\n const load = (cwd: string): Promise<LoadedConfig> =>\n loaded.getOrInsertComputed(resolve(cwd), (root) => loadConfig(root, options));\n\n const resolveAt = async (root: string): Promise<ResolvedConfig> => {\n const { config, root: configRoot } = await load(root);\n\n return resolveConfig(config, configRoot);\n };\n\n return {\n load,\n resolve: (cwd: string): Promise<ResolvedConfig> => resolved.getOrInsertComputed(resolve(cwd), resolveAt),\n };\n};\n\nexport { loadConfig, createConfigLoader, type LoadedConfig, type ConfigLoader, type LoadConfigOptions };\n"]}
1
+ {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gB,EAAE;IACzE,0BAA0B,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAuC,IAAI,GAAG,EAAE,CAAC;IAC7D,MAAM,QAAQ,GAAyC,IAAI,GAAG,EAAE,CAAC;IAEjE,MAAM,IAAI,GAAG,CAAC,GAAW,EAAyB,EAAE,CAChD,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAElF,MAAM,SAAS,GAAG,KAAK,EAAE,IAAY,EAA2B,EAAE;QAC9D,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;QAEzE,OAAO,aAAa,CAAC,MAAM,EAAE,iBAAiB,EAAE,UAAU,CAAC,CAAC;IAChE,CAAC,CAAC;IAEF,OAAO;QACH,IAAI;QACJ,OAAO,EAAE,CAAC,GAAW,EAA2B,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC;KAC3G,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAgE,CAAC","sourcesContent":["import { isPathInside, warn } from \"@gtkx/utils\";\nimport { loadConfig as loadConfigFile } from \"c12\";\nimport { defu } from \"defu\";\nimport { existsSync } from \"node:fs\";\nimport { relative, resolve } from \"node:path\";\nimport {\n addConfigSource,\n captureConfigDependencies,\n createConfigImporter,\n setConfigDependencies,\n} from \"./config-dependencies.ts\";\nimport { isRecord, missingConfigFileError } from \"./config-error.ts\";\nimport { configCandidatePaths, type ConfigResolutionOptions, localConfigSourcePaths } from \"./config-source.ts\";\nimport {\n type ApplicationConfig,\n type Config,\n graduatedFutureKeys,\n resolveConfig,\n type ResolvedConfig,\n validateConfig,\n} from \"./config.ts\";\nimport { assertSupportedNodeVersion } from \"./node-version.ts\";\n\n/** Result of loading a project's `gtkx.config.ts` file. */\ntype LoadedConfig = {\n /** The parsed and validated configuration, with the default application ID filled in when one stood in. */\n config: ApplicationConfig;\n /** Whether the configuration names its own `applicationId`, rather than a default standing in for it. */\n isApplication: boolean;\n /**\n * Absolute path of the configuration file that was loaded, or of `gtkx.config.ts` in the project root\n * when a default application ID stood in for a missing file.\n */\n configFile: string;\n /** Absolute path of the project root the configuration was resolved against. */\n root: string;\n /**\n * The gettext domain: the `applicationId` production builds use, so a `$development` application ID\n * shares the production catalogs.\n */\n translationDomain: string;\n};\n\n/** How a configuration file is read, shared by {@link loadConfig} and `createConfigLoader`. */\ntype LoadConfigOptions = {\n /**\n * Environment name such as `development`: the config's matching `$<mode>` block is layered over the\n * top-level values, and the name is passed to a config authored as a function.\n */\n mode?: string | undefined;\n /** Whether to report graduated future flags; supervising processes can own these warnings. Defaults to true. */\n shouldWarnGraduatedFuture?: boolean | undefined;\n /**\n * Application ID for a project that is not an application, such as a component library running its\n * tests: it stands in for a missing `applicationId`, and for a missing configuration file unless\n * `configFile` names a file other than `gtkx.config.ts` in the project root.\n */\n defaultApplicationId?: string | undefined;\n} & Partial<Record<\"configFile\", string | undefined>>;\n\n/** Reads a project's configuration once per directory, caching what it loads and what it resolves. */\ntype ConfigLoader = {\n /** Loads the configuration file the given directory resolves to, as {@link loadConfig} does. */\n load: (cwd: string) => Promise<LoadedConfig>;\n /** Loads the configuration for the given directory and reduces it to what the build and the app need. */\n resolve: (cwd: string) => Promise<ResolvedConfig>;\n};\n\nconst graduatedFutureWarnings: Map<string, string> = new Map();\nconst PRODUCTION_MODE = \"production\";\nconst EXTEND_KEY = \"extends\";\nconst DEFAULT_CONFIG_FILE_NAME = \"gtkx.config.ts\";\n\nconst recordOrEmpty = (value: unknown): Record<string, unknown> => (isRecord(value) ? value : {});\n\nconst modeOverrides = (layer: Record<string, unknown>, mode: string): Record<string, unknown> => ({\n ...recordOrEmpty(layer[`$${mode}`]),\n ...recordOrEmpty(recordOrEmpty(layer.$env)[mode]),\n});\n\nconst configForMode = (layers: Record<string, unknown>[], mode: string | undefined): Record<string, unknown> => {\n const merged: Record<string, unknown> = defu(\n {},\n ...layers.map((layer) => (mode ? defu(modeOverrides(layer, mode), layer) : layer)),\n );\n\n for (const key of Object.keys(merged)) {\n if (key === EXTEND_KEY || key.startsWith(\"$\")) {\n Reflect.deleteProperty(merged, key);\n }\n }\n\n return merged;\n};\n\nconst productionApplicationId = (layers: Record<string, unknown>[], config: ApplicationConfig): string => {\n const { applicationId } = configForMode(layers, PRODUCTION_MODE);\n\n return typeof applicationId === \"string\" ? applicationId : config.applicationId;\n};\n\nconst withDefaultApplicationId = (\n config: Record<string, unknown>,\n applicationId: string | undefined,\n): Record<string, unknown> =>\n applicationId === undefined || config.applicationId !== undefined ? config : { ...config, applicationId };\n\nconst rejectMissingLocalConfig = (source: string, options: ConfigResolutionOptions): undefined => {\n const paths = localConfigSourcePaths(source, options);\n\n for (const path of paths) {\n addConfigSource(path);\n }\n\n if (paths.length > 0 && !paths.some((path) => existsSync(path))) {\n throw new Error(`Extended configuration ${source} does not exist in ${options.cwd ?? process.cwd()}`);\n }\n};\n\nconst withConfigDependencies = <T>(dependencies: string[], operation: () => T): T => {\n try {\n return operation();\n } catch (error) {\n if (typeof error === \"object\" && error !== null) {\n setConfigDependencies(error, dependencies);\n }\n\n throw error;\n }\n};\n\nconst selectedConfigFile = (root: string, configured: string | undefined): string | undefined => {\n if (configured === undefined) {\n return undefined;\n }\n\n const path = resolve(root, configured);\n\n if (!isPathInside(root, path)) {\n throw new Error(`Configuration file ${configured} must be inside the project root ${root}`);\n }\n\n return relative(root, path);\n};\n\nconst explicitConfigFile = (root: string, selected: string | undefined): string | undefined =>\n selected !== undefined && configCandidatePaths(root).find((path) => existsSync(path)) === resolve(root, selected)\n ? undefined\n : selected;\n\nconst warnGraduatedFuture = (config: unknown, root: string): void => {\n const keys = graduatedFutureKeys(config);\n const signature = keys.join(\",\");\n\n if (keys.length === 0 || graduatedFutureWarnings.get(root) === signature) {\n return;\n }\n\n graduatedFutureWarnings.set(root, signature);\n warn(`GTKX 2 ignores graduated future flags: ${keys.join(\", \")}. Remove them from gtkx.config.ts.`);\n};\n\n/**\n * Loads and validates the `gtkx.config.ts` file for a project.\n * @param cwd Directory the configuration file is looked up in; parent directories are not searched.\n * @param options Loading options, such as the environment mode whose overrides are applied.\n * @throws When that directory holds no configuration file, or when the configuration fails validation.\n */\nconst loadConfig = async (cwd: string, options: LoadConfigOptions = {}): Promise<LoadedConfig> => {\n assertSupportedNodeVersion();\n const searched = resolve(cwd);\n const requestedConfigFile = selectedConfigFile(searched, options.configFile);\n const c12ConfigFile = explicitConfigFile(searched, requestedConfigFile);\n\n const captured = await captureConfigDependencies(() =>\n loadConfigFile<Config>({\n name: \"gtkx\",\n cwd: searched,\n rcFile: false,\n globalRc: false,\n packageJson: false,\n envName: false,\n context: { mode: options.mode },\n jiti: createConfigImporter(),\n resolve: rejectMissingLocalConfig,\n ...(c12ConfigFile !== undefined && { configFile: c12ConfigFile }),\n }),\n );\n const result = captured.value;\n\n const configFile = result.configFile;\n const root = result.cwd ?? searched;\n const layerFiles = (result.layers ?? []).flatMap((layer) =>\n layer.configFile === undefined ? [] : [resolve(layer.cwd ?? root, layer.configFile)],\n );\n const dependencies = [...(configFile === undefined ? [] : [configFile]), ...layerFiles, ...captured.dependencies];\n const foundConfigFile =\n configFile !== undefined && existsSync(resolve(searched, configFile)) ? configFile : undefined;\n const isConfigFileOptional =\n options.defaultApplicationId !== undefined &&\n (requestedConfigFile === undefined || requestedConfigFile === DEFAULT_CONFIG_FILE_NAME);\n\n return withConfigDependencies(dependencies, () => {\n if (foundConfigFile === undefined && !isConfigFileOptional) {\n throw missingConfigFileError(searched, requestedConfigFile);\n }\n\n const layers = (result.layers ?? []).flatMap((layer) => (isRecord(layer.config) ? [layer.config] : []));\n const authored = configForMode(layers, options.mode ?? process.env.NODE_ENV);\n const config = withDefaultApplicationId(authored, options.defaultApplicationId);\n const loadedConfigFile = foundConfigFile ?? resolve(searched, DEFAULT_CONFIG_FILE_NAME);\n validateConfig(config, loadedConfigFile);\n if (options.shouldWarnGraduatedFuture !== false) {\n warnGraduatedFuture(config, root);\n }\n\n const loaded = {\n config,\n isApplication: authored.applicationId !== undefined,\n configFile: loadedConfigFile,\n root,\n translationDomain: productionApplicationId(layers, config),\n };\n setConfigDependencies(loaded, dependencies);\n\n return loaded;\n });\n};\n\nconst createConfigLoader = (options: LoadConfigOptions = {}): ConfigLoader => {\n assertSupportedNodeVersion();\n const loaded: Map<string, Promise<LoadedConfig>> = new Map();\n const resolved: Map<string, Promise<ResolvedConfig>> = new Map();\n\n const load = (cwd: string): Promise<LoadedConfig> =>\n loaded.getOrInsertComputed(resolve(cwd), (root) => loadConfig(root, options));\n\n const resolveAt = async (root: string): Promise<ResolvedConfig> => {\n const { config, root: configRoot, translationDomain } = await load(root);\n\n return resolveConfig(config, translationDomain, configRoot);\n };\n\n return {\n load,\n resolve: (cwd: string): Promise<ResolvedConfig> => resolved.getOrInsertComputed(resolve(cwd), resolveAt),\n };\n};\n\nexport { loadConfig, createConfigLoader, type LoadedConfig, type ConfigLoader, type LoadConfigOptions };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"virtual.d.ts","sourceRoot":"","sources":["../src/virtual.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,QAAA,MAAM,sBAAsB,wBAAwB,CAAC;AACrD,QAAA,MAAM,+BAA+B,0BAAgC,CAAC;AAEtE,QAAA,MAAM,kBAAkB,WAAY,cAAc,cAAa,MAAM,GAAG,IAAI,KAAU,MAqBrF,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,kBAAkB,EAAE,CAAC"}
1
+ {"version":3,"file":"virtual.d.ts","sourceRoot":"","sources":["../src/virtual.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,QAAA,MAAM,sBAAsB,wBAAwB,CAAC;AACrD,QAAA,MAAM,+BAA+B,0BAAgC,CAAC;AAEtE,QAAA,MAAM,kBAAkB,WAAY,cAAc,cAAa,MAAM,GAAG,IAAI,KAAU,MAsBrF,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,kBAAkB,EAAE,CAAC"}
package/dist/virtual.js CHANGED
@@ -12,6 +12,7 @@ const renderConfigModule = (config, localeDir = null) => {
12
12
  return [
13
13
  ...behaviorImports,
14
14
  `export const applicationId = ${JSON.stringify(config.applicationId)};`,
15
+ `export const translationDomain = ${JSON.stringify(config.translationDomain)};`,
15
16
  `export const localeDir = ${JSON.stringify(localeDir)};`,
16
17
  `export const resourceBasePath = ${JSON.stringify(resourceBasePath(config.applicationId))};`,
17
18
  `export const userEventSignals = ${JSON.stringify(config.userEventSignals)};`,
@@ -1 +1 @@
1
- {"version":3,"file":"virtual.js","sourceRoot":"","sources":["../src/virtual.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,sBAAsB,GAAG,qBAAqB,CAAC;AACrD,MAAM,+BAA+B,GAAG,KAAK,sBAAsB,EAAE,CAAC;AAEtE,MAAM,kBAAkB,GAAG,CAAC,MAAsB,EAAE,SAAS,GAAkB,IAAI,EAAU,EAAE;IAC3F,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjH,MAAM,eAAe,GACjB,MAAM,CAAC,QAAQ,KAAK,IAAI;QACpB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC;YACI,2DAA2D;YAC3D,kCAAkC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG;SACvE,CAAC;IAEZ,OAAO;QACH,GAAG,eAAe;QAClB,gCAAgC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG;QACvE,4BAA4B,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG;QACxD,mCAAmC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,GAAG;QAC5F,mCAAmC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG;QAC7E,MAAM,CAAC,QAAQ,KAAK,IAAI;YACpB,CAAC,CAAC,2BAA2B,QAAQ,GAAG;YACxC,CAAC,CAAC,mEAAmE,QAAQ,IAAI;KACxF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["import type { ResolvedConfig } from \"./config.ts\";\nimport { resourceBasePath } from \"./resource-base-path.ts\";\n\nconst GTKX_CONFIG_VIRTUAL_ID = \"virtual:gtkx-config\";\nconst RESOLVED_GTKX_CONFIG_VIRTUAL_ID = `\\0${GTKX_CONFIG_VIRTUAL_ID}`;\n\nconst renderConfigModule = (config: ResolvedConfig, localeDir: string | null = null): string => {\n const lazyJson = JSON.stringify(Object.fromEntries(config.lazyElements.map((type) => [type, { isLazy: true }])));\n\n const behaviorImports =\n config.elements === null\n ? []\n : [\n 'import { mergeElementConfigs } from \"@gtkx/react/config\";',\n `import __elementBehaviors from ${JSON.stringify(config.elements)};`,\n ];\n\n return [\n ...behaviorImports,\n `export const applicationId = ${JSON.stringify(config.applicationId)};`,\n `export const localeDir = ${JSON.stringify(localeDir)};`,\n `export const resourceBasePath = ${JSON.stringify(resourceBasePath(config.applicationId))};`,\n `export const userEventSignals = ${JSON.stringify(config.userEventSignals)};`,\n config.elements === null\n ? `export const elements = ${lazyJson};`\n : `export const elements = mergeElementConfigs(__elementBehaviors, ${lazyJson});`,\n ].join(\"\\n\");\n};\n\nexport { GTKX_CONFIG_VIRTUAL_ID, RESOLVED_GTKX_CONFIG_VIRTUAL_ID, renderConfigModule };\n"]}
1
+ {"version":3,"file":"virtual.js","sourceRoot":"","sources":["../src/virtual.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,sBAAsB,GAAG,qBAAqB,CAAC;AACrD,MAAM,+BAA+B,GAAG,KAAK,sBAAsB,EAAE,CAAC;AAEtE,MAAM,kBAAkB,GAAG,CAAC,MAAsB,EAAE,SAAS,GAAkB,IAAI,EAAU,EAAE;IAC3F,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjH,MAAM,eAAe,GACjB,MAAM,CAAC,QAAQ,KAAK,IAAI;QACpB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC;YACI,2DAA2D;YAC3D,kCAAkC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG;SACvE,CAAC;IAEZ,OAAO;QACH,GAAG,eAAe;QAClB,gCAAgC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG;QACvE,oCAAoC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,iBAAiB,CAAC,GAAG;QAC/E,4BAA4B,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG;QACxD,mCAAmC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,GAAG;QAC5F,mCAAmC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG;QAC7E,MAAM,CAAC,QAAQ,KAAK,IAAI;YACpB,CAAC,CAAC,2BAA2B,QAAQ,GAAG;YACxC,CAAC,CAAC,mEAAmE,QAAQ,IAAI;KACxF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["import type { ResolvedConfig } from \"./config.ts\";\nimport { resourceBasePath } from \"./resource-base-path.ts\";\n\nconst GTKX_CONFIG_VIRTUAL_ID = \"virtual:gtkx-config\";\nconst RESOLVED_GTKX_CONFIG_VIRTUAL_ID = `\\0${GTKX_CONFIG_VIRTUAL_ID}`;\n\nconst renderConfigModule = (config: ResolvedConfig, localeDir: string | null = null): string => {\n const lazyJson = JSON.stringify(Object.fromEntries(config.lazyElements.map((type) => [type, { isLazy: true }])));\n\n const behaviorImports =\n config.elements === null\n ? []\n : [\n 'import { mergeElementConfigs } from \"@gtkx/react/config\";',\n `import __elementBehaviors from ${JSON.stringify(config.elements)};`,\n ];\n\n return [\n ...behaviorImports,\n `export const applicationId = ${JSON.stringify(config.applicationId)};`,\n `export const translationDomain = ${JSON.stringify(config.translationDomain)};`,\n `export const localeDir = ${JSON.stringify(localeDir)};`,\n `export const resourceBasePath = ${JSON.stringify(resourceBasePath(config.applicationId))};`,\n `export const userEventSignals = ${JSON.stringify(config.userEventSignals)};`,\n config.elements === null\n ? `export const elements = ${lazyJson};`\n : `export const elements = mergeElementConfigs(__elementBehaviors, ${lazyJson});`,\n ].join(\"\\n\");\n};\n\nexport { GTKX_CONFIG_VIRTUAL_ID, RESOLVED_GTKX_CONFIG_VIRTUAL_ID, renderConfigModule };\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtkx/config",
3
- "version": "2.0.0-beta.12",
3
+ "version": "2.0.0-beta.13",
4
4
  "description": "Typed application configuration for GTKX.",
5
5
  "keywords": [
6
6
  "gtkx",
@@ -62,15 +62,15 @@
62
62
  "node": ">=26.7.0"
63
63
  },
64
64
  "dependencies": {
65
- "@gtkx/utils": "2.0.0-beta.12",
65
+ "@gtkx/utils": "^2.0.0-beta.13",
66
66
  "c12": "^3.3.4",
67
67
  "defu": "^6.1.7",
68
68
  "jiti": "^2.7.0",
69
- "vite": "^8.3.4",
69
+ "vite": "^8.3.5",
70
70
  "zod": "^4.6.7"
71
71
  },
72
72
  "devDependencies": {
73
- "vitest": "5.0.5"
73
+ "vitest": "5.1.0"
74
74
  },
75
75
  "scripts": {
76
76
  "release": "node ../../scripts/release/publish-package.ts"
@@ -38,18 +38,48 @@ const SINGLE_CHILD_TYPES: string[] = [
38
38
 
39
39
  const CONTENT_SETTER_TYPES: string[] = ["AdwBottomSheet", "AdwOverlaySplitView"];
40
40
 
41
+ const SINGLE_CHILD_CONFIG: ElementConfigOptions = { props: internal("ChildrenProps"), omittedProps: ["child"] };
42
+ const CONTENT_SETTER_CONFIG: ElementConfigOptions = { props: internal("ChildrenProps"), omittedProps: ["content"] };
43
+
44
+ /** `GMenuItem` props written as the GtkBuilder menu attribute of the same name, keyed by prop. */
45
+ const MENU_ITEM_ATTRIBUTES = {
46
+ custom: "custom",
47
+ hiddenWhen: "hidden-when",
48
+ accel: "accel",
49
+ icon: "icon",
50
+ verbIcon: "verb-icon",
51
+ useMarkup: "use-markup",
52
+ submenuAction: "submenu-action",
53
+ displayHint: "display-hint",
54
+ textDirection: "text-direction",
55
+ } as const satisfies Record<string, string>;
56
+
41
57
  /**
42
58
  * Built-in GTK and Adwaita element metadata: base props, component wrappers, omitted properties,
43
59
  * and parent-created objects. Contains no behaviors and can be imported without loading GI bindings.
44
60
  */
45
61
  const BUILTIN_ELEMENTS: Record<string, ElementConfigOptions> = {
46
- ...forTypes(SINGLE_CHILD_TYPES, {
47
- props: internal("ChildrenProps"),
48
- omittedProps: ["child"],
49
- }),
62
+ ...forTypes(SINGLE_CHILD_TYPES, SINGLE_CHILD_CONFIG),
63
+ GtkSearchBar: {
64
+ ...SINGLE_CHILD_CONFIG,
65
+ component: internal("createSearchBarComponent"),
66
+ },
50
67
  ...forTypes(["GtkHeaderBar", "GtkActionBar"], {
51
68
  props: internal("GtkHeaderBarProps"),
52
69
  }),
70
+ GtkMenuButton: {
71
+ props: internal("GtkMenuButtonProps"),
72
+ component: internal("createCustomChildrenComponent"),
73
+ omittedProps: ["child"],
74
+ },
75
+ GtkPopoverMenu: {
76
+ props: internal("CustomChildrenProps"),
77
+ component: internal("createCustomChildrenComponent"),
78
+ },
79
+ GtkPopoverMenuBar: {
80
+ props: internal("CustomChildrenProps"),
81
+ component: internal("createCustomChildrenComponent"),
82
+ },
53
83
  GtkWindow: {
54
84
  props: internal("ChildrenProps"),
55
85
  component: internal("createWindowComponent"),
@@ -149,7 +179,10 @@ const BUILTIN_ELEMENTS: Record<string, ElementConfigOptions> = {
149
179
  },
150
180
  GMenuItem: {
151
181
  component: internal("createMenuItemComponent"),
152
- props: { ...internal("MenuItemProps"), constructOnly: ["label", "action"] },
182
+ props: {
183
+ ...internal("MenuItemProps"),
184
+ constructOnly: ["label", "action", ...Object.keys(MENU_ITEM_ATTRIBUTES)],
185
+ },
153
186
  },
154
187
  GtkColumnView: {
155
188
  acceptedChildTypes: ["GtkColumnViewColumn"],
@@ -202,10 +235,14 @@ const BUILTIN_ELEMENTS: Record<string, ElementConfigOptions> = {
202
235
  GtkDragSource: {
203
236
  props: internal("GtkDragSourceProps"),
204
237
  },
205
- ...forTypes(CONTENT_SETTER_TYPES, {
206
- props: internal("ChildrenProps"),
207
- omittedProps: ["content"],
208
- }),
238
+ AdwBottomSheet: {
239
+ ...CONTENT_SETTER_CONFIG,
240
+ component: internal("createBottomSheetComponent"),
241
+ },
242
+ AdwOverlaySplitView: {
243
+ ...CONTENT_SETTER_CONFIG,
244
+ component: internal("createOverlaySplitViewComponent"),
245
+ },
209
246
  AdwClampScrollable: {
210
247
  props: internal("ChildrenProps"),
211
248
  omittedProps: ["child"],
@@ -222,6 +259,7 @@ const BUILTIN_ELEMENTS: Record<string, ElementConfigOptions> = {
222
259
  },
223
260
  AdwTabOverview: {
224
261
  props: internal("AdwTabDropProps"),
262
+ component: internal("createTabOverviewComponent"),
225
263
  omittedProps: ["child"],
226
264
  },
227
265
  AdwAboutDialog: {
@@ -277,6 +315,7 @@ const BUILTIN_ELEMENTS: Record<string, ElementConfigOptions> = {
277
315
  AdwNavigationSplitView: {
278
316
  acceptedChildTypes: ["AdwNavigationPage"],
279
317
  props: internal("ChildrenProps"),
318
+ component: internal("createNavigationSplitViewComponent"),
280
319
  omittedProps: ["content"],
281
320
  },
282
321
  AdwWrapBox: {
@@ -333,6 +372,6 @@ const BUILTIN_ELEMENTS: Record<string, ElementConfigOptions> = {
333
372
  },
334
373
  };
335
374
 
336
- export { SINGLE_CHILD_TYPES, CONTENT_SETTER_TYPES, BUILTIN_ELEMENTS };
375
+ export { SINGLE_CHILD_TYPES, CONTENT_SETTER_TYPES, MENU_ITEM_ATTRIBUTES, BUILTIN_ELEMENTS };
337
376
 
338
377
  export type { ElementConfigOptions, ElementPropsExport, ModuleExport } from "./config.ts";
@@ -33,16 +33,20 @@ const isDirectoryConfigSource = (source: string): boolean => {
33
33
  return extension.length === 0 || extension === basename(source);
34
34
  };
35
35
 
36
- const localConfigSourcePath = (source: string, options: ConfigResolutionOptions): string | undefined => {
36
+ const localConfigSourcePaths = (source: string, options: ConfigResolutionOptions): string[] => {
37
37
  if (source === "." || !isLocalConfigSource(source)) {
38
- return undefined;
38
+ return [];
39
39
  }
40
40
 
41
- const cwd = options.cwd ?? process.cwd();
41
+ const path = resolve(options.cwd ?? process.cwd(), source);
42
42
 
43
- return isDirectoryConfigSource(source)
44
- ? resolve(cwd, source, options.configFile ?? "gtkx.config")
45
- : resolve(cwd, source);
43
+ if (!isDirectoryConfigSource(source)) {
44
+ return [path];
45
+ }
46
+
47
+ return options.configFile === undefined || options.configFile === CONFIG_LOCATIONS[0]
48
+ ? configCandidatePaths(path)
49
+ : [join(path, options.configFile)];
46
50
  };
47
51
 
48
- export { configCandidatePaths, configSourceCandidates, localConfigSourcePath, type ConfigResolutionOptions };
52
+ export { configCandidatePaths, configSourceCandidates, localConfigSourcePaths, type ConfigResolutionOptions };