@gtkx/config 2.0.0-beta.10 → 2.0.0-beta.11
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 +11 -169
- package/dist/config-dependencies.d.ts.map +1 -1
- package/dist/config-dependencies.js +3 -2
- package/dist/config-dependencies.js.map +1 -1
- package/dist/config-reloader.d.ts +8 -0
- package/dist/config-reloader.d.ts.map +1 -0
- package/dist/config-reloader.js +38 -0
- package/dist/config-reloader.js.map +1 -0
- package/dist/config-source.d.ts +7 -0
- package/dist/config-source.d.ts.map +1 -0
- package/dist/config-source.js +17 -0
- package/dist/config-source.js.map +1 -0
- package/dist/config.d.ts +32 -22
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +16 -10
- package/dist/config.js.map +1 -1
- package/dist/deploy.d.ts +3 -7
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +1 -2
- package/dist/deploy.js.map +1 -1
- package/dist/internal.d.ts +4 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +4 -2
- package/dist/internal.js.map +1 -1
- package/dist/loader.d.ts +1 -1
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +3 -15
- package/dist/loader.js.map +1 -1
- package/dist/node-version.d.ts +2 -1
- package/dist/node-version.d.ts.map +1 -1
- package/dist/node-version.js +2 -1
- package/dist/node-version.js.map +1 -1
- package/dist/static-dependencies.d.ts +3 -0
- package/dist/static-dependencies.d.ts.map +1 -0
- package/dist/static-dependencies.js +350 -0
- package/dist/static-dependencies.js.map +1 -0
- package/dist/virtual.d.ts.map +1 -1
- package/dist/virtual.js +0 -2
- package/dist/virtual.js.map +1 -1
- package/dist/vite-plugin.d.ts.map +1 -1
- package/dist/vite-plugin.js.map +1 -1
- package/package.json +20 -6
- package/src/config-dependencies.ts +4 -2
- package/src/config-reloader.ts +54 -0
- package/src/config-source.ts +25 -0
- package/src/config.ts +22 -14
- package/src/deploy.ts +2 -3
- package/src/internal.ts +4 -1
- package/src/loader.ts +4 -24
- package/src/node-version.ts +2 -1
- package/src/static-dependencies.ts +464 -0
- package/src/virtual.ts +0 -2
- package/src/vite-plugin.ts +0 -2
package/README.md
CHANGED
|
@@ -1,177 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
<img src="https://raw.githubusercontent.com/gtkx-org/gtkx/main/logo.svg" alt="GTKX" width="100" />
|
|
3
|
-
</p>
|
|
1
|
+
# @gtkx/config
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
Typed application configuration for GTKX.
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
The React framework for Linux.<br />
|
|
9
|
-
Write native GNOME applications with React and TypeScript.
|
|
10
|
-
Real Adwaita and GTK4 widgets with standard web tooling.
|
|
11
|
-
</p>
|
|
5
|
+
Use `defineConfig` in `gtkx.config.ts` to declare the application ID, native libraries, resources, and deployment settings. The CLI loads this configuration for development, code generation, and builds.
|
|
12
6
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<a href="https://www.npmjs.com/package/create-gtkx"><img src="https://img.shields.io/npm/dm/create-gtkx?color=cb3837&logo=npm&label=downloads" alt="npm downloads" /></a>
|
|
16
|
-
<img src="https://img.shields.io/badge/node-%E2%89%A526.7-339933?logo=node.js&logoColor=white" alt="Node >= 26.7" />
|
|
17
|
-
<a href="https://github.com/gtkx-org/gtkx/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MPL--2.0-blue.svg" alt="License: MPL-2.0" /></a>
|
|
18
|
-
<a href="https://github.com/gtkx-org/gtkx/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/gtkx-org/gtkx/ci.yml?branch=main&logo=github&label=CI" alt="CI status" /></a>
|
|
19
|
-
<img src="https://img.shields.io/badge/TypeScript-strict-3178c6?logo=typescript&logoColor=white" alt="TypeScript" />
|
|
20
|
-
</p>
|
|
7
|
+
```ts
|
|
8
|
+
import { defineConfig } from "@gtkx/config";
|
|
21
9
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
<a href="https://github.com/gtkx-org/gtkx/tree/main/examples">Examples</a> ·
|
|
26
|
-
<a href="https://github.com/gtkx-org/gtkx/blob/main/CONTRIBUTING.md">Contributing</a>
|
|
27
|
-
</p>
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
<p align="center">
|
|
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." />
|
|
33
|
-
</p>
|
|
34
|
-
|
|
35
|
-
<p align="center">
|
|
36
|
-
<em>The Tasks app you build in the <a href="https://gtkx.dev/tutorial/">tutorial</a>.</em>
|
|
37
|
-
</p>
|
|
38
|
-
|
|
39
|
-
## Demo
|
|
40
|
-
|
|
41
|
-
This app starts with an Adwaita application shell, renders native GTK4 widgets inside it, and uses ordinary React hooks and events:
|
|
42
|
-
|
|
43
|
-
```tsx
|
|
44
|
-
import * as Gtk from "@gtkx/gi/gtk";
|
|
45
|
-
import { AdwApplication, AdwApplicationWindow, AdwHeaderBar, AdwToolbarView } from "@gtkx/jsx/adw";
|
|
46
|
-
import { GtkBox, GtkButton, GtkLabel } from "@gtkx/jsx/gtk";
|
|
47
|
-
import { createRoot, quit } from "@gtkx/react";
|
|
48
|
-
import { useState } from "react";
|
|
49
|
-
|
|
50
|
-
const Counter = () => {
|
|
51
|
-
const [count, setCount] = useState(0);
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<AdwApplicationWindow
|
|
55
|
-
title="Hello GTKX"
|
|
56
|
-
defaultWidth={400}
|
|
57
|
-
defaultHeight={300}
|
|
58
|
-
onCloseRequest={quit}
|
|
59
|
-
>
|
|
60
|
-
<AdwToolbarView topBar={<AdwHeaderBar />}>
|
|
61
|
-
<GtkBox
|
|
62
|
-
orientation={Gtk.Orientation.VERTICAL}
|
|
63
|
-
spacing={20}
|
|
64
|
-
marginTop={40}
|
|
65
|
-
marginBottom={40}
|
|
66
|
-
marginStart={40}
|
|
67
|
-
marginEnd={40}
|
|
68
|
-
valign={Gtk.Align.CENTER}
|
|
69
|
-
halign={Gtk.Align.CENTER}
|
|
70
|
-
>
|
|
71
|
-
<GtkLabel cssClasses={["title-1"]}>Welcome to GTKX!</GtkLabel>
|
|
72
|
-
<GtkLabel cssClasses={["title-2"]}>{`Count: ${String(count)}`}</GtkLabel>
|
|
73
|
-
<GtkButton
|
|
74
|
-
label="Increment"
|
|
75
|
-
onClicked={() => setCount((c) => c + 1)}
|
|
76
|
-
cssClasses={["suggested-action", "pill"]}
|
|
77
|
-
/>
|
|
78
|
-
</GtkBox>
|
|
79
|
-
</AdwToolbarView>
|
|
80
|
-
</AdwApplicationWindow>
|
|
81
|
-
);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const App = () => (
|
|
85
|
-
<AdwApplication>
|
|
86
|
-
<Counter />
|
|
87
|
-
</AdwApplication>
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
createRoot().render(<App />);
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
This is the [`hello-world`](https://github.com/gtkx-org/gtkx/tree/main/examples/hello-world) example, with `app.tsx` and `index.tsx` combined into a single snippet. `@gtkx/gi` and `@gtkx/jsx` are per-project bindings generated by the CLI, not packages you install from npm.
|
|
94
|
-
|
|
95
|
-
## Why GTKX
|
|
96
|
-
|
|
97
|
-
### Adwaita-first application development
|
|
98
|
-
|
|
99
|
-
GTKX uses Adwaita as the foundation for applications, windows, navigation, dialogs, and adaptive layouts, with the complete GTK4 toolkit underneath. It adds a declarative React layer and an integrated TypeScript toolchain to the GNOME platform:
|
|
100
|
-
|
|
101
|
-
- a React reconciler that exposes every GObject as a JSX element,
|
|
102
|
-
- a CLI for scaffolding, development, and production builds,
|
|
103
|
-
- a dev server with Fast Refresh that patches your running UI in place,
|
|
104
|
-
- CSS-in-JS styling, React Hook Form-powered Adwaita controls, gettext-backed react-i18next localization, React Spring animations, React Navigation stack, tab, drawer, and split view navigators, and high-level list, grid, and dialog components,
|
|
105
|
-
- a Testing Library-style API for querying and driving your widgets in tests,
|
|
106
|
-
- and a Model Context Protocol (MCP) server that exposes your live app to AI agents.
|
|
107
|
-
|
|
108
|
-
### Native GNOME widgets, without a compatibility layer
|
|
109
|
-
|
|
110
|
-
React Native and similar frameworks hide the native toolkit so one API can run everywhere. GTKX renders real Adwaita and GTK4 widgets and exposes any other GObject-Introspection library on your system. It is GNOME-native and Linux-only by design.
|
|
111
|
-
|
|
112
|
-
### Why Node.js, and why generated bindings
|
|
113
|
-
|
|
114
|
-
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 what running on Node.js means day to day.
|
|
115
|
-
|
|
116
|
-
GTKX generates the TypeScript types and native FFI calls from the same GObject-Introspection data, so the types cannot drift from the calls they back. `Adw-1` is the sole default GIR root; its GIR include pulls in `Gtk-4.0`, so codegen covers both complete API surfaces. Neither belongs in a GTKX 2 `libraries` list.
|
|
117
|
-
|
|
118
|
-
At runtime, the native Rust core calls straight into the system Adwaita, GTK4, and GLib libraries through libffi, without loading libgirepository at all.
|
|
119
|
-
|
|
120
|
-
## Quick start
|
|
121
|
-
|
|
122
|
-
GTKX is Linux-only and needs Node.js 26.7 or later. See [Requirements](#requirements).
|
|
123
|
-
|
|
124
|
-
Scaffold a new app with the `create-gtkx` initializer:
|
|
125
|
-
|
|
126
|
-
```sh
|
|
127
|
-
npm create gtkx@beta
|
|
10
|
+
export default defineConfig({
|
|
11
|
+
applicationId: "com.example.MyApp",
|
|
12
|
+
});
|
|
128
13
|
```
|
|
129
14
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
Then run your new app:
|
|
133
|
-
|
|
134
|
-
```sh
|
|
135
|
-
cd my-app
|
|
136
|
-
npm run dev
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
To go further, follow the [tutorial](https://gtkx.dev/tutorial/).
|
|
140
|
-
|
|
141
|
-
## Documentation
|
|
142
|
-
|
|
143
|
-
The documentation at **[gtkx.dev](https://gtkx.dev)** includes a step-by-step tutorial that builds a complete GNOME app, from scaffolding to packaging and shipping, plus guides and a full API reference.
|
|
144
|
-
|
|
145
|
-
**[Read the docs →](https://gtkx.dev/guide/why-gtkx)**
|
|
146
|
-
|
|
147
|
-
## Requirements
|
|
148
|
-
|
|
149
|
-
GTKX is Linux-only. You need:
|
|
150
|
-
|
|
151
|
-
- Linux with the Adwaita (1.8 or later), GTK4 (4.20 or later), and GLib development libraries
|
|
152
|
-
- Node.js 26.7 or later
|
|
153
|
-
|
|
154
|
-
The `@gtkx/native` addon ships prebuilt for x64 and arm64 glibc Linux; other targets need to build it from the GTKX repository, which requires a Rust toolchain.
|
|
155
|
-
|
|
156
|
-
## Examples
|
|
157
|
-
|
|
158
|
-
Explore the [example apps](https://github.com/gtkx-org/gtkx/tree/main/examples):
|
|
159
|
-
|
|
160
|
-
- [`hello-world`](https://github.com/gtkx-org/gtkx/tree/main/examples/hello-world): the Adwaita counter above.
|
|
161
|
-
- [`gtk-demo`](https://github.com/gtkx-org/gtkx/tree/main/examples/gtk-demo): the official GTK4 widget showcase in an Adwaita application shell, covering lists, dialogs, gestures, CSS, and OpenGL.
|
|
162
|
-
- [`browser`](https://github.com/gtkx-org/gtkx/tree/main/examples/browser): an Adwaita browser built around `WebKitWebView`.
|
|
163
|
-
- [`animations`](https://github.com/gtkx-org/gtkx/tree/main/examples/animations): an Adwaita showcase for `@gtkx/animated`, with React Spring animations driven by the GTK frame clock.
|
|
164
|
-
- [`navigation`](https://github.com/gtkx-org/gtkx/tree/main/examples/navigation): a tour of `@gtkx/navigation`, React Navigation's stack, tab, and drawer navigators rendered with libadwaita.
|
|
165
|
-
- [`tutorial`](https://github.com/gtkx-org/gtkx/tree/main/examples/tutorial): the Tasks app the documentation builds.
|
|
166
|
-
|
|
167
|
-
## Status
|
|
168
|
-
|
|
169
|
-
GTKX is stable and ready for production use.
|
|
170
|
-
|
|
171
|
-
## Contributing
|
|
172
|
-
|
|
173
|
-
Contributions are welcome. See [CONTRIBUTING.md](https://github.com/gtkx-org/gtkx/blob/main/CONTRIBUTING.md), the [Code of Conduct](https://github.com/gtkx-org/gtkx/blob/main/CODE_OF_CONDUCT.md), and the [security policy](https://github.com/gtkx-org/gtkx/blob/main/SECURITY.md). Building the repo needs Node.js 26.7 or later, pnpm, and a Rust toolchain.
|
|
15
|
+
[Guide](https://gtkx.dev/v2/guide/configuration-and-codegen) · [API reference](https://gtkx.dev/v2/reference/@gtkx/config/) · [GTKX](https://gtkx.dev)
|
|
174
16
|
|
|
175
|
-
|
|
17
|
+
GTKX runs on Linux with Node.js and system native libraries. See [Getting Started](https://gtkx.dev/v2/guide/getting-started) for supported versions and installation. This README describes the 2.0 beta.
|
|
176
18
|
|
|
177
|
-
|
|
19
|
+
[MPL-2.0](https://github.com/gtkx-org/gtkx/blob/main/LICENSE).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-dependencies.d.ts","sourceRoot":"","sources":["../src/config-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,MAAM,CAAC;AAO1F,KAAK,cAAc,CAAC,CAAC,IAAI;IAAE,YAAY,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"config-dependencies.d.ts","sourceRoot":"","sources":["../src/config-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,MAAM,CAAC;AAO1F,KAAK,cAAc,CAAC,CAAC,IAAI;IAAE,YAAY,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC;AAyD9D,QAAA,MAAM,qBAAqB,GAAI,SAAS,gBAAgB,KAAG,eAY1D,CAAC;AAEF,QAAA,MAAM,qBAAqB,GAAI,OAAO,MAAM,EAAE,cAAc,QAAQ,CAAC,MAAM,CAAC,KAAG,IAI9E,CAAC;AAEF,QAAA,MAAM,qBAAqB,GAAI,OAAO,OAAO,KAAG,MAAM,EACqC,CAAC;AAE5F,QAAA,MAAM,yBAAyB,GAAU,CAAC,EAAE,WAAW,MAAM,OAAO,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAqBlG,CAAC;AAEF,OAAO,EACH,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,GACxB,CAAC"}
|
|
@@ -18,7 +18,8 @@ const addUrl = (url) => {
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
const cacheBustedUrl = (url) => {
|
|
21
|
-
|
|
21
|
+
const state = captureStorage.getStore();
|
|
22
|
+
if (state === undefined || !url.startsWith("file:")) {
|
|
22
23
|
return url;
|
|
23
24
|
}
|
|
24
25
|
const path = fileURLToPath(url);
|
|
@@ -26,7 +27,7 @@ const cacheBustedUrl = (url) => {
|
|
|
26
27
|
return url;
|
|
27
28
|
}
|
|
28
29
|
const parsed = new URL(url);
|
|
29
|
-
parsed.searchParams.set("gtkx-config-load",
|
|
30
|
+
parsed.searchParams.set("gtkx-config-load", state.cacheKey);
|
|
30
31
|
return parsed.href;
|
|
31
32
|
};
|
|
32
33
|
const registerResolutionHook = () => registerHooks({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-dependencies.js","sourceRoot":"","sources":["../src/config-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA0D,MAAM,MAAM,CAAC;AAC1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,E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AAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YAC9C,qBAAqB,CAAC,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;QACrD,CAAC;QAED,MAAM,KAAK,CAAC;IAChB,CAAC;YAAS,CAAC;QACP,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EACH,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,GACxB,CAAC","sourcesContent":["import { createJiti, type Jiti, type TransformOptions, type TransformResult } from \"jiti\";\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport { createRequire, registerHooks } from \"node:module\";\nimport { extname, sep } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\ntype CaptureState = { cacheKey: string; dependencies: Set<string>; transformer: Jiti };\ntype CapturedConfig<T> = { dependencies: string[]; value: T };\n\nconst captureStorage: AsyncLocalStorage<CaptureState> = new AsyncLocalStorage();\nconst dependenciesByValue: WeakMap<object, string[]> = new WeakMap();\nconst CACHE_BUSTED_EXTENSIONS: ReadonlySet<string> = new Set([\".cjs\", \".js\", \".json\", \".mjs\"]);\n\nconst isTrackedPath = (path: string): boolean => !path.includes(`${sep}node_modules${sep}`);\n\nconst addPath = (path: string): void => {\n if (isTrackedPath(path)) {\n captureStorage.getStore()?.dependencies.add(path);\n }\n};\n\nconst addUrl = (url: string): void => {\n if (url.startsWith(\"file:\")) {\n addPath(fileURLToPath(url));\n }\n};\n\nconst cacheBustedUrl = (url: string): string => {\n const state = captureStorage.getStore();\n\n if (state === undefined || !url.startsWith(\"file:\")) {\n return url;\n }\n\n const path = fileURLToPath(url);\n\n if (!isTrackedPath(path) || !CACHE_BUSTED_EXTENSIONS.has(extname(path))) {\n return url;\n }\n\n const parsed = new URL(url);\n parsed.searchParams.set(\"gtkx-config-load\", state.cacheKey);\n\n return parsed.href;\n};\n\nconst registerResolutionHook = (): ReturnType<typeof registerHooks> =>\n registerHooks({\n resolve(specifier, context, nextResolve) {\n const result = nextResolve(specifier, context);\n addUrl(result.url);\n\n return { ...result, url: cacheBustedUrl(result.url) };\n },\n });\n\nconst clearNativeModuleCache = (dependencies: Iterable<string>): void => {\n const cache = createRequire(import.meta.url).cache;\n\n for (const path of dependencies) {\n Reflect.deleteProperty(cache, path);\n }\n};\n\nconst transformConfigModule = (options: TransformOptions): TransformResult => {\n const state = captureStorage.getStore();\n\n if (state === undefined) {\n throw new Error(\"Configuration transformation started outside a dependency capture\");\n }\n\n if (options.filename !== undefined) {\n addPath(options.filename);\n }\n\n return { code: state.transformer.transform(options) };\n};\n\nconst setConfigDependencies = (value: object, dependencies: Iterable<string>): void => {\n const paths = [...new Set(dependencies)];\n dependenciesByValue.set(value, paths);\n clearNativeModuleCache(paths);\n};\n\nconst configDependenciesFor = (value: unknown): string[] =>\n typeof value === \"object\" && value !== null ? dependenciesByValue.get(value) ?? [] : [];\n\nconst captureConfigDependencies = async <T>(operation: () => Promise<T>): Promise<CapturedConfig<T>> => {\n const state: CaptureState = {\n cacheKey: process.hrtime.bigint().toString(),\n dependencies: new Set(),\n transformer: createJiti(import.meta.url, { fsCache: false, moduleCache: false }),\n };\n const hook = registerResolutionHook();\n\n try {\n const value = await captureStorage.run(state, operation);\n\n return { dependencies: [...state.dependencies], value };\n } catch (error) {\n if (typeof error === \"object\" && error !== null) {\n setConfigDependencies(error, state.dependencies);\n }\n\n throw error;\n } finally {\n hook.deregister();\n }\n};\n\nexport {\n captureConfigDependencies,\n configDependenciesFor,\n setConfigDependencies,\n transformConfigModule,\n};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type LoadConfigOptions, type LoadedConfig } from "./loader.ts";
|
|
2
|
+
type ConfigReloader = {
|
|
3
|
+
reload: () => Promise<LoadedConfig>;
|
|
4
|
+
resolvePaths: () => string[];
|
|
5
|
+
};
|
|
6
|
+
declare const createConfigReloader: (cwd: string, options?: LoadConfigOptions, initialDependencies?: string[]) => Promise<ConfigReloader>;
|
|
7
|
+
export { createConfigReloader };
|
|
8
|
+
//# sourceMappingURL=config-reloader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-reloader.d.ts","sourceRoot":"","sources":["../src/config-reloader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,KAAK,iBAAiB,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAGpF,KAAK,cAAc,GAAG;IAClB,MAAM,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;IACpC,YAAY,EAAE,MAAM,MAAM,EAAE,CAAC;CAChC,CAAC;AAEF,QAAA,MAAM,oBAAoB,GACtB,KAAK,MAAM,EACX,UAAS,iBAAsB,EAC/B,sBAAqB,MAAM,EAAO,KACnC,OAAO,CAAC,cAAc,CAqCxB,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { relative, resolve } from "node:path";
|
|
2
|
+
import { configDependenciesFor } from "./config-dependencies.js";
|
|
3
|
+
import { loadConfig } from "./loader.js";
|
|
4
|
+
import { resolveConfigDependencies } from "./static-dependencies.js";
|
|
5
|
+
const createConfigReloader = async (cwd, options = {}, initialDependencies = []) => {
|
|
6
|
+
let selectedConfigFile;
|
|
7
|
+
let knownDependencies = initialDependencies;
|
|
8
|
+
if (options.configFile === undefined) {
|
|
9
|
+
const loaded = await loadConfig(cwd, options);
|
|
10
|
+
selectedConfigFile = loaded.configFile;
|
|
11
|
+
knownDependencies = [...knownDependencies, ...configDependenciesFor(loaded)];
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
selectedConfigFile = resolve(cwd, options.configFile);
|
|
15
|
+
}
|
|
16
|
+
const selectedConfigName = relative(cwd, selectedConfigFile);
|
|
17
|
+
const resolvePaths = () => [
|
|
18
|
+
...new Set([selectedConfigFile, ...knownDependencies]
|
|
19
|
+
.flatMap((path) => resolveConfigDependencies(path, selectedConfigName, cwd))),
|
|
20
|
+
];
|
|
21
|
+
return {
|
|
22
|
+
resolvePaths,
|
|
23
|
+
reload: async () => {
|
|
24
|
+
let loaded;
|
|
25
|
+
try {
|
|
26
|
+
loaded = await loadConfig(cwd, { ...options, configFile: selectedConfigFile });
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
knownDependencies = [...new Set([...knownDependencies, ...configDependenciesFor(error)])];
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
knownDependencies = configDependenciesFor(loaded);
|
|
33
|
+
return loaded;
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export { createConfigReloader };
|
|
38
|
+
//# sourceMappingURL=config-reloader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-reloader.js","sourceRoot":"","sources":["../src/config-reloader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,UAAU,EAA6C,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAOrE,MAAM,oBAAoB,GAAG,KAAK,EAC9B,GAAW,EACX,UAA6B,EAAE,EAC/B,sBAAgC,EAAE,EACX,EAAE;IACzB,IAAI,kBAA0B,CAAC;IAC/B,IAAI,iBAAiB,GAAG,mBAAmB,CAAC;IAE5C,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC9C,kBAAkB,GAAG,MAAM,CAAC,UAAU,CAAC;QACvC,iBAAiB,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC;IACjF,CAAC;SAAM,CAAC;QACJ,kBAAkB,GAAG,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,kBAAkB,GAAG,QAAQ,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;IAC7D,MAAM,YAAY,GAAG,GAAa,EAAE,CAAC;QACjC,GAAG,IAAI,GAAG,CACN,CAAC,kBAAkB,EAAE,GAAG,iBAAiB,CAAC;aACrC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,yBAAyB,CAAC,IAAI,EAAE,kBAAkB,EAAE,GAAG,CAAC,CAAC,CACnF;KACJ,CAAC;IAEF,OAAO;QACH,YAAY;QACZ,MAAM,EAAE,KAAK,IAAI,EAAE;YACf,IAAI,MAAoB,CAAC;YAEzB,IAAI,CAAC;gBACD,MAAM,GAAG,MAAM,UAAU,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAC,CAAC;YACnF,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,iBAAiB,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,iBAAiB,EAAE,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC1F,MAAM,KAAK,CAAC;YAChB,CAAC;YAED,iBAAiB,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;YAElD,OAAO,MAAM,CAAC;QAClB,CAAC;KACJ,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,CAAC","sourcesContent":["import { relative, resolve } from \"node:path\";\nimport { configDependenciesFor } from \"./config-dependencies.ts\";\nimport { loadConfig, type LoadConfigOptions, type LoadedConfig } from \"./loader.ts\";\nimport { resolveConfigDependencies } from \"./static-dependencies.ts\";\n\ntype ConfigReloader = {\n reload: () => Promise<LoadedConfig>;\n resolvePaths: () => string[];\n};\n\nconst createConfigReloader = async (\n cwd: string,\n options: LoadConfigOptions = {},\n initialDependencies: string[] = [],\n): Promise<ConfigReloader> => {\n let selectedConfigFile: string;\n let knownDependencies = initialDependencies;\n\n if (options.configFile === undefined) {\n const loaded = await loadConfig(cwd, options);\n selectedConfigFile = loaded.configFile;\n knownDependencies = [...knownDependencies, ...configDependenciesFor(loaded)];\n } else {\n selectedConfigFile = resolve(cwd, options.configFile);\n }\n\n const selectedConfigName = relative(cwd, selectedConfigFile);\n const resolvePaths = (): string[] => [\n ...new Set(\n [selectedConfigFile, ...knownDependencies]\n .flatMap((path) => resolveConfigDependencies(path, selectedConfigName, cwd)),\n ),\n ];\n\n return {\n resolvePaths,\n reload: async () => {\n let loaded: LoadedConfig;\n\n try {\n loaded = await loadConfig(cwd, { ...options, configFile: selectedConfigFile });\n } catch (error) {\n knownDependencies = [...new Set([...knownDependencies, ...configDependenciesFor(error)])];\n throw error;\n }\n\n knownDependencies = configDependenciesFor(loaded);\n\n return loaded;\n },\n };\n};\n\nexport { createConfigReloader };\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type ConfigResolutionOptions = {
|
|
2
|
+
configFile?: string | undefined;
|
|
3
|
+
cwd?: string | undefined;
|
|
4
|
+
};
|
|
5
|
+
declare const localConfigSourcePath: (source: string, options: ConfigResolutionOptions) => string | undefined;
|
|
6
|
+
export { localConfigSourcePath, type ConfigResolutionOptions };
|
|
7
|
+
//# sourceMappingURL=config-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-source.d.ts","sourceRoot":"","sources":["../src/config-source.ts"],"names":[],"mappings":"AAEA,KAAK,uBAAuB,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAU7F,QAAA,MAAM,qBAAqB,GAAI,QAAQ,MAAM,EAAE,SAAS,uBAAuB,KAAG,MAAM,GAAG,SAU1F,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,KAAK,uBAAuB,EAAE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { basename, extname, isAbsolute, resolve } from "node:path";
|
|
2
|
+
const isLocalConfigSource = (source) => source.startsWith(".") || isAbsolute(source);
|
|
3
|
+
const isDirectoryConfigSource = (source) => {
|
|
4
|
+
const extension = extname(source);
|
|
5
|
+
return extension.length === 0 || extension === basename(source);
|
|
6
|
+
};
|
|
7
|
+
const localConfigSourcePath = (source, options) => {
|
|
8
|
+
if (source === "." || !isLocalConfigSource(source)) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
const cwd = options.cwd ?? process.cwd();
|
|
12
|
+
return isDirectoryConfigSource(source)
|
|
13
|
+
? resolve(cwd, source, options.configFile ?? "gtkx.config")
|
|
14
|
+
: resolve(cwd, source);
|
|
15
|
+
};
|
|
16
|
+
export { localConfigSourcePath };
|
|
17
|
+
//# sourceMappingURL=config-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-source.js","sourceRoot":"","sources":["../src/config-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAInE,MAAM,mBAAmB,GAAG,CAAC,MAAc,EAAW,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;AAEtG,MAAM,uBAAuB,GAAG,CAAC,MAAc,EAAW,EAAE;IACxD,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAElC,OAAO,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,SAAS,KAAK,QAAQ,CAAC,MAAM,CAAC,CAAC;AACpE,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,MAAc,EAAE,OAAgC,EAAsB,EAAE;IACnG,IAAI,MAAM,KAAK,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QACjD,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAEzC,OAAO,uBAAuB,CAAC,MAAM,CAAC;QAClC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,UAAU,IAAI,aAAa,CAAC;QAC3D,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAgC,CAAC","sourcesContent":["import { basename, extname, isAbsolute, resolve } from \"node:path\";\n\ntype ConfigResolutionOptions = { configFile?: string | undefined; cwd?: string | undefined };\n\nconst isLocalConfigSource = (source: string): boolean => source.startsWith(\".\") || isAbsolute(source);\n\nconst isDirectoryConfigSource = (source: string): boolean => {\n const extension = extname(source);\n\n return extension.length === 0 || extension === basename(source);\n};\n\nconst localConfigSourcePath = (source: string, options: ConfigResolutionOptions): string | undefined => {\n if (source === \".\" || !isLocalConfigSource(source)) {\n return undefined;\n }\n\n const cwd = options.cwd ?? process.cwd();\n\n return isDirectoryConfigSource(source)\n ? resolve(cwd, source, options.configFile ?? \"gtkx.config\")\n : resolve(cwd, source);\n};\n\nexport { localConfigSourcePath, type ConfigResolutionOptions };\n"]}
|
package/dist/config.d.ts
CHANGED
|
@@ -16,13 +16,11 @@ type ResolvedReactCompilerOptions = ReactCompilerOptions & {
|
|
|
16
16
|
target: "19";
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
* to bind and where to find them, the GApplication id, per-element configuration, the React
|
|
21
|
-
* Compiler, codegen, and user event signal settings, and the `agents` and `mcp` blocks controlling
|
|
22
|
-
* what coding agents are given.
|
|
19
|
+
* GTKX project configuration authored in `gtkx.config.ts` and validated when loaded.
|
|
23
20
|
*/
|
|
24
21
|
type Config = z.infer<typeof configSchema>;
|
|
25
22
|
type ModuleExport = z.infer<typeof moduleExportSchema>;
|
|
23
|
+
type ElementPropsExport = z.infer<typeof elementPropsSchema>;
|
|
26
24
|
type McpSettings = {
|
|
27
25
|
tools: string[];
|
|
28
26
|
isReadOnly: boolean;
|
|
@@ -51,7 +49,16 @@ declare const PANIC_THRESHOLDS: readonly ["none", "critical_errors", "all_errors
|
|
|
51
49
|
declare const moduleExportSchema: z.ZodObject<{
|
|
52
50
|
module: z.ZodString;
|
|
53
51
|
export: z.ZodString;
|
|
54
|
-
}, z.core.$
|
|
52
|
+
}, z.core.$strict>;
|
|
53
|
+
declare const elementPropsSchema: z.ZodObject<{
|
|
54
|
+
module: z.ZodString;
|
|
55
|
+
export: z.ZodString;
|
|
56
|
+
composition: z.ZodOptional<z.ZodEnum<{
|
|
57
|
+
intersection: "intersection";
|
|
58
|
+
factory: "factory";
|
|
59
|
+
}>>;
|
|
60
|
+
constructOnly: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
61
|
+
}, z.core.$strict>;
|
|
55
62
|
/** Schema every `gtkx.config.ts` is validated against, and the source of the {@link Config} type. */
|
|
56
63
|
declare const configSchema: z.ZodObject<{
|
|
57
64
|
libraries: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -69,7 +76,7 @@ declare const configSchema: z.ZodObject<{
|
|
|
69
76
|
critical_errors: "critical_errors";
|
|
70
77
|
all_errors: "all_errors";
|
|
71
78
|
}>>;
|
|
72
|
-
}, z.core.$
|
|
79
|
+
}, z.core.$strict>]>>;
|
|
73
80
|
codegen: z.ZodOptional<z.ZodBoolean>;
|
|
74
81
|
userEventSignals: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
75
82
|
elements: z.ZodOptional<z.ZodObject<{
|
|
@@ -78,15 +85,21 @@ declare const configSchema: z.ZodObject<{
|
|
|
78
85
|
component: z.ZodOptional<z.ZodObject<{
|
|
79
86
|
module: z.ZodString;
|
|
80
87
|
export: z.ZodString;
|
|
81
|
-
}, z.core.$
|
|
88
|
+
}, z.core.$strict>>;
|
|
82
89
|
props: z.ZodOptional<z.ZodObject<{
|
|
83
90
|
module: z.ZodString;
|
|
84
91
|
export: z.ZodString;
|
|
85
|
-
|
|
92
|
+
composition: z.ZodOptional<z.ZodEnum<{
|
|
93
|
+
intersection: "intersection";
|
|
94
|
+
factory: "factory";
|
|
95
|
+
}>>;
|
|
96
|
+
constructOnly: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
97
|
+
}, z.core.$strict>>;
|
|
86
98
|
isLazy: z.ZodOptional<z.ZodBoolean>;
|
|
99
|
+
acceptedChildTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
87
100
|
omittedProps: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
88
|
-
}, z.core.$
|
|
89
|
-
}, z.core.$
|
|
101
|
+
}, z.core.$strict>>>;
|
|
102
|
+
}, z.core.$strict>>;
|
|
90
103
|
applicationIcon: z.ZodOptional<z.ZodString>;
|
|
91
104
|
deploy: z.ZodOptional<z.ZodObject<{
|
|
92
105
|
targets: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
@@ -254,11 +267,7 @@ declare const configSchema: z.ZodObject<{
|
|
|
254
267
|
}, z.core.$strict>>;
|
|
255
268
|
appimage: z.ZodOptional<z.ZodObject<{
|
|
256
269
|
fileName: z.ZodOptional<z.ZodString>;
|
|
257
|
-
compression: z.ZodOptional<z.
|
|
258
|
-
gzip: "gzip";
|
|
259
|
-
xz: "xz";
|
|
260
|
-
zstd: "zstd";
|
|
261
|
-
}>>;
|
|
270
|
+
compression: z.ZodOptional<z.ZodLiteral<"zstd">>;
|
|
262
271
|
updateInformation: z.ZodOptional<z.ZodString>;
|
|
263
272
|
runtimeFile: z.ZodOptional<z.ZodString>;
|
|
264
273
|
}, z.core.$strict>>;
|
|
@@ -268,9 +277,9 @@ declare const configSchema: z.ZodObject<{
|
|
|
268
277
|
priority: z.ZodOptional<z.ZodString>;
|
|
269
278
|
compression: z.ZodOptional<z.ZodEnum<{
|
|
270
279
|
gzip: "gzip";
|
|
280
|
+
none: "none";
|
|
271
281
|
xz: "xz";
|
|
272
282
|
zstd: "zstd";
|
|
273
|
-
none: "none";
|
|
274
283
|
}>>;
|
|
275
284
|
fields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
276
285
|
}, z.core.$strict>>;
|
|
@@ -322,15 +331,15 @@ declare const configSchema: z.ZodObject<{
|
|
|
322
331
|
agents: z.ZodOptional<z.ZodObject<{
|
|
323
332
|
rules: z.ZodOptional<z.ZodBoolean>;
|
|
324
333
|
reference: z.ZodOptional<z.ZodBoolean>;
|
|
325
|
-
}, z.core.$
|
|
334
|
+
}, z.core.$strict>>;
|
|
326
335
|
mcp: z.ZodOptional<z.ZodObject<{
|
|
327
336
|
tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
328
337
|
readOnly: z.ZodOptional<z.ZodBoolean>;
|
|
329
|
-
}, z.core.$
|
|
338
|
+
}, z.core.$strict>>;
|
|
330
339
|
deprecations: z.ZodOptional<z.ZodObject<{
|
|
331
340
|
silence: z.ZodOptional<z.ZodArray<z.ZodNever>>;
|
|
332
|
-
}, z.core.$
|
|
333
|
-
}, z.core.$
|
|
341
|
+
}, z.core.$strict>>;
|
|
342
|
+
}, z.core.$strict>;
|
|
334
343
|
/**
|
|
335
344
|
* Returns the given configuration unchanged, typed as {@link Config}, so `gtkx.config.ts` gets
|
|
336
345
|
* autocompletion and type checking.
|
|
@@ -346,11 +355,12 @@ declare const graduatedFutureKeys: (config: unknown) => string[];
|
|
|
346
355
|
declare const mergeConfig: (base: Config, override: Config) => Config;
|
|
347
356
|
declare const resolveLazyElements: (elements: Config["elements"]) => string[];
|
|
348
357
|
declare const resolveElementComponents: (elements: Config["elements"]) => Record<string, ModuleExport>;
|
|
349
|
-
declare const resolveElementProps: (elements: Config["elements"]) => Record<string,
|
|
358
|
+
declare const resolveElementProps: (elements: Config["elements"]) => Record<string, ElementPropsExport>;
|
|
359
|
+
declare const resolveAcceptedChildTypes: (elements: Config["elements"]) => Record<string, string[]>;
|
|
350
360
|
declare const resolveOmittedProps: (elements: Config["elements"]) => Record<string, string[]>;
|
|
351
361
|
declare const isAgentRulesEnabled: (config: Config) => boolean;
|
|
352
362
|
declare const isAgentReferenceEnabled: (config: Config) => boolean;
|
|
353
363
|
declare const resolveMcpSettings: (config: Config) => McpSettings;
|
|
354
364
|
declare const resolveConfig: (config: Config, root?: string) => ResolvedConfig;
|
|
355
|
-
export { APPLICATION_ID_MAX_LENGTH, defineConfig, isAgentReferenceEnabled, isAgentRulesEnabled, isValidApplicationId, graduatedFutureKeys, validateConfig, mergeConfig, resolveLazyElements, resolveElementComponents, resolveElementProps, resolveMcpSettings, resolveOmittedProps, resolveConfig, type McpSettings, type ResolvedReactCompilerOptions, type Config, type ResolvedConfig, };
|
|
365
|
+
export { APPLICATION_ID_MAX_LENGTH, defineConfig, isAgentReferenceEnabled, isAgentRulesEnabled, isValidApplicationId, graduatedFutureKeys, validateConfig, mergeConfig, resolveLazyElements, resolveElementComponents, resolveElementProps, resolveAcceptedChildTypes, resolveMcpSettings, resolveOmittedProps, resolveConfig, type McpSettings, type ResolvedReactCompilerOptions, type Config, type ResolvedConfig, };
|
|
356
366
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -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;AAMxB,iGAAiG;AACjG,KAAK,oBAAoB,GAAG;IACxB,8CAA8C;IAC9C,eAAe,CAAC,EAAE,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;IACrD,iDA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),
|
|
29
|
-
z.
|
|
29
|
+
z.strictObject({
|
|
30
30
|
compilationMode: z.enum(COMPILATION_MODES).optional(),
|
|
31
31
|
panicThreshold: z.enum(PANIC_THRESHOLDS).optional(),
|
|
32
32
|
}),
|
|
@@ -34,32 +34,37 @@ const reactCompilerSchema = z.union([
|
|
|
34
34
|
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" }), {
|
|
35
35
|
error: "must be an array of signal names",
|
|
36
36
|
}), { error: "must be a record of GLib type names to signal name arrays" });
|
|
37
|
-
const moduleExportSchema = z.
|
|
37
|
+
const moduleExportSchema = z.strictObject({
|
|
38
38
|
module: z.string({ error: "must be a module specifier" }).min(1, { error: "must be a module specifier" }),
|
|
39
39
|
export: z.string({ error: "must be an export name" }).min(1, { error: "must be an export name" }),
|
|
40
40
|
}, { error: "must be a { module, export } object" });
|
|
41
|
-
const
|
|
41
|
+
const elementPropsSchema = moduleExportSchema.extend({
|
|
42
|
+
composition: z.enum(["factory", "intersection"]).optional(),
|
|
43
|
+
constructOnly: z.array(z.string()).optional(),
|
|
44
|
+
});
|
|
45
|
+
const elementConfigSchema = z.strictObject({
|
|
42
46
|
component: moduleExportSchema.optional(),
|
|
43
|
-
props:
|
|
47
|
+
props: elementPropsSchema.optional(),
|
|
44
48
|
isLazy: z.boolean({ error: "must be a boolean" }).optional(),
|
|
49
|
+
acceptedChildTypes: z.array(z.string()).optional(),
|
|
45
50
|
omittedProps: z
|
|
46
51
|
.array(z.string({ error: "must be a non-empty property name" }).min(1, {
|
|
47
52
|
error: "must be a non-empty property name",
|
|
48
53
|
}), { error: "must be an array of property names" })
|
|
49
54
|
.optional(),
|
|
50
55
|
});
|
|
51
|
-
const elementsSchema = z.
|
|
56
|
+
const elementsSchema = z.strictObject({
|
|
52
57
|
behaviors: z
|
|
53
58
|
.string({ error: "must be a path to a module exporting element behaviors" })
|
|
54
59
|
.min(1, { error: "must be a path to a module exporting element behaviors" })
|
|
55
60
|
.optional(),
|
|
56
61
|
config: z.record(z.string(), elementConfigSchema).optional(),
|
|
57
62
|
});
|
|
58
|
-
const agentsSchema = z.
|
|
63
|
+
const agentsSchema = z.strictObject({
|
|
59
64
|
rules: z.boolean({ error: "must be a boolean" }).optional(),
|
|
60
65
|
reference: z.boolean({ error: "must be a boolean" }).optional(),
|
|
61
66
|
});
|
|
62
|
-
const mcpSchema = z.
|
|
67
|
+
const mcpSchema = z.strictObject({
|
|
63
68
|
tools: z
|
|
64
69
|
.array(z.string({ error: "must be a tool name pattern" }).min(1, { error: "must be a tool name pattern" }), {
|
|
65
70
|
error: "must be an array of tool name patterns",
|
|
@@ -78,7 +83,7 @@ const graduatedFutureSchema = z
|
|
|
78
83
|
v2TreeShaking: z.literal(true, { error: "can only be true; remove the flag" }).optional(),
|
|
79
84
|
})
|
|
80
85
|
.strict();
|
|
81
|
-
const deprecationsSchema = z.
|
|
86
|
+
const deprecationsSchema = z.strictObject({
|
|
82
87
|
silence: z
|
|
83
88
|
.array(z.never({ error: "does not name a current deprecation" }), {
|
|
84
89
|
error: "must be an array of current deprecation ids",
|
|
@@ -86,7 +91,7 @@ const deprecationsSchema = z.object({
|
|
|
86
91
|
.optional(),
|
|
87
92
|
});
|
|
88
93
|
/** Schema every `gtkx.config.ts` is validated against, and the source of the {@link Config} type. */
|
|
89
|
-
const configSchema = z.
|
|
94
|
+
const configSchema = z.strictObject({
|
|
90
95
|
libraries: librariesSchema.optional(),
|
|
91
96
|
girPath: z.array(z.string(), { error: "must be an array of strings if provided" }).optional(),
|
|
92
97
|
applicationId: applicationIdSchema,
|
|
@@ -150,6 +155,7 @@ const elementEntryValues = (elements, pick) => Object.fromEntries(Object.entries
|
|
|
150
155
|
}));
|
|
151
156
|
const resolveElementComponents = (elements) => elementEntryValues(elements, (entry) => entry.component);
|
|
152
157
|
const resolveElementProps = (elements) => elementEntryValues(elements, (entry) => entry.props);
|
|
158
|
+
const resolveAcceptedChildTypes = (elements) => elementEntryValues(elements, (entry) => entry.acceptedChildTypes);
|
|
153
159
|
const resolveOmittedProps = (elements) => elementEntryValues(elements, (entry) => entry.omittedProps);
|
|
154
160
|
const isAgentRulesEnabled = (config) => config.agents?.rules !== false;
|
|
155
161
|
const isAgentReferenceEnabled = (config) => config.agents?.reference !== false;
|
|
@@ -164,5 +170,5 @@ const resolveConfig = (config, root) => ({
|
|
|
164
170
|
elements: resolveElementsModule(config.elements?.behaviors, root),
|
|
165
171
|
lazyElements: resolveLazyElements(config.elements),
|
|
166
172
|
});
|
|
167
|
-
export { APPLICATION_ID_MAX_LENGTH, defineConfig, isAgentReferenceEnabled, isAgentRulesEnabled, isValidApplicationId, graduatedFutureKeys, validateConfig, mergeConfig, resolveLazyElements, resolveElementComponents, resolveElementProps, resolveMcpSettings, resolveOmittedProps, resolveConfig, };
|
|
173
|
+
export { APPLICATION_ID_MAX_LENGTH, defineConfig, isAgentReferenceEnabled, isAgentRulesEnabled, isValidApplicationId, graduatedFutureKeys, validateConfig, mergeConfig, resolveLazyElements, resolveElementComponents, resolveElementProps, resolveAcceptedChildTypes, resolveMcpSettings, resolveOmittedProps, resolveConfig, };
|
|
168
174
|
//# sourceMappingURL=config.js.map
|