@gtkx/config 1.6.0 → 2.0.0-beta.10
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 +47 -44
- package/dist/config-dependencies.d.ts +11 -0
- package/dist/config-dependencies.d.ts.map +1 -0
- package/dist/config-dependencies.js +83 -0
- package/dist/config-dependencies.js.map +1 -0
- package/dist/config-error.d.ts +4 -15
- package/dist/config-error.d.ts.map +1 -1
- package/dist/config-error.js +8 -55
- package/dist/config-error.js.map +1 -1
- package/dist/config.d.ts +35 -61
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +49 -94
- package/dist/config.js.map +1 -1
- package/dist/deploy.d.ts +26 -16
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +29 -4
- package/dist/deploy.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +5 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +4 -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 +96 -22
- 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/dist/vite-plugin.d.ts.map +1 -1
- package/dist/vite-plugin.js +14 -5
- package/dist/vite-plugin.js.map +1 -1
- package/dist/vite-root.d.ts +9 -0
- package/dist/vite-root.d.ts.map +1 -0
- package/dist/vite-root.js +3 -0
- package/dist/vite-root.js.map +1 -0
- package/package.json +14 -5
- package/src/config-dependencies.ts +114 -0
- package/src/config-error.ts +10 -78
- package/src/config.ts +60 -166
- package/src/deploy.ts +61 -7
- package/src/index.ts +1 -2
- package/src/internal.ts +4 -3
- package/src/loader.ts +138 -31
- package/src/node-version.ts +16 -0
- package/src/schema-text.ts +1 -1
- package/src/virtual.ts +1 -4
- package/src/vite-plugin.ts +17 -7
- package/src/vite-root.ts +8 -0
- 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/dist/config.js
CHANGED
|
@@ -2,61 +2,35 @@ import { createDefineConfig } 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.js";
|
|
6
6
|
import { deploySchema } from "./deploy.js";
|
|
7
|
-
import {
|
|
8
|
-
import { isGirLibrary, text } from "./schema-text.js";
|
|
7
|
+
import { girLibrary, text } from "./schema-text.js";
|
|
9
8
|
import { resolveUserEventSignals } from "./user-event-signals.js";
|
|
10
|
-
const LIBRARIES_WILDCARD = "*";
|
|
11
9
|
const APPLICATION_ID_PATTERN = /^[A-Za-z_][A-Za-z0-9_-]*(\.[A-Za-z_][A-Za-z0-9_-]*)+$/;
|
|
12
10
|
const APPLICATION_ID_MAX_LENGTH = 255;
|
|
11
|
+
const IMPLICIT_LIBRARIES = new Set(["Adw-1", "Gtk-4.0"]);
|
|
13
12
|
/** Compilation modes `babel-plugin-react-compiler` accepts. */
|
|
14
13
|
const COMPILATION_MODES = ["infer", "syntax", "annotation", "all"];
|
|
15
14
|
/** Panic thresholds `babel-plugin-react-compiler` accepts. */
|
|
16
15
|
const PANIC_THRESHOLDS = ["none", "critical_errors", "all_errors"];
|
|
17
16
|
const REACT_COMPILER_TARGET = "19";
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const librariesSchema = z
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
for (const [index, entry] of value.entries()) {
|
|
30
|
-
ctx.issues.push(...libraryEntryIssues(value, index, entry));
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
const applicationIdSchema = z.custom().check((ctx) => {
|
|
34
|
-
const value = ctx.value;
|
|
35
|
-
if (typeof value !== "string" || !isValidApplicationId(value)) {
|
|
36
|
-
ctx.issues.push(rawIssue(value, [], `invalid \`applicationId\` "${value}", must satisfy g_application_id_is_valid ` +
|
|
37
|
-
'(e.g. "org.example.MyApp")', true));
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
const reactCompilerSchema = z.custom().check((ctx) => {
|
|
41
|
-
const value = ctx.value;
|
|
42
|
-
if (typeof value === "boolean") {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (!isRecord(value)) {
|
|
46
|
-
ctx.issues.push(rawIssue(value, [], "must be a boolean or an options object"));
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const compilationMode = value.compilationMode;
|
|
50
|
-
if (!isValidReactCompilerOption(compilationMode, COMPILATION_MODE_SET)) {
|
|
51
|
-
ctx.issues.push(rawIssue(value, [], `invalid \`reactCompiler.compilationMode\` "${String(compilationMode)}", ` +
|
|
52
|
-
`must be one of ${COMPILATION_MODES.join(", ")}`, true));
|
|
53
|
-
}
|
|
54
|
-
const panicThreshold = value.panicThreshold;
|
|
55
|
-
if (!isValidReactCompilerOption(panicThreshold, PANIC_THRESHOLD_SET)) {
|
|
56
|
-
ctx.issues.push(rawIssue(value, [], `invalid \`reactCompiler.panicThreshold\` "${String(panicThreshold)}", ` +
|
|
57
|
-
`must be one of ${PANIC_THRESHOLDS.join(", ")}`, true));
|
|
58
|
-
}
|
|
17
|
+
const librarySchema = girLibrary('must be of the form "Name-Version", such as "Adw-1"')
|
|
18
|
+
.refine((library) => !IMPLICIT_LIBRARIES.has(library), { error: "is bound implicitly; remove it" });
|
|
19
|
+
const librariesSchema = z
|
|
20
|
+
.array(librarySchema, { error: "must be a non-empty string array or omitted" })
|
|
21
|
+
.min(1, { error: "must be a non-empty string array or omitted" });
|
|
22
|
+
const applicationIdSchema = z
|
|
23
|
+
.string({ error: "must satisfy g_application_id_is_valid" })
|
|
24
|
+
.refine((value) => isValidApplicationId(value), {
|
|
25
|
+
error: 'must satisfy g_application_id_is_valid, such as "org.example.MyApp"',
|
|
59
26
|
});
|
|
27
|
+
const reactCompilerSchema = z.union([
|
|
28
|
+
z.boolean(),
|
|
29
|
+
z.object({
|
|
30
|
+
compilationMode: z.enum(COMPILATION_MODES).optional(),
|
|
31
|
+
panicThreshold: z.enum(PANIC_THRESHOLDS).optional(),
|
|
32
|
+
}),
|
|
33
|
+
]);
|
|
60
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" }), {
|
|
61
35
|
error: "must be an array of signal names",
|
|
62
36
|
}), { error: "must be a record of GLib type names to signal name arrays" });
|
|
@@ -93,27 +67,26 @@ const mcpSchema = z.object({
|
|
|
93
67
|
.optional(),
|
|
94
68
|
readOnly: z.boolean({ error: "must be a boolean" }).optional(),
|
|
95
69
|
});
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
|
|
70
|
+
const graduatedFutureSchema = z
|
|
71
|
+
.object({
|
|
72
|
+
v2ByteArrays: z.literal(true, { error: "can only be true; remove the flag" }).optional(),
|
|
73
|
+
v2ValueReturns: z.literal(true, { error: "can only be true; remove the flag" }).optional(),
|
|
74
|
+
v2FinishResults: z.literal(true, { error: "can only be true; remove the flag" }).optional(),
|
|
75
|
+
v2InoutReturns: z.literal(true, { error: "can only be true; remove the flag" }).optional(),
|
|
76
|
+
v2ResourceImports: z.literal(true, { error: "can only be true; remove the flag" }).optional(),
|
|
77
|
+
v2DefaultLibraries: z.literal(true, { error: "can only be true; remove the flag" }).optional(),
|
|
78
|
+
v2TreeShaking: z.literal(true, { error: "can only be true; remove the flag" }).optional(),
|
|
79
|
+
})
|
|
80
|
+
.strict();
|
|
107
81
|
const deprecationsSchema = z.object({
|
|
108
82
|
silence: z
|
|
109
|
-
.array(z.
|
|
110
|
-
error: "must be an array of deprecation ids",
|
|
83
|
+
.array(z.never({ error: "does not name a current deprecation" }), {
|
|
84
|
+
error: "must be an array of current deprecation ids",
|
|
111
85
|
})
|
|
112
86
|
.optional(),
|
|
113
87
|
});
|
|
114
88
|
/** Schema every `gtkx.config.ts` is validated against, and the source of the {@link Config} type. */
|
|
115
89
|
const configSchema = z.object({
|
|
116
|
-
future: futureSchema.optional(),
|
|
117
90
|
libraries: librariesSchema.optional(),
|
|
118
91
|
girPath: z.array(z.string(), { error: "must be an array of strings if provided" }).optional(),
|
|
119
92
|
applicationId: applicationIdSchema,
|
|
@@ -132,39 +105,31 @@ const configSchema = z.object({
|
|
|
132
105
|
* autocompletion and type checking.
|
|
133
106
|
*/
|
|
134
107
|
const defineConfig = createDefineConfig();
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
return [];
|
|
138
|
-
}
|
|
139
|
-
if (entry === LIBRARIES_WILDCARD) {
|
|
140
|
-
const message = `to generate every library, set \`libraries: "${LIBRARIES_WILDCARD}"\` as a bare string, ` +
|
|
141
|
-
"not an array entry";
|
|
142
|
-
return [rawIssue(value, [index], message, true)];
|
|
143
|
-
}
|
|
144
|
-
const message = `invalid library identifier "${String(entry)}", must be of the form "Name-Version" ` +
|
|
145
|
-
'(e.g. "Gtk-4.0")';
|
|
146
|
-
return [rawIssue(value, [index], message, true)];
|
|
147
|
-
};
|
|
148
|
-
const isValidApplicationId = (applicationId) => {
|
|
149
|
-
if (applicationId.length === 0 || applicationId.length > APPLICATION_ID_MAX_LENGTH) {
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
return APPLICATION_ID_PATTERN.test(applicationId);
|
|
153
|
-
};
|
|
108
|
+
const validationSchema = configSchema.extend({ future: graduatedFutureSchema.optional() });
|
|
109
|
+
const isValidApplicationId = (applicationId) => applicationId.length <= APPLICATION_ID_MAX_LENGTH && APPLICATION_ID_PATTERN.test(applicationId);
|
|
154
110
|
const resolveReactCompilerOptions = (setting) => {
|
|
155
111
|
if (setting === false) {
|
|
156
112
|
return null;
|
|
157
113
|
}
|
|
158
114
|
const overrides = setting === undefined || setting === true ? {} : setting;
|
|
159
|
-
return {
|
|
115
|
+
return {
|
|
116
|
+
...(overrides.compilationMode !== undefined && { compilationMode: overrides.compilationMode }),
|
|
117
|
+
...(overrides.panicThreshold !== undefined && { panicThreshold: overrides.panicThreshold }),
|
|
118
|
+
target: REACT_COMPILER_TARGET,
|
|
119
|
+
};
|
|
160
120
|
};
|
|
161
|
-
const
|
|
162
|
-
const
|
|
163
|
-
const result = configSchema.safeParse(config);
|
|
121
|
+
const validateConfig = (config, configFile) => {
|
|
122
|
+
const result = validationSchema.safeParse(config);
|
|
164
123
|
if (!result.success) {
|
|
165
|
-
throw configError(result.error);
|
|
124
|
+
throw configError(result.error, configFile);
|
|
166
125
|
}
|
|
167
126
|
};
|
|
127
|
+
const graduatedFutureKeys = (config) => {
|
|
128
|
+
if (!isRecord(config) || !isRecord(config.future)) {
|
|
129
|
+
return [];
|
|
130
|
+
}
|
|
131
|
+
return Object.keys(config.future).toSorted((first, second) => first.localeCompare(second));
|
|
132
|
+
};
|
|
168
133
|
/**
|
|
169
134
|
* Deep-merges a configuration over a base. `override` wins over `base` on conflicting scalar and object keys, while
|
|
170
135
|
* arrays are concatenated with the `override` entries first.
|
|
@@ -192,16 +157,6 @@ const resolveMcpSettings = (config) => ({
|
|
|
192
157
|
tools: config.mcp?.tools ?? [],
|
|
193
158
|
isReadOnly: config.mcp?.readOnly === true,
|
|
194
159
|
});
|
|
195
|
-
const resolveFuture = (future) => ({
|
|
196
|
-
isByteArrayTyped: future?.v2ByteArrays === true,
|
|
197
|
-
isValueUnwrapped: future?.v2ValueReturns === true,
|
|
198
|
-
isFinishTrimmed: future?.v2FinishResults === true,
|
|
199
|
-
isInoutInPlace: future?.v2InoutReturns === true,
|
|
200
|
-
isResourceImported: future?.v2ResourceImports === true,
|
|
201
|
-
isAdwaitaDefault: future?.v2DefaultLibraries === true,
|
|
202
|
-
isTreeShaken: future?.v2TreeShaking === true,
|
|
203
|
-
});
|
|
204
|
-
const unknownFutureKeys = (future) => Object.keys(future ?? {}).filter((key) => !FUTURE_KEYS.has(key));
|
|
205
160
|
const resolveConfig = (config, root) => ({
|
|
206
161
|
applicationId: config.applicationId,
|
|
207
162
|
reactCompiler: resolveReactCompilerOptions(config.reactCompiler),
|
|
@@ -209,5 +164,5 @@ const resolveConfig = (config, root) => ({
|
|
|
209
164
|
elements: resolveElementsModule(config.elements?.behaviors, root),
|
|
210
165
|
lazyElements: resolveLazyElements(config.elements),
|
|
211
166
|
});
|
|
212
|
-
export { APPLICATION_ID_MAX_LENGTH, defineConfig, isAgentReferenceEnabled, isAgentRulesEnabled, isValidApplicationId, validateConfig, mergeConfig, resolveLazyElements, resolveElementComponents, resolveElementProps, resolveMcpSettings, resolveOmittedProps, resolveConfig,
|
|
167
|
+
export { APPLICATION_ID_MAX_LENGTH, defineConfig, isAgentReferenceEnabled, isAgentRulesEnabled, isValidApplicationId, graduatedFutureKeys, validateConfig, mergeConfig, resolveLazyElements, resolveElementComponents, resolveElementProps, resolveMcpSettings, resolveOmittedProps, resolveConfig, };
|
|
213
168
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,KAAK,CAAC;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iB,GAMpB,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 { deploySchema } from \"./deploy.ts\";\nimport { DEPRECATION_IDS } from \"./deprecations.ts\";\nimport { isGirLibrary, text } from \"./schema-text.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, the React\n * Compiler, codegen, and user event signal settings, the `agents` and `mcp` blocks controlling what\n * coding agents are given, the `future` block opting into behavior that becomes the default in the\n * next major version, and the `deprecations` block silencing the warnings about flags left unset.\n */\ntype Config = z.infer<typeof configSchema>;\ntype ModuleExport = z.infer<typeof moduleExportSchema>;\ntype ElementConfigEntry = z.infer<typeof elementConfigSchema>;\n\ntype McpSettings = {\n tools: string[];\n isReadOnly: boolean;\n};\n\ntype ResolvedFuture = {\n isByteArrayTyped: boolean;\n isValueUnwrapped: boolean;\n isFinishTrimmed: boolean;\n isInoutInPlace: boolean;\n isResourceImported: boolean;\n isAdwaitaDefault: boolean;\n isTreeShaken: boolean;\n};\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 /**\n * Signal names, keyed by GLib type name, that stay suppressed while a React commit writes to a widget.\n * `notify` stays suppressed only for the property being written.\n */\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 APPLICATION_ID_PATTERN = /^[A-Za-z_][A-Za-z0-9_-]*(\\.[A-Za-z_][A-Za-z0-9_-]*)+$/;\nconst APPLICATION_ID_MAX_LENGTH = 255;\n/** Compilation modes `babel-plugin-react-compiler` accepts. */\nconst COMPILATION_MODES = [\"infer\", \"syntax\", \"annotation\", \"all\"] as const;\n/** Panic thresholds `babel-plugin-react-compiler` accepts. */\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 isLazy: z.boolean({ error: \"must be a boolean\" }).optional(),\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\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 agentsSchema = z.object({\n rules: z.boolean({ error: \"must be a boolean\" }).optional(),\n reference: z.boolean({ error: \"must be a boolean\" }).optional(),\n});\n\nconst mcpSchema = z.object({\n tools: z\n .array(z.string({ error: \"must be a tool name pattern\" }).min(1, { error: \"must be a tool name pattern\" }), {\n error: \"must be an array of tool name patterns\",\n })\n .optional(),\n readOnly: z.boolean({ error: \"must be a boolean\" }).optional(),\n});\n\nconst futureSchema = z.object({\n v2ByteArrays: z.boolean({ error: \"must be a boolean\" }).optional(),\n v2ValueReturns: z.boolean({ error: \"must be a boolean\" }).optional(),\n v2FinishResults: z.boolean({ error: \"must be a boolean\" }).optional(),\n v2InoutReturns: z.boolean({ error: \"must be a boolean\" }).optional(),\n v2ResourceImports: z.boolean({ error: \"must be a boolean\" }).optional(),\n v2DefaultLibraries: z.boolean({ error: \"must be a boolean\" }).optional(),\n v2TreeShaking: z.boolean({ error: \"must be a boolean\" }).optional(),\n});\n\nconst FUTURE_KEYS: Set<string> = new Set(Object.keys(futureSchema.shape));\nconst DEPRECATION_ID_ERROR = `must be one of ${DEPRECATION_IDS.join(\", \")}`;\n\nconst deprecationsSchema = z.object({\n silence: z\n .array(z.enum(DEPRECATION_IDS, { error: DEPRECATION_ID_ERROR }), {\n error: \"must be an array of deprecation ids\",\n })\n .optional(),\n});\n\n/** Schema every `gtkx.config.ts` is validated against, and the source of the {@link Config} type. */\nconst configSchema = z.object({\n future: futureSchema.optional(),\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 applicationIcon: text(\"must be a path to an icon theme directory or a single icon file\").optional(),\n deploy: deploySchema.optional(),\n agents: agentsSchema.optional(),\n mcp: mcpSchema.optional(),\n deprecations: deprecationsSchema.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\" && isGirLibrary(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 a configuration over a base. `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 isAgentRulesEnabled = (config: Config): boolean => config.agents?.rules !== false;\nconst isAgentReferenceEnabled = (config: Config): boolean => config.agents?.reference !== false;\n\nconst resolveMcpSettings = (config: Config): McpSettings => ({\n tools: config.mcp?.tools ?? [],\n isReadOnly: config.mcp?.readOnly === true,\n});\n\nconst resolveFuture = (future: Config[\"future\"]): ResolvedFuture => ({\n isByteArrayTyped: future?.v2ByteArrays === true,\n isValueUnwrapped: future?.v2ValueReturns === true,\n isFinishTrimmed: future?.v2FinishResults === true,\n isInoutInPlace: future?.v2InoutReturns === true,\n isResourceImported: future?.v2ResourceImports === true,\n isAdwaitaDefault: future?.v2DefaultLibraries === true,\n isTreeShaken: future?.v2TreeShaking === true,\n});\n\nconst unknownFutureKeys = (future: Config[\"future\"]): string[] =>\n Object.keys(future ?? {}).filter((key) => !FUTURE_KEYS.has(key));\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 APPLICATION_ID_MAX_LENGTH,\n defineConfig,\n isAgentReferenceEnabled,\n isAgentRulesEnabled,\n isValidApplicationId,\n validateConfig,\n mergeConfig,\n resolveLazyElements,\n resolveElementComponents,\n resolveElementProps,\n resolveMcpSettings,\n resolveOmittedProps,\n resolveConfig,\n resolveFuture,\n unknownFutureKeys,\n type McpSettings,\n type ResolvedReactCompilerOptions,\n type Config,\n type ResolvedConfig,\n type ResolvedFuture,\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,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAmDlE,MAAM,sBAAsB,GAAG,uDAAuD,CAAC;AACvF,MAAM,yBAAyB,GAAG,GAAG,CAAC;AACtC,MAAM,kBAAkB,GAAgB,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;AACtE,+DAA+D;AAC/D,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,QAAQ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AQ,KAAK,IAAI;CAC5C,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,CAAC,MAAc,EAAE,IAAa,EAAkB,EAAE,CAAC,CAAC;IACtE,aAAa,EAAE,MAAM,CAAC,aAAa;IACnC,aAAa,EAAE,2BAA2B,CAAC,MAAM,CAAC,aAAa,CAAC;IAChE,gBAAgB,EAAE,uBAAuB,CAAC,MAAM,CAAC,gBAAgB,CAAC;IAClE,QAAQ,EAAE,qBAAqB,CAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC;IACjE,YAAY,EAAE,mBAAmB,CAAC,MAAM,CAAC,QAAQ,CAAC;CACrD,CAAC,CAAC;AAEH,OAAO,EACH,yBAAyB,EACzB,YAAY,EACZ,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,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 } from \"./config-error.ts\";\nimport { deploySchema } from \"./deploy.ts\";\nimport { girLibrary, text } from \"./schema-text.ts\";\nimport { resolveUserEventSignals } from \"./user-event-signals.ts\";\n\n/** Object form of the `reactCompiler` config key, forwarded to `babel-plugin-react-compiler`. */\ntype ReactCompilerOptions = {\n /** Which functions the compiler processes. */\n compilationMode?: (typeof COMPILATION_MODES)[number];\n /** Which compiler diagnostics fail the build. */\n panicThreshold?: (typeof PANIC_THRESHOLDS)[number];\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, the React\n * Compiler, codegen, and user event signal settings, and the `agents` and `mcp` blocks controlling\n * what coding agents are given.\n */\ntype Config = z.infer<typeof configSchema>;\ntype ModuleExport = z.infer<typeof moduleExportSchema>;\ntype ElementConfigEntry = z.infer<typeof elementConfigSchema>;\n\ntype McpSettings = {\n tools: string[];\n isReadOnly: boolean;\n};\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 /**\n * Signal names, keyed by GLib type name, that stay suppressed while a React commit writes to a widget.\n * `notify` stays suppressed only for the property being written.\n */\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 APPLICATION_ID_PATTERN = /^[A-Za-z_][A-Za-z0-9_-]*(\\.[A-Za-z_][A-Za-z0-9_-]*)+$/;\nconst APPLICATION_ID_MAX_LENGTH = 255;\nconst IMPLICIT_LIBRARIES: Set<string> = new Set([\"Adw-1\", \"Gtk-4.0\"]);\n/** Compilation modes `babel-plugin-react-compiler` accepts. */\nconst COMPILATION_MODES = [\"infer\", \"syntax\", \"annotation\", \"all\"] as const;\n/** Panic thresholds `babel-plugin-react-compiler` accepts. */\nconst PANIC_THRESHOLDS = [\"none\", \"critical_errors\", \"all_errors\"] as const;\nconst REACT_COMPILER_TARGET = \"19\";\n\nconst librarySchema = girLibrary('must be of the form \"Name-Version\", such as \"Adw-1\"')\n .refine((library) => !IMPLICIT_LIBRARIES.has(library), { error: \"is bound implicitly; remove it\" });\n\nconst librariesSchema = z\n .array(librarySchema, { error: \"must be a non-empty string array or omitted\" })\n .min(1, { error: \"must be a non-empty string array or omitted\" });\n\nconst applicationIdSchema = z\n .string({ error: \"must satisfy g_application_id_is_valid\" })\n .refine((value) => isValidApplicationId(value), {\n error: 'must satisfy g_application_id_is_valid, such as \"org.example.MyApp\"',\n });\n\nconst reactCompilerSchema = z.union([\n z.boolean(),\n z.object({\n compilationMode: z.enum(COMPILATION_MODES).optional(),\n panicThreshold: z.enum(PANIC_THRESHOLDS).optional(),\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 isLazy: z.boolean({ error: \"must be a boolean\" }).optional(),\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\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 agentsSchema = z.object({\n rules: z.boolean({ error: \"must be a boolean\" }).optional(),\n reference: z.boolean({ error: \"must be a boolean\" }).optional(),\n});\n\nconst mcpSchema = z.object({\n tools: z\n .array(z.string({ error: \"must be a tool name pattern\" }).min(1, { error: \"must be a tool name pattern\" }), {\n error: \"must be an array of tool name patterns\",\n })\n .optional(),\n readOnly: z.boolean({ error: \"must be a boolean\" }).optional(),\n});\n\nconst graduatedFutureSchema = z\n .object({\n v2ByteArrays: z.literal(true, { error: \"can only be true; remove the flag\" }).optional(),\n v2ValueReturns: z.literal(true, { error: \"can only be true; remove the flag\" }).optional(),\n v2FinishResults: z.literal(true, { error: \"can only be true; remove the flag\" }).optional(),\n v2InoutReturns: z.literal(true, { error: \"can only be true; remove the flag\" }).optional(),\n v2ResourceImports: z.literal(true, { error: \"can only be true; remove the flag\" }).optional(),\n v2DefaultLibraries: z.literal(true, { error: \"can only be true; remove the flag\" }).optional(),\n v2TreeShaking: z.literal(true, { error: \"can only be true; remove the flag\" }).optional(),\n })\n .strict();\n\nconst deprecationsSchema = z.object({\n silence: z\n .array(z.never({ error: \"does not name a current deprecation\" }), {\n error: \"must be an array of current deprecation ids\",\n })\n .optional(),\n});\n\n/** Schema every `gtkx.config.ts` is validated against, and the source of the {@link Config} type. */\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 applicationIcon: text(\"must be a path to an icon theme directory or a single icon file\").optional(),\n deploy: deploySchema.optional(),\n agents: agentsSchema.optional(),\n mcp: mcpSchema.optional(),\n deprecations: deprecationsSchema.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>();\nconst validationSchema = configSchema.extend({ future: graduatedFutureSchema.optional() });\n\nconst isValidApplicationId = (applicationId: string): boolean =>\n applicationId.length <= APPLICATION_ID_MAX_LENGTH && APPLICATION_ID_PATTERN.test(applicationId);\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 {\n ...(overrides.compilationMode !== undefined && { compilationMode: overrides.compilationMode }),\n ...(overrides.panicThreshold !== undefined && { panicThreshold: overrides.panicThreshold }),\n target: REACT_COMPILER_TARGET,\n };\n};\n\nconst validateConfig = (config: unknown, configFile?: string): void => {\n const result = validationSchema.safeParse(config);\n\n if (!result.success) {\n throw configError(result.error, configFile);\n }\n};\n\nconst graduatedFutureKeys = (config: unknown): string[] => {\n if (!isRecord(config) || !isRecord(config.future)) {\n return [];\n }\n\n return Object.keys(config.future).toSorted((first, second) => first.localeCompare(second));\n};\n\n/**\n * Deep-merges a configuration over a base. `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 isAgentRulesEnabled = (config: Config): boolean => config.agents?.rules !== false;\nconst isAgentReferenceEnabled = (config: Config): boolean => config.agents?.reference !== false;\n\nconst resolveMcpSettings = (config: Config): McpSettings => ({\n tools: config.mcp?.tools ?? [],\n isReadOnly: config.mcp?.readOnly === true,\n});\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 APPLICATION_ID_MAX_LENGTH,\n defineConfig,\n isAgentReferenceEnabled,\n isAgentRulesEnabled,\n isValidApplicationId,\n graduatedFutureKeys,\n validateConfig,\n mergeConfig,\n resolveLazyElements,\n resolveElementComponents,\n resolveElementProps,\n resolveMcpSettings,\n resolveOmittedProps,\n resolveConfig,\n type McpSettings,\n type ResolvedReactCompilerOptions,\n type Config,\n type ResolvedConfig,\n};\n"]}
|
package/dist/deploy.d.ts
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* A `deploy.extraFiles` entry in object form: the source file, resolved against the project root, that is
|
|
4
|
+
* installed at the entry's prefix-relative destination, and the octal mode it is installed with.
|
|
5
|
+
*/
|
|
6
|
+
type DeployExtraFileOptions = Record<"source", string> & {
|
|
7
|
+
/** Octal file mode. Setuid and setgid bits are rejected. */
|
|
8
|
+
mode?: string | undefined;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The `deploy.node` options: where the Node.js runtime bundled with the application comes from, the version it
|
|
12
|
+
* is expected to be, whether its binary is stripped, and whether the launcher enables the compile cache.
|
|
13
|
+
*/
|
|
14
|
+
type DeployNodeOptions = Partial<Record<"source", "download" | "host" | "path" | undefined> & Record<"path", string | undefined> & Record<"shouldStrip" | "shouldUseCompileCache", boolean | undefined>> & {
|
|
15
|
+
/** Expected Node.js version. Downloaded runtimes default to exactly 26.7.0 when omitted. */
|
|
16
|
+
version?: string | undefined;
|
|
17
|
+
};
|
|
2
18
|
declare const deploySchema: z.ZodObject<{
|
|
3
19
|
targets: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
4
20
|
appimage: "appimage";
|
|
@@ -6,6 +22,10 @@ declare const deploySchema: z.ZodObject<{
|
|
|
6
22
|
flatpak: "flatpak";
|
|
7
23
|
rpm: "rpm";
|
|
8
24
|
}>>>;
|
|
25
|
+
architectures: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
26
|
+
arm64: "arm64";
|
|
27
|
+
x64: "x64";
|
|
28
|
+
}>>>;
|
|
9
29
|
outDir: z.ZodOptional<z.ZodString>;
|
|
10
30
|
name: z.ZodOptional<z.ZodString>;
|
|
11
31
|
genericName: z.ZodOptional<z.ZodString>;
|
|
@@ -73,6 +93,8 @@ declare const deploySchema: z.ZodObject<{
|
|
|
73
93
|
url: z.ZodOptional<z.ZodURL>;
|
|
74
94
|
}, z.core.$strict>>>;
|
|
75
95
|
execArgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
96
|
+
launcherEnv: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
97
|
+
nodeFlags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
76
98
|
fileAssociations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
77
99
|
extension: z.ZodString;
|
|
78
100
|
mimeType: z.ZodString;
|
|
@@ -85,11 +107,9 @@ declare const deploySchema: z.ZodObject<{
|
|
|
85
107
|
icon: z.ZodOptional<z.ZodString>;
|
|
86
108
|
}, z.core.$strict>>>;
|
|
87
109
|
desktopEntry: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
110
|
+
metainfoExtra: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
88
111
|
isDbusActivatable: z.ZodOptional<z.ZodBoolean>;
|
|
89
|
-
extraFiles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.
|
|
90
|
-
source: z.ZodString;
|
|
91
|
-
mode: z.ZodOptional<z.ZodString>;
|
|
92
|
-
}, z.core.$strict>]>>>;
|
|
112
|
+
extraFiles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodType<DeployExtraFileOptions, unknown, z.core.$ZodTypeInternals<DeployExtraFileOptions, unknown>>]>>>;
|
|
93
113
|
minimumLibraryVersions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
94
114
|
depends: z.ZodOptional<z.ZodObject<{
|
|
95
115
|
deb: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -131,17 +151,7 @@ declare const deploySchema: z.ZodObject<{
|
|
|
131
151
|
preRemove: z.ZodOptional<z.ZodString>;
|
|
132
152
|
postRemove: z.ZodOptional<z.ZodString>;
|
|
133
153
|
}, z.core.$strict>>;
|
|
134
|
-
node: z.ZodOptional<z.
|
|
135
|
-
source: z.ZodOptional<z.ZodEnum<{
|
|
136
|
-
path: "path";
|
|
137
|
-
download: "download";
|
|
138
|
-
host: "host";
|
|
139
|
-
}>>;
|
|
140
|
-
version: z.ZodOptional<z.ZodString>;
|
|
141
|
-
path: z.ZodOptional<z.ZodString>;
|
|
142
|
-
shouldStrip: z.ZodOptional<z.ZodBoolean>;
|
|
143
|
-
shouldUseCompileCache: z.ZodOptional<z.ZodBoolean>;
|
|
144
|
-
}, z.core.$strict>>;
|
|
154
|
+
node: z.ZodOptional<z.ZodType<DeployNodeOptions, unknown, z.core.$ZodTypeInternals<DeployNodeOptions, unknown>>>;
|
|
145
155
|
signing: z.ZodOptional<z.ZodObject<{
|
|
146
156
|
appimage: z.ZodOptional<z.ZodObject<{
|
|
147
157
|
gpgKeyId: z.ZodString;
|
|
@@ -236,5 +246,5 @@ declare const deploySchema: z.ZodObject<{
|
|
|
236
246
|
prefixes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
237
247
|
}, z.core.$strict>>;
|
|
238
248
|
}, z.core.$strict>;
|
|
239
|
-
export { deploySchema };
|
|
249
|
+
export { deploySchema, type DeployExtraFileOptions, type DeployNodeOptions };
|
|
240
250
|
//# sourceMappingURL=deploy.d.ts.map
|
package/dist/deploy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../src/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../src/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAuHxB;;;GAGG;AACH,KAAK,sBAAsB,GAAG,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG;IACrD,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AA2BF;;;GAGG;AACH,KAAK,iBAAiB,GAAG,OAAO,CAC5B,MAAM,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,GAC1D,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAClC,MAAM,CAAC,aAAa,GAAG,uBAAuB,EAAE,OAAO,GAAG,SAAS,CAAC,CACvE,GAAG;IACA,4FAA4F;IAC5F,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAAC;AA2GF,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAwEhB,CAAC;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,sBAAsB,EAAE,KAAK,iBAAiB,EAAE,CAAC"}
|
package/dist/deploy.js
CHANGED
|
@@ -4,6 +4,7 @@ const APPIMAGE_COMPRESSIONS = ["gzip", "xz", "zstd"];
|
|
|
4
4
|
const DEB_COMPRESSIONS = ["gzip", "none", "xz", "zstd"];
|
|
5
5
|
const DEB_SIGN_METHODS = ["debsign", "dpkg-sig"];
|
|
6
6
|
const DEB_SIGN_TYPES = ["archive", "maint", "origin"];
|
|
7
|
+
const DEPLOY_ARCH_NAMES = ["arm64", "x64"];
|
|
7
8
|
const DEPLOY_TARGET_NAMES = ["appimage", "deb", "flatpak", "rpm"];
|
|
8
9
|
const FLATPAK_MODES = ["prebuilt", "source"];
|
|
9
10
|
const NODE_SOURCES = ["download", "host", "path"];
|
|
@@ -25,16 +26,22 @@ const URL_KINDS = [
|
|
|
25
26
|
const BOOLEAN_ERROR = "must be a boolean";
|
|
26
27
|
const EPOCH_ERROR = "must be a non-negative integer";
|
|
27
28
|
const EXTRA_FILE_ERROR = "must be a source path or a { source, mode } entry";
|
|
28
|
-
const FILE_MODE_ERROR = "must be an octal file mode such as 755";
|
|
29
|
+
const FILE_MODE_ERROR = "must be an octal file mode without setuid or setgid bits, such as 755";
|
|
29
30
|
const FILE_MODE_PATTERN = /^[0-7]{3,4}$/;
|
|
31
|
+
const FILE_MODE_RADIX = 8;
|
|
32
|
+
const PRIVILEGED_FILE_MODE_MASK = 0o6000;
|
|
30
33
|
const HEX_COLOR_ERROR = "must be a #rrggbb color";
|
|
31
34
|
const HEX_COLOR_PATTERN = /^#[\dA-Fa-f]{6}$/;
|
|
32
35
|
const KEY_FILE_ERROR = "must be a path to a PGP key file";
|
|
33
36
|
const KEY_ID_ERROR = "must be a PGP key id";
|
|
37
|
+
const LAUNCHER_ENV_ERROR = "must be a record of POSIX environment names to values without null bytes";
|
|
38
|
+
const LAUNCHER_ENV_NAME_ERROR = "must be a POSIX environment name";
|
|
39
|
+
const LAUNCHER_ENV_NAME_PATTERN = /^[A-Za-z_]\w*$/;
|
|
34
40
|
const MINIMUM_LIBRARY_VERSION_ERROR = "must be a version such as 4.18";
|
|
35
41
|
const MINIMUM_LIBRARY_VERSION_PATTERN = /^\d+(?:\.\d+)*$/;
|
|
36
42
|
const MINIMUM_LIBRARY_VERSIONS_ERROR = "must be a record of GIR library ids to a minimum version";
|
|
37
|
-
const
|
|
43
|
+
const NODE_FLAG_ERROR = "must be a Node.js flag beginning with a hyphen and containing no null bytes";
|
|
44
|
+
const LIBRARY_ID_ERROR = 'must be a GIR library identifier of the form "Name-Version", such as "Adw-1"';
|
|
38
45
|
const SCRIPT_ERROR = "must be a path to a shell script";
|
|
39
46
|
const SOURCE_PATH_ERROR = "must be a source path";
|
|
40
47
|
const SPDX_ERROR = "must be an SPDX license expression";
|
|
@@ -90,12 +97,22 @@ const brandingSchema = z.strictObject({
|
|
|
90
97
|
});
|
|
91
98
|
const extraFileSchema = z.strictObject({
|
|
92
99
|
source: text(SOURCE_PATH_ERROR),
|
|
93
|
-
mode: z
|
|
100
|
+
mode: z
|
|
101
|
+
.string({ error: FILE_MODE_ERROR })
|
|
102
|
+
.regex(FILE_MODE_PATTERN, { error: FILE_MODE_ERROR })
|
|
103
|
+
.refine((mode) => (Number.parseInt(mode, FILE_MODE_RADIX) & PRIVILEGED_FILE_MODE_MASK) === 0, {
|
|
104
|
+
error: FILE_MODE_ERROR,
|
|
105
|
+
})
|
|
106
|
+
.optional(),
|
|
94
107
|
});
|
|
95
108
|
const extraFileEntrySchema = z.union([text(SOURCE_PATH_ERROR), extraFileSchema], { error: EXTRA_FILE_ERROR });
|
|
109
|
+
const launcherEnvSchema = z.record(z.string({ error: LAUNCHER_ENV_NAME_ERROR }).regex(LAUNCHER_ENV_NAME_PATTERN, { error: LAUNCHER_ENV_NAME_ERROR }), z.string({ error: LAUNCHER_ENV_ERROR }).refine((value) => !value.includes("\0"), { error: LAUNCHER_ENV_ERROR }), { error: (issue) => issue.code === "invalid_key" ? LAUNCHER_ENV_NAME_ERROR : LAUNCHER_ENV_ERROR });
|
|
110
|
+
const nodeFlagsSchema = z.array(z
|
|
111
|
+
.string({ error: NODE_FLAG_ERROR })
|
|
112
|
+
.refine((value) => value.startsWith("-") && !value.includes("\0"), { error: NODE_FLAG_ERROR }), { error: "must be an array of Node.js flags" });
|
|
96
113
|
const nodeRuntimeSchema = z.strictObject({
|
|
97
114
|
source: z.enum(NODE_SOURCES, { error: "must be one of download, host, path" }).optional(),
|
|
98
|
-
version: text("must be a Node.js version such as
|
|
115
|
+
version: text("must be a Node.js version such as 26.7.0").optional(),
|
|
99
116
|
path: text("must be a path to a node binary").optional(),
|
|
100
117
|
shouldStrip: flag(BOOLEAN_ERROR).optional(),
|
|
101
118
|
shouldUseCompileCache: flag(BOOLEAN_ERROR).optional(),
|
|
@@ -192,6 +209,11 @@ const deploySchema = z.strictObject({
|
|
|
192
209
|
error: "must be an array of deploy targets",
|
|
193
210
|
})
|
|
194
211
|
.optional(),
|
|
212
|
+
architectures: z
|
|
213
|
+
.array(z.enum(DEPLOY_ARCH_NAMES, { error: "must be one of arm64, x64" }), {
|
|
214
|
+
error: "must be an array of deploy architectures",
|
|
215
|
+
})
|
|
216
|
+
.optional(),
|
|
195
217
|
outDir: text("must be a directory path relative to the project root").optional(),
|
|
196
218
|
name: text("must be the display name shown in the launcher").optional(),
|
|
197
219
|
genericName: text("must be a generic application name").optional(),
|
|
@@ -225,6 +247,8 @@ const deploySchema = z.strictObject({
|
|
|
225
247
|
.optional(),
|
|
226
248
|
releases: z.array(releaseSchema, { error: "must be an array of releases" }).optional(),
|
|
227
249
|
execArgs: textList("argument", "must be an array of arguments appended to Exec").optional(),
|
|
250
|
+
launcherEnv: launcherEnvSchema.optional(),
|
|
251
|
+
nodeFlags: nodeFlagsSchema.optional(),
|
|
228
252
|
fileAssociations: z
|
|
229
253
|
.array(fileAssociationSchema, { error: "must be an array of file associations" })
|
|
230
254
|
.optional(),
|
|
@@ -234,6 +258,7 @@ const deploySchema = z.strictObject({
|
|
|
234
258
|
.optional(),
|
|
235
259
|
desktopEntry: textRecord("must be a desktop entry value", "must be a record of desktop entry keys to values")
|
|
236
260
|
.optional(),
|
|
261
|
+
metainfoExtra: textList("AppStream XML fragment", "must be an array of AppStream XML fragments").optional(),
|
|
237
262
|
isDbusActivatable: flag(BOOLEAN_ERROR).optional(),
|
|
238
263
|
extraFiles: relativePathRecord("must be a destination path inside the install prefix, without a leading slash or a .. segment", extraFileEntrySchema, "must be a record of prefix-relative destinations to source paths or { source, mode } entries").optional(),
|
|
239
264
|
minimumLibraryVersions: minimumLibraryVersionsSchema.optional(),
|