@vestra-player/sdk 1.7.2 → 1.7.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.7.4
4
+
5
+ **Who must change: nobody.** A documentation release: no API change, `apiVersion` stays `vestra/1`, the API surface snapshot is unchanged.
6
+
7
+ - **One general guide restored**: [How a plugin works](docs/guides/how-plugins-work.md) puts on one page the rules the 1.7.2 cut lost: values between TypeScript and Slint, `set` versus `bind`, the window life cycle, commands, what keeps a plugin running, processing layers, and failures. It is listed in the Guides and the Tutorial, and `vestra-plugin docs` finds it under plugins, ui, commands, processing and playback.
8
+
9
+ ## 1.7.3
10
+
11
+ **Who must change: plugins whose tests wrote a value of the wrong type — their test now fails the way the player already failed.** No API change, `apiVersion` stays `vestra/1`, the API surface snapshot is unchanged.
12
+
13
+ - **The test host checks property values against the plugin's Slint files**, as the player does (its conversion, then `ui_values::set`): `ui.open`, `ui.set`, `ui.mount`, `ui.setMount`, `settings.register` and `settings.set` refuse a value the player refuses, with the player's code and message. Twice a plugin passed every check and test and then failed in the player when its window opened: `high-tint: wrong type: high-tint is a string where the declaration has a brush` (a string for a `brush`), and `segments: wrong type: segments is an array that does not match the declared an array type` (rows whose struct has a field the declared struct does not). The rules are Slint's: a struct may leave fields out but not add any; any number fits `int`, `float`, `length` and the other number types, a numeric string does not; an image only as a `plugin.ui.image` reference; no value fits `brush`, `color` or an enum; inside an array without Markdown documents `null` is an empty image, so it fits where an image is declared and nowhere else, and outside one it fits nothing; a Markdown document's rows (`MarkdownBlock` structs) must fit the declared row type, an empty document has none. A property the exported component or global does not declare (or declares `private`) is `no such property`, an `out` property is `not writable (an out property)`, except that a write which only repeats the value an `out` property holds does nothing, as the player compares before it writes (not when a window opens). The words name the first field that differs as far as the property's current value shows the declared type, as the player's do. Before any of that, the player's conversion refuses a struct field name not in Slint's canonical spelling (`outer: UI object field "a_b" is not in Slint canonical spelling`, code `host`), at any depth and whatever the declaration says.
14
+ - Codes and words follow the player per request: `ui.open` fails with `host` (`name: wrong type: …`, `name: no such property`); `ui.set` with `ui` and `ui.setMount` with `host`, an undeclared property as just `no such property` (the player reads the property first); a row patch whose result the view refuses is refused the same way. A panel's or settings page's initial value with a field name not in Slint's spelling is left out and reported with `ui.error` (`onError`, code `host`), as the player refuses it when the request comes; the panel mounts and the page registers. A panel's initial value of a type the panel refuses is reported with `ui.error` (code `ui`, `name: name: wrong type: …`); the panel mounts and shows its default, and that value stays stored, as in the player. Stricter than the player for settings pages: their values are checked when written, where the player checks them when the Options window shows the page and then fails to show it.
15
+ - **How**: a small parser reads the `struct`, `enum`, `import` and `export` declarations and the `property` declarations of the exported component (a window) or global (a panel, a settings page), wherever they stand in its body (after `states`, `transitions` or `@children` too), following imports, `export *`, `@vestra/…` (the SDK's own `slint/vestra`), nested and anonymous structs. A view's types are kept while none of the files they were read from changed. What it cannot read is declared loosely, so it never refuses what the player takes: a type name it cannot resolve (from `std-widgets.slint`, or a name declared nowhere) takes any value, as does a struct where it holds itself (Slint refuses such a file; the test host resolves each struct once and stops there); a component that inherits a component of the plugin's own or one it imports takes undeclared names; a file it cannot read, or a window file without exactly one exported component, is not checked. A host without a package directory (no `startPlugin`) checks the field names only.
16
+ - The SDK's own test fixtures now declare the properties their tests write (`test/slint-types.test.ts` is new: a string for a brush, a wrong struct field in an array, numbers, images, `null`, nested, imported, self-holding and mutually exported structs, declarations after `states` and `@children`, a changed imported file, Markdown rows, field name spelling in writes and initial values, a deep struct type used in many places, unknown and `out` properties, a refused window patch, panels and settings pages, and a refused 20,000-row write that fails once, promptly, the panel keeping its last good value). The machinery tests whose rows no Slint struct would hold (holes, documents, mixed shapes) declare a row type the test host does not resolve, which takes any rows. The examples pass unchanged, and none of the player's built-in plugins writes a value its Slint refuses.
17
+ - A note for test authors: `assert.deepEqual` of a large array that differs builds a diff that can take gigabytes and minutes; compare the length or use `util.isDeepStrictEqual` in an `assert.ok` for lists of thousands of rows.
18
+
3
19
  ## 1.7.2
4
20
 
5
21
  **Who must change: nobody.** A documentation release: no API change, `apiVersion` stays `vestra/1`, the API surface snapshot is unchanged. The documentation goes from seven groups to four, and the remarks about players that were never released are gone.
Binary file
@@ -90,6 +90,7 @@ import { registerCoreActions, windowFacts, coreActionsHandlers, } from "./core-a
90
90
  import { translate, i18nHandlers } from "./i18n.js";
91
91
  import { mountOther, unmountOther, mounted, setTimelineRanges, setTimelineLayer, layoutHandlers, } from "./layout.js";
92
92
  import { osdHandlers } from "./osd.js";
93
+ import { packageDirectories } from "./slint-types.js";
93
94
  import { failStream, jobsHandlers } from "./jobs.js";
94
95
  import { upscalingState, failVideoRender, failVideoShaders, upscalingDecoding, processingHandlers, } from "./processing.js";
95
96
  import { sourceIntent, startResolution, setSource, mediaHandlers, initialSource, } from "./media.js";
@@ -2706,6 +2707,9 @@ export async function startPlugin(activate, options = {}) {
2706
2707
  }
2707
2708
  host.manifestId = manifest.id;
2708
2709
  host.loadCatalog(directory);
2710
+ // Its Slint files: the values its views are given are checked against
2711
+ // their declared types.
2712
+ packageDirectories.set(host, directory);
2709
2713
  const data = options.dataDirectory ?? host.dataDirectory;
2710
2714
  for (const [key, value] of options.sessionStorage ?? [])
2711
2715
  host.sessionStorage.set(key, sortedJson(value));
@@ -20,6 +20,13 @@ export declare class Internals {
20
20
  seq: number;
21
21
  rows: Json[];
22
22
  }>;
23
+ /** The exported global each mounted panel's properties belong to, by slot. */
24
+ readonly globals: Map<string, string | undefined>;
25
+ /**
26
+ * A panel's properties (view and name) whose stored initial value the
27
+ * panel could not take: it shows the property's default.
28
+ */
29
+ readonly unshown: Set<string>;
23
30
  nextOwner: number;
24
31
  /** Owners of other plugins' panels, by plugin id ({@link TestHost.mountOther}). */
25
32
  readonly others: Map<string, {
@@ -20,6 +20,13 @@ export class Internals {
20
20
  writes = new Map();
21
21
  /** The parts of a whole value held until its last part, by view and property. */
22
22
  parts = new Map();
23
+ /** The exported global each mounted panel's properties belong to, by slot. */
24
+ globals = new Map();
25
+ /**
26
+ * A panel's properties (view and name) whose stored initial value the
27
+ * panel could not take: it shows the property's default.
28
+ */
29
+ unshown = new Set();
23
30
  nextOwner = 2;
24
31
  /** Owners of other plugins' panels, by plugin id ({@link TestHost.mountOther}). */
25
32
  others = new Map();
@@ -1,6 +1,7 @@
1
1
  import type { Json, LayoutPanel } from "../../wire.ts";
2
2
  import type { FakePanel, TestHost } from "./index.ts";
3
3
  import type { Handler, Internals } from "./internals.ts";
4
+ import type { Refusal, ViewTypes } from "./slint-types.ts";
4
5
  export declare const kebab: (name: string) => string;
5
6
  export declare const SLOT_LABELS: Record<string, string>;
6
7
  /** The view a panel's writes are kept under (the player's, per slot). */
@@ -43,16 +44,58 @@ export declare function resetWrites(_host: TestHost, inner: Internals, view: str
43
44
  * otherwise). The result is checked against the value limits whole: the
44
45
  * player counts the rows a patch keeps too.
45
46
  */
46
- export declare function writeProperty(host: TestHost, inner: Internals, view: string, property: string, p: Record<string, Json>, current: Json | undefined): Json | undefined;
47
+ export declare function writeProperty(host: TestHost, inner: Internals, view: string, property: string, p: Record<string, Json>, current: Json | undefined, typed?: TypedView | null): Json | undefined;
47
48
  /**
48
49
  * Refuse property values over the player's limits ({@link UI_VALUE_LIMITS})
49
50
  * with `limit`, naming the property, as the player does.
50
51
  */
51
52
  export declare function checkValues(_host: TestHost, _inner: Internals, values: Record<string, Json>): void;
53
+ /**
54
+ * A view's declared property types, with how the player words a refusal
55
+ * there: the error `code`, and `bare` when it reads the property before it
56
+ * writes it (`ui.set`, `ui.setMount`, `settings.set`, a panel's or settings
57
+ * page's initial values), so that an unknown one is refused as "no such
58
+ * property" without its name. Those writes compare first
59
+ * (`ui_values::reconcile_in`): a value equal to what the property holds
60
+ * does nothing, on an `out` property too. `fresh`: the property shows its
61
+ * default although a value is stored (a panel's initial value it could
62
+ * not take).
63
+ */
64
+ export interface TypedView {
65
+ types: ViewTypes;
66
+ code: string;
67
+ bare: boolean;
68
+ fresh?: boolean;
69
+ }
70
+ /**
71
+ * The declared types of the view in `file` of the plugin's package: its
72
+ * exported component, or `global` (a panel's or settings page's). `null`
73
+ * (nothing checked) when the host runs no package or the file cannot be
74
+ * read.
75
+ */
76
+ export declare function typedView(host: TestHost, file: string, global: string | undefined, code: string, bare: boolean): TypedView | null;
77
+ /** A refusal in the player's words, for a write that reads the property first (`bare`) or not. */
78
+ export declare const refusalText: (found: Refusal, bare: boolean) => string;
79
+ /**
80
+ * Refuse a value the player's Slint refuses for `property` (a value of
81
+ * another type than declared, an undeclared or `out` property), with the
82
+ * player's code and words. `current`: what the property shows now (none:
83
+ * its default), which the words describe the declared type by.
84
+ */
85
+ export declare function checkType(typed: TypedView, property: string, value: Json, current: Json | undefined): void;
86
+ /**
87
+ * Refuse a struct field name the player's conversion refuses (not in
88
+ * Slint's canonical spelling), whatever the view declares: code `host`,
89
+ * the property named.
90
+ */
91
+ export declare function checkSpelling(property: string, value: Json): void;
92
+ /** Property names in the order the player sets them (a `BTreeMap`). */
93
+ export declare const inSetOrder: (values: Record<string, Json>) => string[];
52
94
  /**
53
95
  * A panel's or settings page's initial properties, as the player keeps
54
- * them: one over the limits is left out (the property keeps its default)
55
- * and reported with `ui.error`, the request itself succeeds.
96
+ * them: one over the limits (`limit`) or with a struct field name not in
97
+ * Slint's canonical spelling (`host`) is left out (the property keeps its
98
+ * default) and reported with `ui.error`, the request itself succeeds.
56
99
  */
57
100
  export declare function initialValues(host: TestHost, _inner: Internals, values: Record<string, Json>): Record<string, Json>;
58
101
  export declare function seeImages(host: TestHost, _inner: Internals, values: Record<string, Json> | Json[]): void;
@@ -14,6 +14,7 @@ import { isTextValue } from "../../i18n.js";
14
14
  import { taken } from "./transport.js";
15
15
  import { windowFacts } from "./core-actions.js";
16
16
  import { declaredText, shownValues, hostText } from "./i18n.js";
17
+ import { packageDirectories, refusal, spellingProblem, viewTypes, } from "./slint-types.js";
17
18
  export const kebab = (name) => name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
18
19
  export const SLOT_LABELS = {
19
20
  bottom: "bottom bar",
@@ -118,8 +119,15 @@ export function resetWrites(_host, inner, view) {
118
119
  * otherwise). The result is checked against the value limits whole: the
119
120
  * player counts the rows a patch keeps too.
120
121
  */
121
- export function writeProperty(host, inner, view, property, p, current) {
122
+ export function writeProperty(host, inner, view, property, p, current, typed = null) {
122
123
  const slot = `${view}\u0000${property}`;
124
+ // The value the view shows after the write: its type is checked once
125
+ // the value is whole, as the player sets it then.
126
+ const shown = (value) => {
127
+ checkSpelling(property, value);
128
+ if (typed)
129
+ checkType(typed, property, value, current);
130
+ };
123
131
  const patch = p.patch;
124
132
  // A whole array sent in parts (player 0.6.0, SDK 1.5.46): every part but
125
133
  // the last carries `more`; the player holds them and writes the whole
@@ -153,6 +161,7 @@ export function writeProperty(host, inner, view, property, p, current) {
153
161
  inner.parts.set(slot, { seq: patch.seq, rows });
154
162
  return undefined;
155
163
  }
164
+ shown(rows);
156
165
  seeImages(host, inner, [rows]);
157
166
  inner.writes.set(slot, patch.seq);
158
167
  return rows;
@@ -162,6 +171,7 @@ export function writeProperty(host, inner, view, property, p, current) {
162
171
  if (patch === undefined) {
163
172
  const value = shownValues(host, inner, p.value);
164
173
  checkValues(host, inner, { [property]: value });
174
+ shown(value);
165
175
  seeImages(host, inner, [value]);
166
176
  inner.writes.set(slot, typeof p.seq === "number" ? p.seq : 0);
167
177
  return value;
@@ -183,6 +193,7 @@ export function writeProperty(host, inner, view, property, p, current) {
183
193
  : op);
184
194
  const value = applyOps(current, resolved);
185
195
  checkValues(host, inner, { [property]: value });
196
+ shown(value);
186
197
  seeImages(host, inner, resolved.flatMap((op) => op.op === "set" ? [op.row] : op.op === "insert" ? op.rows : []));
187
198
  inner.writes.set(slot, seq);
188
199
  return value;
@@ -198,20 +209,63 @@ export function checkValues(_host, _inner, values) {
198
209
  throw new HostError("limit", `${property}: ${problem}`);
199
210
  }
200
211
  }
212
+ /**
213
+ * The declared types of the view in `file` of the plugin's package: its
214
+ * exported component, or `global` (a panel's or settings page's). `null`
215
+ * (nothing checked) when the host runs no package or the file cannot be
216
+ * read.
217
+ */
218
+ export function typedView(host, file, global, code, bare) {
219
+ const directory = packageDirectories.get(host);
220
+ const types = directory === undefined ? null : viewTypes(directory, file, global);
221
+ return types && { types, code, bare };
222
+ }
223
+ /** A refusal in the player's words, for a write that reads the property first (`bare`) or not. */
224
+ export const refusalText = (found, bare) => bare && found.why === "missing" ? "no such property" : found.message;
225
+ /**
226
+ * Refuse a value the player's Slint refuses for `property` (a value of
227
+ * another type than declared, an undeclared or `out` property), with the
228
+ * player's code and words. `current`: what the property shows now (none:
229
+ * its default), which the words describe the declared type by.
230
+ */
231
+ export function checkType(typed, property, value, current) {
232
+ const found = refusal(typed.types, property, value, typed.fresh ? undefined : current, { reconciles: typed.bare });
233
+ if (found)
234
+ throw new HostError(typed.code, refusalText(found, typed.bare));
235
+ }
236
+ /**
237
+ * Refuse a struct field name the player's conversion refuses (not in
238
+ * Slint's canonical spelling), whatever the view declares: code `host`,
239
+ * the property named.
240
+ */
241
+ export function checkSpelling(property, value) {
242
+ const problem = spellingProblem(value);
243
+ if (problem)
244
+ throw new HostError("host", `${property}: ${problem}`);
245
+ }
246
+ /** Property names in the order the player sets them (a `BTreeMap`). */
247
+ export const inSetOrder = (values) => Object.keys(values).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
201
248
  /**
202
249
  * A panel's or settings page's initial properties, as the player keeps
203
- * them: one over the limits is left out (the property keeps its default)
204
- * and reported with `ui.error`, the request itself succeeds.
250
+ * them: one over the limits (`limit`) or with a struct field name not in
251
+ * Slint's canonical spelling (`host`) is left out (the property keeps its
252
+ * default) and reported with `ui.error`, the request itself succeeds.
205
253
  */
206
254
  export function initialValues(host, _inner, values) {
207
255
  const kept = {};
208
256
  for (const [property, value] of Object.entries(values)) {
209
257
  const problem = valueLimitProblem(value);
258
+ const spelling = problem ? null : spellingProblem(value);
210
259
  if (problem)
211
260
  host.emit("ui.error", {
212
261
  code: "limit",
213
262
  message: `${property}: ${problem}`,
214
263
  });
264
+ else if (spelling)
265
+ host.emit("ui.error", {
266
+ code: "host",
267
+ message: `${property}: ${spelling}`,
268
+ });
215
269
  else
216
270
  kept[property] = value;
217
271
  }
@@ -358,6 +412,14 @@ export function layoutHandlers(host, inner) {
358
412
  resetWrites(host, inner, `w:${id}`);
359
413
  const properties = shownValues(host, inner, p.properties);
360
414
  checkValues(host, inner, properties);
415
+ // Converted, then set one by one on the new component: the first
416
+ // one refused fails the open (code `host`, the property named).
417
+ for (const name of inSetOrder(properties))
418
+ checkSpelling(name, properties[name]);
419
+ const typed = typedView(host, String(p.file), undefined, "host", false);
420
+ if (typed)
421
+ for (const name of inSetOrder(properties))
422
+ checkType(typed, name, properties[name], undefined);
361
423
  seeImages(host, inner, properties);
362
424
  host.windows.set(id, {
363
425
  file: String(p.file),
@@ -381,7 +443,7 @@ export function layoutHandlers(host, inner) {
381
443
  if (!window)
382
444
  throw new HostError("missing", "view not found");
383
445
  const property = String(p.property);
384
- const next = writeProperty(host, inner, `w:${String(p.id)}`, property, p, window.props[property]);
446
+ const next = writeProperty(host, inner, `w:${String(p.id)}`, property, p, window.props[property], typedView(host, window.file, undefined, "ui", true));
385
447
  // A part of a value sent in parts is held until the last (player 0.6.0).
386
448
  if (next !== undefined)
387
449
  window.props[property] = next;
@@ -416,8 +478,32 @@ export function layoutHandlers(host, inner) {
416
478
  String(holder),
417
479
  ]));
418
480
  const properties = initialValues(host, inner, shownValues(host, inner, p.properties));
419
- seeImages(host, inner, properties);
420
481
  const panelSlot = String(p.slot);
482
+ const global = typeof p.global === "string" ? p.global : undefined;
483
+ inner.globals.set(panelSlot, global);
484
+ // A value of a type the panel refuses is reported with `ui.error` as
485
+ // the player reports it when it builds the panel (named before the
486
+ // refusal). The panel shows its default for it; the value stays
487
+ // stored, as in the player, and a patch applies on it.
488
+ const view = mountView(panelSlot);
489
+ for (const key of [...inner.unshown])
490
+ if (key.startsWith(`${view}\u0000`))
491
+ inner.unshown.delete(key);
492
+ const typed = global === undefined
493
+ ? null
494
+ : typedView(host, String(p.file), global, "ui", true);
495
+ if (typed)
496
+ for (const name of inSetOrder(properties)) {
497
+ const found = refusal(typed.types, name, properties[name], undefined, { reconciles: true });
498
+ if (!found)
499
+ continue;
500
+ inner.unshown.add(`${view}\u0000${name}`);
501
+ host.emit("ui.error", {
502
+ code: "ui",
503
+ message: `${name}: ${refusalText(found, true)}`,
504
+ });
505
+ }
506
+ seeImages(host, inner, properties);
421
507
  resetWrites(host, inner, mountView(panelSlot));
422
508
  host.panels.set(panelSlot, {
423
509
  slot: panelSlot,
@@ -527,10 +613,19 @@ export function layoutHandlers(host, inner) {
527
613
  "ui.setMount": (p) => {
528
614
  const panel = panelFor(host, inner, p);
529
615
  const property = String(p.property);
530
- const next = writeProperty(host, inner, mountView(panel.slot), property, p, panel.props[property]);
616
+ const global = inner.globals.get(panel.slot);
617
+ const unshown = `${mountView(panel.slot)}\u0000${property}`;
618
+ const typed = global === undefined
619
+ ? null
620
+ : typedView(host, panel.file, global, "host", true);
621
+ if (typed)
622
+ typed.fresh = inner.unshown.has(unshown);
623
+ const next = writeProperty(host, inner, mountView(panel.slot), property, p, panel.props[property], typed);
531
624
  // A part of a value sent in parts is held until the last (player 0.6.0).
532
- if (next !== undefined)
625
+ if (next !== undefined) {
533
626
  panel.props[property] = next;
627
+ inner.unshown.delete(unshown);
628
+ }
534
629
  },
535
630
  "timeline.marks": () => ({
536
631
  marks: host.timeline.marks,
@@ -12,7 +12,7 @@ import { SESSION_STORAGE_LIMITS } from "../services.js";
12
12
  import { validStep } from "../player/rules.js";
13
13
  import { runCore, windowFacts } from "./core-actions.js";
14
14
  import { shownText, declaredText, shownValues, hostText } from "./i18n.js";
15
- import { resetWrites, writeProperty, initialValues, seeImages, kebab, } from "./layout.js";
15
+ import { resetWrites, writeProperty, initialValues, seeImages, kebab, typedView, checkType, inSetOrder, } from "./layout.js";
16
16
  /** A `plugin.storage.session` key, checked as the player does. */
17
17
  export function sessionKey(key) {
18
18
  if (typeof key !== "string" ||
@@ -219,6 +219,14 @@ export function servicesHandlers(host, inner) {
219
219
  if (host.settings.pages.size >= 8)
220
220
  throw new HostError("invalid", "a plugin has at most 8 settings pages");
221
221
  const properties = initialValues(host, inner, shownValues(host, inner, p.properties));
222
+ // Stricter than the player, which sets a page's values when the
223
+ // Options window shows it (and fails to show it, code `ui`): the
224
+ // test host checks their types when they are written, so a test
225
+ // need not open the window.
226
+ const typed = typedView(host, String(p.file), String(p.global), "ui", true);
227
+ if (typed)
228
+ for (const name of inSetOrder(properties))
229
+ checkType(typed, name, properties[name], undefined);
222
230
  seeImages(host, inner, properties);
223
231
  resetWrites(host, inner, `$settings:${id}`);
224
232
  host.settings.pages.set(id, {
@@ -243,7 +251,7 @@ export function servicesHandlers(host, inner) {
243
251
  if (!page)
244
252
  throw new HostError("missing", "page not registered");
245
253
  const property = String(p.property);
246
- const next = writeProperty(host, inner, `$settings:${String(p.id)}`, property, p, page.props[property]);
254
+ const next = writeProperty(host, inner, `$settings:${String(p.id)}`, property, p, page.props[property], typedView(host, page.file, page.global, "ui", true));
247
255
  // A part of a value sent in parts is held until the last (player 0.6.0).
248
256
  if (next !== undefined)
249
257
  page.props[property] = next;
@@ -0,0 +1,75 @@
1
+ import type { Json } from "../../wire.ts";
2
+ import type { TestHost } from "./index.ts";
3
+ /** The package directory of the plugin a host runs (set by `startPlugin`). */
4
+ export declare const packageDirectories: WeakMap<TestHost, string>;
5
+ /** A declared type, resolved. `any`: not known here, every value passes. */
6
+ export type SlintType = {
7
+ k: "number" | "string" | "bool" | "image" | "brush" | "enum" | "other";
8
+ } | {
9
+ k: "array";
10
+ of: SlintType;
11
+ } | {
12
+ k: "struct";
13
+ fields: Map<string, SlintType>;
14
+ } | {
15
+ k: "any";
16
+ };
17
+ type Visibility = "in" | "out" | "in-out" | "private";
18
+ /**
19
+ * Slint's `normalize_identifier`: `_` is `-` except as the first
20
+ * character, where `-` is `_`.
21
+ */
22
+ export declare const normalize: (name: string) => string;
23
+ /** A property as declared: its visibility, type and default rows. */
24
+ export interface Declared {
25
+ visibility: Visibility;
26
+ type: SlintType;
27
+ rows: boolean;
28
+ /**
29
+ * The value it holds before any write, as the player's `to_json` gives
30
+ * it, when the test host can tell (`undefined`: it cannot).
31
+ */
32
+ initial: Json | undefined;
33
+ }
34
+ /**
35
+ * The writable surface of a view: its properties by normalized name.
36
+ * `open`: names not listed may still exist (the component inherits a
37
+ * component this parser does not look into), so they are not refused.
38
+ */
39
+ export interface ViewTypes {
40
+ properties: Map<string, Declared>;
41
+ open: boolean;
42
+ }
43
+ /**
44
+ * The properties of the view `file` (relative to `directory`) shows: its
45
+ * one exported component (a window), or the exported `global` (a panel or
46
+ * settings page). `null` when the file cannot be read or the view cannot
47
+ * be found: then nothing is checked. Kept while none of the files it was
48
+ * read from (the view's and those it imports) changed.
49
+ */
50
+ export declare function viewTypes(directory: string, file: string, global?: string): ViewTypes | null;
51
+ /** Why the player refuses a write: no such property, an out property, or the type. */
52
+ export interface Refusal {
53
+ why: "missing" | "readonly" | "type";
54
+ /** The player's words (`ui_values::refusal`), the property named first. */
55
+ message: string;
56
+ }
57
+ /**
58
+ * The player's refusal of `value` for `property` of a view of `types`, or
59
+ * `null` when it takes it. `current`: what the property holds (the last
60
+ * value it took; none: its default), which the words of a type refusal
61
+ * describe the declaration by, as the player's do.
62
+ */
63
+ export declare function refusal(types: ViewTypes, property: string, value: Json, current: Json | undefined, options?: {
64
+ reconciles?: boolean;
65
+ }): Refusal | null;
66
+ /**
67
+ * The player's conversion refuses a struct field name not in Slint's
68
+ * canonical spelling (`ui_values`: no `-` first, no `_` after the first
69
+ * character), whatever the declaration says: the first such name in the
70
+ * order the player meets them (fields by name, a field's value before its
71
+ * name), in its words; `null` when there is none. Image references and
72
+ * Markdown documents are not structs.
73
+ */
74
+ export declare function spellingProblem(value: Json): string | null;
75
+ export {};