@gtkx/config 1.0.0-rc.3 → 1.0.0-rc.4

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/README.md CHANGED
@@ -6,7 +6,8 @@
6
6
 
7
7
  <p align="center">
8
8
  The React framework for Linux.<br />
9
- Build GTK4 and Adwaita apps in TypeScript, with React components and hooks driving GNOME's own widgets. What you ship is a GNOME app.
9
+ Write native Linux applications with React and TypeScript.
10
+ Built on the GNOME stack and standard web tooling.
10
11
  </p>
11
12
 
12
13
  <p align="center">
@@ -20,15 +21,13 @@
20
21
 
21
22
  <p align="center">
22
23
  <a href="https://gtkx.dev">Homepage</a> &middot;
23
- <a href="https://gtkx.dev/guide/why-gtkx">Documentation</a> &middot;
24
+ <a href="https://gtkx.dev/guide/getting-started">Documentation</a> &middot;
24
25
  <a href="https://github.com/gtkx-org/gtkx/tree/main/examples">Examples</a> &middot;
25
26
  <a href="https://github.com/gtkx-org/gtkx/blob/main/CONTRIBUTING.md">Contributing</a>
26
27
  </p>
27
28
 
28
29
  ---
29
30
 
30
- GTKX generates fully typed bindings for the entire GTK4 and Adwaita surface directly from GObject-Introspection. On top of those bindings you get the React programming model: components and hooks driving GObject instances, with Fast Refresh while you develop.
31
-
32
31
  <p align="center">
33
32
  <img src="https://raw.githubusercontent.com/gtkx-org/gtkx/main/examples/tutorial/assets/screenshot.png" alt="The Tasks app: an Adwaita window with a sidebar of smart views and colored lists on the left, and a boxed task list on the right." />
34
33
  </p>
@@ -109,7 +108,7 @@ React Native and similar frameworks hide the native toolkit so one API can run e
109
108
 
110
109
  ### Why Node.js, and why generated bindings
111
110
 
112
- GTKX runs on Node.js, which puts native modules, the npm ecosystem, and the tooling built for Node.js APIs within reach. GJS is GNOME's own runtime, built on SpiderMonkey rather than V8; node-gtk runs on Node.js but is lightly maintained, on the older nan/V8 ABI rather than N-API, and still centered on GTK3. The [why-gtkx guide](https://gtkx.dev/guide/why-gtkx) covers the comparison in full.
111
+ GTKX runs on Node.js, which puts native modules, the npm ecosystem, and the tooling built for Node.js APIs within reach. GJS is GNOME's own runtime, built on SpiderMonkey rather than V8; node-gtk runs on Node.js but is lightly maintained, on the older nan/V8 ABI rather than N-API, and still centered on GTK3. The [Why GTKX guide](https://gtkx.dev/guide/why-gtkx) covers the comparison in full.
113
112
 
114
113
  GTKX generates the TypeScript types and the native FFI calls from the same GObject-Introspection data, so the types cannot drift from the calls they back. Codegen covers the whole GTK4 and Adwaita surface.
115
114
 
package/dist/config.d.ts CHANGED
@@ -1,48 +1,53 @@
1
1
  import { type DefineConfig } from "c12";
2
2
  import { z } from "zod";
3
+ /** Accepted `reactCompiler.compilationMode` values, choosing which functions the compiler processes. */
3
4
  type ReactCompilerCompilationMode = (typeof COMPILATION_MODES)[number];
5
+ /** Accepted `reactCompiler.panicThreshold` values, choosing which compiler diagnostics fail the build. */
4
6
  type ReactCompilerPanicThreshold = (typeof PANIC_THRESHOLDS)[number];
7
+ /** Object form of the `reactCompiler` config key, forwarded as-is to `babel-plugin-react-compiler`. */
5
8
  type ReactCompilerOptions = {
9
+ /** Which functions the compiler processes; left to the compiler's own default when omitted. */
6
10
  compilationMode?: ReactCompilerCompilationMode;
11
+ /** Which compiler diagnostics fail the build; left to the compiler's own default when omitted. */
7
12
  panicThreshold?: ReactCompilerPanicThreshold;
8
13
  };
9
14
  /**
10
- * React Compiler options resolved for the build, with the compilation target
11
- * fixed to React 19.
15
+ * The React Compiler options the build hands to `babel-plugin-react-compiler`, with the React version
16
+ * GTKX targets filled in.
12
17
  */
13
18
  type ResolvedReactCompilerOptions = ReactCompilerOptions & {
19
+ /** React major version the compiler emits for. */
14
20
  target: "19";
15
21
  };
16
22
  /**
17
- * User-facing configuration for a GTKX project, as authored in `gtkx.config.ts`:
18
- * the GIR libraries to bind, extra `.gir` search paths, the GApplication id,
19
- * a module of per-element configuration (lazy flags and custom behaviors),
20
- * per-element component wrappers and omitted props keyed by GLib type name, the
21
- * React Compiler and codegen settings, additional user event signals to suppress
22
- * during React commits, and extra GIR records to treat as class structs.
23
+ * User-facing configuration for a GTKX project, as authored in `gtkx.config.ts`: the GIR libraries
24
+ * to bind and where to find them, the GApplication id, per-element configuration, and the React
25
+ * Compiler, codegen, and user event signal settings.
23
26
  */
24
27
  type Config = z.infer<typeof configSchema>;
25
- /** A `{ module, export }` reference to a named export, as element config entries carry it. */
28
+ /** A named export referenced as plain data, so codegen can emit an import for it without loading the module. */
26
29
  type ModuleExport = z.infer<typeof moduleExportSchema>;
27
- /**
28
- * Configuration reduced to the values needed at runtime: the GApplication
29
- * identifier, the resolved React Compiler options (`null` when disabled), the
30
- * user event signals suppressed while a React commit is in progress, and the
31
- * module path holding per-element configuration (`null` when unset).
32
- */
30
+ /** Configuration reduced to the values the app runtime and the build need, with paths already resolved. */
33
31
  type ResolvedConfig = {
32
+ /** The GApplication identifier the app registers under. */
34
33
  applicationId: string;
34
+ /** React Compiler options for the build, or `null` when the compiler is disabled. */
35
35
  reactCompiler: ResolvedReactCompilerOptions | null;
36
+ /** Signal names, keyed by GLib type name, that stay suppressed while a React commit runs. */
36
37
  userEventSignals: Record<string, string[]>;
38
+ /** Path of the module exporting per-element configs, or `null` when none is configured. */
37
39
  elements: string | null;
40
+ /** GLib type names of the elements marked `isLazy`, whose GObject their parent container creates. */
38
41
  lazyElements: string[];
39
42
  };
40
43
  declare const COMPILATION_MODES: readonly ["infer", "syntax", "annotation", "all"];
41
44
  declare const PANIC_THRESHOLDS: readonly ["none", "critical_errors", "all_errors"];
45
+ /** Validates a `{ module, export }` reference to a named export. */
42
46
  declare const moduleExportSchema: z.ZodObject<{
43
47
  module: z.ZodString;
44
48
  export: z.ZodString;
45
49
  }, z.core.$strip>;
50
+ /** The shape every `gtkx.config.ts` is validated against, and the source of the {@link Config} type. */
46
51
  declare const configSchema: z.ZodObject<{
47
52
  libraries: z.ZodOptional<z.ZodCustom<string[] | "*", string[] | "*">>;
48
53
  girPath: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -61,29 +66,28 @@ declare const configSchema: z.ZodObject<{
61
66
  module: z.ZodString;
62
67
  export: z.ZodString;
63
68
  }, z.core.$strip>>;
64
- lazy: z.ZodOptional<z.ZodBoolean>;
65
- omitProps: z.ZodOptional<z.ZodArray<z.ZodString>>;
69
+ isLazy: z.ZodOptional<z.ZodBoolean>;
70
+ omittedProps: z.ZodOptional<z.ZodArray<z.ZodString>>;
66
71
  }, z.core.$strip>>>;
67
72
  }, z.core.$strip>>;
68
73
  }, z.core.$strip>;
69
74
  /**
70
- * Identity helper that returns the given configuration typed as {@link Config},
71
- * enabling editor autocompletion and type checking in `gtkx.config.ts`.
75
+ * Returns the given configuration unchanged, typed as {@link Config}, so `gtkx.config.ts` gets
76
+ * autocompletion and type checking.
72
77
  */
73
78
  declare const defineConfig: DefineConfig<Config>;
74
79
  declare const isValidApplicationId: (applicationId: string) => boolean;
75
80
  declare const resolveReactCompilerOptions: (setting: Config["reactCompiler"]) => ResolvedReactCompilerOptions | null;
76
81
  declare const validateConfig: (config: Config) => void;
77
82
  /**
78
- * Deep-merges two configurations, with `override` taking precedence over `base`.
79
- * @param base The lower-priority configuration.
80
- * @param override The higher-priority configuration whose values win on conflict.
83
+ * Deep-merges two configurations. `override` wins over `base` on conflicting scalar and object keys, while
84
+ * arrays are concatenated with the `override` entries first.
81
85
  */
82
86
  declare const mergeConfig: (base: Config, override: Config) => Config;
83
87
  declare const resolveLazyElements: (elements: Config["elements"]) => string[];
84
88
  declare const resolveElementComponents: (elements: Config["elements"]) => Record<string, ModuleExport>;
85
89
  declare const resolveElementProps: (elements: Config["elements"]) => Record<string, ModuleExport>;
86
- declare const resolveOmitProps: (elements: Config["elements"]) => Record<string, string[]>;
90
+ declare const resolveOmittedProps: (elements: Config["elements"]) => Record<string, string[]>;
87
91
  declare const resolveConfig: (config: Config, root?: string) => ResolvedConfig;
88
- export { defineConfig, isValidApplicationId, resolveReactCompilerOptions, validateConfig, mergeConfig, resolveLazyElements, resolveElementComponents, resolveElementProps, resolveOmitProps, resolveConfig, type ResolvedReactCompilerOptions, type Config, type ModuleExport, type ResolvedConfig, };
92
+ export { defineConfig, isValidApplicationId, resolveReactCompilerOptions, validateConfig, mergeConfig, resolveLazyElements, resolveElementComponents, resolveElementProps, resolveOmittedProps, resolveConfig, type ResolvedReactCompilerOptions, type Config, type ModuleExport, type ResolvedConfig, };
89
93
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,KAAK,CAAC;AAG5D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,KAAK,4BAA4B,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AACvE,KAAK,2BAA2B,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAErE,KAAK,oBAAoB,GAAG;IACxB,eAAe,CAAC,EAAE,4BAA4B,CAAC;IAC/C,cAAc,CAAC,EAAE,2BAA2B,CAAC;CAChD,CAAC;AAEF;;;GAGG;AACH,KAAK,4BAA4B,GAAG,oBAAoB,GAAG;IACvD,MAAM,EAAE,IAAI,CAAC;CAChB,CAAC;AAEF;;;;;;;GAOG;AACH,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAC3C,8FAA8F;AAC9F,KAAK,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAGvD;;;;;GAKG;AACH,KAAK,cAAc,GAAG;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,4BAA4B,GAAG,IAAI,CAAC;IACnD,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC3C,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,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oB,EACpB,2BAA2B,EAC3B,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,KAAK,4BAA4B,EACjC,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,cAAc,GACtB,CAAC"}
package/dist/config.js CHANGED
@@ -13,6 +13,7 @@ const PANIC_THRESHOLDS = ["none", "critical_errors", "all_errors"];
13
13
  const REACT_COMPILER_TARGET = "19";
14
14
  const COMPILATION_MODE_SET = new Set(COMPILATION_MODES);
15
15
  const PANIC_THRESHOLD_SET = new Set(PANIC_THRESHOLDS);
16
+ /** Validates `libraries`: the `"*"` wildcard on its own, or a non-empty array of `Name-Version` identifiers. */
16
17
  const librariesSchema = z.custom().check((ctx) => {
17
18
  const value = ctx.value;
18
19
  if (value === LIBRARIES_WILDCARD) {
@@ -26,6 +27,7 @@ const librariesSchema = z.custom().check((ctx) => {
26
27
  ctx.issues.push(...libraryEntryIssues(value, index, entry));
27
28
  }
28
29
  });
30
+ /** Validates `applicationId` against the reverse-DNS form `g_application_id_is_valid` accepts. */
29
31
  const applicationIdSchema = z.custom().check((ctx) => {
30
32
  const value = ctx.value;
31
33
  if (typeof value !== "string" || !isValidApplicationId(value)) {
@@ -33,6 +35,7 @@ const applicationIdSchema = z.custom().check((ctx) => {
33
35
  '(e.g. "org.example.MyApp")', true));
34
36
  }
35
37
  });
38
+ /** Validates `reactCompiler`: a boolean, or an options object whose mode and threshold are known values. */
36
39
  const reactCompilerSchema = z.custom().check((ctx) => {
37
40
  const value = ctx.value;
38
41
  if (typeof value === "boolean") {
@@ -53,42 +56,71 @@ const reactCompilerSchema = z.custom().check((ctx) => {
53
56
  `must be one of ${PANIC_THRESHOLDS.join(", ")}`, true));
54
57
  }
55
58
  });
59
+ /** Validates `userEventSignals`: GLib type names mapped to arrays of non-empty signal names. */
56
60
  const userEventSignalsSchema = z.record(z.string(), z.array(z.string({ error: "must be a non-empty signal name" }).min(1, { error: "must be a non-empty signal name" }), {
57
61
  error: "must be an array of signal names",
58
62
  }), { error: "must be a record of GLib type names to signal name arrays" });
63
+ /** Validates a `{ module, export }` reference to a named export. */
59
64
  const moduleExportSchema = z.object({
65
+ /** Specifier the export is imported from. */
60
66
  module: z.string({ error: "must be a module specifier" }).min(1, { error: "must be a module specifier" }),
67
+ /** Identifier the module exports it under. */
61
68
  export: z.string({ error: "must be an export name" }).min(1, { error: "must be an export name" }),
62
69
  }, { error: "must be a { module, export } object" });
70
+ /** Validates one entry of `elements.config`. */
63
71
  const elementConfigSchema = z.object({
72
+ /** Component that wraps the generated element. */
64
73
  component: moduleExportSchema.optional(),
74
+ /** Base props interface the generated element props extend. */
65
75
  props: moduleExportSchema.optional(),
66
- lazy: z.boolean({ error: "must be a boolean" }).optional(),
67
- omitProps: z
76
+ /** Marks the element as having no GObject of its own, its parent container creating one instead. */
77
+ isLazy: z.boolean({ error: "must be a boolean" }).optional(),
78
+ /** GObject properties to leave out of the generated element props, such as those a behavior fills. */
79
+ omittedProps: z
68
80
  .array(z.string({ error: "must be a non-empty property name" }).min(1, {
69
81
  error: "must be a non-empty property name",
70
82
  }), { error: "must be an array of property names" })
71
83
  .optional(),
72
84
  });
85
+ /** Validates `elements`: the behaviors module the app loads at runtime, plus the per-type entries. */
73
86
  const elementsSchema = z.object({
87
+ /**
88
+ * Path, resolved against the project root, of a module default-exporting element configs keyed by
89
+ * GLib type name, as `defineElements` returns.
90
+ */
74
91
  behaviors: z
75
92
  .string({ error: "must be a path to a module exporting element behaviors" })
76
93
  .min(1, { error: "must be a path to a module exporting element behaviors" })
77
94
  .optional(),
95
+ /** Per-element entries, keyed by GLib type name. */
78
96
  config: z.record(z.string(), elementConfigSchema).optional(),
79
97
  });
98
+ /** The shape every `gtkx.config.ts` is validated against, and the source of the {@link Config} type. */
80
99
  const configSchema = z.object({
100
+ /**
101
+ * GIR namespaces to bind as `Name-Version`, or `"*"` for every one installed; omitting it gives
102
+ * `Gtk-4.0`, which is also prepended to any list that names no Gtk version of its own.
103
+ */
81
104
  libraries: librariesSchema.optional(),
105
+ /** Directories searched for `.gir` files ahead of `GTKX_GIR_PATH` and the system locations. */
82
106
  girPath: z.array(z.string(), { error: "must be an array of strings if provided" }).optional(),
107
+ /** Reverse-DNS GApplication identifier, and the default `applicationId` of the application element. */
83
108
  applicationId: applicationIdSchema,
109
+ /** React Compiler settings; the compiler runs unless this is `false`. */
84
110
  reactCompiler: reactCompilerSchema.optional(),
111
+ /** Whether to generate the binding stores; `false` makes the CLI resolve an already-installed one. */
85
112
  codegen: z.boolean({ error: "must be a boolean" }).optional(),
113
+ /**
114
+ * Signal names, keyed by GLib type name, that stay suppressed while a React commit applies props, so
115
+ * their handlers only ever report user interaction. Unioned with the built-in GTK4 and Adwaita table.
116
+ */
86
117
  userEventSignals: userEventSignalsSchema.optional(),
118
+ /** Per-element customization: where the behaviors module lives and how each type's element is shaped. */
87
119
  elements: elementsSchema.optional(),
88
120
  });
89
121
  /**
90
- * Identity helper that returns the given configuration typed as {@link Config},
91
- * enabling editor autocompletion and type checking in `gtkx.config.ts`.
122
+ * Returns the given configuration unchanged, typed as {@link Config}, so `gtkx.config.ts` gets
123
+ * autocompletion and type checking.
92
124
  */
93
125
  const defineConfig = createDefineConfig();
94
126
  const libraryEntryIssues = (value, index, entry) => {
@@ -125,9 +157,8 @@ const validateConfig = (config) => {
125
157
  }
126
158
  };
127
159
  /**
128
- * Deep-merges two configurations, with `override` taking precedence over `base`.
129
- * @param base The lower-priority configuration.
130
- * @param override The higher-priority configuration whose values win on conflict.
160
+ * Deep-merges two configurations. `override` wins over `base` on conflicting scalar and object keys, while
161
+ * arrays are concatenated with the `override` entries first.
131
162
  */
132
163
  const mergeConfig = (base, override) => defu(override, base);
133
164
  const resolveElementsModule = (behaviors, root) => {
@@ -137,7 +168,7 @@ const resolveElementsModule = (behaviors, root) => {
137
168
  return root === undefined ? behaviors : resolve(root, behaviors);
138
169
  };
139
170
  const resolveLazyElements = (elements) => Object.entries(elements?.config ?? {})
140
- .filter(([, entry]) => entry.lazy === true)
171
+ .filter(([, entry]) => entry.isLazy === true)
141
172
  .map(([type]) => type);
142
173
  const elementEntryValues = (elements, pick) => Object.fromEntries(Object.entries(elements?.config ?? {}).flatMap(([type, entry]) => {
143
174
  const value = pick(entry);
@@ -145,7 +176,7 @@ const elementEntryValues = (elements, pick) => Object.fromEntries(Object.entries
145
176
  }));
146
177
  const resolveElementComponents = (elements) => elementEntryValues(elements, (entry) => entry.component);
147
178
  const resolveElementProps = (elements) => elementEntryValues(elements, (entry) => entry.props);
148
- const resolveOmitProps = (elements) => elementEntryValues(elements, (entry) => entry.omitProps);
179
+ const resolveOmittedProps = (elements) => elementEntryValues(elements, (entry) => entry.omittedProps);
149
180
  const resolveConfig = (config, root) => ({
150
181
  applicationId: config.applicationId,
151
182
  reactCompiler: resolveReactCompilerOptions(config.reactCompiler),
@@ -153,5 +184,5 @@ const resolveConfig = (config, root) => ({
153
184
  elements: resolveElementsModule(config.elements?.behaviors, root),
154
185
  lazyElements: resolveLazyElements(config.elements),
155
186
  });
156
- export { defineConfig, isValidApplicationId, resolveReactCompilerOptions, validateConfig, mergeConfig, resolveLazyElements, resolveElementComponents, resolveElementProps, resolveOmitProps, resolveConfig, };
187
+ export { defineConfig, isValidApplicationId, resolveReactCompilerOptions, validateConfig, mergeConfig, resolveLazyElements, resolveElementComponents, resolveElementProps, resolveOmittedProps, resolveConfig, };
157
188
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,QAAQ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,WAAW,EACX,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,GAKhB,CAAC","sourcesContent":["import { createDefineConfig, type DefineConfig } from \"c12\";\nimport { defu } from \"defu\";\nimport { resolve } from \"node:path\";\nimport { z } from \"zod\";\nimport { configError, isRecord, rawIssue } from \"./config-error.js\";\nimport { resolveUserEventSignals } from \"./user-event-signals.js\";\n\ntype ReactCompilerCompilationMode = (typeof COMPILATION_MODES)[number];\ntype ReactCompilerPanicThreshold = (typeof PANIC_THRESHOLDS)[number];\n\ntype ReactCompilerOptions = {\n compilationMode?: ReactCompilerCompilationMode;\n panicThreshold?: ReactCompilerPanicThreshold;\n};\n\n/**\n * React Compiler options resolved for the build, with the compilation target\n * fixed to React 19.\n */\ntype ResolvedReactCompilerOptions = ReactCompilerOptions & {\n target: \"19\";\n};\n\n/**\n * User-facing configuration for a GTKX project, as authored in `gtkx.config.ts`:\n * the GIR libraries to bind, extra `.gir` search paths, the GApplication id,\n * a module of per-element configuration (lazy flags and custom behaviors),\n * per-element component wrappers and omitted props keyed by GLib type name, the\n * React Compiler and codegen settings, additional user event signals to suppress\n * during React commits, and extra GIR records to treat as class structs.\n */\ntype Config = z.infer<typeof configSchema>;\n/** A `{ module, export }` reference to a named export, as element config entries carry it. */\ntype ModuleExport = z.infer<typeof moduleExportSchema>;\ntype ElementConfigEntry = z.infer<typeof elementConfigSchema>;\n\n/**\n * Configuration reduced to the values needed at runtime: the GApplication\n * identifier, the resolved React Compiler options (`null` when disabled), the\n * user event signals suppressed while a React commit is in progress, and the\n * module path holding per-element configuration (`null` when unset).\n */\ntype ResolvedConfig = {\n applicationId: string;\n reactCompiler: ResolvedReactCompilerOptions | null;\n userEventSignals: Record<string, string[]>;\n elements: string | null;\n lazyElements: string[];\n};\n\nconst LIBRARIES_WILDCARD = \"*\";\nconst GIR_LIBRARY_PATTERN = /^[A-Za-z][A-Za-z0-9]*-\\d+(?:\\.\\d+)*$/;\nconst APPLICATION_ID_PATTERN = /^[A-Za-z_][A-Za-z0-9_-]*(\\.[A-Za-z_][A-Za-z0-9_-]*)+$/;\nconst APPLICATION_ID_MAX_LENGTH = 255;\nconst COMPILATION_MODES = [\"infer\", \"syntax\", \"annotation\", \"all\"] as const;\nconst PANIC_THRESHOLDS = [\"none\", \"critical_errors\", \"all_errors\"] as const;\nconst REACT_COMPILER_TARGET = \"19\";\nconst COMPILATION_MODE_SET: Set<string> = new Set(COMPILATION_MODES);\nconst PANIC_THRESHOLD_SET: Set<string> = new Set(PANIC_THRESHOLDS);\n\nconst librariesSchema = z.custom<typeof LIBRARIES_WILDCARD | string[]>().check((ctx) => {\n const value = ctx.value;\n\n if (value === LIBRARIES_WILDCARD) {\n return;\n }\n\n if (!Array.isArray(value) || value.length === 0) {\n ctx.issues.push(rawIssue(value, [], `must be \"${LIBRARIES_WILDCARD}\", a non-empty string array, or omitted`));\n\n return;\n }\n\n for (const [index, entry] of value.entries()) {\n ctx.issues.push(...libraryEntryIssues(value, index, entry));\n }\n});\n\nconst applicationIdSchema = z.custom<string>().check((ctx) => {\n const value = ctx.value;\n\n if (typeof value !== \"string\" || !isValidApplicationId(value)) {\n ctx.issues.push(\n rawIssue(\n value,\n [],\n `invalid \\`applicationId\\` \"${value}\", must satisfy g_application_id_is_valid ` +\n '(e.g. \"org.example.MyApp\")',\n true,\n ),\n );\n }\n});\n\nconst reactCompilerSchema = z.custom<boolean | ReactCompilerOptions>().check((ctx) => {\n const value = ctx.value;\n\n if (typeof value === \"boolean\") {\n return;\n }\n\n if (!isRecord(value)) {\n ctx.issues.push(rawIssue(value, [], \"must be a boolean or an options object\"));\n\n return;\n }\n\n const compilationMode = value.compilationMode;\n\n if (!isValidReactCompilerOption(compilationMode, COMPILATION_MODE_SET)) {\n ctx.issues.push(\n rawIssue(\n value,\n [],\n `invalid \\`reactCompiler.compilationMode\\` \"${String(compilationMode)}\", ` +\n `must be one of ${COMPILATION_MODES.join(\", \")}`,\n true,\n ),\n );\n }\n\n const panicThreshold = value.panicThreshold;\n\n if (!isValidReactCompilerOption(panicThreshold, PANIC_THRESHOLD_SET)) {\n ctx.issues.push(\n rawIssue(\n value,\n [],\n `invalid \\`reactCompiler.panicThreshold\\` \"${String(panicThreshold)}\", ` +\n `must be one of ${PANIC_THRESHOLDS.join(\", \")}`,\n true,\n ),\n );\n }\n});\n\nconst userEventSignalsSchema = z.record(\n z.string(),\n z.array(\n z.string({ error: \"must be a non-empty signal name\" }).min(1, { error: \"must be a non-empty signal name\" }),\n {\n error: \"must be an array of signal names\",\n },\n ),\n { error: \"must be a record of GLib type names to signal name arrays\" },\n);\n\nconst moduleExportSchema = z.object(\n {\n module: z.string({ error: \"must be a module specifier\" }).min(1, { error: \"must be a module specifier\" }),\n export: z.string({ error: \"must be an export name\" }).min(1, { error: \"must be an export name\" }),\n },\n { error: \"must be a { module, export } object\" },\n);\n\nconst elementConfigSchema = z.object({\n component: moduleExportSchema.optional(),\n props: moduleExportSchema.optional(),\n lazy: z.boolean({ error: \"must be a boolean\" }).optional(),\n omitProps: z\n .array(\n z.string({ error: \"must be a non-empty property name\" }).min(1, {\n error: \"must be a non-empty property name\",\n }),\n { error: \"must be an array of property names\" },\n )\n .optional(),\n});\n\nconst elementsSchema = z.object({\n behaviors: z\n .string({ error: \"must be a path to a module exporting element behaviors\" })\n .min(1, { error: \"must be a path to a module exporting element behaviors\" })\n .optional(),\n config: z.record(z.string(), elementConfigSchema).optional(),\n});\n\nconst configSchema = z.object({\n libraries: librariesSchema.optional(),\n girPath: z.array(z.string(), { error: \"must be an array of strings if provided\" }).optional(),\n applicationId: applicationIdSchema,\n reactCompiler: reactCompilerSchema.optional(),\n codegen: z.boolean({ error: \"must be a boolean\" }).optional(),\n userEventSignals: userEventSignalsSchema.optional(),\n elements: elementsSchema.optional(),\n});\n\n/**\n * Identity helper that returns the given configuration typed as {@link Config},\n * enabling editor autocompletion and type checking in `gtkx.config.ts`.\n */\nconst defineConfig: DefineConfig<Config> = createDefineConfig<Config>();\n\nconst libraryEntryIssues = (value: unknown[], index: number, entry: unknown): ReturnType<typeof rawIssue>[] => {\n if (typeof entry === \"string\" && GIR_LIBRARY_PATTERN.test(entry)) {\n return [];\n }\n\n if (entry === LIBRARIES_WILDCARD) {\n const message =\n `to generate every library, set \\`libraries: \"${LIBRARIES_WILDCARD}\"\\` as a bare string, ` +\n \"not an array entry\";\n\n return [rawIssue(value, [index], message, true)];\n }\n\n const message =\n `invalid library identifier \"${String(entry)}\", must be of the form \"Name-Version\" ` +\n '(e.g. \"Gtk-4.0\")';\n\n return [rawIssue(value, [index], message, true)];\n};\n\nconst isValidApplicationId = (applicationId: string): boolean => {\n if (applicationId.length === 0 || applicationId.length > APPLICATION_ID_MAX_LENGTH) {\n return false;\n }\n\n return APPLICATION_ID_PATTERN.test(applicationId);\n};\n\nconst resolveReactCompilerOptions = (setting: Config[\"reactCompiler\"]): ResolvedReactCompilerOptions | null => {\n if (setting === false) {\n return null;\n }\n\n const overrides = setting === undefined || setting === true ? {} : setting;\n\n return { ...overrides, target: REACT_COMPILER_TARGET };\n};\n\nconst isValidReactCompilerOption = (value: unknown, allowed: Set<string>): boolean =>\n value === undefined || (typeof value === \"string\" && allowed.has(value));\n\nconst validateConfig = (config: Config): void => {\n const result = configSchema.safeParse(config);\n\n if (!result.success) {\n throw configError(result.error);\n }\n};\n\n/**\n * Deep-merges two configurations, with `override` taking precedence over `base`.\n * @param base The lower-priority configuration.\n * @param override The higher-priority configuration whose values win on conflict.\n */\nconst mergeConfig = (base: Config, override: Config): Config => defu(override, base);\n\nconst resolveElementsModule = (behaviors: string | undefined, root: string | undefined): string | null => {\n if (behaviors === undefined) {\n return null;\n }\n\n return root === undefined ? behaviors : resolve(root, behaviors);\n};\n\nconst resolveLazyElements = (elements: Config[\"elements\"]): string[] =>\n Object.entries(elements?.config ?? {})\n .filter(([, entry]) => entry.lazy === true)\n .map(([type]) => type);\n\nconst elementEntryValues = <T>(\n elements: Config[\"elements\"],\n pick: (entry: ElementConfigEntry) => T | undefined,\n): Record<string, T> =>\n Object.fromEntries(\n Object.entries(elements?.config ?? {}).flatMap(([type, entry]) => {\n const value = pick(entry);\n\n return value === undefined ? [] : [[type, value] as const];\n }),\n );\n\nconst resolveElementComponents = (elements: Config[\"elements\"]): Record<string, ModuleExport> =>\n elementEntryValues(elements, (entry) => entry.component);\n\nconst resolveElementProps = (elements: Config[\"elements\"]): Record<string, ModuleExport> =>\n elementEntryValues(elements, (entry) => entry.props);\n\nconst resolveOmitProps = (elements: Config[\"elements\"]): Record<string, string[]> =>\n elementEntryValues(elements, (entry) => entry.omitProps);\n\nconst resolveConfig = (config: Config, root?: string): ResolvedConfig => ({\n applicationId: config.applicationId,\n reactCompiler: resolveReactCompilerOptions(config.reactCompiler),\n userEventSignals: resolveUserEventSignals(config.userEventSignals),\n elements: resolveElementsModule(config.elements?.behaviors, root),\n lazyElements: resolveLazyElements(config.elements),\n});\n\nexport {\n defineConfig,\n isValidApplicationId,\n resolveReactCompilerOptions,\n validateConfig,\n mergeConfig,\n resolveLazyElements,\n resolveElementComponents,\n resolveElementProps,\n resolveOmitProps,\n resolveConfig,\n type ResolvedReactCompilerOptions,\n type Config,\n type ModuleExport,\n type ResolvedConfig,\n};\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAiDlE,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,mBAAmB,GAAG,sC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SAAS,EAAE,IAAI,CAAC;IACjE,YAAY,EAAE,mBAAmB,CAAC,MAAM,CAAC,QAAQ,CAAC;CACrD,CAAC,CAAC;AAEH,OAAO,EACH,YAAY,EACZ,oBAAoB,EACpB,2BAA2B,EAC3B,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,GAKhB,CAAC","sourcesContent":["import { createDefineConfig, type DefineConfig } from \"c12\";\nimport { defu } from \"defu\";\nimport { resolve } from \"node:path\";\nimport { z } from \"zod\";\nimport { configError, isRecord, rawIssue } from \"./config-error.ts\";\nimport { resolveUserEventSignals } from \"./user-event-signals.ts\";\n\n/** Accepted `reactCompiler.compilationMode` values, choosing which functions the compiler processes. */\ntype ReactCompilerCompilationMode = (typeof COMPILATION_MODES)[number];\n/** Accepted `reactCompiler.panicThreshold` values, choosing which compiler diagnostics fail the build. */\ntype ReactCompilerPanicThreshold = (typeof PANIC_THRESHOLDS)[number];\n\n/** Object form of the `reactCompiler` config key, forwarded as-is to `babel-plugin-react-compiler`. */\ntype ReactCompilerOptions = {\n /** Which functions the compiler processes; left to the compiler's own default when omitted. */\n compilationMode?: ReactCompilerCompilationMode;\n /** Which compiler diagnostics fail the build; left to the compiler's own default when omitted. */\n panicThreshold?: ReactCompilerPanicThreshold;\n};\n\n/**\n * The React Compiler options the build hands to `babel-plugin-react-compiler`, with the React version\n * GTKX targets filled in.\n */\ntype ResolvedReactCompilerOptions = ReactCompilerOptions & {\n /** React major version the compiler emits for. */\n target: \"19\";\n};\n\n/**\n * User-facing configuration for a GTKX project, as authored in `gtkx.config.ts`: the GIR libraries\n * to bind and where to find them, the GApplication id, per-element configuration, and the React\n * Compiler, codegen, and user event signal settings.\n */\ntype Config = z.infer<typeof configSchema>;\n/** A named export referenced as plain data, so codegen can emit an import for it without loading the module. */\ntype ModuleExport = z.infer<typeof moduleExportSchema>;\n/** One `elements.config` entry, describing how a single GLib type's generated element is shaped. */\ntype ElementConfigEntry = z.infer<typeof elementConfigSchema>;\n\n/** Configuration reduced to the values the app runtime and the build need, with paths already resolved. */\ntype ResolvedConfig = {\n /** The GApplication identifier the app registers under. */\n applicationId: string;\n /** React Compiler options for the build, or `null` when the compiler is disabled. */\n reactCompiler: ResolvedReactCompilerOptions | null;\n /** Signal names, keyed by GLib type name, that stay suppressed while a React commit runs. */\n userEventSignals: Record<string, string[]>;\n /** Path of the module exporting per-element configs, or `null` when none is configured. */\n elements: string | null;\n /** GLib type names of the elements marked `isLazy`, whose GObject their parent container creates. */\n lazyElements: string[];\n};\n\nconst LIBRARIES_WILDCARD = \"*\";\nconst GIR_LIBRARY_PATTERN = /^[A-Za-z][A-Za-z0-9]*-\\d+(?:\\.\\d+)*$/;\nconst APPLICATION_ID_PATTERN = /^[A-Za-z_][A-Za-z0-9_-]*(\\.[A-Za-z_][A-Za-z0-9_-]*)+$/;\nconst APPLICATION_ID_MAX_LENGTH = 255;\nconst COMPILATION_MODES = [\"infer\", \"syntax\", \"annotation\", \"all\"] as const;\nconst PANIC_THRESHOLDS = [\"none\", \"critical_errors\", \"all_errors\"] as const;\nconst REACT_COMPILER_TARGET = \"19\";\nconst COMPILATION_MODE_SET: Set<string> = new Set(COMPILATION_MODES);\nconst PANIC_THRESHOLD_SET: Set<string> = new Set(PANIC_THRESHOLDS);\n\n/** Validates `libraries`: the `\"*\"` wildcard on its own, or a non-empty array of `Name-Version` identifiers. */\nconst librariesSchema = z.custom<typeof LIBRARIES_WILDCARD | string[]>().check((ctx) => {\n const value = ctx.value;\n\n if (value === LIBRARIES_WILDCARD) {\n return;\n }\n\n if (!Array.isArray(value) || value.length === 0) {\n ctx.issues.push(rawIssue(value, [], `must be \"${LIBRARIES_WILDCARD}\", a non-empty string array, or omitted`));\n\n return;\n }\n\n for (const [index, entry] of value.entries()) {\n ctx.issues.push(...libraryEntryIssues(value, index, entry));\n }\n});\n\n/** Validates `applicationId` against the reverse-DNS form `g_application_id_is_valid` accepts. */\nconst applicationIdSchema = z.custom<string>().check((ctx) => {\n const value = ctx.value;\n\n if (typeof value !== \"string\" || !isValidApplicationId(value)) {\n ctx.issues.push(\n rawIssue(\n value,\n [],\n `invalid \\`applicationId\\` \"${value}\", must satisfy g_application_id_is_valid ` +\n '(e.g. \"org.example.MyApp\")',\n true,\n ),\n );\n }\n});\n\n/** Validates `reactCompiler`: a boolean, or an options object whose mode and threshold are known values. */\nconst reactCompilerSchema = z.custom<boolean | ReactCompilerOptions>().check((ctx) => {\n const value = ctx.value;\n\n if (typeof value === \"boolean\") {\n return;\n }\n\n if (!isRecord(value)) {\n ctx.issues.push(rawIssue(value, [], \"must be a boolean or an options object\"));\n\n return;\n }\n\n const compilationMode = value.compilationMode;\n\n if (!isValidReactCompilerOption(compilationMode, COMPILATION_MODE_SET)) {\n ctx.issues.push(\n rawIssue(\n value,\n [],\n `invalid \\`reactCompiler.compilationMode\\` \"${String(compilationMode)}\", ` +\n `must be one of ${COMPILATION_MODES.join(\", \")}`,\n true,\n ),\n );\n }\n\n const panicThreshold = value.panicThreshold;\n\n if (!isValidReactCompilerOption(panicThreshold, PANIC_THRESHOLD_SET)) {\n ctx.issues.push(\n rawIssue(\n value,\n [],\n `invalid \\`reactCompiler.panicThreshold\\` \"${String(panicThreshold)}\", ` +\n `must be one of ${PANIC_THRESHOLDS.join(\", \")}`,\n true,\n ),\n );\n }\n});\n\n/** Validates `userEventSignals`: GLib type names mapped to arrays of non-empty signal names. */\nconst userEventSignalsSchema = z.record(\n z.string(),\n z.array(\n z.string({ error: \"must be a non-empty signal name\" }).min(1, { error: \"must be a non-empty signal name\" }),\n {\n error: \"must be an array of signal names\",\n },\n ),\n { error: \"must be a record of GLib type names to signal name arrays\" },\n);\n\n/** Validates a `{ module, export }` reference to a named export. */\nconst moduleExportSchema = z.object(\n {\n /** Specifier the export is imported from. */\n module: z.string({ error: \"must be a module specifier\" }).min(1, { error: \"must be a module specifier\" }),\n /** Identifier the module exports it under. */\n export: z.string({ error: \"must be an export name\" }).min(1, { error: \"must be an export name\" }),\n },\n { error: \"must be a { module, export } object\" },\n);\n\n/** Validates one entry of `elements.config`. */\nconst elementConfigSchema = z.object({\n /** Component that wraps the generated element. */\n component: moduleExportSchema.optional(),\n /** Base props interface the generated element props extend. */\n props: moduleExportSchema.optional(),\n /** Marks the element as having no GObject of its own, its parent container creating one instead. */\n isLazy: z.boolean({ error: \"must be a boolean\" }).optional(),\n /** GObject properties to leave out of the generated element props, such as those a behavior fills. */\n omittedProps: z\n .array(\n z.string({ error: \"must be a non-empty property name\" }).min(1, {\n error: \"must be a non-empty property name\",\n }),\n { error: \"must be an array of property names\" },\n )\n .optional(),\n});\n\n/** Validates `elements`: the behaviors module the app loads at runtime, plus the per-type entries. */\nconst elementsSchema = z.object({\n /**\n * Path, resolved against the project root, of a module default-exporting element configs keyed by\n * GLib type name, as `defineElements` returns.\n */\n behaviors: z\n .string({ error: \"must be a path to a module exporting element behaviors\" })\n .min(1, { error: \"must be a path to a module exporting element behaviors\" })\n .optional(),\n /** Per-element entries, keyed by GLib type name. */\n config: z.record(z.string(), elementConfigSchema).optional(),\n});\n\n/** The shape every `gtkx.config.ts` is validated against, and the source of the {@link Config} type. */\nconst configSchema = z.object({\n /**\n * GIR namespaces to bind as `Name-Version`, or `\"*\"` for every one installed; omitting it gives\n * `Gtk-4.0`, which is also prepended to any list that names no Gtk version of its own.\n */\n libraries: librariesSchema.optional(),\n /** Directories searched for `.gir` files ahead of `GTKX_GIR_PATH` and the system locations. */\n girPath: z.array(z.string(), { error: \"must be an array of strings if provided\" }).optional(),\n /** Reverse-DNS GApplication identifier, and the default `applicationId` of the application element. */\n applicationId: applicationIdSchema,\n /** React Compiler settings; the compiler runs unless this is `false`. */\n reactCompiler: reactCompilerSchema.optional(),\n /** Whether to generate the binding stores; `false` makes the CLI resolve an already-installed one. */\n codegen: z.boolean({ error: \"must be a boolean\" }).optional(),\n /**\n * Signal names, keyed by GLib type name, that stay suppressed while a React commit applies props, so\n * their handlers only ever report user interaction. Unioned with the built-in GTK4 and Adwaita table.\n */\n userEventSignals: userEventSignalsSchema.optional(),\n /** Per-element customization: where the behaviors module lives and how each type's element is shaped. */\n elements: elementsSchema.optional(),\n});\n\n/**\n * Returns the given configuration unchanged, typed as {@link Config}, so `gtkx.config.ts` gets\n * autocompletion and type checking.\n */\nconst defineConfig: DefineConfig<Config> = createDefineConfig<Config>();\n\nconst libraryEntryIssues = (value: unknown[], index: number, entry: unknown): ReturnType<typeof rawIssue>[] => {\n if (typeof entry === \"string\" && GIR_LIBRARY_PATTERN.test(entry)) {\n return [];\n }\n\n if (entry === LIBRARIES_WILDCARD) {\n const message =\n `to generate every library, set \\`libraries: \"${LIBRARIES_WILDCARD}\"\\` as a bare string, ` +\n \"not an array entry\";\n\n return [rawIssue(value, [index], message, true)];\n }\n\n const message =\n `invalid library identifier \"${String(entry)}\", must be of the form \"Name-Version\" ` +\n '(e.g. \"Gtk-4.0\")';\n\n return [rawIssue(value, [index], message, true)];\n};\n\nconst isValidApplicationId = (applicationId: string): boolean => {\n if (applicationId.length === 0 || applicationId.length > APPLICATION_ID_MAX_LENGTH) {\n return false;\n }\n\n return APPLICATION_ID_PATTERN.test(applicationId);\n};\n\nconst resolveReactCompilerOptions = (setting: Config[\"reactCompiler\"]): ResolvedReactCompilerOptions | null => {\n if (setting === false) {\n return null;\n }\n\n const overrides = setting === undefined || setting === true ? {} : setting;\n\n return { ...overrides, target: REACT_COMPILER_TARGET };\n};\n\nconst isValidReactCompilerOption = (value: unknown, allowed: Set<string>): boolean =>\n value === undefined || (typeof value === \"string\" && allowed.has(value));\n\nconst validateConfig = (config: Config): void => {\n const result = configSchema.safeParse(config);\n\n if (!result.success) {\n throw configError(result.error);\n }\n};\n\n/**\n * Deep-merges two configurations. `override` wins over `base` on conflicting scalar and object keys, while\n * arrays are concatenated with the `override` entries first.\n */\nconst mergeConfig = (base: Config, override: Config): Config => defu(override, base);\n\nconst resolveElementsModule = (behaviors: string | undefined, root: string | undefined): string | null => {\n if (behaviors === undefined) {\n return null;\n }\n\n return root === undefined ? behaviors : resolve(root, behaviors);\n};\n\nconst resolveLazyElements = (elements: Config[\"elements\"]): string[] =>\n Object.entries(elements?.config ?? {})\n .filter(([, entry]) => entry.isLazy === true)\n .map(([type]) => type);\n\nconst elementEntryValues = <T>(\n elements: Config[\"elements\"],\n pick: (entry: ElementConfigEntry) => T | undefined,\n): Record<string, T> =>\n Object.fromEntries(\n Object.entries(elements?.config ?? {}).flatMap(([type, entry]) => {\n const value = pick(entry);\n\n return value === undefined ? [] : [[type, value] as const];\n }),\n );\n\nconst resolveElementComponents = (elements: Config[\"elements\"]): Record<string, ModuleExport> =>\n elementEntryValues(elements, (entry) => entry.component);\n\nconst resolveElementProps = (elements: Config[\"elements\"]): Record<string, ModuleExport> =>\n elementEntryValues(elements, (entry) => entry.props);\n\nconst resolveOmittedProps = (elements: Config[\"elements\"]): Record<string, string[]> =>\n elementEntryValues(elements, (entry) => entry.omittedProps);\n\nconst resolveConfig = (config: Config, root?: string): ResolvedConfig => ({\n applicationId: config.applicationId,\n reactCompiler: resolveReactCompilerOptions(config.reactCompiler),\n userEventSignals: resolveUserEventSignals(config.userEventSignals),\n elements: resolveElementsModule(config.elements?.behaviors, root),\n lazyElements: resolveLazyElements(config.elements),\n});\n\nexport {\n defineConfig,\n isValidApplicationId,\n resolveReactCompilerOptions,\n validateConfig,\n mergeConfig,\n resolveLazyElements,\n resolveElementComponents,\n resolveElementProps,\n resolveOmittedProps,\n resolveConfig,\n type ResolvedReactCompilerOptions,\n type Config,\n type ModuleExport,\n type ResolvedConfig,\n};\n"]}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
- export { type Config, defineConfig, mergeConfig, type ResolvedConfig, type ResolvedReactCompilerOptions, } from "./config.js";
2
- export { type LoadedConfig, loadConfig } from "./loader.js";
1
+ /** @public */
2
+ export { type Config, defineConfig, mergeConfig, type ResolvedConfig } from "./config.ts";
3
+ /** @public */
4
+ export { type LoadedConfig, loadConfig } from "./loader.ts";
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,MAAM,EACX,YAAY,EACZ,WAAW,EACX,KAAK,cAAc,EACnB,KAAK,4BAA4B,GACpC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,EAAE,KAAK,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAC1F,cAAc;AACd,OAAO,EAAE,KAAK,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
- export { defineConfig, mergeConfig, } from "./config.js";
1
+ /** @public */
2
+ export { defineConfig, mergeConfig } from "./config.js";
3
+ /** @public */
2
4
  export { loadConfig } from "./loader.js";
3
5
  //# 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,EAEH,YAAY,EACZ,WAAW,GAGd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAqB,UAAU,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export {\n type Config,\n defineConfig,\n mergeConfig,\n type ResolvedConfig,\n type ResolvedReactCompilerOptions,\n} from \"./config.js\";\nexport { type LoadedConfig, loadConfig } from \"./loader.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,EAAe,YAAY,EAAE,WAAW,EAAuB,MAAM,aAAa,CAAC;AAC1F,cAAc;AACd,OAAO,EAAqB,UAAU,EAAE,MAAM,aAAa,CAAC","sourcesContent":["/** @public */\nexport { type Config, defineConfig, mergeConfig, type ResolvedConfig } from \"./config.ts\";\n/** @public */\nexport { type LoadedConfig, loadConfig } from \"./loader.ts\";\n"]}
@@ -1,3 +1,4 @@
1
- export { isValidApplicationId, resolveElementComponents, resolveElementProps, resolveLazyElements, resolveOmitProps, } from "./config.js";
2
- export { type ConfigLoader, createConfigLoader } from "./loader.js";
1
+ export type { ResolvedReactCompilerOptions } from "./config.ts";
2
+ export { isValidApplicationId, resolveElementComponents, resolveElementProps, resolveLazyElements, resolveOmittedProps, } from "./config.ts";
3
+ export { type ConfigLoader, createConfigLoader } from "./loader.ts";
3
4
  //# sourceMappingURL=internal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EACH,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC"}
package/dist/internal.js CHANGED
@@ -1,3 +1,3 @@
1
- export { isValidApplicationId, resolveElementComponents, resolveElementProps, resolveLazyElements, resolveOmitProps, } from "./config.js";
1
+ export { isValidApplicationId, resolveElementComponents, resolveElementProps, resolveLazyElements, resolveOmittedProps, } from "./config.js";
2
2
  export { createConfigLoader } from "./loader.js";
3
3
  //# sourceMappingURL=internal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAqB,kBAAkB,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export {\n isValidApplicationId,\n resolveElementComponents,\n resolveElementProps,\n resolveLazyElements,\n resolveOmitProps,\n} from \"./config.js\";\nexport { type ConfigLoader, createConfigLoader } from \"./loader.js\";\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AACA,OAAO,EACH,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAqB,kBAAkB,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export type { ResolvedReactCompilerOptions } from \"./config.ts\";\nexport {\n isValidApplicationId,\n resolveElementComponents,\n resolveElementProps,\n resolveLazyElements,\n resolveOmittedProps,\n} from \"./config.ts\";\nexport { type ConfigLoader, createConfigLoader } from \"./loader.ts\";\n"]}
package/dist/loader.d.ts CHANGED
@@ -1,29 +1,30 @@
1
- import { type Config, type ResolvedConfig } from "./config.js";
2
- /**
3
- * Result of loading a `gtkx.config.ts` file: the parsed configuration, the
4
- * resolved config file path, and the project root it was loaded from.
5
- */
1
+ import { type Config, type ResolvedConfig } from "./config.ts";
2
+ /** Result of loading a project's `gtkx.config.ts` file. */
6
3
  type LoadedConfig = {
4
+ /** The parsed and validated configuration. */
7
5
  config: Config;
6
+ /** Absolute path of the configuration file that was loaded. */
8
7
  configFile: string;
8
+ /** Absolute path of the project root the configuration was resolved against. */
9
9
  root: string;
10
10
  };
11
+ /** How a configuration file is read, shared by {@link loadConfig} and `createConfigLoader`. */
11
12
  type LoadConfigOptions = {
13
+ /**
14
+ * Environment name such as `development`: the config's matching `$<mode>` block is layered over the
15
+ * top-level values, and the name is passed to a config authored as a function.
16
+ */
12
17
  mode?: string | undefined;
13
18
  };
14
- /**
15
- * Caching accessor for a project's configuration: `load` yields the validated authored config together with
16
- * its file path, and `resolve` yields the projection an app needs at runtime.
17
- */
18
19
  type ConfigLoader = {
19
20
  load: (cwd: string) => Promise<LoadedConfig>;
20
21
  resolve: (cwd: string) => Promise<ResolvedConfig>;
21
22
  };
22
23
  /**
23
- * Loads and validates the `gtkx.config.ts` file for a project, returning the
24
- * parsed configuration together with the config file path and project root.
25
- * @param cwd Directory from which to search for the configuration file.
26
- * @param options Loading options, such as the environment mode.
24
+ * Loads and validates the `gtkx.config.ts` file for a project.
25
+ * @param cwd Directory the configuration file is looked up in.
26
+ * @param options Loading options, such as the environment mode whose overrides are applied.
27
+ * @throws When the configuration fails validation, or when no configuration file is found.
27
28
  */
28
29
  declare const loadConfig: (cwd: string, options?: LoadConfigOptions) => Promise<LoadedConfig>;
29
30
  declare const createConfigLoader: (options?: LoadConfigOptions) => ConfigLoader;
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAiB,KAAK,cAAc,EAAkB,MAAM,aAAa,CAAC;AAE9F;;;GAGG;AACH,KAAK,YAAY,GAAG;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACrB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF;;;GAGG;AACH,KAAK,YAAY,GAAG;IAChB,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IAC7C,OAAO,EAAE,CAAC,GAAG,EAAE,M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,KAAK,iBAAiB,EAAE,KAAK,YAAY,EAAE,CAAC"}
package/dist/loader.js CHANGED
@@ -4,10 +4,10 @@ import { existsSync } from "node:fs";
4
4
  import { resolve } from "node:path";
5
5
  import { resolveConfig, validateConfig } from "./config.js";
6
6
  /**
7
- * Loads and validates the `gtkx.config.ts` file for a project, returning the
8
- * parsed configuration together with the config file path and project root.
9
- * @param cwd Directory from which to search for the configuration file.
10
- * @param options Loading options, such as the environment mode.
7
+ * Loads and validates the `gtkx.config.ts` file for a project.
8
+ * @param cwd Directory the configuration file is looked up in.
9
+ * @param options Loading options, such as the environment mode whose overrides are applied.
10
+ * @throws When the configuration fails validation, or when no configuration file is found.
11
11
  */
12
12
  const loadConfig = async (cwd, options = {}) => {
13
13
  const result = await loadConfigFile({
@@ -1 +1 @@
1
- {"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,KAAK,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAe,aAAa,EAAuB,cAAc,EAAE,MAAM,aAAa,CAAC;AAyB9F;;;;;GAKG;AACH,MAAM,UAAU,GAAG,KAAK,EAAE,GAAW,EAAE,UAA6B,EAAE,EAAyB,EAAE;IAC7F,MAAM,MAAM,GAAG,MAAM,cAAc,CAAS;QACxC,IAAI,EAAE,MAAM;QACZ,GAAG;QACH,MAAM,EAAE,KAAK;QACb,QAAQ,EAAE,KAAK;QACf,WAAW,EAAE,KAAK;QAClB,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE;QAC/B,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,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,kBAAkB,EAAgE,CAAC","sourcesContent":["import { getOrInsert } from \"@gtkx/utils\";\nimport { loadConfig as loadConfigFile } from \"c12\";\nimport { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { type Config, resolveConfig, type ResolvedConfig, validateConfig } from \"./config.js\";\n\n/**\n * Result of loading a `gtkx.config.ts` file: the parsed configuration, the\n * resolved config file path, and the project root it was loaded from.\n */\ntype LoadedConfig = {\n config: Config;\n configFile: string;\n root: string;\n};\n\ntype LoadConfigOptions = {\n mode?: string | undefined;\n};\n\n/**\n * Caching accessor for a project's configuration: `load` yields the validated authored config together with\n * its file path, and `resolve` yields the projection an app needs at runtime.\n */\ntype ConfigLoader = {\n load: (cwd: string) => Promise<LoadedConfig>;\n resolve: (cwd: string) => Promise<ResolvedConfig>;\n};\n\n/**\n * Loads and validates the `gtkx.config.ts` file for a project, returning the\n * parsed configuration together with the config file path and project root.\n * @param cwd Directory from which to search for the configuration file.\n * @param options Loading options, such as the environment mode.\n */\nconst loadConfig = async (cwd: string, options: LoadConfigOptions = {}): Promise<LoadedConfig> => {\n const result = await loadConfigFile<Config>({\n name: \"gtkx\",\n cwd,\n rcFile: false,\n globalRc: false,\n packageJson: false,\n context: { mode: options.mode },\n ...((options.mode !== undefined) && { envName: options.mode }),\n });\n\n const config = result.config;\n const configFile = result.configFile;\n validateConfig(config);\n\n if (configFile === undefined || !existsSync(resolve(cwd, configFile))) {\n throw new Error(`gtkx.config.ts: no configuration file was found from ${cwd}`);\n }\n\n return {\n config,\n configFile,\n root: result.cwd ?? cwd,\n };\n};\n\nconst createConfigLoader = (options: LoadConfigOptions = {}): ConfigLoader => {\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 getOrInsert(loaded, 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> => getOrInsert(resolved, resolve(cwd), resolveAt),\n };\n};\n\nexport { loadConfig, createConfigLoader, type LoadedConfig, type LoadConfigOptions, type ConfigLoader };\n"]}
1
+ {"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,KAAK,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAe,aAAa,EAAuB,cAAc,EAAE,MAAM,aAAa,CAAC;AA0B9F;;;;;GAKG;AACH,MAAM,UAAU,GAAG,KAAK,EAAE,GAAW,EAAE,UAA6B,EAAE,EAAyB,EAAE;IAC7F,MAAM,MAAM,GAAG,MAAM,cAAc,CAAS;QACxC,IAAI,EAAE,MAAM;QACZ,GAAG;QACH,MAAM,EAAE,KAAK;QACb,QAAQ,EAAE,KAAK;QACf,WAAW,EAAE,KAAK;QAClB,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE;QAC/B,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;KACjE,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7B,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IACrC,cAAc,CAAC,MAAM,CAAC,CAAC;IAEvB,IAAI,UAAU,KAAK,SAAS,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC;QACpE,MAAM,IAAI,KAAK,CAAC,wDAAwD,GAAG,EAAE,CAAC,CAAC;IACnF,CAAC;IAED,OAAO;QACH,MAAM;QACN,UAAU;QACV,IAAI,EAAE,MAAM,CAAC,GAAG,IAAI,GAAG;KAC1B,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,UAA6B,EAAE,EAAgB,EAAE;IACzE,MAAM,MAAM,GAAuC,IAAI,GAAG,EAAE,CAAC;IAC7D,MAAM,QAAQ,GAAyC,IAAI,GAAG,EAAE,CAAC;IAEjE,MAAM,IAAI,GAAG,CAAC,GAAW,EAAyB,EAAE,CAChD,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAE3E,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,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC;KACpG,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAgE,CAAC","sourcesContent":["import { getOrInsert } from \"@gtkx/utils\";\nimport { loadConfig as loadConfigFile } from \"c12\";\nimport { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { type Config, resolveConfig, type ResolvedConfig, validateConfig } from \"./config.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};\n\ntype ConfigLoader = {\n load: (cwd: string) => Promise<LoadedConfig>;\n resolve: (cwd: string) => Promise<ResolvedConfig>;\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.\n * @param options Loading options, such as the environment mode whose overrides are applied.\n * @throws When the configuration fails validation, or when no configuration file is found.\n */\nconst loadConfig = async (cwd: string, options: LoadConfigOptions = {}): Promise<LoadedConfig> => {\n const result = await loadConfigFile<Config>({\n name: \"gtkx\",\n cwd,\n rcFile: false,\n globalRc: false,\n packageJson: false,\n context: { mode: options.mode },\n ...((options.mode !== undefined) && { envName: options.mode }),\n });\n\n const config = result.config;\n const configFile = result.configFile;\n validateConfig(config);\n\n if (configFile === undefined || !existsSync(resolve(cwd, configFile))) {\n throw new Error(`gtkx.config.ts: no configuration file was found from ${cwd}`);\n }\n\n return {\n config,\n configFile,\n root: result.cwd ?? cwd,\n };\n};\n\nconst createConfigLoader = (options: LoadConfigOptions = {}): ConfigLoader => {\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 getOrInsert(loaded, 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> => getOrInsert(resolved, resolve(cwd), resolveAt),\n };\n};\n\nexport { loadConfig, createConfigLoader, type LoadedConfig, type LoadConfigOptions, type ConfigLoader };\n"]}
package/dist/virtual.d.ts CHANGED
@@ -1,10 +1,6 @@
1
- import type { ResolvedConfig } from "./config.js";
1
+ import type { ResolvedConfig } from "./config.ts";
2
2
  declare const GTKX_CONFIG_VIRTUAL_ID = "virtual:gtkx-config";
3
3
  declare const RESOLVED_GTKX_CONFIG_VIRTUAL_ID = "\0virtual:gtkx-config";
4
- /**
5
- * The runtime element config is the app's static per-element config (currently its lazy flags) merged
6
- * with its behaviors module, so a single `elements` map is registered.
7
- */
8
4
  declare const renderConfigModule: (config: ResolvedConfig) => string;
9
5
  export { GTKX_CONFIG_VIRTUAL_ID, RESOLVED_GTKX_CONFIG_VIRTUAL_ID, renderConfigModule };
10
6
  //# sourceMappingURL=virtual.d.ts.map
@@ -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;AAElD,QAAA,MAAM,sBAAsB,wBAAwB,CAAC;AACrD,QAAA,MAAM,+BAA+B,0BAAgC,CAAC;AAMtE;;;GAGG;AACH,QAAA,MAAM,kBAAkB,GAAI,QAAQ,cAAc,KAAG,MAoBpD,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;AAElD,QAAA,MAAM,sBAAsB,wBAAwB,CAAC;AACrD,QAAA,MAAM,+BAA+B,0BAAgC,CAAC;AAMtE,QAAA,MAAM,kBAAkB,GAAI,QAAQ,cAAc,KAAG,MAoBpD,CAAC;AAEF,OAAO,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,kBAAkB,EAAE,CAAC"}
package/dist/virtual.js CHANGED
@@ -1,11 +1,7 @@
1
1
  const GTKX_CONFIG_VIRTUAL_ID = "virtual:gtkx-config";
2
2
  const RESOLVED_GTKX_CONFIG_VIRTUAL_ID = `\0${GTKX_CONFIG_VIRTUAL_ID}`;
3
3
  const METADATA_SPECIFIER = "@gtkx/jsx/metadata";
4
- const lazyElementConfig = (lazyElements) => Object.fromEntries(lazyElements.map((type) => [type, { lazy: true }]));
5
- /**
6
- * The runtime element config is the app's static per-element config (currently its lazy flags) merged
7
- * with its behaviors module, so a single `elements` map is registered.
8
- */
4
+ const lazyElementConfig = (lazyElements) => Object.fromEntries(lazyElements.map((type) => [type, { isLazy: true }]));
9
5
  const renderConfigModule = (config) => {
10
6
  const lazyJson = JSON.stringify(lazyElementConfig(config.lazyElements));
11
7
  const behaviorImports = config.elements === null
@@ -1 +1 @@
1
- {"version":3,"file":"virtual.js","sourceRoot":"","sources":["../src/virtual.ts"],"names":[],"mappings":"AAEA,MAAM,sBAAsB,GAAG,qBAAqB,CAAC;AACrD,MAAM,+BAA+B,GAAG,KAAK,sBAAsB,EAAE,CAAC;AACtE,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAEhD,MAAM,iBAAiB,GAAG,CAAC,YAAsB,EAAkC,EAAE,CACjF,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAE3E;;;GAGG;AACH,MAAM,kBAAkB,GAAG,CAAC,MAAsB,EAAU,EAAE;IAC1D,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAExE,MAAM,eAAe,GACjB,MAAM,CAAC,QAAQ,KAAK,IAAI;QACpB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC;YACM,6DAA6D;YAC7D,kCAAkC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG;SACvE,CAAC;IAEd,OAAO;QACH,GAAG,eAAe;QAClB,iBAAiB,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,GAAG;QACtD,gCAAgC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG;QACvE,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.js\";\n\nconst GTKX_CONFIG_VIRTUAL_ID = \"virtual:gtkx-config\";\nconst RESOLVED_GTKX_CONFIG_VIRTUAL_ID = `\\0${GTKX_CONFIG_VIRTUAL_ID}`;\nconst METADATA_SPECIFIER = \"@gtkx/jsx/metadata\";\n\nconst lazyElementConfig = (lazyElements: string[]): Record<string, { lazy: true }> =>\n Object.fromEntries(lazyElements.map((type) => [type, { lazy: true }]));\n\n/**\n * The runtime element config is the app's static per-element config (currently its lazy flags) merged\n * with its behaviors module, so a single `elements` map is registered.\n */\nconst renderConfigModule = (config: ResolvedConfig): string => {\n const lazyJson = JSON.stringify(lazyElementConfig(config.lazyElements));\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 * from ${JSON.stringify(METADATA_SPECIFIER)};`,\n `export const applicationId = ${JSON.stringify(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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AEF,OAAO,EAAE,sBAAsB,EAAE,+BAA+B,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["import type { ResolvedConfig } from \"./config.ts\";\n\nconst GTKX_CONFIG_VIRTUAL_ID = \"virtual:gtkx-config\";\nconst RESOLVED_GTKX_CONFIG_VIRTUAL_ID = `\\0${GTKX_CONFIG_VIRTUAL_ID}`;\nconst METADATA_SPECIFIER = \"@gtkx/jsx/metadata\";\n\nconst lazyElementConfig = (lazyElements: string[]): Record<string, { isLazy: boolean }> =>\n Object.fromEntries(lazyElements.map((type) => [type, { isLazy: true }]));\n\nconst renderConfigModule = (config: ResolvedConfig): string => {\n const lazyJson = JSON.stringify(lazyElementConfig(config.lazyElements));\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 * from ${JSON.stringify(METADATA_SPECIFIER)};`,\n `export const applicationId = ${JSON.stringify(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,12 +1,5 @@
1
1
  import type { Plugin, UserConfig } from "vite";
2
- import { type ConfigLoader } from "./loader.js";
3
- /**
4
- * Creates the Vite plugin that resolves and serves the `virtual:gtkx-config`
5
- * module, exposing the JSX metadata and the resolved application ID from the
6
- * project's configuration.
7
- * @param options Plugin name, an optional custom {@link ConfigLoader}, and an
8
- * optional hook returning extra Vite user config.
9
- */
2
+ import { type ConfigLoader } from "./loader.ts";
10
3
  declare const createConfigPlugin: (options: {
11
4
  name: string;
12
5
  loadConfig?: ConfigLoader;
@@ -1 +1 @@
1
- {"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAC/C,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,aAAa,CAAC;AAsBpE;;;;;;GAMG;AACH,QAAA,MAAM,kBAAkB,GAAI,SAAS;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;CAC9C,KAAG,MAcH,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAC/C,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,aAAa,CAAC;AAsBpE,QAAA,MAAM,kBAAkB,GAAI,SAAS;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;CAC9C,KAAG,MAcH,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -7,13 +7,6 @@ const loadVirtualModule = async (id, loadConfig, state) => {
7
7
  }
8
8
  return renderConfigModule(await loadConfig.resolve(state.root ?? process.cwd()));
9
9
  };
10
- /**
11
- * Creates the Vite plugin that resolves and serves the `virtual:gtkx-config`
12
- * module, exposing the JSX metadata and the resolved application ID from the
13
- * project's configuration.
14
- * @param options Plugin name, an optional custom {@link ConfigLoader}, and an
15
- * optional hook returning extra Vite user config.
16
- */
17
10
  const createConfigPlugin = (options) => {
18
11
  const loadConfig = options.loadConfig ?? createConfigLoader();
19
12
  const state = { root: und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AE,KAAK,CAAC;KACjE,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC","sourcesContent":["import type { Plugin, UserConfig } from \"vite\";\nimport { type ConfigLoader, createConfigLoader } from \"./loader.js\";\nimport { GTKX_CONFIG_VIRTUAL_ID, renderConfigModule, RESOLVED_GTKX_CONFIG_VIRTUAL_ID } from \"./virtual.js\";\n\ntype PluginState = {\n root: string | undefined;\n};\n\nconst resolveVirtualId = (id: string): string | null =>\n id === GTKX_CONFIG_VIRTUAL_ID ? RESOLVED_GTKX_CONFIG_VIRTUAL_ID : null;\n\nconst loadVirtualModule = async (\n id: string,\n loadConfig: ConfigLoader,\n state: PluginState,\n): Promise<string | undefined> => {\n if (id !== RESOLVED_GTKX_CONFIG_VIRTUAL_ID) {\n return undefined;\n }\n\n return renderConfigModule(await loadConfig.resolve(state.root ?? process.cwd()));\n};\n\n/**\n * Creates the Vite plugin that resolves and serves the `virtual:gtkx-config`\n * module, exposing the JSX metadata and the resolved application ID from the\n * project's configuration.\n * @param options Plugin name, an optional custom {@link ConfigLoader}, and an\n * optional hook returning extra Vite user config.\n */\nconst createConfigPlugin = (options: {\n name: string;\n loadConfig?: ConfigLoader;\n config?: () => Omit<UserConfig, \"plugins\">;\n}): Plugin => {\n const loadConfig = options.loadConfig ?? createConfigLoader();\n const state: PluginState = { root: undefined };\n\n return {\n name: options.name,\n config(config: UserConfig) {\n state.root = config.root ?? state.root;\n\n return options.config?.();\n },\n resolveId: (id: string) => resolveVirtualId(id),\n load: (id: string) => loadVirtualModule(id, loadConfig, state),\n };\n};\n\nexport default createConfigPlugin;\n"]}
1
+ {"version":3,"file":"vite-plugin.js","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,+BAA+B,EAAE,MAAM,cAAc,CAAC;AAM3G,MAAM,gBAAgB,GAAG,CAAC,EAAU,EAAiB,EAAE,CACnD,EAAE,KAAK,sBAAsB,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,IAAI,CAAC;AAE3E,MAAM,iBAAiB,GAAG,KAAK,EAC3B,EAAU,EACV,UAAwB,EACxB,KAAkB,EACS,EAAE;IAC7B,IAAI,EAAE,KAAK,+BAA+B,EAAE,CAAC;QACzC,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AACrF,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,OAI3B,EAAU,EAAE;IACT,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,kBAAkB,EAAE,CAAC;IAC9D,MAAM,KAAK,GAAgB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAE/C,OAAO;QACH,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,MAAM,CAAC,MAAkB;YACrB,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC;YAEvC,OAAO,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;QAC9B,CAAC;QACD,SAAS,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC/C,IAAI,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC;KACjE,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC","sourcesContent":["import type { Plugin, UserConfig } from \"vite\";\nimport { type ConfigLoader, createConfigLoader } from \"./loader.ts\";\nimport { GTKX_CONFIG_VIRTUAL_ID, renderConfigModule, RESOLVED_GTKX_CONFIG_VIRTUAL_ID } from \"./virtual.ts\";\n\ntype PluginState = {\n root: string | undefined;\n};\n\nconst resolveVirtualId = (id: string): string | null =>\n id === GTKX_CONFIG_VIRTUAL_ID ? RESOLVED_GTKX_CONFIG_VIRTUAL_ID : null;\n\nconst loadVirtualModule = async (\n id: string,\n loadConfig: ConfigLoader,\n state: PluginState,\n): Promise<string | undefined> => {\n if (id !== RESOLVED_GTKX_CONFIG_VIRTUAL_ID) {\n return undefined;\n }\n\n return renderConfigModule(await loadConfig.resolve(state.root ?? process.cwd()));\n};\n\nconst createConfigPlugin = (options: {\n name: string;\n loadConfig?: ConfigLoader;\n config?: () => Omit<UserConfig, \"plugins\">;\n}): Plugin => {\n const loadConfig = options.loadConfig ?? createConfigLoader();\n const state: PluginState = { root: undefined };\n\n return {\n name: options.name,\n config(config: UserConfig) {\n state.root = config.root ?? state.root;\n\n return options.config?.();\n },\n resolveId: (id: string) => resolveVirtualId(id),\n load: (id: string) => loadVirtualModule(id, loadConfig, state),\n };\n};\n\nexport default createConfigPlugin;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtkx/config",
3
- "version": "1.0.0-rc.3",
3
+ "version": "1.0.0-rc.4",
4
4
  "description": "gtkx.config.ts schema, loader, and the element-prop mapping language shared across the GTKX toolchain",
5
5
  "keywords": [
6
6
  "gtkx",
@@ -50,9 +50,9 @@
50
50
  "dependencies": {
51
51
  "c12": "^3.3.4",
52
52
  "defu": "^6.1.7",
53
- "vite": "^8.1.5",
53
+ "vite": "^8.2.0",
54
54
  "zod": "^4.4.3",
55
- "@gtkx/utils": "1.0.0-rc.3"
55
+ "@gtkx/utils": "1.0.0-rc.4"
56
56
  },
57
57
  "scripts": {
58
58
  "release": "tsx ../../scripts/release-package.ts"
package/src/config.ts CHANGED
@@ -2,49 +2,53 @@ import { createDefineConfig, type DefineConfig } from "c12";
2
2
  import { defu } from "defu";
3
3
  import { resolve } from "node:path";
4
4
  import { z } from "zod";
5
- import { configError, isRecord, rawIssue } from "./config-error.js";
6
- import { resolveUserEventSignals } from "./user-event-signals.js";
5
+ import { configError, isRecord, rawIssue } from "./config-error.ts";
6
+ import { resolveUserEventSignals } from "./user-event-signals.ts";
7
7
 
8
+ /** Accepted `reactCompiler.compilationMode` values, choosing which functions the compiler processes. */
8
9
  type ReactCompilerCompilationMode = (typeof COMPILATION_MODES)[number];
10
+ /** Accepted `reactCompiler.panicThreshold` values, choosing which compiler diagnostics fail the build. */
9
11
  type ReactCompilerPanicThreshold = (typeof PANIC_THRESHOLDS)[number];
10
12
 
13
+ /** Object form of the `reactCompiler` config key, forwarded as-is to `babel-plugin-react-compiler`. */
11
14
  type ReactCompilerOptions = {
15
+ /** Which functions the compiler processes; left to the compiler's own default when omitted. */
12
16
  compilationMode?: ReactCompilerCompilationMode;
17
+ /** Which compiler diagnostics fail the build; left to the compiler's own default when omitted. */
13
18
  panicThreshold?: ReactCompilerPanicThreshold;
14
19
  };
15
20
 
16
21
  /**
17
- * React Compiler options resolved for the build, with the compilation target
18
- * fixed to React 19.
22
+ * The React Compiler options the build hands to `babel-plugin-react-compiler`, with the React version
23
+ * GTKX targets filled in.
19
24
  */
20
25
  type ResolvedReactCompilerOptions = ReactCompilerOptions & {
26
+ /** React major version the compiler emits for. */
21
27
  target: "19";
22
28
  };
23
29
 
24
30
  /**
25
- * User-facing configuration for a GTKX project, as authored in `gtkx.config.ts`:
26
- * the GIR libraries to bind, extra `.gir` search paths, the GApplication id,
27
- * a module of per-element configuration (lazy flags and custom behaviors),
28
- * per-element component wrappers and omitted props keyed by GLib type name, the
29
- * React Compiler and codegen settings, additional user event signals to suppress
30
- * during React commits, and extra GIR records to treat as class structs.
31
+ * User-facing configuration for a GTKX project, as authored in `gtkx.config.ts`: the GIR libraries
32
+ * to bind and where to find them, the GApplication id, per-element configuration, and the React
33
+ * Compiler, codegen, and user event signal settings.
31
34
  */
32
35
  type Config = z.infer<typeof configSchema>;
33
- /** A `{ module, export }` reference to a named export, as element config entries carry it. */
36
+ /** A named export referenced as plain data, so codegen can emit an import for it without loading the module. */
34
37
  type ModuleExport = z.infer<typeof moduleExportSchema>;
38
+ /** One `elements.config` entry, describing how a single GLib type's generated element is shaped. */
35
39
  type ElementConfigEntry = z.infer<typeof elementConfigSchema>;
36
40
 
37
- /**
38
- * Configuration reduced to the values needed at runtime: the GApplication
39
- * identifier, the resolved React Compiler options (`null` when disabled), the
40
- * user event signals suppressed while a React commit is in progress, and the
41
- * module path holding per-element configuration (`null` when unset).
42
- */
41
+ /** Configuration reduced to the values the app runtime and the build need, with paths already resolved. */
43
42
  type ResolvedConfig = {
43
+ /** The GApplication identifier the app registers under. */
44
44
  applicationId: string;
45
+ /** React Compiler options for the build, or `null` when the compiler is disabled. */
45
46
  reactCompiler: ResolvedReactCompilerOptions | null;
47
+ /** Signal names, keyed by GLib type name, that stay suppressed while a React commit runs. */
46
48
  userEventSignals: Record<string, string[]>;
49
+ /** Path of the module exporting per-element configs, or `null` when none is configured. */
47
50
  elements: string | null;
51
+ /** GLib type names of the elements marked `isLazy`, whose GObject their parent container creates. */
48
52
  lazyElements: string[];
49
53
  };
50
54
 
@@ -58,6 +62,7 @@ const REACT_COMPILER_TARGET = "19";
58
62
  const COMPILATION_MODE_SET: Set<string> = new Set(COMPILATION_MODES);
59
63
  const PANIC_THRESHOLD_SET: Set<string> = new Set(PANIC_THRESHOLDS);
60
64
 
65
+ /** Validates `libraries`: the `"*"` wildcard on its own, or a non-empty array of `Name-Version` identifiers. */
61
66
  const librariesSchema = z.custom<typeof LIBRARIES_WILDCARD | string[]>().check((ctx) => {
62
67
  const value = ctx.value;
63
68
 
@@ -76,6 +81,7 @@ const librariesSchema = z.custom<typeof LIBRARIES_WILDCARD | string[]>().check((
76
81
  }
77
82
  });
78
83
 
84
+ /** Validates `applicationId` against the reverse-DNS form `g_application_id_is_valid` accepts. */
79
85
  const applicationIdSchema = z.custom<string>().check((ctx) => {
80
86
  const value = ctx.value;
81
87
 
@@ -92,6 +98,7 @@ const applicationIdSchema = z.custom<string>().check((ctx) => {
92
98
  }
93
99
  });
94
100
 
101
+ /** Validates `reactCompiler`: a boolean, or an options object whose mode and threshold are known values. */
95
102
  const reactCompilerSchema = z.custom<boolean | ReactCompilerOptions>().check((ctx) => {
96
103
  const value = ctx.value;
97
104
 
@@ -134,6 +141,7 @@ const reactCompilerSchema = z.custom<boolean | ReactCompilerOptions>().check((ct
134
141
  }
135
142
  });
136
143
 
144
+ /** Validates `userEventSignals`: GLib type names mapped to arrays of non-empty signal names. */
137
145
  const userEventSignalsSchema = z.record(
138
146
  z.string(),
139
147
  z.array(
@@ -145,19 +153,27 @@ const userEventSignalsSchema = z.record(
145
153
  { error: "must be a record of GLib type names to signal name arrays" },
146
154
  );
147
155
 
156
+ /** Validates a `{ module, export }` reference to a named export. */
148
157
  const moduleExportSchema = z.object(
149
158
  {
159
+ /** Specifier the export is imported from. */
150
160
  module: z.string({ error: "must be a module specifier" }).min(1, { error: "must be a module specifier" }),
161
+ /** Identifier the module exports it under. */
151
162
  export: z.string({ error: "must be an export name" }).min(1, { error: "must be an export name" }),
152
163
  },
153
164
  { error: "must be a { module, export } object" },
154
165
  );
155
166
 
167
+ /** Validates one entry of `elements.config`. */
156
168
  const elementConfigSchema = z.object({
169
+ /** Component that wraps the generated element. */
157
170
  component: moduleExportSchema.optional(),
171
+ /** Base props interface the generated element props extend. */
158
172
  props: moduleExportSchema.optional(),
159
- lazy: z.boolean({ error: "must be a boolean" }).optional(),
160
- omitProps: z
173
+ /** Marks the element as having no GObject of its own, its parent container creating one instead. */
174
+ isLazy: z.boolean({ error: "must be a boolean" }).optional(),
175
+ /** GObject properties to leave out of the generated element props, such as those a behavior fills. */
176
+ omittedProps: z
161
177
  .array(
162
178
  z.string({ error: "must be a non-empty property name" }).min(1, {
163
179
  error: "must be a non-empty property name",
@@ -167,27 +183,47 @@ const elementConfigSchema = z.object({
167
183
  .optional(),
168
184
  });
169
185
 
186
+ /** Validates `elements`: the behaviors module the app loads at runtime, plus the per-type entries. */
170
187
  const elementsSchema = z.object({
188
+ /**
189
+ * Path, resolved against the project root, of a module default-exporting element configs keyed by
190
+ * GLib type name, as `defineElements` returns.
191
+ */
171
192
  behaviors: z
172
193
  .string({ error: "must be a path to a module exporting element behaviors" })
173
194
  .min(1, { error: "must be a path to a module exporting element behaviors" })
174
195
  .optional(),
196
+ /** Per-element entries, keyed by GLib type name. */
175
197
  config: z.record(z.string(), elementConfigSchema).optional(),
176
198
  });
177
199
 
200
+ /** The shape every `gtkx.config.ts` is validated against, and the source of the {@link Config} type. */
178
201
  const configSchema = z.object({
202
+ /**
203
+ * GIR namespaces to bind as `Name-Version`, or `"*"` for every one installed; omitting it gives
204
+ * `Gtk-4.0`, which is also prepended to any list that names no Gtk version of its own.
205
+ */
179
206
  libraries: librariesSchema.optional(),
207
+ /** Directories searched for `.gir` files ahead of `GTKX_GIR_PATH` and the system locations. */
180
208
  girPath: z.array(z.string(), { error: "must be an array of strings if provided" }).optional(),
209
+ /** Reverse-DNS GApplication identifier, and the default `applicationId` of the application element. */
181
210
  applicationId: applicationIdSchema,
211
+ /** React Compiler settings; the compiler runs unless this is `false`. */
182
212
  reactCompiler: reactCompilerSchema.optional(),
213
+ /** Whether to generate the binding stores; `false` makes the CLI resolve an already-installed one. */
183
214
  codegen: z.boolean({ error: "must be a boolean" }).optional(),
215
+ /**
216
+ * Signal names, keyed by GLib type name, that stay suppressed while a React commit applies props, so
217
+ * their handlers only ever report user interaction. Unioned with the built-in GTK4 and Adwaita table.
218
+ */
184
219
  userEventSignals: userEventSignalsSchema.optional(),
220
+ /** Per-element customization: where the behaviors module lives and how each type's element is shaped. */
185
221
  elements: elementsSchema.optional(),
186
222
  });
187
223
 
188
224
  /**
189
- * Identity helper that returns the given configuration typed as {@link Config},
190
- * enabling editor autocompletion and type checking in `gtkx.config.ts`.
225
+ * Returns the given configuration unchanged, typed as {@link Config}, so `gtkx.config.ts` gets
226
+ * autocompletion and type checking.
191
227
  */
192
228
  const defineConfig: DefineConfig<Config> = createDefineConfig<Config>();
193
229
 
@@ -241,9 +277,8 @@ const validateConfig = (config: Config): void => {
241
277
  };
242
278
 
243
279
  /**
244
- * Deep-merges two configurations, with `override` taking precedence over `base`.
245
- * @param base The lower-priority configuration.
246
- * @param override The higher-priority configuration whose values win on conflict.
280
+ * Deep-merges two configurations. `override` wins over `base` on conflicting scalar and object keys, while
281
+ * arrays are concatenated with the `override` entries first.
247
282
  */
248
283
  const mergeConfig = (base: Config, override: Config): Config => defu(override, base);
249
284
 
@@ -257,7 +292,7 @@ const resolveElementsModule = (behaviors: string | undefined, root: string | und
257
292
 
258
293
  const resolveLazyElements = (elements: Config["elements"]): string[] =>
259
294
  Object.entries(elements?.config ?? {})
260
- .filter(([, entry]) => entry.lazy === true)
295
+ .filter(([, entry]) => entry.isLazy === true)
261
296
  .map(([type]) => type);
262
297
 
263
298
  const elementEntryValues = <T>(
@@ -278,8 +313,8 @@ const resolveElementComponents = (elements: Config["elements"]): Record<string,
278
313
  const resolveElementProps = (elements: Config["elements"]): Record<string, ModuleExport> =>
279
314
  elementEntryValues(elements, (entry) => entry.props);
280
315
 
281
- const resolveOmitProps = (elements: Config["elements"]): Record<string, string[]> =>
282
- elementEntryValues(elements, (entry) => entry.omitProps);
316
+ const resolveOmittedProps = (elements: Config["elements"]): Record<string, string[]> =>
317
+ elementEntryValues(elements, (entry) => entry.omittedProps);
283
318
 
284
319
  const resolveConfig = (config: Config, root?: string): ResolvedConfig => ({
285
320
  applicationId: config.applicationId,
@@ -298,7 +333,7 @@ export {
298
333
  resolveLazyElements,
299
334
  resolveElementComponents,
300
335
  resolveElementProps,
301
- resolveOmitProps,
336
+ resolveOmittedProps,
302
337
  resolveConfig,
303
338
  type ResolvedReactCompilerOptions,
304
339
  type Config,
package/src/index.ts CHANGED
@@ -1,8 +1,4 @@
1
- export {
2
- type Config,
3
- defineConfig,
4
- mergeConfig,
5
- type ResolvedConfig,
6
- type ResolvedReactCompilerOptions,
7
- } from "./config.js";
8
- export { type LoadedConfig, loadConfig } from "./loader.js";
1
+ /** @public */
2
+ export { type Config, defineConfig, mergeConfig, type ResolvedConfig } from "./config.ts";
3
+ /** @public */
4
+ export { type LoadedConfig, loadConfig } from "./loader.ts";
package/src/internal.ts CHANGED
@@ -1,8 +1,9 @@
1
+ export type { ResolvedReactCompilerOptions } from "./config.ts";
1
2
  export {
2
3
  isValidApplicationId,
3
4
  resolveElementComponents,
4
5
  resolveElementProps,
5
6
  resolveLazyElements,
6
- resolveOmitProps,
7
- } from "./config.js";
8
- export { type ConfigLoader, createConfigLoader } from "./loader.js";
7
+ resolveOmittedProps,
8
+ } from "./config.ts";
9
+ export { type ConfigLoader, createConfigLoader } from "./loader.ts";
package/src/loader.ts CHANGED
@@ -2,36 +2,37 @@ import { getOrInsert } from "@gtkx/utils";
2
2
  import { loadConfig as loadConfigFile } from "c12";
3
3
  import { existsSync } from "node:fs";
4
4
  import { resolve } from "node:path";
5
- import { type Config, resolveConfig, type ResolvedConfig, validateConfig } from "./config.js";
5
+ import { type Config, resolveConfig, type ResolvedConfig, validateConfig } from "./config.ts";
6
6
 
7
- /**
8
- * Result of loading a `gtkx.config.ts` file: the parsed configuration, the
9
- * resolved config file path, and the project root it was loaded from.
10
- */
7
+ /** Result of loading a project's `gtkx.config.ts` file. */
11
8
  type LoadedConfig = {
9
+ /** The parsed and validated configuration. */
12
10
  config: Config;
11
+ /** Absolute path of the configuration file that was loaded. */
13
12
  configFile: string;
13
+ /** Absolute path of the project root the configuration was resolved against. */
14
14
  root: string;
15
15
  };
16
16
 
17
+ /** How a configuration file is read, shared by {@link loadConfig} and `createConfigLoader`. */
17
18
  type LoadConfigOptions = {
19
+ /**
20
+ * Environment name such as `development`: the config's matching `$<mode>` block is layered over the
21
+ * top-level values, and the name is passed to a config authored as a function.
22
+ */
18
23
  mode?: string | undefined;
19
24
  };
20
25
 
21
- /**
22
- * Caching accessor for a project's configuration: `load` yields the validated authored config together with
23
- * its file path, and `resolve` yields the projection an app needs at runtime.
24
- */
25
26
  type ConfigLoader = {
26
27
  load: (cwd: string) => Promise<LoadedConfig>;
27
28
  resolve: (cwd: string) => Promise<ResolvedConfig>;
28
29
  };
29
30
 
30
31
  /**
31
- * Loads and validates the `gtkx.config.ts` file for a project, returning the
32
- * parsed configuration together with the config file path and project root.
33
- * @param cwd Directory from which to search for the configuration file.
34
- * @param options Loading options, such as the environment mode.
32
+ * Loads and validates the `gtkx.config.ts` file for a project.
33
+ * @param cwd Directory the configuration file is looked up in.
34
+ * @param options Loading options, such as the environment mode whose overrides are applied.
35
+ * @throws When the configuration fails validation, or when no configuration file is found.
35
36
  */
36
37
  const loadConfig = async (cwd: string, options: LoadConfigOptions = {}): Promise<LoadedConfig> => {
37
38
  const result = await loadConfigFile<Config>({
package/src/virtual.ts CHANGED
@@ -1,16 +1,12 @@
1
- import type { ResolvedConfig } from "./config.js";
1
+ import type { ResolvedConfig } from "./config.ts";
2
2
 
3
3
  const GTKX_CONFIG_VIRTUAL_ID = "virtual:gtkx-config";
4
4
  const RESOLVED_GTKX_CONFIG_VIRTUAL_ID = `\0${GTKX_CONFIG_VIRTUAL_ID}`;
5
5
  const METADATA_SPECIFIER = "@gtkx/jsx/metadata";
6
6
 
7
- const lazyElementConfig = (lazyElements: string[]): Record<string, { lazy: true }> =>
8
- Object.fromEntries(lazyElements.map((type) => [type, { lazy: true }]));
7
+ const lazyElementConfig = (lazyElements: string[]): Record<string, { isLazy: boolean }> =>
8
+ Object.fromEntries(lazyElements.map((type) => [type, { isLazy: true }]));
9
9
 
10
- /**
11
- * The runtime element config is the app's static per-element config (currently its lazy flags) merged
12
- * with its behaviors module, so a single `elements` map is registered.
13
- */
14
10
  const renderConfigModule = (config: ResolvedConfig): string => {
15
11
  const lazyJson = JSON.stringify(lazyElementConfig(config.lazyElements));
16
12
 
@@ -1,6 +1,6 @@
1
1
  import type { Plugin, UserConfig } from "vite";
2
- import { type ConfigLoader, createConfigLoader } from "./loader.js";
3
- import { GTKX_CONFIG_VIRTUAL_ID, renderConfigModule, RESOLVED_GTKX_CONFIG_VIRTUAL_ID } from "./virtual.js";
2
+ import { type ConfigLoader, createConfigLoader } from "./loader.ts";
3
+ import { GTKX_CONFIG_VIRTUAL_ID, renderConfigModule, RESOLVED_GTKX_CONFIG_VIRTUAL_ID } from "./virtual.ts";
4
4
 
5
5
  type PluginState = {
6
6
  root: string | undefined;
@@ -21,13 +21,6 @@ const loadVirtualModule = async (
21
21
  return renderConfigModule(await loadConfig.resolve(state.root ?? process.cwd()));
22
22
  };
23
23
 
24
- /**
25
- * Creates the Vite plugin that resolves and serves the `virtual:gtkx-config`
26
- * module, exposing the JSX metadata and the resolved application ID from the
27
- * project's configuration.
28
- * @param options Plugin name, an optional custom {@link ConfigLoader}, and an
29
- * optional hook returning extra Vite user config.
30
- */
31
24
  const createConfigPlugin = (options: {
32
25
  name: string;
33
26
  loadConfig?: ConfigLoader;