@gtkx/config 1.0.0-rc.1 → 1.0.0-rc.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.
Files changed (45) hide show
  1. package/dist/config-error.d.ts +16 -0
  2. package/dist/config-error.d.ts.map +1 -0
  3. package/dist/config-error.js +45 -0
  4. package/dist/config-error.js.map +1 -0
  5. package/dist/config.d.ts +51 -56
  6. package/dist/config.d.ts.map +1 -1
  7. package/dist/config.js +90 -42
  8. package/dist/config.js.map +1 -1
  9. package/dist/index.d.ts +0 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js.map +1 -1
  12. package/dist/internal.d.ts +1 -1
  13. package/dist/internal.d.ts.map +1 -1
  14. package/dist/internal.js +1 -1
  15. package/dist/internal.js.map +1 -1
  16. package/dist/loader.d.ts +6 -5
  17. package/dist/loader.d.ts.map +1 -1
  18. package/dist/loader.js +10 -8
  19. package/dist/loader.js.map +1 -1
  20. package/dist/user-event-signals.d.ts +4 -0
  21. package/dist/user-event-signals.d.ts.map +1 -0
  22. package/dist/user-event-signals.js +54 -0
  23. package/dist/user-event-signals.js.map +1 -0
  24. package/dist/virtual.d.ts +8 -3
  25. package/dist/virtual.d.ts.map +1 -1
  26. package/dist/virtual.js +26 -6
  27. package/dist/virtual.js.map +1 -1
  28. package/dist/vite-plugin.d.ts.map +1 -1
  29. package/dist/vite-plugin.js +12 -13
  30. package/dist/vite-plugin.js.map +1 -1
  31. package/package.json +3 -9
  32. package/src/config-error.ts +67 -0
  33. package/src/config.ts +176 -84
  34. package/src/index.ts +0 -12
  35. package/src/internal.ts +1 -1
  36. package/src/loader.ts +22 -13
  37. package/src/user-event-signals.ts +57 -0
  38. package/src/virtual.ts +28 -5
  39. package/src/vite-plugin.ts +25 -11
  40. package/dist/element-props.d.ts +0 -180
  41. package/dist/element-props.d.ts.map +0 -1
  42. package/dist/element-props.js +0 -154
  43. package/dist/element-props.js.map +0 -1
  44. package/env.d.ts +0 -8
  45. package/src/element-props.ts +0 -248
@@ -1,180 +0,0 @@
1
- import { z } from "zod";
2
- declare const ARG_REFS: readonly ["child", "item", "index", "sibling", "adopted"];
3
- type JsonValue = string | number | boolean | null | JsonValue[] | {
4
- [key: string]: JsonValue;
5
- };
6
- /**
7
- * Named reference to a value available while invoking a {@link Call}: the child
8
- * widget, the current list item, its index, the preceding sibling, or the
9
- * adopted instance a container returned for the child.
10
- */
11
- export type ArgRef = (typeof ARG_REFS)[number];
12
- /**
13
- * A single argument passed to a method {@link Call}: an {@link ArgRef}, a value
14
- * read from a React prop (`{ prop }`), a field read off the current item with an
15
- * optional fallback (`{ field, or }`), or a constant (`{ literal }`).
16
- */
17
- export type Arg = ArgRef | {
18
- prop: string;
19
- } | {
20
- field: string;
21
- or?: JsonValue;
22
- } | {
23
- literal: JsonValue;
24
- };
25
- /**
26
- * A GObject method invocation: either a bare method name called with default
27
- * arguments, or a method name paired with an explicit list of {@link Arg}s.
28
- */
29
- export type Call = string | {
30
- method: string;
31
- args: Arg[];
32
- };
33
- export declare const isRecord: (value: unknown) => value is Record<string, unknown>;
34
- type IssuePath = Array<string | number>;
35
- export declare const rawIssue: (input: unknown, path: IssuePath, message: string, standalone?: boolean) => {
36
- code: "custom";
37
- input: unknown;
38
- path: IssuePath;
39
- message: string;
40
- continue: true;
41
- params?: {
42
- standalone: boolean;
43
- };
44
- };
45
- declare const containerSchema: z.ZodObject<{
46
- kind: z.ZodLiteral<"container">;
47
- prop: z.ZodString;
48
- child: z.ZodString;
49
- append: z.ZodOptional<z.ZodCustom<Call, Call>>;
50
- remove: z.ZodOptional<z.ZodCustom<Call, Call>>;
51
- insert: z.ZodOptional<z.ZodCustom<Call, Call>>;
52
- reorder: z.ZodOptional<z.ZodCustom<Call, Call>>;
53
- autowrap: z.ZodOptional<z.ZodString>;
54
- adopt: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodString]>>;
55
- }, z.core.$strict>;
56
- declare const valueSchema: z.ZodObject<{
57
- kind: z.ZodLiteral<"value">;
58
- prop: z.ZodString;
59
- call: z.ZodCustom<Call, Call>;
60
- after: z.ZodOptional<z.ZodString>;
61
- }, z.core.$strict>;
62
- declare const controlledTextSchema: z.ZodObject<{
63
- kind: z.ZodLiteral<"controlled-text">;
64
- prop: z.ZodString;
65
- }, z.core.$strict>;
66
- declare const lazySchema: z.ZodObject<{
67
- kind: z.ZodLiteral<"lazy">;
68
- prop: z.ZodString;
69
- lookup: z.ZodOptional<z.ZodString>;
70
- }, z.core.$strict>;
71
- declare const listSchema: z.ZodObject<{
72
- kind: z.ZodLiteral<"list">;
73
- prop: z.ZodString;
74
- add: z.ZodUnion<readonly [z.ZodCustom<Call, Call>, z.ZodArray<z.ZodCustom<Call, Call>>]>;
75
- remove: z.ZodOptional<z.ZodCustom<Call, Call>>;
76
- clear: z.ZodOptional<z.ZodCustom<Call, Call>>;
77
- }, z.core.$strict>;
78
- declare const elementPropSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
79
- kind: z.ZodLiteral<"container">;
80
- prop: z.ZodString;
81
- child: z.ZodString;
82
- append: z.ZodOptional<z.ZodCustom<Call, Call>>;
83
- remove: z.ZodOptional<z.ZodCustom<Call, Call>>;
84
- insert: z.ZodOptional<z.ZodCustom<Call, Call>>;
85
- reorder: z.ZodOptional<z.ZodCustom<Call, Call>>;
86
- autowrap: z.ZodOptional<z.ZodString>;
87
- adopt: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodString]>>;
88
- }, z.core.$strict>, z.ZodObject<{
89
- kind: z.ZodLiteral<"value">;
90
- prop: z.ZodString;
91
- call: z.ZodCustom<Call, Call>;
92
- after: z.ZodOptional<z.ZodString>;
93
- }, z.core.$strict>, z.ZodObject<{
94
- kind: z.ZodLiteral<"controlled-text">;
95
- prop: z.ZodString;
96
- }, z.core.$strict>, z.ZodObject<{
97
- kind: z.ZodLiteral<"lazy">;
98
- prop: z.ZodString;
99
- lookup: z.ZodOptional<z.ZodString>;
100
- }, z.core.$strict>, z.ZodObject<{
101
- kind: z.ZodLiteral<"list">;
102
- prop: z.ZodString;
103
- add: z.ZodUnion<readonly [z.ZodCustom<Call, Call>, z.ZodArray<z.ZodCustom<Call, Call>>]>;
104
- remove: z.ZodOptional<z.ZodCustom<Call, Call>>;
105
- clear: z.ZodOptional<z.ZodCustom<Call, Call>>;
106
- }, z.core.$strict>], "kind">;
107
- export declare const elementPropsSchema: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
108
- kind: z.ZodLiteral<"container">;
109
- prop: z.ZodString;
110
- child: z.ZodString;
111
- append: z.ZodOptional<z.ZodCustom<Call, Call>>;
112
- remove: z.ZodOptional<z.ZodCustom<Call, Call>>;
113
- insert: z.ZodOptional<z.ZodCustom<Call, Call>>;
114
- reorder: z.ZodOptional<z.ZodCustom<Call, Call>>;
115
- autowrap: z.ZodOptional<z.ZodString>;
116
- adopt: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodString]>>;
117
- }, z.core.$strict>, z.ZodObject<{
118
- kind: z.ZodLiteral<"value">;
119
- prop: z.ZodString;
120
- call: z.ZodCustom<Call, Call>;
121
- after: z.ZodOptional<z.ZodString>;
122
- }, z.core.$strict>, z.ZodObject<{
123
- kind: z.ZodLiteral<"controlled-text">;
124
- prop: z.ZodString;
125
- }, z.core.$strict>, z.ZodObject<{
126
- kind: z.ZodLiteral<"lazy">;
127
- prop: z.ZodString;
128
- lookup: z.ZodOptional<z.ZodString>;
129
- }, z.core.$strict>, z.ZodObject<{
130
- kind: z.ZodLiteral<"list">;
131
- prop: z.ZodString;
132
- add: z.ZodUnion<readonly [z.ZodCustom<Call, Call>, z.ZodArray<z.ZodCustom<Call, Call>>]>;
133
- remove: z.ZodOptional<z.ZodCustom<Call, Call>>;
134
- clear: z.ZodOptional<z.ZodCustom<Call, Call>>;
135
- }, z.core.$strict>], "kind">>>;
136
- /**
137
- * Rule describing how children of a given type are attached to and removed from a
138
- * container element. `prop` is the React prop holding the children and `child` the
139
- * child GObject type. `append`/`remove` add and remove a child, `insert` places
140
- * one at an index or after a sibling, `reorder` moves an existing child, `autowrap`
141
- * names a widget type each child is wrapped in before attaching, and `adopt` marks
142
- * pre-existing children as adopted (`true`) or names the getter returning them.
143
- */
144
- export type ContainerProp = z.infer<typeof containerSchema>;
145
- /**
146
- * Rule that applies a scalar prop value by invoking `call` whenever the value
147
- * changes, optionally running the method named by `after` once it is set.
148
- */
149
- export type ValueProp = z.infer<typeof valueSchema>;
150
- /**
151
- * Rule for a controlled text prop: `prop` is written directly to the GObject
152
- * property and kept in sync with the element's own edits.
153
- */
154
- export type ControlledTextProp = z.infer<typeof controlledTextSchema>;
155
- /**
156
- * Rule for a prop applied after construction rather than at construction time,
157
- * optionally guarded by `lookup`, a method that must succeed for the value before
158
- * it is assigned.
159
- */
160
- export type LazyProp = z.infer<typeof lazySchema>;
161
- /**
162
- * Rule mapping an array prop to method calls: `add` runs per added item (a single
163
- * call, or a sequence of calls applied in order when one item needs several), `remove`
164
- * per removed item, and `clear` empties the collection before re-adding.
165
- */
166
- export type ListProp = z.infer<typeof listSchema>;
167
- /**
168
- * Any prop rule applied directly to an element instance rather than through
169
- * container child attachment: a {@link ValueProp}, {@link ControlledTextProp},
170
- * {@link LazyProp}, or {@link ListProp}.
171
- */
172
- export type AppliedProp = ValueProp | ControlledTextProp | LazyProp | ListProp;
173
- /**
174
- * A single entry in an element's prop mapping, discriminated by `kind`: a
175
- * container, value, controlled-text, lazy, or list rule.
176
- */
177
- export type ElementProp = z.infer<typeof elementPropSchema>;
178
- export declare const configError: (error: z.ZodError) => Error;
179
- export {};
180
- //# sourceMappingURL=element-props.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"element-props.d.ts","sourceRoot":"","sources":["../src/element-props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,QAAQ,YAA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AC;AAEP,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAAmD,CAAC;AAEnF;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE5D;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEpD;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEtE;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAElD;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAElD;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,kBAAkB,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE/E;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAwB5D,eAAO,MAAM,WAAW,UAAW,CAAC,CAAC,QAAQ,KAAG,KAI/C,CAAC"}
@@ -1,154 +0,0 @@
1
- import { z } from "zod";
2
- const ARG_REFS = ["child", "item", "index", "sibling", "adopted"];
3
- const NAME_MESSAGE = "must be a non-empty string";
4
- const JSON_MESSAGE = "must be a JSON-serializable value";
5
- const ARG_MESSAGE = "must be one of: reference name, { prop }, { field }, { literal }";
6
- const ARG_REF_SET = new Set(ARG_REFS);
7
- export const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
8
- const isJsonValue = (value) => {
9
- if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
10
- return true;
11
- }
12
- if (Array.isArray(value))
13
- return value.every(isJsonValue);
14
- if (isRecord(value))
15
- return Object.values(value).every(isJsonValue);
16
- return false;
17
- };
18
- export const rawIssue = (input, path, message, standalone = false) => ({
19
- code: "custom",
20
- input,
21
- path,
22
- message,
23
- continue: true,
24
- ...(standalone ? { params: { standalone: true } } : {}),
25
- });
26
- const unknownKeyIssues = (value, allowed) => Object.keys(value)
27
- .filter((key) => !allowed.includes(key))
28
- .map((key) => ({ path: [key], message: "is not a recognized key" }));
29
- const requireName = (value) => typeof value === "string" && value.length > 0;
30
- const collectPropArgIssues = (value) => {
31
- const issues = unknownKeyIssues(value, ["prop"]);
32
- if (!requireName(value.prop))
33
- issues.push({ path: ["prop"], message: NAME_MESSAGE });
34
- return issues;
35
- };
36
- const collectFieldArgIssues = (value) => {
37
- const issues = unknownKeyIssues(value, ["field", "or"]);
38
- if (!requireName(value.field))
39
- issues.push({ path: ["field"], message: NAME_MESSAGE });
40
- if ("or" in value && !isJsonValue(value.or))
41
- issues.push({ path: ["or"], message: JSON_MESSAGE });
42
- return issues;
43
- };
44
- const collectLiteralArgIssues = (value) => {
45
- const issues = unknownKeyIssues(value, ["literal"]);
46
- if (!isJsonValue(value.literal))
47
- issues.push({ path: ["literal"], message: JSON_MESSAGE });
48
- return issues;
49
- };
50
- const collectArgIssues = (value) => {
51
- if (typeof value === "string") {
52
- return ARG_REF_SET.has(value) ? [] : [{ path: [], message: `has unknown reference "${value}"` }];
53
- }
54
- if (!isRecord(value))
55
- return [{ path: [], message: ARG_MESSAGE }];
56
- if ("prop" in value)
57
- return collectPropArgIssues(value);
58
- if ("field" in value)
59
- return collectFieldArgIssues(value);
60
- if ("literal" in value)
61
- return collectLiteralArgIssues(value);
62
- return [{ path: [], message: ARG_MESSAGE }];
63
- };
64
- const collectArgsIssues = (args) => args.flatMap((arg, index) => collectArgIssues(arg).map((issue) => ({ path: ["args", index, ...issue.path], message: issue.message })));
65
- const collectCallIssues = (value) => {
66
- if (typeof value === "string")
67
- return value.length === 0 ? [{ path: [], message: NAME_MESSAGE }] : [];
68
- if (!isRecord(value))
69
- return [{ path: [], message: "must be an object" }];
70
- const issues = unknownKeyIssues(value, ["method", "args"]);
71
- if (!requireName(value.method))
72
- issues.push({ path: ["method"], message: NAME_MESSAGE });
73
- if (!Array.isArray(value.args))
74
- issues.push({ path: ["args"], message: "must be an array" });
75
- else
76
- issues.push(...collectArgsIssues(value.args));
77
- return issues;
78
- };
79
- const callSchema = z.custom().check((ctx) => {
80
- ctx.issues.push(...collectCallIssues(ctx.value).map((issue) => rawIssue(ctx.value, issue.path, issue.message)));
81
- });
82
- const nameSchema = z.string({ error: NAME_MESSAGE }).min(1, { error: NAME_MESSAGE });
83
- const adoptSchema = z.union([z.literal(true), nameSchema], {
84
- error: "must be `true` or the name of a getter method",
85
- });
86
- const containerSchema = z.strictObject({
87
- kind: z.literal("container"),
88
- prop: nameSchema,
89
- child: nameSchema,
90
- append: callSchema.optional(),
91
- remove: callSchema.optional(),
92
- insert: callSchema.optional(),
93
- reorder: callSchema.optional(),
94
- autowrap: nameSchema.optional(),
95
- adopt: adoptSchema.optional(),
96
- });
97
- const valueSchema = z.strictObject({
98
- kind: z.literal("value"),
99
- prop: nameSchema,
100
- call: callSchema,
101
- after: nameSchema.optional(),
102
- });
103
- const controlledTextSchema = z.strictObject({
104
- kind: z.literal("controlled-text"),
105
- prop: nameSchema,
106
- });
107
- const lazySchema = z.strictObject({
108
- kind: z.literal("lazy"),
109
- prop: nameSchema,
110
- lookup: nameSchema.optional(),
111
- });
112
- const listSchema = z.strictObject({
113
- kind: z.literal("list"),
114
- prop: nameSchema,
115
- add: z.union([callSchema, z.array(callSchema).min(1)]),
116
- remove: callSchema.optional(),
117
- clear: callSchema.optional(),
118
- });
119
- const elementPropSchema = z
120
- .discriminatedUnion("kind", [containerSchema, valueSchema, controlledTextSchema, lazySchema, listSchema], {
121
- error: "must be one of container, value, controlled-text, lazy, list",
122
- })
123
- .check((ctx) => {
124
- const prop = ctx.value;
125
- if (prop.kind === "container" && prop.append === undefined && prop.remove === undefined) {
126
- ctx.issues.push(rawIssue(prop, [], "must define at least one of `append` or `remove`"));
127
- }
128
- });
129
- export const elementPropsSchema = z.record(nameSchema, z.array(elementPropSchema));
130
- const CONFIG_PREFIX = "gtkx.config.ts:";
131
- const dottedPath = (segments) => segments.reduce((acc, segment) => {
132
- if (typeof segment === "number")
133
- return `${acc}[${segment}]`;
134
- return acc === "" ? String(segment) : `${acc}.${String(segment)}`;
135
- }, "");
136
- const isStandaloneIssue = (issue) => "params" in issue && isRecord(issue.params) && issue.params.standalone === true;
137
- const formatIssue = (issue, fullPath) => {
138
- if (issue.code === "unrecognized_keys") {
139
- const [key] = issue.keys;
140
- const path = dottedPath(key === undefined ? fullPath : [...fullPath, key]);
141
- return `${CONFIG_PREFIX} \`${path}\` is not a recognized key`;
142
- }
143
- if (isStandaloneIssue(issue))
144
- return `${CONFIG_PREFIX} ${issue.message}`;
145
- const path = dottedPath(fullPath);
146
- return path === "" ? `${CONFIG_PREFIX} ${issue.message}` : `${CONFIG_PREFIX} \`${path}\` ${issue.message}`;
147
- };
148
- export const configError = (error) => {
149
- const issue = error.issues[0];
150
- if (issue === undefined)
151
- return new Error(`${CONFIG_PREFIX} invalid configuration`);
152
- return new Error(formatIssue(issue, issue.path));
153
- };
154
- //# sourceMappingURL=element-props.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"element-props.js","sourceRoot":"","sources":["../src/element-props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,CAAU,CAAC;AAwB3E,MAAM,YAAY,GAAG,4BAA4B,CAAC;AAElD,MAAM,YAAY,GAAG,mCAAmC,CAAC;AAEzD,MAAM,WAAW,GAAG,kEAAkE,CAAC;AAEvF,MAAM,WAAW,GAAgB,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;AAEnD,MAAM,CAAC,MAAM,QAAQ,GAAG,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EAAE,CAAC,CAAC,CAAC,GAAG,aAAa,MAAM,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;AAC/G,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAiB,EAAS,EAAE;IACpD,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9B,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,KAAK,CAAC,GAAG,aAAa,wBAAwB,CAAC,CAAC;IACpF,OAAO,IAAI,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AACrD,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\n\nconst ARG_REFS = [\"child\", \"item\", \"index\", \"sibling\", \"adopted\"] as const;\n\ntype JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };\n\n/**\n * Named reference to a value available while invoking a {@link Call}: the child\n * widget, the current list item, its index, the preceding sibling, or the\n * adopted instance a container returned for the child.\n */\nexport type ArgRef = (typeof ARG_REFS)[number];\n\n/**\n * A single argument passed to a method {@link Call}: an {@link ArgRef}, a value\n * read from a React prop (`{ prop }`), a field read off the current item with an\n * optional fallback (`{ field, or }`), or a constant (`{ literal }`).\n */\nexport type Arg = ArgRef | { prop: string } | { field: string; or?: JsonValue } | { literal: JsonValue };\n\n/**\n * A GObject method invocation: either a bare method name called with default\n * arguments, or a method name paired with an explicit list of {@link Arg}s.\n */\nexport type Call = string | { method: string; args: Arg[] };\n\nconst NAME_MESSAGE = \"must be a non-empty string\";\n\nconst JSON_MESSAGE = \"must be a JSON-serializable value\";\n\nconst ARG_MESSAGE = \"must be one of: reference name, { prop }, { field }, { literal }\";\n\nconst ARG_REF_SET: Set<string> = new Set(ARG_REFS);\n\nexport const isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isJsonValue = (value: unknown): boolean => {\n if (value === null || typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n return true;\n }\n if (Array.isArray(value)) return value.every(isJsonValue);\n if (isRecord(value)) return Object.values(value).every(isJsonValue);\n return false;\n};\n\ntype IssuePath = Array<string | number>;\n\ntype CollectedIssue = { path: IssuePath; message: string };\n\nexport const rawIssue = (input: unknown, path: IssuePath, message: string, standalone = false) => ({\n code: \"custom\" as const,\n input,\n path,\n message,\n continue: true as const,\n ...(standalone ? { params: { standalone: true } } : {}),\n});\n\nconst unknownKeyIssues = (value: Record<string, unknown>, allowed: string[]): CollectedIssue[] =>\n Object.keys(value)\n .filter((key) => !allowed.includes(key))\n .map((key) => ({ path: [key], message: \"is not a recognized key\" }));\n\nconst requireName = (value: unknown): boolean => typeof value === \"string\" && value.length > 0;\n\nconst collectPropArgIssues = (value: Record<string, unknown>): CollectedIssue[] => {\n const issues = unknownKeyIssues(value, [\"prop\"]);\n if (!requireName(value.prop)) issues.push({ path: [\"prop\"], message: NAME_MESSAGE });\n return issues;\n};\n\nconst collectFieldArgIssues = (value: Record<string, unknown>): CollectedIssue[] => {\n const issues = unknownKeyIssues(value, [\"field\", \"or\"]);\n if (!requireName(value.field)) issues.push({ path: [\"field\"], message: NAME_MESSAGE });\n if (\"or\" in value && !isJsonValue(value.or)) issues.push({ path: [\"or\"], message: JSON_MESSAGE });\n return issues;\n};\n\nconst collectLiteralArgIssues = (value: Record<string, unknown>): CollectedIssue[] => {\n const issues = unknownKeyIssues(value, [\"literal\"]);\n if (!isJsonValue(value.literal)) issues.push({ path: [\"literal\"], message: JSON_MESSAGE });\n return issues;\n};\n\nconst collectArgIssues = (value: unknown): CollectedIssue[] => {\n if (typeof value === \"string\") {\n return ARG_REF_SET.has(value) ? [] : [{ path: [], message: `has unknown reference \"${value}\"` }];\n }\n if (!isRecord(value)) return [{ path: [], message: ARG_MESSAGE }];\n if (\"prop\" in value) return collectPropArgIssues(value);\n if (\"field\" in value) return collectFieldArgIssues(value);\n if (\"literal\" in value) return collectLiteralArgIssues(value);\n return [{ path: [], message: ARG_MESSAGE }];\n};\n\nconst collectArgsIssues = (args: unknown[]): CollectedIssue[] =>\n args.flatMap((arg, index) =>\n collectArgIssues(arg).map((issue) => ({ path: [\"args\", index, ...issue.path], message: issue.message })),\n );\n\nconst collectCallIssues = (value: unknown): CollectedIssue[] => {\n if (typeof value === \"string\") return value.length === 0 ? [{ path: [], message: NAME_MESSAGE }] : [];\n if (!isRecord(value)) return [{ path: [], message: \"must be an object\" }];\n const issues = unknownKeyIssues(value, [\"method\", \"args\"]);\n if (!requireName(value.method)) issues.push({ path: [\"method\"], message: NAME_MESSAGE });\n if (!Array.isArray(value.args)) issues.push({ path: [\"args\"], message: \"must be an array\" });\n else issues.push(...collectArgsIssues(value.args));\n return issues;\n};\n\nconst callSchema = z.custom<Call>().check((ctx) => {\n ctx.issues.push(...collectCallIssues(ctx.value).map((issue) => rawIssue(ctx.value, issue.path, issue.message)));\n});\n\nconst nameSchema = z.string({ error: NAME_MESSAGE }).min(1, { error: NAME_MESSAGE });\n\nconst adoptSchema = z.union([z.literal(true), nameSchema], {\n error: \"must be `true` or the name of a getter method\",\n});\n\nconst containerSchema = z.strictObject({\n kind: z.literal(\"container\"),\n prop: nameSchema,\n child: nameSchema,\n append: callSchema.optional(),\n remove: callSchema.optional(),\n insert: callSchema.optional(),\n reorder: callSchema.optional(),\n autowrap: nameSchema.optional(),\n adopt: adoptSchema.optional(),\n});\n\nconst valueSchema = z.strictObject({\n kind: z.literal(\"value\"),\n prop: nameSchema,\n call: callSchema,\n after: nameSchema.optional(),\n});\n\nconst controlledTextSchema = z.strictObject({\n kind: z.literal(\"controlled-text\"),\n prop: nameSchema,\n});\n\nconst lazySchema = z.strictObject({\n kind: z.literal(\"lazy\"),\n prop: nameSchema,\n lookup: nameSchema.optional(),\n});\n\nconst listSchema = z.strictObject({\n kind: z.literal(\"list\"),\n prop: nameSchema,\n add: z.union([callSchema, z.array(callSchema).min(1)]),\n remove: callSchema.optional(),\n clear: callSchema.optional(),\n});\n\nconst elementPropSchema = z\n .discriminatedUnion(\"kind\", [containerSchema, valueSchema, controlledTextSchema, lazySchema, listSchema], {\n error: \"must be one of container, value, controlled-text, lazy, list\",\n })\n .check((ctx) => {\n const prop = ctx.value;\n if (prop.kind === \"container\" && prop.append === undefined && prop.remove === undefined) {\n ctx.issues.push(rawIssue(prop, [], \"must define at least one of `append` or `remove`\"));\n }\n });\n\nexport const elementPropsSchema = z.record(nameSchema, z.array(elementPropSchema));\n\n/**\n * Rule describing how children of a given type are attached to and removed from a\n * container element. `prop` is the React prop holding the children and `child` the\n * child GObject type. `append`/`remove` add and remove a child, `insert` places\n * one at an index or after a sibling, `reorder` moves an existing child, `autowrap`\n * names a widget type each child is wrapped in before attaching, and `adopt` marks\n * pre-existing children as adopted (`true`) or names the getter returning them.\n */\nexport type ContainerProp = z.infer<typeof containerSchema>;\n\n/**\n * Rule that applies a scalar prop value by invoking `call` whenever the value\n * changes, optionally running the method named by `after` once it is set.\n */\nexport type ValueProp = z.infer<typeof valueSchema>;\n\n/**\n * Rule for a controlled text prop: `prop` is written directly to the GObject\n * property and kept in sync with the element's own edits.\n */\nexport type ControlledTextProp = z.infer<typeof controlledTextSchema>;\n\n/**\n * Rule for a prop applied after construction rather than at construction time,\n * optionally guarded by `lookup`, a method that must succeed for the value before\n * it is assigned.\n */\nexport type LazyProp = z.infer<typeof lazySchema>;\n\n/**\n * Rule mapping an array prop to method calls: `add` runs per added item (a single\n * call, or a sequence of calls applied in order when one item needs several), `remove`\n * per removed item, and `clear` empties the collection before re-adding.\n */\nexport type ListProp = z.infer<typeof listSchema>;\n\n/**\n * Any prop rule applied directly to an element instance rather than through\n * container child attachment: a {@link ValueProp}, {@link ControlledTextProp},\n * {@link LazyProp}, or {@link ListProp}.\n */\nexport type AppliedProp = ValueProp | ControlledTextProp | LazyProp | ListProp;\n\n/**\n * A single entry in an element's prop mapping, discriminated by `kind`: a\n * container, value, controlled-text, lazy, or list rule.\n */\nexport type ElementProp = z.infer<typeof elementPropSchema>;\n\nconst CONFIG_PREFIX = \"gtkx.config.ts:\";\n\nconst dottedPath = (segments: PropertyKey[]): string =>\n segments.reduce<string>((acc, segment) => {\n if (typeof segment === \"number\") return `${acc}[${segment}]`;\n return acc === \"\" ? String(segment) : `${acc}.${String(segment)}`;\n }, \"\");\n\nconst isStandaloneIssue = (issue: z.core.$ZodIssue): boolean =>\n \"params\" in issue && isRecord(issue.params) && issue.params.standalone === true;\n\nconst formatIssue = (issue: z.core.$ZodIssue, fullPath: PropertyKey[]): string => {\n if (issue.code === \"unrecognized_keys\") {\n const [key] = issue.keys;\n const path = dottedPath(key === undefined ? fullPath : [...fullPath, key]);\n return `${CONFIG_PREFIX} \\`${path}\\` is not a recognized key`;\n }\n if (isStandaloneIssue(issue)) return `${CONFIG_PREFIX} ${issue.message}`;\n const path = dottedPath(fullPath);\n return path === \"\" ? `${CONFIG_PREFIX} ${issue.message}` : `${CONFIG_PREFIX} \\`${path}\\` ${issue.message}`;\n};\n\nexport const configError = (error: z.ZodError): Error => {\n const issue = error.issues[0];\n if (issue === undefined) return new Error(`${CONFIG_PREFIX} invalid configuration`);\n return new Error(formatIssue(issue, issue.path));\n};\n"]}
package/env.d.ts DELETED
@@ -1,8 +0,0 @@
1
- declare module "virtual:gtkx-config" {
2
- export const SIGNALS: Record<string, Record<string, string>>;
3
- export const CONSTRUCT_ONLY_PROPS: Record<string, Set<string>>;
4
- export const CONSTRUCT_PROPS: Record<string, Set<string>>;
5
- export const DEFAULT_PROPS: Record<string, Record<string, unknown>>;
6
- export const ELEMENT_PROPS: Record<string, import("@gtkx/config").ElementProp[]>;
7
- export const applicationId: import("@gtkx/config").ResolvedConfig["applicationId"];
8
- }
@@ -1,248 +0,0 @@
1
- import { z } from "zod";
2
-
3
- const ARG_REFS = ["child", "item", "index", "sibling", "adopted"] as const;
4
-
5
- type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };
6
-
7
- /**
8
- * Named reference to a value available while invoking a {@link Call}: the child
9
- * widget, the current list item, its index, the preceding sibling, or the
10
- * adopted instance a container returned for the child.
11
- */
12
- export type ArgRef = (typeof ARG_REFS)[number];
13
-
14
- /**
15
- * A single argument passed to a method {@link Call}: an {@link ArgRef}, a value
16
- * read from a React prop (`{ prop }`), a field read off the current item with an
17
- * optional fallback (`{ field, or }`), or a constant (`{ literal }`).
18
- */
19
- export type Arg = ArgRef | { prop: string } | { field: string; or?: JsonValue } | { literal: JsonValue };
20
-
21
- /**
22
- * A GObject method invocation: either a bare method name called with default
23
- * arguments, or a method name paired with an explicit list of {@link Arg}s.
24
- */
25
- export type Call = string | { method: string; args: Arg[] };
26
-
27
- const NAME_MESSAGE = "must be a non-empty string";
28
-
29
- const JSON_MESSAGE = "must be a JSON-serializable value";
30
-
31
- const ARG_MESSAGE = "must be one of: reference name, { prop }, { field }, { literal }";
32
-
33
- const ARG_REF_SET: Set<string> = new Set(ARG_REFS);
34
-
35
- export const isRecord = (value: unknown): value is Record<string, unknown> =>
36
- typeof value === "object" && value !== null && !Array.isArray(value);
37
-
38
- const isJsonValue = (value: unknown): boolean => {
39
- if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
40
- return true;
41
- }
42
- if (Array.isArray(value)) return value.every(isJsonValue);
43
- if (isRecord(value)) return Object.values(value).every(isJsonValue);
44
- return false;
45
- };
46
-
47
- type IssuePath = Array<string | number>;
48
-
49
- type CollectedIssue = { path: IssuePath; message: string };
50
-
51
- export const rawIssue = (input: unknown, path: IssuePath, message: string, standalone = false) => ({
52
- code: "custom" as const,
53
- input,
54
- path,
55
- message,
56
- continue: true as const,
57
- ...(standalone ? { params: { standalone: true } } : {}),
58
- });
59
-
60
- const unknownKeyIssues = (value: Record<string, unknown>, allowed: string[]): CollectedIssue[] =>
61
- Object.keys(value)
62
- .filter((key) => !allowed.includes(key))
63
- .map((key) => ({ path: [key], message: "is not a recognized key" }));
64
-
65
- const requireName = (value: unknown): boolean => typeof value === "string" && value.length > 0;
66
-
67
- const collectPropArgIssues = (value: Record<string, unknown>): CollectedIssue[] => {
68
- const issues = unknownKeyIssues(value, ["prop"]);
69
- if (!requireName(value.prop)) issues.push({ path: ["prop"], message: NAME_MESSAGE });
70
- return issues;
71
- };
72
-
73
- const collectFieldArgIssues = (value: Record<string, unknown>): CollectedIssue[] => {
74
- const issues = unknownKeyIssues(value, ["field", "or"]);
75
- if (!requireName(value.field)) issues.push({ path: ["field"], message: NAME_MESSAGE });
76
- if ("or" in value && !isJsonValue(value.or)) issues.push({ path: ["or"], message: JSON_MESSAGE });
77
- return issues;
78
- };
79
-
80
- const collectLiteralArgIssues = (value: Record<string, unknown>): CollectedIssue[] => {
81
- const issues = unknownKeyIssues(value, ["literal"]);
82
- if (!isJsonValue(value.literal)) issues.push({ path: ["literal"], message: JSON_MESSAGE });
83
- return issues;
84
- };
85
-
86
- const collectArgIssues = (value: unknown): CollectedIssue[] => {
87
- if (typeof value === "string") {
88
- return ARG_REF_SET.has(value) ? [] : [{ path: [], message: `has unknown reference "${value}"` }];
89
- }
90
- if (!isRecord(value)) return [{ path: [], message: ARG_MESSAGE }];
91
- if ("prop" in value) return collectPropArgIssues(value);
92
- if ("field" in value) return collectFieldArgIssues(value);
93
- if ("literal" in value) return collectLiteralArgIssues(value);
94
- return [{ path: [], message: ARG_MESSAGE }];
95
- };
96
-
97
- const collectArgsIssues = (args: unknown[]): CollectedIssue[] =>
98
- args.flatMap((arg, index) =>
99
- collectArgIssues(arg).map((issue) => ({ path: ["args", index, ...issue.path], message: issue.message })),
100
- );
101
-
102
- const collectCallIssues = (value: unknown): CollectedIssue[] => {
103
- if (typeof value === "string") return value.length === 0 ? [{ path: [], message: NAME_MESSAGE }] : [];
104
- if (!isRecord(value)) return [{ path: [], message: "must be an object" }];
105
- const issues = unknownKeyIssues(value, ["method", "args"]);
106
- if (!requireName(value.method)) issues.push({ path: ["method"], message: NAME_MESSAGE });
107
- if (!Array.isArray(value.args)) issues.push({ path: ["args"], message: "must be an array" });
108
- else issues.push(...collectArgsIssues(value.args));
109
- return issues;
110
- };
111
-
112
- const callSchema = z.custom<Call>().check((ctx) => {
113
- ctx.issues.push(...collectCallIssues(ctx.value).map((issue) => rawIssue(ctx.value, issue.path, issue.message)));
114
- });
115
-
116
- const nameSchema = z.string({ error: NAME_MESSAGE }).min(1, { error: NAME_MESSAGE });
117
-
118
- const adoptSchema = z.union([z.literal(true), nameSchema], {
119
- error: "must be `true` or the name of a getter method",
120
- });
121
-
122
- const containerSchema = z.strictObject({
123
- kind: z.literal("container"),
124
- prop: nameSchema,
125
- child: nameSchema,
126
- append: callSchema.optional(),
127
- remove: callSchema.optional(),
128
- insert: callSchema.optional(),
129
- reorder: callSchema.optional(),
130
- autowrap: nameSchema.optional(),
131
- adopt: adoptSchema.optional(),
132
- });
133
-
134
- const valueSchema = z.strictObject({
135
- kind: z.literal("value"),
136
- prop: nameSchema,
137
- call: callSchema,
138
- after: nameSchema.optional(),
139
- });
140
-
141
- const controlledTextSchema = z.strictObject({
142
- kind: z.literal("controlled-text"),
143
- prop: nameSchema,
144
- });
145
-
146
- const lazySchema = z.strictObject({
147
- kind: z.literal("lazy"),
148
- prop: nameSchema,
149
- lookup: nameSchema.optional(),
150
- });
151
-
152
- const listSchema = z.strictObject({
153
- kind: z.literal("list"),
154
- prop: nameSchema,
155
- add: z.union([callSchema, z.array(callSchema).min(1)]),
156
- remove: callSchema.optional(),
157
- clear: callSchema.optional(),
158
- });
159
-
160
- const elementPropSchema = z
161
- .discriminatedUnion("kind", [containerSchema, valueSchema, controlledTextSchema, lazySchema, listSchema], {
162
- error: "must be one of container, value, controlled-text, lazy, list",
163
- })
164
- .check((ctx) => {
165
- const prop = ctx.value;
166
- if (prop.kind === "container" && prop.append === undefined && prop.remove === undefined) {
167
- ctx.issues.push(rawIssue(prop, [], "must define at least one of `append` or `remove`"));
168
- }
169
- });
170
-
171
- export const elementPropsSchema = z.record(nameSchema, z.array(elementPropSchema));
172
-
173
- /**
174
- * Rule describing how children of a given type are attached to and removed from a
175
- * container element. `prop` is the React prop holding the children and `child` the
176
- * child GObject type. `append`/`remove` add and remove a child, `insert` places
177
- * one at an index or after a sibling, `reorder` moves an existing child, `autowrap`
178
- * names a widget type each child is wrapped in before attaching, and `adopt` marks
179
- * pre-existing children as adopted (`true`) or names the getter returning them.
180
- */
181
- export type ContainerProp = z.infer<typeof containerSchema>;
182
-
183
- /**
184
- * Rule that applies a scalar prop value by invoking `call` whenever the value
185
- * changes, optionally running the method named by `after` once it is set.
186
- */
187
- export type ValueProp = z.infer<typeof valueSchema>;
188
-
189
- /**
190
- * Rule for a controlled text prop: `prop` is written directly to the GObject
191
- * property and kept in sync with the element's own edits.
192
- */
193
- export type ControlledTextProp = z.infer<typeof controlledTextSchema>;
194
-
195
- /**
196
- * Rule for a prop applied after construction rather than at construction time,
197
- * optionally guarded by `lookup`, a method that must succeed for the value before
198
- * it is assigned.
199
- */
200
- export type LazyProp = z.infer<typeof lazySchema>;
201
-
202
- /**
203
- * Rule mapping an array prop to method calls: `add` runs per added item (a single
204
- * call, or a sequence of calls applied in order when one item needs several), `remove`
205
- * per removed item, and `clear` empties the collection before re-adding.
206
- */
207
- export type ListProp = z.infer<typeof listSchema>;
208
-
209
- /**
210
- * Any prop rule applied directly to an element instance rather than through
211
- * container child attachment: a {@link ValueProp}, {@link ControlledTextProp},
212
- * {@link LazyProp}, or {@link ListProp}.
213
- */
214
- export type AppliedProp = ValueProp | ControlledTextProp | LazyProp | ListProp;
215
-
216
- /**
217
- * A single entry in an element's prop mapping, discriminated by `kind`: a
218
- * container, value, controlled-text, lazy, or list rule.
219
- */
220
- export type ElementProp = z.infer<typeof elementPropSchema>;
221
-
222
- const CONFIG_PREFIX = "gtkx.config.ts:";
223
-
224
- const dottedPath = (segments: PropertyKey[]): string =>
225
- segments.reduce<string>((acc, segment) => {
226
- if (typeof segment === "number") return `${acc}[${segment}]`;
227
- return acc === "" ? String(segment) : `${acc}.${String(segment)}`;
228
- }, "");
229
-
230
- const isStandaloneIssue = (issue: z.core.$ZodIssue): boolean =>
231
- "params" in issue && isRecord(issue.params) && issue.params.standalone === true;
232
-
233
- const formatIssue = (issue: z.core.$ZodIssue, fullPath: PropertyKey[]): string => {
234
- if (issue.code === "unrecognized_keys") {
235
- const [key] = issue.keys;
236
- const path = dottedPath(key === undefined ? fullPath : [...fullPath, key]);
237
- return `${CONFIG_PREFIX} \`${path}\` is not a recognized key`;
238
- }
239
- if (isStandaloneIssue(issue)) return `${CONFIG_PREFIX} ${issue.message}`;
240
- const path = dottedPath(fullPath);
241
- return path === "" ? `${CONFIG_PREFIX} ${issue.message}` : `${CONFIG_PREFIX} \`${path}\` ${issue.message}`;
242
- };
243
-
244
- export const configError = (error: z.ZodError): Error => {
245
- const issue = error.issues[0];
246
- if (issue === undefined) return new Error(`${CONFIG_PREFIX} invalid configuration`);
247
- return new Error(formatIssue(issue, issue.path));
248
- };