@gtkx/config 1.6.0 → 2.0.0-beta.2
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 +5 -5
- package/dist/config-error.d.ts +2 -13
- package/dist/config-error.d.ts.map +1 -1
- package/dist/config-error.js +3 -53
- package/dist/config-error.js.map +1 -1
- package/dist/config.d.ts +29 -46
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +47 -92
- package/dist/config.js.map +1 -1
- package/dist/deploy.d.ts +3 -0
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +22 -3
- package/dist/deploy.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +3 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +2 -1
- package/dist/internal.js.map +1 -1
- package/dist/loader.d.ts +2 -4
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +35 -9
- package/dist/loader.js.map +1 -1
- package/dist/node-version.d.ts +4 -0
- package/dist/node-version.d.ts.map +1 -0
- package/dist/node-version.js +12 -0
- package/dist/node-version.js.map +1 -0
- package/dist/schema-text.d.ts +1 -2
- package/dist/schema-text.d.ts.map +1 -1
- package/dist/schema-text.js +1 -1
- package/dist/schema-text.js.map +1 -1
- package/dist/virtual.d.ts.map +1 -1
- package/dist/virtual.js +1 -2
- package/dist/virtual.js.map +1 -1
- package/package.json +10 -4
- package/src/config-error.ts +3 -76
- package/src/config.ts +59 -165
- package/src/deploy.ts +31 -3
- package/src/index.ts +0 -2
- package/src/internal.ts +2 -3
- package/src/loader.ts +52 -10
- package/src/node-version.ts +16 -0
- package/src/schema-text.ts +1 -1
- package/src/virtual.ts +1 -4
- package/dist/deprecations.d.ts +0 -5
- package/dist/deprecations.d.ts.map +0 -1
- package/dist/deprecations.js +0 -97
- package/dist/deprecations.js.map +0 -1
- package/src/deprecations.ts +0 -130
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.2",
|
|
4
4
|
"description": "Config schema, loader, and element-prop mapping for the GTK toolchain.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtkx",
|
|
@@ -28,14 +28,20 @@
|
|
|
28
28
|
"./package.json": "./package.json",
|
|
29
29
|
".": {
|
|
30
30
|
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.js",
|
|
32
|
+
"require": null,
|
|
31
33
|
"default": "./dist/index.js"
|
|
32
34
|
},
|
|
33
35
|
"./internal": {
|
|
34
36
|
"types": "./dist/internal.d.ts",
|
|
37
|
+
"import": "./dist/internal.js",
|
|
38
|
+
"require": null,
|
|
35
39
|
"default": "./dist/internal.js"
|
|
36
40
|
},
|
|
37
41
|
"./vite-plugin": {
|
|
38
42
|
"types": "./dist/vite-plugin.d.ts",
|
|
43
|
+
"import": "./dist/vite-plugin.js",
|
|
44
|
+
"require": null,
|
|
39
45
|
"default": "./dist/vite-plugin.js"
|
|
40
46
|
}
|
|
41
47
|
},
|
|
@@ -55,14 +61,14 @@
|
|
|
55
61
|
}
|
|
56
62
|
},
|
|
57
63
|
"engines": {
|
|
58
|
-
"node": ">=
|
|
64
|
+
"node": ">=26.7.0"
|
|
59
65
|
},
|
|
60
66
|
"dependencies": {
|
|
67
|
+
"@gtkx/utils": "2.0.0-beta.2",
|
|
61
68
|
"c12": "^3.3.4",
|
|
62
69
|
"defu": "^6.1.7",
|
|
63
70
|
"vite": "^8.2.2",
|
|
64
|
-
"zod": "^4.4
|
|
65
|
-
"@gtkx/utils": "1.6.0"
|
|
71
|
+
"zod": "^4.5.4"
|
|
66
72
|
},
|
|
67
73
|
"scripts": {
|
|
68
74
|
"release": "tsx ../../scripts/release-package.ts"
|
package/src/config-error.ts
CHANGED
|
@@ -1,86 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
type IssuePath = (string | number)[];
|
|
1
|
+
import { z } from "zod";
|
|
4
2
|
|
|
5
3
|
const CONFIG_PREFIX = "gtkx.config.ts:";
|
|
6
|
-
const UNRECOGNIZED_KEY_REASON = "is not a recognized key";
|
|
7
4
|
|
|
8
5
|
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
9
6
|
typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10
7
|
|
|
11
|
-
const rawIssue = (input: unknown, path: IssuePath, message: string, isStandalone = false) => ({
|
|
12
|
-
code: "custom" as const,
|
|
13
|
-
input,
|
|
14
|
-
path,
|
|
15
|
-
message,
|
|
16
|
-
continue: true as const,
|
|
17
|
-
...(isStandalone && { params: { standalone: true } }),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const appendSegment = (path: string, segment: PropertyKey): string => {
|
|
21
|
-
if (typeof segment === "number") {
|
|
22
|
-
return `${path}[${String(segment)}]`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return path === "" ? String(segment) : `${path}.${String(segment)}`;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const dottedPath = (segments: PropertyKey[]): string => {
|
|
29
|
-
let path = "";
|
|
30
|
-
|
|
31
|
-
for (const segment of segments) {
|
|
32
|
-
path = appendSegment(path, segment);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return path;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const isStandaloneIssue = (issue: z.core.$ZodIssue): boolean =>
|
|
39
|
-
"params" in issue && isRecord(issue.params) && issue.params.standalone === true;
|
|
40
|
-
|
|
41
|
-
const unrecognizedKeyPath = (issue: z.core.$ZodIssue, fullPath: PropertyKey[]): string | undefined => {
|
|
42
|
-
if (issue.code === "unrecognized_keys") {
|
|
43
|
-
const [key] = issue.keys;
|
|
44
|
-
|
|
45
|
-
return dottedPath(key === undefined ? fullPath : [...fullPath, key]);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return issue.code === "invalid_key" ? dottedPath(fullPath) : undefined;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const keyRejectionReason = (issue: z.core.$ZodIssue): string => {
|
|
52
|
-
const nested = issue.code === "invalid_key" ? issue.issues[0] : undefined;
|
|
53
|
-
|
|
54
|
-
return nested?.code === "custom" ? nested.message : UNRECOGNIZED_KEY_REASON;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const formatIssue = (issue: z.core.$ZodIssue, fullPath: PropertyKey[]): string => {
|
|
58
|
-
const unrecognized = unrecognizedKeyPath(issue, fullPath);
|
|
59
|
-
|
|
60
|
-
if (unrecognized !== undefined) {
|
|
61
|
-
return `${CONFIG_PREFIX} \`${unrecognized}\` ${keyRejectionReason(issue)}`;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (isStandaloneIssue(issue)) {
|
|
65
|
-
return `${CONFIG_PREFIX} ${issue.message}`;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const path = dottedPath(fullPath);
|
|
69
|
-
|
|
70
|
-
return path === "" ? `${CONFIG_PREFIX} ${issue.message}` : `${CONFIG_PREFIX} \`${path}\` ${issue.message}`;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
8
|
const missingConfigFileError = (cwd: string): Error =>
|
|
74
9
|
new Error(`${CONFIG_PREFIX} no configuration file found in ${cwd}`);
|
|
75
10
|
|
|
76
|
-
const configError = (error: z.ZodError): Error => {
|
|
77
|
-
const issue = error.issues[0];
|
|
78
|
-
|
|
79
|
-
if (issue === undefined) {
|
|
80
|
-
return new Error(`${CONFIG_PREFIX} invalid configuration`);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return new Error(formatIssue(issue, issue.path));
|
|
84
|
-
};
|
|
11
|
+
const configError = (error: z.ZodError): Error => new Error(`${CONFIG_PREFIX}\n${z.prettifyError(error)}`);
|
|
85
12
|
|
|
86
|
-
export { isRecord,
|
|
13
|
+
export { isRecord, missingConfigFileError, configError };
|
package/src/config.ts
CHANGED
|
@@ -2,23 +2,17 @@ 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
|
|
5
|
+
import { configError, isRecord } from "./config-error.ts";
|
|
6
6
|
import { deploySchema } from "./deploy.ts";
|
|
7
|
-
import {
|
|
8
|
-
import { isGirLibrary, text } from "./schema-text.ts";
|
|
7
|
+
import { girLibrary, text } from "./schema-text.ts";
|
|
9
8
|
import { resolveUserEventSignals } from "./user-event-signals.ts";
|
|
10
9
|
|
|
11
|
-
/**
|
|
12
|
-
type ReactCompilerCompilationMode = (typeof COMPILATION_MODES)[number];
|
|
13
|
-
/** Accepted `reactCompiler.panicThreshold` values, choosing which compiler diagnostics fail the build. */
|
|
14
|
-
type ReactCompilerPanicThreshold = (typeof PANIC_THRESHOLDS)[number];
|
|
15
|
-
|
|
16
|
-
/** Object form of the `reactCompiler` config key, forwarded as-is to `babel-plugin-react-compiler`. */
|
|
10
|
+
/** Object form of the `reactCompiler` config key, forwarded to `babel-plugin-react-compiler`. */
|
|
17
11
|
type ReactCompilerOptions = {
|
|
18
|
-
/** Which functions the compiler processes
|
|
19
|
-
compilationMode?:
|
|
20
|
-
/** Which compiler diagnostics fail the build
|
|
21
|
-
panicThreshold?:
|
|
12
|
+
/** Which functions the compiler processes. */
|
|
13
|
+
compilationMode?: (typeof COMPILATION_MODES)[number];
|
|
14
|
+
/** Which compiler diagnostics fail the build. */
|
|
15
|
+
panicThreshold?: (typeof PANIC_THRESHOLDS)[number];
|
|
22
16
|
};
|
|
23
17
|
|
|
24
18
|
/**
|
|
@@ -33,9 +27,8 @@ type ResolvedReactCompilerOptions = ReactCompilerOptions & {
|
|
|
33
27
|
/**
|
|
34
28
|
* User-facing configuration for a GTKX project, as authored in `gtkx.config.ts`: the GIR libraries
|
|
35
29
|
* to bind and where to find them, the GApplication id, per-element configuration, the React
|
|
36
|
-
* Compiler, codegen, and user event signal settings, the `agents` and `mcp` blocks controlling
|
|
37
|
-
* coding agents are given
|
|
38
|
-
* next major version, and the `deprecations` block silencing the warnings about flags left unset.
|
|
30
|
+
* Compiler, codegen, and user event signal settings, and the `agents` and `mcp` blocks controlling
|
|
31
|
+
* what coding agents are given.
|
|
39
32
|
*/
|
|
40
33
|
type Config = z.infer<typeof configSchema>;
|
|
41
34
|
type ModuleExport = z.infer<typeof moduleExportSchema>;
|
|
@@ -46,16 +39,6 @@ type McpSettings = {
|
|
|
46
39
|
isReadOnly: boolean;
|
|
47
40
|
};
|
|
48
41
|
|
|
49
|
-
type ResolvedFuture = {
|
|
50
|
-
isByteArrayTyped: boolean;
|
|
51
|
-
isValueUnwrapped: boolean;
|
|
52
|
-
isFinishTrimmed: boolean;
|
|
53
|
-
isInoutInPlace: boolean;
|
|
54
|
-
isResourceImported: boolean;
|
|
55
|
-
isAdwaitaDefault: boolean;
|
|
56
|
-
isTreeShaken: boolean;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
42
|
/** Configuration reduced to the values the app runtime and the build need, with paths already resolved. */
|
|
60
43
|
type ResolvedConfig = {
|
|
61
44
|
/** The GApplication identifier the app registers under. */
|
|
@@ -73,92 +56,35 @@ type ResolvedConfig = {
|
|
|
73
56
|
lazyElements: string[];
|
|
74
57
|
};
|
|
75
58
|
|
|
76
|
-
const LIBRARIES_WILDCARD = "*";
|
|
77
59
|
const APPLICATION_ID_PATTERN = /^[A-Za-z_][A-Za-z0-9_-]*(\.[A-Za-z_][A-Za-z0-9_-]*)+$/;
|
|
78
60
|
const APPLICATION_ID_MAX_LENGTH = 255;
|
|
61
|
+
const DEFAULT_LIBRARIES: Set<string> = new Set(["Gtk-4.0", "Adw-1"]);
|
|
79
62
|
/** Compilation modes `babel-plugin-react-compiler` accepts. */
|
|
80
63
|
const COMPILATION_MODES = ["infer", "syntax", "annotation", "all"] as const;
|
|
81
64
|
/** Panic thresholds `babel-plugin-react-compiler` accepts. */
|
|
82
65
|
const PANIC_THRESHOLDS = ["none", "critical_errors", "all_errors"] as const;
|
|
83
66
|
const REACT_COMPILER_TARGET = "19";
|
|
84
|
-
const COMPILATION_MODE_SET: Set<string> = new Set(COMPILATION_MODES);
|
|
85
|
-
const PANIC_THRESHOLD_SET: Set<string> = new Set(PANIC_THRESHOLDS);
|
|
86
|
-
|
|
87
|
-
const librariesSchema = z.custom<typeof LIBRARIES_WILDCARD | string[]>().check((ctx) => {
|
|
88
|
-
const value = ctx.value;
|
|
89
|
-
|
|
90
|
-
if (value === LIBRARIES_WILDCARD) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
67
|
|
|
94
|
-
|
|
95
|
-
|
|
68
|
+
const librarySchema = girLibrary('must be of the form "Name-Version", such as "Gtk-4.0"')
|
|
69
|
+
.refine((library) => !DEFAULT_LIBRARIES.has(library), { error: "is bound by default; remove it" });
|
|
96
70
|
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
for (const [index, entry] of value.entries()) {
|
|
101
|
-
ctx.issues.push(...libraryEntryIssues(value, index, entry));
|
|
102
|
-
}
|
|
103
|
-
});
|
|
71
|
+
const librariesSchema = z
|
|
72
|
+
.array(librarySchema, { error: "must be a non-empty string array or omitted" })
|
|
73
|
+
.min(1, { error: "must be a non-empty string array or omitted" });
|
|
104
74
|
|
|
105
|
-
const applicationIdSchema = z
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
rawIssue(
|
|
111
|
-
value,
|
|
112
|
-
[],
|
|
113
|
-
`invalid \`applicationId\` "${value}", must satisfy g_application_id_is_valid ` +
|
|
114
|
-
'(e.g. "org.example.MyApp")',
|
|
115
|
-
true,
|
|
116
|
-
),
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
});
|
|
75
|
+
const applicationIdSchema = z
|
|
76
|
+
.string({ error: "must satisfy g_application_id_is_valid" })
|
|
77
|
+
.refine((value) => isValidApplicationId(value), {
|
|
78
|
+
error: 'must satisfy g_application_id_is_valid, such as "org.example.MyApp"',
|
|
79
|
+
});
|
|
120
80
|
|
|
121
|
-
const reactCompilerSchema = z.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (!isRecord(value)) {
|
|
129
|
-
ctx.issues.push(rawIssue(value, [], "must be a boolean or an options object"));
|
|
130
|
-
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const compilationMode = value.compilationMode;
|
|
135
|
-
|
|
136
|
-
if (!isValidReactCompilerOption(compilationMode, COMPILATION_MODE_SET)) {
|
|
137
|
-
ctx.issues.push(
|
|
138
|
-
rawIssue(
|
|
139
|
-
value,
|
|
140
|
-
[],
|
|
141
|
-
`invalid \`reactCompiler.compilationMode\` "${String(compilationMode)}", ` +
|
|
142
|
-
`must be one of ${COMPILATION_MODES.join(", ")}`,
|
|
143
|
-
true,
|
|
144
|
-
),
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const panicThreshold = value.panicThreshold;
|
|
149
|
-
|
|
150
|
-
if (!isValidReactCompilerOption(panicThreshold, PANIC_THRESHOLD_SET)) {
|
|
151
|
-
ctx.issues.push(
|
|
152
|
-
rawIssue(
|
|
153
|
-
value,
|
|
154
|
-
[],
|
|
155
|
-
`invalid \`reactCompiler.panicThreshold\` "${String(panicThreshold)}", ` +
|
|
156
|
-
`must be one of ${PANIC_THRESHOLDS.join(", ")}`,
|
|
157
|
-
true,
|
|
158
|
-
),
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
});
|
|
81
|
+
const reactCompilerSchema = z.union([
|
|
82
|
+
z.boolean(),
|
|
83
|
+
z.object({
|
|
84
|
+
compilationMode: z.enum(COMPILATION_MODES).optional(),
|
|
85
|
+
panicThreshold: z.enum(PANIC_THRESHOLDS).optional(),
|
|
86
|
+
}),
|
|
87
|
+
]);
|
|
162
88
|
|
|
163
89
|
const userEventSignalsSchema = z.record(
|
|
164
90
|
z.string(),
|
|
@@ -215,30 +141,28 @@ const mcpSchema = z.object({
|
|
|
215
141
|
readOnly: z.boolean({ error: "must be a boolean" }).optional(),
|
|
216
142
|
});
|
|
217
143
|
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
})
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
const DEPRECATION_ID_ERROR = `must be one of ${DEPRECATION_IDS.join(", ")}`;
|
|
144
|
+
const graduatedFutureSchema = z
|
|
145
|
+
.object({
|
|
146
|
+
v2ByteArrays: z.literal(true, { error: "can only be true; remove the flag" }).optional(),
|
|
147
|
+
v2ValueReturns: z.literal(true, { error: "can only be true; remove the flag" }).optional(),
|
|
148
|
+
v2FinishResults: z.literal(true, { error: "can only be true; remove the flag" }).optional(),
|
|
149
|
+
v2InoutReturns: z.literal(true, { error: "can only be true; remove the flag" }).optional(),
|
|
150
|
+
v2ResourceImports: z.literal(true, { error: "can only be true; remove the flag" }).optional(),
|
|
151
|
+
v2DefaultLibraries: z.literal(true, { error: "can only be true; remove the flag" }).optional(),
|
|
152
|
+
v2TreeShaking: z.literal(true, { error: "can only be true; remove the flag" }).optional(),
|
|
153
|
+
})
|
|
154
|
+
.strict();
|
|
230
155
|
|
|
231
156
|
const deprecationsSchema = z.object({
|
|
232
157
|
silence: z
|
|
233
|
-
.array(z.
|
|
234
|
-
error: "must be an array of deprecation ids",
|
|
158
|
+
.array(z.never({ error: "does not name a current deprecation" }), {
|
|
159
|
+
error: "must be an array of current deprecation ids",
|
|
235
160
|
})
|
|
236
161
|
.optional(),
|
|
237
162
|
});
|
|
238
163
|
|
|
239
164
|
/** Schema every `gtkx.config.ts` is validated against, and the source of the {@link Config} type. */
|
|
240
165
|
const configSchema = z.object({
|
|
241
|
-
future: futureSchema.optional(),
|
|
242
166
|
libraries: librariesSchema.optional(),
|
|
243
167
|
girPath: z.array(z.string(), { error: "must be an array of strings if provided" }).optional(),
|
|
244
168
|
applicationId: applicationIdSchema,
|
|
@@ -258,34 +182,10 @@ const configSchema = z.object({
|
|
|
258
182
|
* autocompletion and type checking.
|
|
259
183
|
*/
|
|
260
184
|
const defineConfig: DefineConfig<Config> = createDefineConfig<Config>();
|
|
185
|
+
const validationSchema = configSchema.extend({ future: graduatedFutureSchema.optional() });
|
|
261
186
|
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
return [];
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
if (entry === LIBRARIES_WILDCARD) {
|
|
268
|
-
const message =
|
|
269
|
-
`to generate every library, set \`libraries: "${LIBRARIES_WILDCARD}"\` as a bare string, ` +
|
|
270
|
-
"not an array entry";
|
|
271
|
-
|
|
272
|
-
return [rawIssue(value, [index], message, true)];
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
const message =
|
|
276
|
-
`invalid library identifier "${String(entry)}", must be of the form "Name-Version" ` +
|
|
277
|
-
'(e.g. "Gtk-4.0")';
|
|
278
|
-
|
|
279
|
-
return [rawIssue(value, [index], message, true)];
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
const isValidApplicationId = (applicationId: string): boolean => {
|
|
283
|
-
if (applicationId.length === 0 || applicationId.length > APPLICATION_ID_MAX_LENGTH) {
|
|
284
|
-
return false;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
return APPLICATION_ID_PATTERN.test(applicationId);
|
|
288
|
-
};
|
|
187
|
+
const isValidApplicationId = (applicationId: string): boolean =>
|
|
188
|
+
applicationId.length <= APPLICATION_ID_MAX_LENGTH && APPLICATION_ID_PATTERN.test(applicationId);
|
|
289
189
|
|
|
290
190
|
const resolveReactCompilerOptions = (setting: Config["reactCompiler"]): ResolvedReactCompilerOptions | null => {
|
|
291
191
|
if (setting === false) {
|
|
@@ -294,20 +194,29 @@ const resolveReactCompilerOptions = (setting: Config["reactCompiler"]): Resolved
|
|
|
294
194
|
|
|
295
195
|
const overrides = setting === undefined || setting === true ? {} : setting;
|
|
296
196
|
|
|
297
|
-
return {
|
|
197
|
+
return {
|
|
198
|
+
...(overrides.compilationMode !== undefined && { compilationMode: overrides.compilationMode }),
|
|
199
|
+
...(overrides.panicThreshold !== undefined && { panicThreshold: overrides.panicThreshold }),
|
|
200
|
+
target: REACT_COMPILER_TARGET,
|
|
201
|
+
};
|
|
298
202
|
};
|
|
299
203
|
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const validateConfig = (config: Config): void => {
|
|
304
|
-
const result = configSchema.safeParse(config);
|
|
204
|
+
const validateConfig = (config: unknown): void => {
|
|
205
|
+
const result = validationSchema.safeParse(config);
|
|
305
206
|
|
|
306
207
|
if (!result.success) {
|
|
307
208
|
throw configError(result.error);
|
|
308
209
|
}
|
|
309
210
|
};
|
|
310
211
|
|
|
212
|
+
const graduatedFutureKeys = (config: unknown): string[] => {
|
|
213
|
+
if (!isRecord(config) || !isRecord(config.future)) {
|
|
214
|
+
return [];
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return Object.keys(config.future).toSorted((first, second) => first.localeCompare(second));
|
|
218
|
+
};
|
|
219
|
+
|
|
311
220
|
/**
|
|
312
221
|
* Deep-merges a configuration over a base. `override` wins over `base` on conflicting scalar and object keys, while
|
|
313
222
|
* arrays are concatenated with the `override` entries first.
|
|
@@ -356,19 +265,6 @@ const resolveMcpSettings = (config: Config): McpSettings => ({
|
|
|
356
265
|
isReadOnly: config.mcp?.readOnly === true,
|
|
357
266
|
});
|
|
358
267
|
|
|
359
|
-
const resolveFuture = (future: Config["future"]): ResolvedFuture => ({
|
|
360
|
-
isByteArrayTyped: future?.v2ByteArrays === true,
|
|
361
|
-
isValueUnwrapped: future?.v2ValueReturns === true,
|
|
362
|
-
isFinishTrimmed: future?.v2FinishResults === true,
|
|
363
|
-
isInoutInPlace: future?.v2InoutReturns === true,
|
|
364
|
-
isResourceImported: future?.v2ResourceImports === true,
|
|
365
|
-
isAdwaitaDefault: future?.v2DefaultLibraries === true,
|
|
366
|
-
isTreeShaken: future?.v2TreeShaking === true,
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
const unknownFutureKeys = (future: Config["future"]): string[] =>
|
|
370
|
-
Object.keys(future ?? {}).filter((key) => !FUTURE_KEYS.has(key));
|
|
371
|
-
|
|
372
268
|
const resolveConfig = (config: Config, root?: string): ResolvedConfig => ({
|
|
373
269
|
applicationId: config.applicationId,
|
|
374
270
|
reactCompiler: resolveReactCompilerOptions(config.reactCompiler),
|
|
@@ -383,6 +279,7 @@ export {
|
|
|
383
279
|
isAgentReferenceEnabled,
|
|
384
280
|
isAgentRulesEnabled,
|
|
385
281
|
isValidApplicationId,
|
|
282
|
+
graduatedFutureKeys,
|
|
386
283
|
validateConfig,
|
|
387
284
|
mergeConfig,
|
|
388
285
|
resolveLazyElements,
|
|
@@ -391,11 +288,8 @@ export {
|
|
|
391
288
|
resolveMcpSettings,
|
|
392
289
|
resolveOmittedProps,
|
|
393
290
|
resolveConfig,
|
|
394
|
-
resolveFuture,
|
|
395
|
-
unknownFutureKeys,
|
|
396
291
|
type McpSettings,
|
|
397
292
|
type ResolvedReactCompilerOptions,
|
|
398
293
|
type Config,
|
|
399
294
|
type ResolvedConfig,
|
|
400
|
-
type ResolvedFuture,
|
|
401
295
|
};
|
package/src/deploy.ts
CHANGED
|
@@ -37,15 +37,21 @@ const URL_KINDS = [
|
|
|
37
37
|
const BOOLEAN_ERROR = "must be a boolean";
|
|
38
38
|
const EPOCH_ERROR = "must be a non-negative integer";
|
|
39
39
|
const EXTRA_FILE_ERROR = "must be a source path or a { source, mode } entry";
|
|
40
|
-
const FILE_MODE_ERROR = "must be an octal file mode such as 755";
|
|
40
|
+
const FILE_MODE_ERROR = "must be an octal file mode without setuid or setgid bits, such as 755";
|
|
41
41
|
const FILE_MODE_PATTERN = /^[0-7]{3,4}$/;
|
|
42
|
+
const FILE_MODE_RADIX = 8;
|
|
43
|
+
const PRIVILEGED_FILE_MODE_MASK = 0o6000;
|
|
42
44
|
const HEX_COLOR_ERROR = "must be a #rrggbb color";
|
|
43
45
|
const HEX_COLOR_PATTERN = /^#[\dA-Fa-f]{6}$/;
|
|
44
46
|
const KEY_FILE_ERROR = "must be a path to a PGP key file";
|
|
45
47
|
const KEY_ID_ERROR = "must be a PGP key id";
|
|
48
|
+
const LAUNCHER_ENV_ERROR = "must be a record of POSIX environment names to values without null bytes";
|
|
49
|
+
const LAUNCHER_ENV_NAME_ERROR = "must be a POSIX environment name";
|
|
50
|
+
const LAUNCHER_ENV_NAME_PATTERN = /^[A-Za-z_]\w*$/;
|
|
46
51
|
const MINIMUM_LIBRARY_VERSION_ERROR = "must be a version such as 4.18";
|
|
47
52
|
const MINIMUM_LIBRARY_VERSION_PATTERN = /^\d+(?:\.\d+)*$/;
|
|
48
53
|
const MINIMUM_LIBRARY_VERSIONS_ERROR = "must be a record of GIR library ids to a minimum version";
|
|
54
|
+
const NODE_FLAG_ERROR = "must be a Node.js flag beginning with a hyphen and containing no null bytes";
|
|
49
55
|
const LIBRARY_ID_ERROR = 'must be a GIR library identifier of the form "Name-Version", such as "Gtk-4.0"';
|
|
50
56
|
const SCRIPT_ERROR = "must be a path to a shell script";
|
|
51
57
|
const SOURCE_PATH_ERROR = "must be a source path";
|
|
@@ -112,14 +118,33 @@ const brandingSchema = z.strictObject({
|
|
|
112
118
|
|
|
113
119
|
const extraFileSchema = z.strictObject({
|
|
114
120
|
source: text(SOURCE_PATH_ERROR),
|
|
115
|
-
mode: z
|
|
121
|
+
mode: z
|
|
122
|
+
.string({ error: FILE_MODE_ERROR })
|
|
123
|
+
.regex(FILE_MODE_PATTERN, { error: FILE_MODE_ERROR })
|
|
124
|
+
.refine((mode) => (Number.parseInt(mode, FILE_MODE_RADIX) & PRIVILEGED_FILE_MODE_MASK) === 0, {
|
|
125
|
+
error: FILE_MODE_ERROR,
|
|
126
|
+
})
|
|
127
|
+
.optional(),
|
|
116
128
|
});
|
|
117
129
|
|
|
118
130
|
const extraFileEntrySchema = z.union([text(SOURCE_PATH_ERROR), extraFileSchema], { error: EXTRA_FILE_ERROR });
|
|
119
131
|
|
|
132
|
+
const launcherEnvSchema = z.record(
|
|
133
|
+
z.string({ error: LAUNCHER_ENV_NAME_ERROR }).regex(LAUNCHER_ENV_NAME_PATTERN, { error: LAUNCHER_ENV_NAME_ERROR }),
|
|
134
|
+
z.string({ error: LAUNCHER_ENV_ERROR }).refine((value) => !value.includes("\0"), { error: LAUNCHER_ENV_ERROR }),
|
|
135
|
+
{ error: LAUNCHER_ENV_ERROR },
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
const nodeFlagsSchema = z.array(
|
|
139
|
+
z
|
|
140
|
+
.string({ error: NODE_FLAG_ERROR })
|
|
141
|
+
.refine((value) => value.startsWith("-") && !value.includes("\0"), { error: NODE_FLAG_ERROR }),
|
|
142
|
+
{ error: "must be an array of Node.js flags" },
|
|
143
|
+
);
|
|
144
|
+
|
|
120
145
|
const nodeRuntimeSchema = z.strictObject({
|
|
121
146
|
source: z.enum(NODE_SOURCES, { error: "must be one of download, host, path" }).optional(),
|
|
122
|
-
version: text("must be a Node.js version such as
|
|
147
|
+
version: text("must be a Node.js version such as 26.7.0").optional(),
|
|
123
148
|
path: text("must be a path to a node binary").optional(),
|
|
124
149
|
shouldStrip: flag(BOOLEAN_ERROR).optional(),
|
|
125
150
|
shouldUseCompileCache: flag(BOOLEAN_ERROR).optional(),
|
|
@@ -262,6 +287,8 @@ const deploySchema = z.strictObject({
|
|
|
262
287
|
.optional(),
|
|
263
288
|
releases: z.array(releaseSchema, { error: "must be an array of releases" }).optional(),
|
|
264
289
|
execArgs: textList("argument", "must be an array of arguments appended to Exec").optional(),
|
|
290
|
+
launcherEnv: launcherEnvSchema.optional(),
|
|
291
|
+
nodeFlags: nodeFlagsSchema.optional(),
|
|
265
292
|
fileAssociations: z
|
|
266
293
|
.array(fileAssociationSchema, { error: "must be an array of file associations" })
|
|
267
294
|
.optional(),
|
|
@@ -271,6 +298,7 @@ const deploySchema = z.strictObject({
|
|
|
271
298
|
.optional(),
|
|
272
299
|
desktopEntry: textRecord("must be a desktop entry value", "must be a record of desktop entry keys to values")
|
|
273
300
|
.optional(),
|
|
301
|
+
metainfoExtra: textList("AppStream XML fragment", "must be an array of AppStream XML fragments").optional(),
|
|
274
302
|
isDbusActivatable: flag(BOOLEAN_ERROR).optional(),
|
|
275
303
|
extraFiles: relativePathRecord(
|
|
276
304
|
"must be a destination path inside the install prefix, without a leading slash or a .. segment",
|
package/src/index.ts
CHANGED
package/src/internal.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { McpSettings,
|
|
1
|
+
export type { McpSettings, ResolvedReactCompilerOptions } from "./config.ts";
|
|
2
2
|
export {
|
|
3
3
|
APPLICATION_ID_MAX_LENGTH,
|
|
4
4
|
isAgentReferenceEnabled,
|
|
@@ -6,11 +6,10 @@ export {
|
|
|
6
6
|
isValidApplicationId,
|
|
7
7
|
resolveElementComponents,
|
|
8
8
|
resolveElementProps,
|
|
9
|
-
resolveFuture,
|
|
10
9
|
resolveLazyElements,
|
|
11
10
|
resolveMcpSettings,
|
|
12
11
|
resolveOmittedProps,
|
|
13
|
-
unknownFutureKeys,
|
|
14
12
|
} from "./config.ts";
|
|
15
13
|
export { createConfigLoader } from "./loader.ts";
|
|
14
|
+
export { assertSupportedNodeVersion, MINIMUM_NODE_VERSION } from "./node-version.ts";
|
|
16
15
|
export { resourceBasePath } from "./resource-base-path.ts";
|