uxml-preview 0.1.0 → 0.3.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/dist/index.d.ts CHANGED
@@ -11,12 +11,14 @@ export type { Span, SourceRef, NodeId, ElementName, Attribute, ElementSpans, Ele
11
11
  export { loadLayoutEngine, isLayoutEngineReady, liveNodeCount } from './layout/yoga';
12
12
  export type { LayoutBox, MeasureText, TextContext, TextMetrics } from './layout/yoga';
13
13
  export { createDefaultMeasureText } from './render/measure';
14
- export { NODE_ATTRIBUTE } from './render/paint';
14
+ export { NODE_ATTRIBUTE, PART_ATTRIBUTE, PART_OWNER_ATTRIBUTE } from './render/paint';
15
15
  export { supportedControlNames } from './controls/registry';
16
16
  export { resolveStyles, explainProperty } from './style/resolve';
17
17
  export type { Candidate, ComputedStyle, ComputedValue, ResolveOptions, ResolveResult, } from './style/resolve';
18
18
  export type { Specificity } from './style/specificity';
19
19
  export { isInherited } from './style/properties';
20
+ export { KNOWN_DIVERGENCES } from './known-divergences';
21
+ export type { KnownDivergence } from './known-divergences';
20
22
  /**
21
23
  * Parse UXML and USS text into a document model.
22
24
  *
@@ -26,12 +28,15 @@ export { isInherited } from './style/properties';
26
28
  */
27
29
  export interface ParseOptions {
28
30
  /**
29
- * Loads the text of an `@import`ed stylesheet. Return `null` when the path
30
- * cannot be resolved; the import is then reported as a warning and its rules
31
+ * Loads the text of a stylesheet the document refers to. Return `null` when
32
+ * the path cannot be resolved; it is then reported as a warning and its rules
31
33
  * simply do not participate.
32
34
  *
33
- * USS import paths look like `project://database/Assets/UI/base.uss`, which
34
- * only the host application knows how to turn into file contents.
35
+ * Used for both ways a document can name a stylesheet — `@import` inside USS,
36
+ * and `<Style src="…">` inside UXML. Both quote paths like
37
+ * `project://database/Assets/UI/base.uss`, which only the host application
38
+ * knows how to turn into file contents, and there is no reason for a host to
39
+ * implement that lookup twice.
35
40
  */
36
41
  resolveImport?: (url: string) => string | null;
37
42
  }
@@ -54,8 +59,15 @@ export interface RenderOptions {
54
59
  * USS background images look like `url("project://database/Assets/foo.png")`
55
60
  * or `resource("foo")`. Browsers cannot load these, so the host application
56
61
  * must map them to real URLs. Return `null` to draw a placeholder instead.
62
+ *
63
+ * `form` says which of the two `path` came from — `'url'` is a path
64
+ * (project-relative or absolute), `'resource'` is a Unity Resources-folder
65
+ * name (no extension, resolved by Unity's own lookup rules). They are not
66
+ * interchangeable: a host that ignores `form` and resolves both as file
67
+ * paths will resolve `resource("foo")` against whatever happens to sit at
68
+ * that path — the wrong image, silently, if one exists there at all.
57
69
  */
58
- resolveAsset?: (path: string) => string | null;
70
+ resolveAsset?: (path: string, form: 'url' | 'resource') => string | null;
59
71
  /** Panel size in pixels. Defaults to the container's client size. */
60
72
  size?: {
61
73
  width: number;
@@ -69,14 +81,30 @@ export interface RenderOptions {
69
81
  * above all — should supply its own.
70
82
  */
71
83
  measureText?: MeasureText;
72
- /** Pseudo-classes to render as active, e.g. `new Set(['hover'])`. */
84
+ /** Pseudo-classes to render as active on every element, e.g. `new Set(['hover'])`. */
73
85
  activeStates?: ReadonlySet<string>;
86
+ /**
87
+ * Pseudo-classes to render as active per element, keyed by USS selector.
88
+ *
89
+ * ```ts
90
+ * render(doc, el, { states: { '#UseButton': ['hover'], '#DropButton': ['disabled'] } });
91
+ * ```
92
+ *
93
+ * States are explicit input rather than real mouse events, so the same call
94
+ * always draws the same picture — which is what makes a rendered screen
95
+ * something you can compare against Unity, or against yesterday.
96
+ *
97
+ * Per element and not per document because real screens mix: one button
98
+ * hovered while another is disabled is the normal case, not an edge one.
99
+ */
100
+ states?: Readonly<Record<string, readonly string[]>>;
74
101
  }
75
102
  export interface RenderResult {
76
103
  /**
77
104
  * Everything the renderer could not honour: unsupported controls, properties,
78
105
  * selectors and units, plus unresolved assets. Distinct from
79
- * `UxmlDocument.warnings`, which only covers malformed input.
106
+ * `UxmlDocument.warnings`, which covers malformed input and unresolved
107
+ * `<Style src="…">` / `@import` references rather than render-time support.
80
108
  */
81
109
  warnings: readonly Warning[];
82
110
  /** Painted element per model node. Lets a host map a click back to the tree. */