@gjsify/gtk-host 0.41.0 → 0.44.0
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 +481 -6
- package/lib/esm/adapters/react.js +1 -0
- package/lib/esm/adapters/solid.js +1 -0
- package/lib/esm/adapters/vue.js +1 -0
- package/lib/esm/attrs.js +0 -0
- package/lib/esm/conformance/diagnostics.js +2 -2
- package/lib/esm/conformance/index.js +2 -2
- package/lib/esm/descriptors/adw.js +1 -1
- package/lib/esm/descriptors/gtk.js +1 -1
- package/lib/esm/descriptors/index.js +1 -1
- package/lib/esm/errors.js +1 -1
- package/lib/esm/generated/props.js +0 -0
- package/lib/esm/generated/widgets.js +1 -0
- package/lib/esm/host.js +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/jsx-runtime.js +1 -0
- package/lib/esm/policies.js +1 -1
- package/lib/esm/probe.js +1 -0
- package/lib/esm/props.js +1 -1
- package/lib/esm/react-jsx-runtime.js +1 -0
- package/lib/esm/registry.js +1 -1
- package/lib/esm/signals.js +1 -1
- package/lib/esm/style/errors.js +1 -0
- package/lib/esm/style/gtk-css.js +1 -0
- package/lib/esm/style/gtk-props.js +1 -0
- package/lib/esm/style/index.js +1 -0
- package/lib/esm/style/layout.js +1 -0
- package/lib/esm/style/paint.js +1 -0
- package/lib/esm/style/resolve.js +1 -0
- package/lib/esm/style/sheet.js +3 -0
- package/lib/esm/style/tokens.js +1 -0
- package/lib/esm/tags.js +2 -0
- package/lib/esm/vue-components.js +0 -0
- package/lib/types/adapters/react.d.ts +224 -0
- package/lib/types/adapters/react.spec.d.ts +2 -0
- package/lib/types/adapters/solid.d.ts +78 -0
- package/lib/types/adapters/solid.spec.d.ts +2 -0
- package/lib/types/adapters/vue.d.ts +24 -0
- package/lib/types/adapters/vue.spec.d.ts +2 -0
- package/lib/types/attrs.d.ts +102 -0
- package/lib/types/buildable.spec.d.ts +2 -0
- package/lib/types/conformance/diagnostics.d.ts +26 -2
- package/lib/types/conformance/index.d.ts +24 -1
- package/lib/types/conformance/vectors.d.mts +34 -0
- package/lib/types/descriptors/index.d.ts +52 -1
- package/lib/types/errors.d.ts +21 -0
- package/lib/types/generated/props.d.ts +5505 -0
- package/lib/types/generated/surface-data.d.mts +22 -0
- package/lib/types/generated/widgets.d.ts +3 -0
- package/lib/types/generated.spec.d.ts +4 -0
- package/lib/types/generator/emit-types.d.mts +54 -0
- package/lib/types/generator/emit.d.mts +50 -0
- package/lib/types/generator/gir.d.mts +164 -0
- package/lib/types/generator/main.d.mts +23 -0
- package/lib/types/generator/mini.fixture.d.mts +30 -0
- package/lib/types/generator/surface.d.mts +62 -0
- package/lib/types/generator/tsmap.d.mts +73 -0
- package/lib/types/generator.spec.d.ts +2 -0
- package/lib/types/host.d.ts +102 -1
- package/lib/types/index.d.ts +6 -3
- package/lib/types/jsx-runtime.d.ts +70 -0
- package/lib/types/policies.d.ts +58 -0
- package/lib/types/probe.d.ts +87 -0
- package/lib/types/props.d.ts +52 -2
- package/lib/types/react-jsx-runtime.d.ts +108 -0
- package/lib/types/registry.d.ts +1 -1
- package/lib/types/signals.d.ts +16 -1
- package/lib/types/style/errors.d.ts +6 -0
- package/lib/types/style/gtk-css.d.ts +24 -0
- package/lib/types/style/gtk-css.spec.d.ts +2 -0
- package/lib/types/style/gtk-props.d.ts +27 -0
- package/lib/types/style/gtk-props.spec.d.ts +2 -0
- package/lib/types/style/index.d.ts +13 -0
- package/lib/types/style/layout.d.ts +163 -0
- package/lib/types/style/layout.spec.d.ts +2 -0
- package/lib/types/style/paint.d.ts +53 -0
- package/lib/types/style/paint.spec.d.ts +2 -0
- package/lib/types/style/resolve.d.ts +58 -0
- package/lib/types/style/sheet.d.ts +40 -0
- package/lib/types/style/sheet.spec.d.ts +2 -0
- package/lib/types/style/tokens.d.ts +58 -0
- package/lib/types/tags.d.ts +25 -0
- package/lib/types/testing/gate.d.mts +25 -0
- package/lib/types/types.d.ts +56 -3
- package/lib/types/vue-components.d.ts +46 -0
- package/package.json +85 -8
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { type StyleTokens } from './tokens.js';
|
|
2
|
+
/** React Native's own `alignItems`/`alignSelf` vocabulary. */
|
|
3
|
+
export type AlignValue = 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline';
|
|
4
|
+
/** React Native's own `justifyContent` vocabulary. */
|
|
5
|
+
export type JustifyValue = 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly';
|
|
6
|
+
/** The four physical edges an absolutely positioned element offsets from. */
|
|
7
|
+
export type Edge = 'top' | 'right' | 'bottom' | 'left';
|
|
8
|
+
/**
|
|
9
|
+
* The properties the layout half understands, in React Native's spelling.
|
|
10
|
+
*
|
|
11
|
+
* The VALUES are React Native's too — `alignItems: 'flex-start'`, not `'start'` —
|
|
12
|
+
* and that is the point of ADR 0032 § 4 rather than a detail. A class list and a
|
|
13
|
+
* `style={{…}}` object are one information set arriving by two routes, and 48 of
|
|
14
|
+
* the measured application's 57 style objects carry exactly these names and values.
|
|
15
|
+
* Normalising the classes into a third spelling would put a translation table
|
|
16
|
+
* between the two front ends and give the partition two truths to keep in step.
|
|
17
|
+
*/
|
|
18
|
+
export interface LayoutProps {
|
|
19
|
+
marginTop?: string;
|
|
20
|
+
marginRight?: string;
|
|
21
|
+
marginBottom?: string;
|
|
22
|
+
marginLeft?: string;
|
|
23
|
+
marginStart?: string;
|
|
24
|
+
marginEnd?: string;
|
|
25
|
+
paddingTop?: string;
|
|
26
|
+
paddingRight?: string;
|
|
27
|
+
paddingBottom?: string;
|
|
28
|
+
paddingLeft?: string;
|
|
29
|
+
flexDirection?: 'row' | 'column';
|
|
30
|
+
flexGrow?: string;
|
|
31
|
+
alignItems?: AlignValue;
|
|
32
|
+
justifyContent?: JustifyValue;
|
|
33
|
+
alignSelf?: AlignValue;
|
|
34
|
+
gap?: string;
|
|
35
|
+
columnGap?: string;
|
|
36
|
+
rowGap?: string;
|
|
37
|
+
width?: string;
|
|
38
|
+
height?: string;
|
|
39
|
+
overflow?: 'visible' | 'hidden' | 'scroll';
|
|
40
|
+
display?: 'flex' | 'none';
|
|
41
|
+
position?: 'relative' | 'absolute';
|
|
42
|
+
top?: string;
|
|
43
|
+
right?: string;
|
|
44
|
+
bottom?: string;
|
|
45
|
+
left?: string;
|
|
46
|
+
textAlign?: 'left' | 'center' | 'right' | 'justify';
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* What L1 could not answer, for L2 to resolve against the shadow tree.
|
|
50
|
+
*
|
|
51
|
+
* Every field here is a case where the same input compiles to DIFFERENT GTK
|
|
52
|
+
* depending on something no per-element function can see. Nothing is an intent for
|
|
53
|
+
* being hard: `overflow-hidden` needs the parent no more than `bg-red` does, and it
|
|
54
|
+
* is a widget property below rather than a field here.
|
|
55
|
+
*/
|
|
56
|
+
export interface LayoutIntent {
|
|
57
|
+
/**
|
|
58
|
+
* `flex-1` — `hexpand` on a row, `vexpand` on a column.
|
|
59
|
+
*
|
|
60
|
+
* ADR 0032 § 6, and the reason the intent mechanism exists at all: the axis is
|
|
61
|
+
* the PARENT's orientation, which an element does not know about itself.
|
|
62
|
+
*/
|
|
63
|
+
readonly expand?: 'main-axis';
|
|
64
|
+
/**
|
|
65
|
+
* `items-*` — the cross-axis alignment of every CHILD.
|
|
66
|
+
*
|
|
67
|
+
* Two things missing at once. GTK has no `align-items`: the alignment lives on
|
|
68
|
+
* each child as `halign`/`valign`, so L2 must walk children this function has
|
|
69
|
+
* never seen. And WHICH of the two it is depends on this element's own
|
|
70
|
+
* orientation, which is `Gtk.Box`'s default when no `flex-row`/`flex-col` says
|
|
71
|
+
* otherwise — and the defaults disagree (`Gtk.Box` is horizontal, a React
|
|
72
|
+
* Native `View` is a column), so there is not even a safe fallback to guess.
|
|
73
|
+
*/
|
|
74
|
+
readonly alignChildren?: AlignValue;
|
|
75
|
+
/**
|
|
76
|
+
* `justify-*` — main-axis distribution.
|
|
77
|
+
*
|
|
78
|
+
* `space-between` is a WIDGET CHOICE, not a property: `Gtk.CenterBox` for two or
|
|
79
|
+
* three children and a named refusal beyond that (ADR 0032 § 6). The child count
|
|
80
|
+
* decides, and L1 has no children. The other three are the box's own
|
|
81
|
+
* `halign`/`valign`, which needs the orientation for the same reason
|
|
82
|
+
* {@link LayoutIntent.alignChildren} does.
|
|
83
|
+
*/
|
|
84
|
+
readonly distribute?: JustifyValue;
|
|
85
|
+
/**
|
|
86
|
+
* `self-*` — this element's own cross-axis alignment.
|
|
87
|
+
*
|
|
88
|
+
* `halign` or `valign` by the PARENT's orientation. Same shape as
|
|
89
|
+
* {@link LayoutIntent.expand}, same reason, one axis over.
|
|
90
|
+
*/
|
|
91
|
+
readonly alignSelf?: AlignValue;
|
|
92
|
+
/**
|
|
93
|
+
* `gap-x-*` / `gap-y-*` — a spacing that is only valid on one orientation.
|
|
94
|
+
*
|
|
95
|
+
* `Gtk.Box` has ONE `spacing` (measured), so an axis-qualified gap is either
|
|
96
|
+
* that spacing or nothing at all, and which it is depends on the orientation
|
|
97
|
+
* L1 cannot see. Refusing the spelling outright was the alternative and is
|
|
98
|
+
* worse: `gap-x-2` on a row is ordinary, unambiguous authoring, and L2 answers
|
|
99
|
+
* it exactly.
|
|
100
|
+
*/
|
|
101
|
+
readonly axisSpacing?: {
|
|
102
|
+
readonly axis: 'horizontal' | 'vertical';
|
|
103
|
+
readonly pixels: number;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* `absolute` / `relative` / `inset-*` / `top-*` — the parent must be a `Gtk.Overlay`.
|
|
107
|
+
*
|
|
108
|
+
* A widget cannot make its own parent a different class, so the child's
|
|
109
|
+
* `absolute` is a request L2 executes on the PARENT. The `context` role is
|
|
110
|
+
* `relative`'s: it sets nothing (an overlay establishes the context by being
|
|
111
|
+
* one) but it is carried rather than dropped, because it is the half of the
|
|
112
|
+
* pair L2 can hold the other half against — an `absolute` child under a parent
|
|
113
|
+
* that never declared `relative` is a real authoring bug, and a dropped
|
|
114
|
+
* `relative` would make it undetectable.
|
|
115
|
+
*/
|
|
116
|
+
readonly overlay?: OverlayIntent;
|
|
117
|
+
/**
|
|
118
|
+
* `text-*` — only a text widget aligns text.
|
|
119
|
+
*
|
|
120
|
+
* `xalign` and `justify` are `Gtk.Label`'s; `Gtk.Box` has neither (measured).
|
|
121
|
+
* A `<View className="text-center">` wrapping a `<Text>` is ordinary React
|
|
122
|
+
* Native, and on GTK the property has to travel to the label, which is a tree
|
|
123
|
+
* walk and therefore L2's.
|
|
124
|
+
*/
|
|
125
|
+
readonly textAlign?: 'left' | 'center' | 'right' | 'justify';
|
|
126
|
+
}
|
|
127
|
+
export type OverlayIntent = {
|
|
128
|
+
readonly role: 'context';
|
|
129
|
+
} | {
|
|
130
|
+
readonly role: 'child';
|
|
131
|
+
readonly edges: Readonly<Partial<Record<Edge, number>>>;
|
|
132
|
+
};
|
|
133
|
+
/** What {@link partitionLayout} contributes to the partition. */
|
|
134
|
+
export interface LayoutPartition {
|
|
135
|
+
readonly css: readonly string[];
|
|
136
|
+
readonly props: Readonly<Record<string, unknown>>;
|
|
137
|
+
readonly intent: LayoutIntent;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* One utility class → the layout properties it sets, or `null` for "not mine".
|
|
141
|
+
*
|
|
142
|
+
* `null` rather than a throw is what lets `resolve.ts` try both halves without
|
|
143
|
+
* either of them knowing the other exists. A family this half DOES own with a bad
|
|
144
|
+
* token still throws, and that distinction is the whole point: `flex-2` is a
|
|
145
|
+
* refusal with a reason, `wibble-3` is an unknown name.
|
|
146
|
+
*/
|
|
147
|
+
export declare function resolveLayoutUtility(utility: string, tokens: StyleTokens): LayoutProps | null;
|
|
148
|
+
/**
|
|
149
|
+
* The {@link LayoutProps} keys, for the dispatch's ownership test.
|
|
150
|
+
*
|
|
151
|
+
* DERIVED from the route table rather than listed: a second list is a second thing
|
|
152
|
+
* to keep true, and the one that drifts is the one that decides whether a property
|
|
153
|
+
* is routed at all.
|
|
154
|
+
*/
|
|
155
|
+
export declare const LAYOUT_PROPERTIES: ReadonlySet<string>;
|
|
156
|
+
/**
|
|
157
|
+
* Layout properties → `{ css, props, intent }`.
|
|
158
|
+
*
|
|
159
|
+
* The two cross-key refusals run first, because both are cases where every
|
|
160
|
+
* individual property is fine and the COMBINATION is what GTK cannot express.
|
|
161
|
+
* They are the reason this is not a per-property `map`.
|
|
162
|
+
*/
|
|
163
|
+
export declare function partitionLayout(props: LayoutProps): LayoutPartition;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type StyleTokens } from './tokens.js';
|
|
2
|
+
/** The properties the paint half understands, in React Native's spelling. */
|
|
3
|
+
export interface PaintProps {
|
|
4
|
+
backgroundColor?: string;
|
|
5
|
+
color?: string;
|
|
6
|
+
opacity?: string;
|
|
7
|
+
borderRadius?: string;
|
|
8
|
+
borderTopLeftRadius?: string;
|
|
9
|
+
borderTopRightRadius?: string;
|
|
10
|
+
borderBottomLeftRadius?: string;
|
|
11
|
+
borderBottomRightRadius?: string;
|
|
12
|
+
borderWidth?: string;
|
|
13
|
+
borderTopWidth?: string;
|
|
14
|
+
borderRightWidth?: string;
|
|
15
|
+
borderBottomWidth?: string;
|
|
16
|
+
borderLeftWidth?: string;
|
|
17
|
+
borderColor?: string;
|
|
18
|
+
fontSize?: string;
|
|
19
|
+
fontWeight?: string;
|
|
20
|
+
fontFamily?: string;
|
|
21
|
+
fontStyle?: string;
|
|
22
|
+
letterSpacing?: string;
|
|
23
|
+
lineHeight?: string;
|
|
24
|
+
textDecorationLine?: string;
|
|
25
|
+
textTransform?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* React Native property name → the GTK CSS property it becomes.
|
|
29
|
+
*
|
|
30
|
+
* Exported so `paint.spec.ts` can assert the invariant this table rests on — that
|
|
31
|
+
* every value is a property GTK measurably accepts — directly, rather than through
|
|
32
|
+
* `partition`'s per-call guard, which no input can reach while the table is right.
|
|
33
|
+
*/
|
|
34
|
+
export declare const CSS_NAME: Readonly<Record<keyof PaintProps, string>>;
|
|
35
|
+
/**
|
|
36
|
+
* One utility class → the paint properties it sets, or `null` for "not mine".
|
|
37
|
+
*
|
|
38
|
+
* Returns a partial record rather than mutating, so a caller can see what a single
|
|
39
|
+
* class contributed — which is what makes the last-wins rule testable.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolvePaintUtility(utility: string, tokens: StyleTokens): PaintProps | null;
|
|
42
|
+
/** The {@link PaintProps} keys, for the dispatch's ownership test. */
|
|
43
|
+
export declare const PAINT_PROPERTIES: ReadonlySet<string>;
|
|
44
|
+
/**
|
|
45
|
+
* Paint properties → GTK CSS declarations.
|
|
46
|
+
*
|
|
47
|
+
* Every emitted name is checked against the MEASURED accepted set rather than
|
|
48
|
+
* trusted: a property this table maps but GTK does not accept would be dropped by
|
|
49
|
+
* GTK's parser with no diagnostic, which is the exact silence the whole partition
|
|
50
|
+
* exists to avoid. The check is cheap and it has caught the one property that looks
|
|
51
|
+
* like paint and is not.
|
|
52
|
+
*/
|
|
53
|
+
export declare function partitionPaint(props: PaintProps): readonly string[];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type LayoutIntent, type LayoutProps } from './layout.js';
|
|
2
|
+
import { type PaintProps } from './paint.js';
|
|
3
|
+
import type { StyleTokens } from './tokens.js';
|
|
4
|
+
/** One normalised property set, in React Native's spelling (ADR 0032 § 4). */
|
|
5
|
+
export type StyleProps = PaintProps & LayoutProps;
|
|
6
|
+
/** What the partition hands back — GTK's three destinations, all of them. */
|
|
7
|
+
export interface Partitioned {
|
|
8
|
+
/** GTK CSS declarations, `property: value`, without the braces. */
|
|
9
|
+
readonly css: readonly string[];
|
|
10
|
+
/**
|
|
11
|
+
* Widget properties in GTK's own spelling, with values the host will apply.
|
|
12
|
+
*
|
|
13
|
+
* The values are what `applyProps` coerces through the ParamSpec — a nick for
|
|
14
|
+
* an enum, a boolean for a boolean, an integer for a `gint`. NOT what a raw
|
|
15
|
+
* GJS setter accepts: `box.orientation = 'vertical'` keeps HORIZONTAL with no
|
|
16
|
+
* diagnostic at all (measured, gjs 1.88.1), which is the whole reason the host
|
|
17
|
+
* has a coercion step.
|
|
18
|
+
*/
|
|
19
|
+
readonly props: Readonly<Record<string, unknown>>;
|
|
20
|
+
/** What only the shadow tree can answer, for L2 at attach time. */
|
|
21
|
+
readonly intent: LayoutIntent;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* One utility class → the properties it sets.
|
|
25
|
+
*
|
|
26
|
+
* Paint runs first, and the order is not arbitrary: the paint families are closed
|
|
27
|
+
* sets of scale names, so its `null` is a cheap "no such family here", while the
|
|
28
|
+
* layout half owns the open-ended spellings (`gap-x-4`, `w-1/2`) whose parsing is
|
|
29
|
+
* where a wrong claim would be expensive.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveUtility(utility: string, tokens: StyleTokens): StyleProps;
|
|
32
|
+
/**
|
|
33
|
+
* A class list → the properties it sets, later classes winning.
|
|
34
|
+
*
|
|
35
|
+
* Last-wins is CSS's own rule for equal specificity and the one authors expect from
|
|
36
|
+
* a utility vocabulary. It is done HERE, on the property record, rather than by
|
|
37
|
+
* emitting two declarations and letting GTK resolve them — GTK resolves equal
|
|
38
|
+
* specificity by SHEET ORDER, not by the order of names in `css-classes`, so
|
|
39
|
+
* "the later class wins" would be false the moment two generated classes met.
|
|
40
|
+
*
|
|
41
|
+
* It is also why `m-*` puts its horizontal half in the same KEYS as `mx-*`: two
|
|
42
|
+
* spellings of one edge only resolve by last-wins while they are one key.
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveUtilities(utilities: readonly string[], tokens: StyleTokens): StyleProps;
|
|
45
|
+
/**
|
|
46
|
+
* Properties → `{ css, props, intent }`.
|
|
47
|
+
*
|
|
48
|
+
* Splits the record by ownership and hands each half to its own partition, because
|
|
49
|
+
* the layout half's refusals are CROSS-KEY (a physical and a logical margin
|
|
50
|
+
* together, two gap spellings at once) and it can only see them with its whole
|
|
51
|
+
* share in hand.
|
|
52
|
+
*
|
|
53
|
+
* A property NEITHER half routes throws rather than being skipped. That is the same
|
|
54
|
+
* rule as an unknown utility, one layer down, and it is the one that catches a
|
|
55
|
+
* `style={{…}}` object carrying a React Native property nobody has mapped yet —
|
|
56
|
+
* the front end with no class name to check.
|
|
57
|
+
*/
|
|
58
|
+
export declare function partition(props: StyleProps): Partitioned;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import Gdk from 'gi://Gdk?version=4.0';
|
|
2
|
+
/** A variant this sheet knows how to express, and the pseudo-class it becomes. */
|
|
3
|
+
export declare const VARIANT_PSEUDO: Readonly<Record<string, string>>;
|
|
4
|
+
/** A rule GTK refused, or one that would have poisoned the document. */
|
|
5
|
+
export declare class StyleSheetError extends Error {
|
|
6
|
+
readonly name = "StyleSheetError";
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
9
|
+
export interface StyleSheetOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Where the provider is installed. Omitted means the default display — the
|
|
12
|
+
* right answer for an application and the wrong one for a test, which is why
|
|
13
|
+
* it is injectable at all.
|
|
14
|
+
*/
|
|
15
|
+
readonly display?: Gdk.Display | null;
|
|
16
|
+
/** Provider priority. Defaults to `STYLE_PROVIDER_PRIORITY_APPLICATION`. */
|
|
17
|
+
readonly priority?: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class StyleSheet {
|
|
20
|
+
#private;
|
|
21
|
+
constructor(options?: StyleSheetOptions);
|
|
22
|
+
/**
|
|
23
|
+
* Register `declarations` (and optional variants) and return their class name.
|
|
24
|
+
*
|
|
25
|
+
* Idempotent: the same declarations always yield the same name and the document
|
|
26
|
+
* gains nothing the second time.
|
|
27
|
+
*/
|
|
28
|
+
classFor(declarations: readonly string[], variants?: Readonly<Record<string, readonly string[]>>): string;
|
|
29
|
+
/** The document as GTK sees it. Exposed because a test that cannot read it proves nothing. */
|
|
30
|
+
toString(): string;
|
|
31
|
+
/** How many distinct rules the document holds. */
|
|
32
|
+
get size(): number;
|
|
33
|
+
/**
|
|
34
|
+
* Load the document now, rather than on the next microtask.
|
|
35
|
+
*
|
|
36
|
+
* A test has no microtask checkpoint it can rely on, and an application that is
|
|
37
|
+
* about to present a window wants the styles already in place.
|
|
38
|
+
*/
|
|
39
|
+
flush(): void;
|
|
40
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** A scale: token name → the CSS value it stands for. */
|
|
2
|
+
export type Scale = Readonly<Record<string, string>>;
|
|
3
|
+
/**
|
|
4
|
+
* Every scale the partition consults.
|
|
5
|
+
*
|
|
6
|
+
* All optional: a project that has no `letterSpacing` scale simply has no
|
|
7
|
+
* `tracking-*` utilities, and asking for one is an error naming the empty scale
|
|
8
|
+
* rather than a silent no-op.
|
|
9
|
+
*/
|
|
10
|
+
export interface StyleTokens {
|
|
11
|
+
/**
|
|
12
|
+
* The one scale `m-*`, `p-*`, `gap-*`, `inset-*` and the edge utilities read.
|
|
13
|
+
*
|
|
14
|
+
* ONE scale for all of them because that is what a token file actually holds —
|
|
15
|
+
* `mt-2xs` and `gap-2xs` name the same 2xs — and splitting it would ask a
|
|
16
|
+
* project to repeat itself once per family.
|
|
17
|
+
*
|
|
18
|
+
* A value only reaches the WIDGET-PROPERTY channel if it is a pixel length:
|
|
19
|
+
* `margin-top` is a `gint` of device pixels (measured, `gtk-props.ts`) and GTK
|
|
20
|
+
* exposes no unit conversion there. A scale spelled in `rem` therefore still
|
|
21
|
+
* works for padding, which is CSS-only, and is a named error on a margin rather
|
|
22
|
+
* than a silently rounded one.
|
|
23
|
+
*/
|
|
24
|
+
readonly spacing?: Scale;
|
|
25
|
+
/** `w-<token>`, falling back to {@link StyleTokens.spacing} — Tailwind's own layering. */
|
|
26
|
+
readonly width?: Scale;
|
|
27
|
+
/** `h-<token>`, falling back to {@link StyleTokens.spacing}. */
|
|
28
|
+
readonly height?: Scale;
|
|
29
|
+
readonly colors?: Scale;
|
|
30
|
+
readonly borderRadius?: Scale;
|
|
31
|
+
readonly borderWidth?: Scale;
|
|
32
|
+
readonly fontSize?: Scale;
|
|
33
|
+
readonly fontWeight?: Scale;
|
|
34
|
+
readonly fontFamily?: Scale;
|
|
35
|
+
readonly letterSpacing?: Scale;
|
|
36
|
+
readonly lineHeight?: Scale;
|
|
37
|
+
readonly opacity?: Scale;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A minimal set, for tests and for a consumer who has no token file yet.
|
|
41
|
+
*
|
|
42
|
+
* Deliberately SMALL rather than a copy of Tailwind's defaults. A large default
|
|
43
|
+
* scale would let a project's typo resolve against a value nobody chose, which is
|
|
44
|
+
* the failure the declared-vocabulary rule exists to prevent — and it would make
|
|
45
|
+
* "the values come from the project" false in the common case.
|
|
46
|
+
*/
|
|
47
|
+
export declare const MINIMAL_TOKENS: StyleTokens;
|
|
48
|
+
/** A token's value, or `undefined` when the scale is absent or does not carry it. */
|
|
49
|
+
export declare const lookupToken: (scale: Scale | undefined, token: string) => string | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* A token's value, or a named error that lists what the scale DOES hold.
|
|
52
|
+
*
|
|
53
|
+
* Both halves of the partition read scales, so the reader lives with the scales
|
|
54
|
+
* rather than in whichever half needed it first. Listing the known keys is the
|
|
55
|
+
* whole value of the message: "not in the borderRadius scale" turns a typo into a
|
|
56
|
+
* search, "Known: full, lg, md, none, sm" turns it into a one-line fix.
|
|
57
|
+
*/
|
|
58
|
+
export declare function requireToken(scale: Scale | undefined, token: string, utility: string, scaleName: string): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GType name <-> kebab tag, and the map must be INJECTIVE.
|
|
3
|
+
*
|
|
4
|
+
* Two spellings exist because two dialects insist on different ones, and the
|
|
5
|
+
* difference is measured rather than chosen (ADR 0028 § 7):
|
|
6
|
+
*
|
|
7
|
+
* - JSX intrinsic elements MUST be kebab. A capitalized `JSX.IntrinsicElements`
|
|
8
|
+
* key is never consulted — `<GtkBox/>` is `TS2304: Cannot find name 'GtkBox'`,
|
|
9
|
+
* because TypeScript reads a capitalized JSX name as a value reference.
|
|
10
|
+
* - A Vue `GlobalComponents` key is the GTYPE name. Volar resolves a kebab tag
|
|
11
|
+
* to EITHER spelling but a Pascal tag only to a Pascal key, so one key covers
|
|
12
|
+
* `<gtk-box>` and `<GtkBox>` both.
|
|
13
|
+
*
|
|
14
|
+
* The GType name therefore stays the table key, the GtkBuilder XML key and the
|
|
15
|
+
* Vue key; kebab is the JSX spelling and an accepted registry alias.
|
|
16
|
+
*/
|
|
17
|
+
/** `GtkGLArea` -> `gtk-gl-area`, `AdwSpinRow` -> `adw-spin-row`, `GtkATContext` -> `gtk-at-context`. */
|
|
18
|
+
export declare function tagOf(gtype: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Refuse a table whose tags are not unique.
|
|
21
|
+
*
|
|
22
|
+
* A collision would make one of the two widgets unreachable by tag, silently —
|
|
23
|
+
* so it is an error at generation time, never a warning in a log nobody reads.
|
|
24
|
+
*/
|
|
25
|
+
export declare function assertInjective(gtypes: readonly string[]): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Runtime } from '@gjsify/unit';
|
|
2
|
+
import type { DiagnosticsGate } from '../conformance/diagnostics.js';
|
|
3
|
+
export declare const gated: (gate: DiagnosticsGate, name: string, body: () => Promise<void>) => Promise<void>;
|
|
4
|
+
/**
|
|
5
|
+
* The runtimes that can host GTK — and an IDENTITY list on purpose.
|
|
6
|
+
*
|
|
7
|
+
* These suites need a reachable GTK, not a particular interpreter, so the
|
|
8
|
+
* expressive form would be a capability (`@gjsify/unit` splits `'Display'` from
|
|
9
|
+
* `'Gl'` for exactly that reason). It is not used here, and the reason is the
|
|
10
|
+
* failure mode rather than taste.
|
|
11
|
+
*
|
|
12
|
+
* A capability can only be PROBED — nothing about `(os, env)` answers "is the Gtk
|
|
13
|
+
* typelib reachable from this process", and `@gjsify/unit` is Tier 1 and must not
|
|
14
|
+
* import `gi://` to find out. A probe that answers "no" makes the whole suite STAND
|
|
15
|
+
* DOWN, and `requireAxes` cannot catch that: it only holds axes the host MATCHES.
|
|
16
|
+
* So a container that lost its GTK would run zero tests and report success — the
|
|
17
|
+
* green-that-checked-nothing shape, arriving through the very gate meant to widen
|
|
18
|
+
* coverage. Measured once already: gated on `'Gjs'` alone, this suite built for the
|
|
19
|
+
* node target exited 0 having run 0 tests from 0 gates, 9 stood down.
|
|
20
|
+
*
|
|
21
|
+
* Named identities instead mean the suite RUNS wherever it was built, and a missing
|
|
22
|
+
* GTK dies loudly at `Gtk.init()` in the first line of each suite. Louder beats
|
|
23
|
+
* more expressive when the quiet failure is a pass.
|
|
24
|
+
*/
|
|
25
|
+
export declare const GTK_HOSTS: Runtime[];
|
package/lib/types/types.d.ts
CHANGED
|
@@ -63,14 +63,31 @@ export interface HostElement extends HostNodeBase {
|
|
|
63
63
|
* criticals per replay, at exit 0.
|
|
64
64
|
*/
|
|
65
65
|
attached: boolean;
|
|
66
|
+
/** True once `destroy` has torn this element down. It never comes back. */
|
|
67
|
+
destroyed: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Children this element already had before the host adopted it.
|
|
70
|
+
*
|
|
71
|
+
* Only an ADOPTED root has any: a renderer mounts into a container the
|
|
72
|
+
* application built, and those children are in the GTK tree while being absent
|
|
73
|
+
* from the shadow tree. Placement offsets past them, or the first insertion
|
|
74
|
+
* computes "first" and the whole rendered tree lands ABOVE the app's own chrome.
|
|
75
|
+
*/
|
|
76
|
+
foreign: readonly Gtk.Widget[];
|
|
66
77
|
}
|
|
67
78
|
export type HostNode = HostElement | HostText | HostAnchor;
|
|
68
79
|
export type PolicyKind = 'none' | 'single' | 'ordered' | 'indexed' | 'slotted' | 'keyed' | 'coords';
|
|
69
80
|
/**
|
|
70
81
|
* How a parent adopts children. GTK4 deleted `GtkContainer`, so there is no
|
|
71
|
-
* generic `add
|
|
72
|
-
* (`typeof headerBar.add_child === 'undefined'`,
|
|
73
|
-
*
|
|
82
|
+
* generic `add`. `Gtk.Buildable.add_child` is introspected as a vfunc only
|
|
83
|
+
* (`typeof headerBar.add_child === 'undefined'`, gjs 1.88.1) — but the vfunc form
|
|
84
|
+
* IS callable and DOES dispatch correctly, measured across 29 containers, so it is
|
|
85
|
+
* a real escape hatch. This comment used to claim otherwise.
|
|
86
|
+
*
|
|
87
|
+
* The table exists because the generic call is unsafe as a default, not because it
|
|
88
|
+
* is unavailable: `GtkLabel.vfunc_add_child` accepts a child and says nothing until
|
|
89
|
+
* `Finalizing GtkLabel …, but it still has children left` at teardown. Every
|
|
90
|
+
* container states its own rules here, and a widget with no rule is REFUSED.
|
|
74
91
|
*/
|
|
75
92
|
export type ChildPolicy = {
|
|
76
93
|
kind: 'none';
|
|
@@ -128,7 +145,36 @@ export type ChildPolicy = {
|
|
|
128
145
|
kind: 'coords';
|
|
129
146
|
attach: string;
|
|
130
147
|
remove: string;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Generated, not curated: the tag exists, its placement rule does not.
|
|
151
|
+
*
|
|
152
|
+
* The generated table adds every concrete GtkWidget descendant the GIR
|
|
153
|
+
* describes — 164 of them — while the curated table measures placement for a
|
|
154
|
+
* fraction. Guessing an adder for the rest would be the worst of the three
|
|
155
|
+
* options: `add` and `append` and `set_child` all exist somewhere in GTK, and
|
|
156
|
+
* calling the wrong one is a warning at exit 0.
|
|
157
|
+
*
|
|
158
|
+
* So the honest state is spelled out. Such a widget can be CREATED and given
|
|
159
|
+
* properties and handlers; inserting a child raises a named error that says
|
|
160
|
+
* which tag needs a curated policy. A leaf widget — most of the 164 — needs
|
|
161
|
+
* nothing more.
|
|
162
|
+
*/
|
|
163
|
+
| {
|
|
164
|
+
kind: 'uncurated';
|
|
131
165
|
};
|
|
166
|
+
/**
|
|
167
|
+
* One row of the GENERATED table: a tag, its GType, and how to reach the class.
|
|
168
|
+
*
|
|
169
|
+
* Deliberately not a `WidgetDescriptor`: it carries no placement rule, so making
|
|
170
|
+
* it the same type would invite a `children` field to appear here and become a
|
|
171
|
+
* second source for what `descriptors/` owns.
|
|
172
|
+
*/
|
|
173
|
+
export interface GeneratedWidget {
|
|
174
|
+
readonly gtype: string;
|
|
175
|
+
readonly tag: string;
|
|
176
|
+
readonly ctor: () => GObject.ObjectClass & (new (props?: Record<string, unknown>) => GObject.Object);
|
|
177
|
+
}
|
|
132
178
|
export interface WidgetDescriptor {
|
|
133
179
|
/** GType name — and the tag a renderer writes. `GtkButton`, `AdwActionRow`. */
|
|
134
180
|
readonly gtype: string;
|
|
@@ -142,4 +188,11 @@ export interface WidgetDescriptor {
|
|
|
142
188
|
readonly textSink?: string;
|
|
143
189
|
/** `onActivate` -> `activate` is derived; irregular pairs live here, in the TABLE. */
|
|
144
190
|
readonly eventAliases?: Readonly<Record<string, string>>;
|
|
191
|
+
/**
|
|
192
|
+
* Construct-only properties whose ABSENCE aborts the process rather than
|
|
193
|
+
* raising — see `REQUIRED_CONSTRUCT_PROPS` in `descriptors/` for the measurement.
|
|
194
|
+
* Checked in `materialize`, because after `g_object_new` there is nothing left
|
|
195
|
+
* to check with.
|
|
196
|
+
*/
|
|
197
|
+
readonly requiresProps?: readonly string[];
|
|
145
198
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Vue surface: `GlobalComponents`, keyed by GType name.
|
|
3
|
+
*
|
|
4
|
+
* Import it once, for its side effect, anywhere in a Vue project:
|
|
5
|
+
*
|
|
6
|
+
* import '@gjsify/gtk-host/vue-components';
|
|
7
|
+
*
|
|
8
|
+
* WHY GTYPE NAMES AND NOT KEBAB. Volar camelizes and capitalises a template tag
|
|
9
|
+
* before it looks the component up, so ONE `GtkBox` key answers both `<GtkBox>`
|
|
10
|
+
* and `<gtk-box>`. A kebab key answers only the kebab spelling — measured, a
|
|
11
|
+
* Pascal tag against a kebab key is TS2339. So the GType name is the key, exactly
|
|
12
|
+
* as it is the registry key and the GtkBuilder key.
|
|
13
|
+
*
|
|
14
|
+
* The exception is generated, not curated: that camelize has no acronym knowledge,
|
|
15
|
+
* so `gtk-gl-area` becomes `GtkGlArea` and misses `GtkGLArea`. Those widgets get
|
|
16
|
+
* an extra kebab key in `WidgetPropsVueAliases`, and the generator finds them by
|
|
17
|
+
* rule rather than by bug report — one today.
|
|
18
|
+
*
|
|
19
|
+
* `strictTemplates: true` IS REQUIRED, AND IT MUST BE SET IN THE BASE OF THE
|
|
20
|
+
* `extends` CHAIN. Measured on `vue-tsc@3.3.11`, four cells, all four: the BASE
|
|
21
|
+
* tsconfig's value wins and the child's is ignored outright — a base with
|
|
22
|
+
* `strictTemplates: true` stays strict under a child that sets `false`, and a lax
|
|
23
|
+
* base stays lax under a child that sets `true`. So in a monorepo the shared base
|
|
24
|
+
* config decides this for every package, a per-package override does nothing, and
|
|
25
|
+
* nothing says so. Check the value with `vue-tsc --showConfig`, not by reading the
|
|
26
|
+
* nearest tsconfig.
|
|
27
|
+
*
|
|
28
|
+
* This is the load-bearing warning.
|
|
29
|
+
* Measured: without it, an unknown prop, an unknown event and an entirely
|
|
30
|
+
* UNRESOLVED tag are all silently accepted, while wrong VALUE types still error.
|
|
31
|
+
* A project without it therefore sees type errors appear and concludes the surface
|
|
32
|
+
* is working, while every misspelled property and every widget whose key does not
|
|
33
|
+
* resolve goes unchecked.
|
|
34
|
+
*/
|
|
35
|
+
import type { DefineComponent } from '@vue/runtime-core';
|
|
36
|
+
import type { VueAttributes, WithOnce } from './attrs.js';
|
|
37
|
+
import type { WidgetPropsByGType, WidgetPropsVueAliases } from './generated/props.js';
|
|
38
|
+
type VueWidgetProps = WidgetPropsByGType & WidgetPropsVueAliases;
|
|
39
|
+
export type GtkGlobalComponents = {
|
|
40
|
+
[K in keyof VueWidgetProps]: DefineComponent<WithOnce<VueWidgetProps[K]> & VueAttributes>;
|
|
41
|
+
};
|
|
42
|
+
declare module '@vue/runtime-core' {
|
|
43
|
+
interface GlobalComponents extends GtkGlobalComponents {
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export {};
|