uxml-preview 0.5.0 → 0.6.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/CHANGELOG.md +227 -4
- package/README.ja.md +84 -0
- package/README.ko.md +84 -0
- package/README.md +46 -502
- package/README.zh-CN.md +84 -0
- package/THIRD-PARTY-NOTICES.md +7 -0
- package/dist/index.d.ts +18 -11
- package/dist/index.js +1918 -1305
- package/dist/layout/yoga.d.ts +14 -1
- package/dist/model/types.d.ts +95 -0
- package/dist/render/css-map.d.ts +18 -1
- package/dist/render/fonts.d.ts +21 -0
- package/dist/render/measure.d.ts +9 -0
- package/dist/render/paint.d.ts +5 -0
- package/dist/render/values.d.ts +4 -0
- package/dist/render/visibility.d.ts +20 -0
- package/dist/style/registry.d.ts +114 -0
- package/dist/style/resolve.d.ts +17 -0
- package/dist/template/expand.d.ts +10 -0
- package/package.json +5 -3
package/dist/layout/yoga.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ElementNode, NodeId, Warning } from '../model/types';
|
|
2
|
-
import { ComputedStyle } from '../style/resolve';
|
|
2
|
+
import { ComputedStyle, DeclarationLocator } from '../style/resolve';
|
|
3
|
+
import { FaceInfo } from '../render/measure';
|
|
3
4
|
/**
|
|
4
5
|
* Purpose: load the Yoga WebAssembly module.
|
|
5
6
|
* Deps/Effects: caches the module; awaiting it more than once is harmless.
|
|
@@ -26,9 +27,19 @@ export interface TextContext {
|
|
|
26
27
|
/** `normal` | `bold` | `italic` | `bold-and-italic`. */
|
|
27
28
|
fontStyle: string;
|
|
28
29
|
whiteSpace: string;
|
|
30
|
+
fontFamily?: string;
|
|
31
|
+
faceInfo?: FaceInfo;
|
|
32
|
+
letterSpacing?: number;
|
|
33
|
+
wordSpacing?: number;
|
|
34
|
+
paragraphSpacing?: number;
|
|
35
|
+
textGenerator?: 'standard' | 'advanced';
|
|
29
36
|
}
|
|
30
37
|
export type MeasureText = (text: string, context: TextContext, availableWidth: number) => TextMetrics;
|
|
31
38
|
export interface LayoutOptions {
|
|
39
|
+
fonts?: ReadonlyMap<ComputedStyle, {
|
|
40
|
+
family: string;
|
|
41
|
+
faceInfo?: FaceInfo;
|
|
42
|
+
}>;
|
|
32
43
|
size: {
|
|
33
44
|
width: number;
|
|
34
45
|
height: number;
|
|
@@ -41,6 +52,8 @@ export interface LayoutOptions {
|
|
|
41
52
|
* accuracy if the measurement shifts underneath it.
|
|
42
53
|
*/
|
|
43
54
|
measureText: MeasureText;
|
|
55
|
+
/** Points a value-level warning at the declaration it came from. */
|
|
56
|
+
locate?: DeclarationLocator;
|
|
44
57
|
}
|
|
45
58
|
/**
|
|
46
59
|
* A laid-out element the file never mentioned, built by a control.
|
package/dist/model/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UssVersion } from '../style/registry';
|
|
1
2
|
/**
|
|
2
3
|
* uxml-preview — in-memory document model.
|
|
3
4
|
*
|
|
@@ -32,6 +33,8 @@ export type SourceRef = {
|
|
|
32
33
|
in: 'uss';
|
|
33
34
|
sheet: number;
|
|
34
35
|
span: Span;
|
|
36
|
+
url?: string | null;
|
|
37
|
+
from?: string | null;
|
|
35
38
|
};
|
|
36
39
|
/**
|
|
37
40
|
* Opaque handle to a node, stable for the lifetime of the document.
|
|
@@ -235,6 +238,91 @@ export type WarningKind = 'unsupported-control' | 'unsupported-property' | 'unsu
|
|
|
235
238
|
export type WarningKindMap<T> = {
|
|
236
239
|
[K in WarningKind]: T;
|
|
237
240
|
};
|
|
241
|
+
/**
|
|
242
|
+
* Why a support warning was raised — what a consumer acts on instead of the
|
|
243
|
+
* message text.
|
|
244
|
+
*
|
|
245
|
+
* - `not-uss` the author wrote something USS does not have
|
|
246
|
+
* - `not-rendered` valid USS/UXML this preview does not draw or apply
|
|
247
|
+
* - `font-fallback` drawn, but Unity draws some glyphs with a fallback font, so text size can differ
|
|
248
|
+
* - `invalid-value` a valid name with a value or target that cannot work
|
|
249
|
+
* - `version-dependent` the result depends on the Unity version
|
|
250
|
+
* - `matches-unity` ignored, and Unity ignores it too; not a defect
|
|
251
|
+
*
|
|
252
|
+
* **An open set.** New reasons may be added in a minor release, so a consumer
|
|
253
|
+
* must give unknown values a default branch rather than an exhaustive switch.
|
|
254
|
+
* Absent when none applies, e.g. malformed text or a file the host could not
|
|
255
|
+
* resolve.
|
|
256
|
+
*/
|
|
257
|
+
export type WarningReason = 'not-uss' | 'not-rendered' | 'font-fallback' | 'invalid-value' | 'version-dependent' | 'matches-unity';
|
|
258
|
+
/**
|
|
259
|
+
* What a warning is about, as data, so a consumer never has to parse it back
|
|
260
|
+
* out of `message`.
|
|
261
|
+
*
|
|
262
|
+
* **An open set**, like `WarningReason`: new variants may be added in a minor
|
|
263
|
+
* release, so switch on `kind` with a default branch.
|
|
264
|
+
*/
|
|
265
|
+
export type WarningSubject = {
|
|
266
|
+
kind: 'property';
|
|
267
|
+
property: string;
|
|
268
|
+
/** As written, before `var()` substitution where the warning is about the declaration. */
|
|
269
|
+
value?: string;
|
|
270
|
+
/** First Unity version whose USS reference lists the property, e.g. `"6000.3"`. */
|
|
271
|
+
since?: string;
|
|
272
|
+
/** USS properties to write instead, for a CSS name USS spells differently. */
|
|
273
|
+
replacements?: readonly string[];
|
|
274
|
+
/**
|
|
275
|
+
* On a `not-rendered` or `font-fallback` warning: whether the property can change a box's size
|
|
276
|
+
* or position in Unity. When true, this preview's coordinates may differ
|
|
277
|
+
* from Unity's — do not treat a coordinate-based finding (zero size,
|
|
278
|
+
* overflow) as settled.
|
|
279
|
+
*/
|
|
280
|
+
affectsLayout?: boolean;
|
|
281
|
+
/**
|
|
282
|
+
* On a `not-rendered` warning: the part this preview did apply, when it
|
|
283
|
+
* applied some. Reserved for a property drawn but not laid out as Unity
|
|
284
|
+
* would; no registry row currently uses this field.
|
|
285
|
+
*/
|
|
286
|
+
applied?: 'paint';
|
|
287
|
+
/** On a `font-fallback` warning: the script the editor default font (Inter) has no glyphs for. */
|
|
288
|
+
missingGlyphs?: 'hangul' | 'han' | 'kana';
|
|
289
|
+
unityEffect?: {
|
|
290
|
+
kind: 'unstyled-from-here' | 'file-inline-dropped';
|
|
291
|
+
versions: readonly UssVersion[];
|
|
292
|
+
};
|
|
293
|
+
} | {
|
|
294
|
+
kind: 'selector';
|
|
295
|
+
/** The selector text as written. */
|
|
296
|
+
selector: string;
|
|
297
|
+
/** The part of it the warning is about, when narrower than the whole. */
|
|
298
|
+
fragment?: string;
|
|
299
|
+
} | {
|
|
300
|
+
kind: 'states-key';
|
|
301
|
+
key: string;
|
|
302
|
+
problem?: 'matches-nothing' | 'state-in-key' | 'unknown-state';
|
|
303
|
+
state?: string;
|
|
304
|
+
} | {
|
|
305
|
+
kind: 'asset';
|
|
306
|
+
path: string;
|
|
307
|
+
form: 'url' | 'resource';
|
|
308
|
+
role?: 'font';
|
|
309
|
+
} | {
|
|
310
|
+
kind: 'import';
|
|
311
|
+
/** Exactly the string the resolver hook was (or would have been) called with. */
|
|
312
|
+
url: string;
|
|
313
|
+
from: string | null;
|
|
314
|
+
} | {
|
|
315
|
+
kind: 'control';
|
|
316
|
+
type: string;
|
|
317
|
+
} | {
|
|
318
|
+
kind: 'name';
|
|
319
|
+
name: string;
|
|
320
|
+
}
|
|
321
|
+
/** An at-rule block, without the `@`. */
|
|
322
|
+
| {
|
|
323
|
+
kind: 'at-rule';
|
|
324
|
+
name: string;
|
|
325
|
+
};
|
|
238
326
|
/**
|
|
239
327
|
* Never a thrown error. One unsupported property must not take down the render
|
|
240
328
|
* (see CLAUDE.md rule 6).
|
|
@@ -244,6 +332,10 @@ export type WarningKindMap<T> = {
|
|
|
244
332
|
*/
|
|
245
333
|
export interface Warning {
|
|
246
334
|
kind: WarningKind;
|
|
335
|
+
/**
|
|
336
|
+
* For people. Read `reason` and `subject` instead; the text may be
|
|
337
|
+
* reworded in any release.
|
|
338
|
+
*/
|
|
247
339
|
message: string;
|
|
248
340
|
/** Document URL for a warning originating outside the entry UXML. */
|
|
249
341
|
sourceDocument?: string | null;
|
|
@@ -251,6 +343,9 @@ export interface Warning {
|
|
|
251
343
|
at?: SourceRef;
|
|
252
344
|
/** Element the warning is about, when it has one. Lets the UI highlight it. */
|
|
253
345
|
node?: NodeId;
|
|
346
|
+
nodes?: NodeId[];
|
|
347
|
+
reason?: WarningReason;
|
|
348
|
+
subject?: WarningSubject;
|
|
254
349
|
}
|
|
255
350
|
export interface UxmlDocument {
|
|
256
351
|
/** The exact UXML text every tree span indexes into. */
|
package/dist/render/css-map.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NodeId, Warning } from '../model/types';
|
|
2
|
-
import { ComputedStyle } from '../style/resolve';
|
|
2
|
+
import { ComputedStyle, DeclarationLocator } from '../style/resolve';
|
|
3
3
|
export interface CssMapOptions {
|
|
4
4
|
/**
|
|
5
5
|
* `form` tells `url("...")` apart from `resource("...")` — Unity resolves
|
|
@@ -11,11 +11,28 @@ export interface CssMapOptions {
|
|
|
11
11
|
* file happens to sit alongside it — or resolves nothing at all.
|
|
12
12
|
*/
|
|
13
13
|
resolveAsset?: ((path: string, form: 'url' | 'resource') => string | null) | undefined;
|
|
14
|
+
/** Points a value-level warning at the declaration it came from. */
|
|
15
|
+
locate?: DeclarationLocator | undefined;
|
|
14
16
|
}
|
|
15
17
|
export interface CssMapResult {
|
|
16
18
|
declarations: Record<string, string>;
|
|
17
19
|
warnings: Warning[];
|
|
18
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* `url("project://...")` or `resource("...")` to its form and bare path.
|
|
23
|
+
*
|
|
24
|
+
* Deps/Effects: decodes XML entities before parsing the wrapper. A value from
|
|
25
|
+
* a `<Style src>`-loaded .uss file never has any (that file was never XML),
|
|
26
|
+
* but a value from an inline `style="…"` attribute is parsed straight from
|
|
27
|
+
* the raw XML source (`inlineDeclarations` in style/resolve.ts) and can still
|
|
28
|
+
* carry `'`/`&`/`"`. Decoding after the regex would be too late:
|
|
29
|
+
* `'` doesn't match `(["']?)`, so the quote wrapper would be read as part
|
|
30
|
+
* of the path instead of stripped from it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function assetPath(value: string): {
|
|
33
|
+
form: 'url' | 'resource';
|
|
34
|
+
path: string;
|
|
35
|
+
} | null;
|
|
19
36
|
/**
|
|
20
37
|
* Purpose: one element's computed style -> CSS declarations.
|
|
21
38
|
* Deps/Effects: calls `resolveAsset` for background images; warnings are
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { NodeId, Warning } from '../model/types';
|
|
2
|
+
import { ComputedStyle, DeclarationLocator } from '../style/resolve';
|
|
3
|
+
import { FaceInfo } from './measure';
|
|
4
|
+
export type ResolvedFont = {
|
|
5
|
+
family: string;
|
|
6
|
+
faceInfo?: FaceInfo;
|
|
7
|
+
};
|
|
8
|
+
export type ResolveFont = (path: string, form: 'url' | 'resource') => string | ResolvedFont | null;
|
|
9
|
+
/**
|
|
10
|
+
* Purpose: resolve font assets for measurement and painting, applying Unity's
|
|
11
|
+
* documented but unmeasured -unity-font-definition precedence.
|
|
12
|
+
* Deps/Effects: calls the host hook once per distinct (path, form) per invocation.
|
|
13
|
+
* Ensures: filters only not-rendered property warnings for processed font
|
|
14
|
+
* declarations, keyed by property, source document and offset
|
|
15
|
+
* (or node when no offset exists). Unresolved assets replace those
|
|
16
|
+
* warnings with one asset-unresolved warning per declaration.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveFonts(styles: ReadonlyMap<NodeId, ComputedStyle>, warnings: readonly Warning[], locate: DeclarationLocator, resolve?: ResolveFont): {
|
|
19
|
+
fonts: Map<ComputedStyle, ResolvedFont>;
|
|
20
|
+
warnings: Warning[];
|
|
21
|
+
};
|
package/dist/render/measure.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { MeasureText } from '../layout/yoga';
|
|
2
|
+
export interface FaceInfo {
|
|
3
|
+
pointSize: number;
|
|
4
|
+
ascentLine: number;
|
|
5
|
+
descentLine: number;
|
|
6
|
+
lineHeight?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const EDITOR_DEFAULT_FACE_INFO: FaceInfo;
|
|
9
|
+
export declare function textHeight(lines: number, fontSize: number, face: FaceInfo, paragraphBreaks?: number, paragraphSpacing?: number): number;
|
|
10
|
+
export declare function fontList(family?: string): string;
|
|
2
11
|
/**
|
|
3
12
|
* Purpose: measure text with a canvas when one is available.
|
|
4
13
|
* Deps/Effects: creates one offscreen canvas and reuses it.
|
package/dist/render/paint.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FaceInfo } from './measure';
|
|
1
2
|
import { ElementNode, NodeId, Warning } from '../model/types';
|
|
2
3
|
import { ComputedStyle } from '../style/resolve';
|
|
3
4
|
import { LayoutBox, LayoutPart } from '../layout/yoga';
|
|
@@ -22,6 +23,10 @@ export interface PaintResult {
|
|
|
22
23
|
}
|
|
23
24
|
export interface PaintOptions extends CssMapOptions {
|
|
24
25
|
document: Document;
|
|
26
|
+
fonts?: ReadonlyMap<ComputedStyle, {
|
|
27
|
+
family: string;
|
|
28
|
+
faceInfo?: FaceInfo;
|
|
29
|
+
}>;
|
|
25
30
|
}
|
|
26
31
|
/**
|
|
27
32
|
* Purpose: build the DOM for one laid-out document under `container`.
|
package/dist/render/values.d.ts
CHANGED
|
@@ -36,6 +36,10 @@ export interface LengthResult {
|
|
|
36
36
|
length: Length | null;
|
|
37
37
|
/** Set when the text names a unit USS does not support, or uses calc(). */
|
|
38
38
|
problem?: string;
|
|
39
|
+
/** Structured marker for a recognised but unsupported USS unit. */
|
|
40
|
+
code?: 'unsupported-unit';
|
|
41
|
+
/** Set with `problem`: USS lacks the syntax, or the value is simply unreadable. */
|
|
42
|
+
reason?: 'not-uss' | 'invalid-value';
|
|
39
43
|
}
|
|
40
44
|
/**
|
|
41
45
|
* Purpose: `"6px"` / `"50%"` / `"auto"` / `"0"` -> a number with a unit.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RenderResult } from '../index';
|
|
2
|
+
import { NodeId, StyleOrigin } from '../model/types';
|
|
3
|
+
export type Visibility = {
|
|
4
|
+
kind: 'shown';
|
|
5
|
+
} | {
|
|
6
|
+
kind: 'hidden';
|
|
7
|
+
by: NodeId;
|
|
8
|
+
origin: StyleOrigin;
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'emptied';
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'collapsed';
|
|
13
|
+
explicitZero: boolean;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Purpose: classify layout absence using the uxml-author 0.2.1 rules.
|
|
17
|
+
* Deps/Effects: pure; reads the expanded tree and computed styles from render.
|
|
18
|
+
* Ensures: every box has a verdict; opacity and visibility do not affect it.
|
|
19
|
+
*/
|
|
20
|
+
export declare function classifyVisibility(result: RenderResult): ReadonlyMap<NodeId, Visibility>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every USS property Unity documents, and what this renderer does with it.
|
|
3
|
+
*
|
|
4
|
+
* Transcribed from Unity's USS property reference, not reasoned from CSS. The
|
|
5
|
+
* renderer's first failure mode is assuming a CSS name or default carries over,
|
|
6
|
+
* and a hand-kept list per concern (inherited, unsupported, version-dependent)
|
|
7
|
+
* had already drifted three ways: `text-shadow` missing from inheritance,
|
|
8
|
+
* `filter` reported as non-USS after 6.3 added it, `gap` reported as
|
|
9
|
+
* version-dependent although no reference table up to 6.6 has it.
|
|
10
|
+
*
|
|
11
|
+
* Source (checked 2026-10-13, see `USS_PROPERTY_SOURCE`):
|
|
12
|
+
* https://docs.unity.com/en-us/engine/6000.0/manual/uitoolkits/uielements/uie-uss/properties/reference (95 rows)
|
|
13
|
+
* https://docs.unity.com/en-us/engine/6000.3/manual/uitoolkits/uielements/uie-uss/properties/reference (99 rows)
|
|
14
|
+
* https://docs.unity.com/en-us/engine/6000.6/manual/uitoolkits/uielements/uie-uss/properties/reference (102 rows)
|
|
15
|
+
*
|
|
16
|
+
* `since` and `inherited` are Unity's facts and come from those tables alone.
|
|
17
|
+
* `handling` is this renderer's fact, observed rather than declared: `layout`
|
|
18
|
+
* means it can move a box (src/layout/yoga.ts), `paint` means it changes what
|
|
19
|
+
* is drawn and never where (src/render/css-map.ts), `none` means nothing
|
|
20
|
+
* reads it. A row's handling may only change together with the code —
|
|
21
|
+
* tests/style/registry.test.ts renders every row and fails when the two
|
|
22
|
+
* disagree.
|
|
23
|
+
*/
|
|
24
|
+
/** The first Unity release whose reference table lists the property. */
|
|
25
|
+
export type UssVersion = '6000.0' | '6000.3' | '6000.6';
|
|
26
|
+
export type Handling = 'layout' | 'paint' | 'none';
|
|
27
|
+
/** What a property can change in Unity: a box's size or position, only pixels, or nothing in a settled frame. */
|
|
28
|
+
export type UnityEffect = 'layout' | 'paint' | 'none';
|
|
29
|
+
export interface UssProperty {
|
|
30
|
+
readonly name: string;
|
|
31
|
+
readonly since: UssVersion;
|
|
32
|
+
/** Unity's "Inherited" column. */
|
|
33
|
+
readonly inherited: boolean;
|
|
34
|
+
/** What THIS renderer does with it. Observed; see the header. */
|
|
35
|
+
readonly handling: Handling;
|
|
36
|
+
/**
|
|
37
|
+
* What it can do IN UNITY — a different question from `handling`, and the
|
|
38
|
+
* two must not be read for each other. Where they disagree (`unity: 'layout'`
|
|
39
|
+
* with `handling` other than `'layout'`), this preview's coordinates can
|
|
40
|
+
* differ from Unity's whenever the property is written.
|
|
41
|
+
*/
|
|
42
|
+
readonly unity: UnityEffect;
|
|
43
|
+
/** Why `unity` is what it is, in one line. */
|
|
44
|
+
readonly basis: string;
|
|
45
|
+
/** True when `basis` is reasoning rather than a Unity statement or a measurement. */
|
|
46
|
+
readonly inferred: boolean;
|
|
47
|
+
}
|
|
48
|
+
export declare const USS_PROPERTY_SOURCE: {
|
|
49
|
+
readonly checked: "2026-10-13";
|
|
50
|
+
readonly tables: {
|
|
51
|
+
readonly '6000.0': "https://docs.unity.com/en-us/engine/6000.0/manual/uitoolkits/uielements/uie-uss/properties/reference";
|
|
52
|
+
readonly '6000.3': "https://docs.unity.com/en-us/engine/6000.3/manual/uitoolkits/uielements/uie-uss/properties/reference";
|
|
53
|
+
readonly '6000.6': "https://docs.unity.com/en-us/engine/6000.6/manual/uitoolkits/uielements/uie-uss/properties/reference";
|
|
54
|
+
};
|
|
55
|
+
/** Row count of each table on the date above. A test holds the data to these. */
|
|
56
|
+
readonly counts: {
|
|
57
|
+
readonly '6000.0': 95;
|
|
58
|
+
readonly '6000.3': 99;
|
|
59
|
+
readonly '6000.6': 102;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export declare const USS_PROPERTIES: readonly UssProperty[];
|
|
63
|
+
/** Undefined for anything Unity does not document, custom properties included. */
|
|
64
|
+
export declare function ussProperty(name: string): UssProperty | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* CSS names an author porting a stylesheet reaches for, and the USS
|
|
67
|
+
* properties that do the same job.
|
|
68
|
+
*
|
|
69
|
+
* Chosen, not exhaustive. The first six are the renamed rows of CLAUDE.md's
|
|
70
|
+
* "이름이 다른 속성" table and docs/uss-reference.md; the rest are CSS
|
|
71
|
+
* shorthands or per-axis splits whose every part USS has under another name.
|
|
72
|
+
* A CSS property with no USS counterpart up to Unity 6.6 (`z-index`, `box-shadow`, `gap`) is
|
|
73
|
+
* deliberately absent — offering a replacement there would invent one.
|
|
74
|
+
*/
|
|
75
|
+
export declare const CSS_REPLACEMENTS: Readonly<Record<string, readonly string[]>>;
|
|
76
|
+
export interface PropertyWarning {
|
|
77
|
+
message: string;
|
|
78
|
+
reason: 'not-uss' | 'not-rendered' | 'invalid-value';
|
|
79
|
+
subject: {
|
|
80
|
+
kind: 'property';
|
|
81
|
+
property: string;
|
|
82
|
+
value: string;
|
|
83
|
+
since?: string;
|
|
84
|
+
replacements?: readonly string[];
|
|
85
|
+
affectsLayout?: boolean;
|
|
86
|
+
applied?: 'paint';
|
|
87
|
+
unityEffect?: {
|
|
88
|
+
kind: 'unstyled-from-here';
|
|
89
|
+
versions: readonly UssVersion[];
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Purpose: what a declaration warrants by its property name alone.
|
|
95
|
+
* Ensures: null for custom properties and for anything this renderer
|
|
96
|
+
* reads; a value-level problem is the reader's to report.
|
|
97
|
+
*
|
|
98
|
+
* Judged per declaration rather than per element, so a rule matching a
|
|
99
|
+
* hundred elements — or matching none — says it once, and an inherited value
|
|
100
|
+
* never says it again on every descendant.
|
|
101
|
+
*/
|
|
102
|
+
export declare function propertyWarning(property: string, value: string): PropertyWarning | null;
|
|
103
|
+
/**
|
|
104
|
+
* The pseudo-class states a Unity element can be in — what `states` and
|
|
105
|
+
* `activeStates` accept and what a USS state selector can match.
|
|
106
|
+
*
|
|
107
|
+
* From Unity's "USS selectors: Pseudo-classes" page (checked 2026-10-13):
|
|
108
|
+
* https://docs.unity3d.com/Manual/UIE-USS-Selectors-Pseudo-Classes.html
|
|
109
|
+
* `:root` is excluded because it names a place in the tree, not a state.
|
|
110
|
+
* `:selected` is excluded because that page says USS does not support it
|
|
111
|
+
* ("Use :checked instead"). Exported so consumers stop keeping their own copy.
|
|
112
|
+
*/
|
|
113
|
+
export declare const USS_STATES: readonly ["hover", "active", "inactive", "focus", "disabled", "enabled", "checked"];
|
|
114
|
+
export type UssState = (typeof USS_STATES)[number];
|
package/dist/style/resolve.d.ts
CHANGED
|
@@ -30,6 +30,8 @@ export interface ResolveOptions {
|
|
|
30
30
|
states?: Readonly<Record<string, readonly string[]>>;
|
|
31
31
|
}
|
|
32
32
|
export interface ResolveResult {
|
|
33
|
+
/** @internal Element matches collected during this cascade, keyed by sheet and item. */
|
|
34
|
+
matchedNodes: ReadonlyMap<string, readonly NodeId[]>;
|
|
33
35
|
styles: ReadonlyMap<NodeId, ComputedStyle>;
|
|
34
36
|
/**
|
|
35
37
|
* Style per control part, keyed by the owning element and then Unity's name
|
|
@@ -72,6 +74,21 @@ export interface Candidate {
|
|
|
72
74
|
order: number;
|
|
73
75
|
winner: boolean;
|
|
74
76
|
}
|
|
77
|
+
/** Derives the resolver request without adding importer state to the model. */
|
|
78
|
+
export declare function sheetLocation(doc: UxmlDocument, index: number): {
|
|
79
|
+
url: string | null;
|
|
80
|
+
from: string | null;
|
|
81
|
+
};
|
|
82
|
+
/** Where a computed value was written, as warning fields. */
|
|
83
|
+
export type DeclarationLocator = (origin: StyleOrigin) => Pick<Warning, 'at' | 'sourceDocument' | 'nodes'>;
|
|
84
|
+
/**
|
|
85
|
+
* Purpose: turn a computed value's origin back into the text it came from,
|
|
86
|
+
* so a value-level warning points at one declaration.
|
|
87
|
+
* Ensures: empty for inherited and built-in values — an inherited value is
|
|
88
|
+
* reported where it was declared, not on every descendant — and
|
|
89
|
+
* for a template's inline style, which names its file instead.
|
|
90
|
+
*/
|
|
91
|
+
export declare function declarationLocator(doc: UxmlDocument, nodes: ReadonlyMap<string, readonly NodeId[]>): DeclarationLocator;
|
|
75
92
|
/**
|
|
76
93
|
* Purpose: compute the style of every element in the document.
|
|
77
94
|
* Deps/Effects: reads `doc` only; nothing on the model is mutated.
|
|
@@ -16,6 +16,16 @@ export interface TemplateExpansion {
|
|
|
16
16
|
document: UxmlDocument;
|
|
17
17
|
warnings: readonly Warning[];
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* How deeply `<ui:Instance>` may nest before expansion stops with
|
|
21
|
+
* `template-depth-exceeded`.
|
|
22
|
+
*
|
|
23
|
+
* Exported so a host that prefetches template files can walk exactly as deep
|
|
24
|
+
* as the core will expand, instead of copying the number and drifting (the
|
|
25
|
+
* VS Code extension's prefetch used 16 while the core went to 32). Not a
|
|
26
|
+
* Unity limit — a bound on this renderer's work.
|
|
27
|
+
*/
|
|
28
|
+
export declare const TEMPLATE_DEPTH_LIMIT = 32;
|
|
19
29
|
/**
|
|
20
30
|
* Expand all instances in a document into a derived tree.
|
|
21
31
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uxml-preview",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "Render Unity UI Toolkit UXML/USS in a browser without the Unity Editor. Laid out by Yoga, the engine UI Toolkit uses; reference Unity 6.3 LTS, measured against real Unity. Byte-exact round trips.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unity",
|
|
7
7
|
"unity3d",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
],
|
|
47
47
|
"sideEffects": false,
|
|
48
48
|
"engines": {
|
|
49
|
-
"node": ">=
|
|
49
|
+
"node": ">=22"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"test": "vitest run",
|
|
68
68
|
"test:watch": "vitest",
|
|
69
69
|
"test:roundtrip": "vitest run tests/roundtrip",
|
|
70
|
+
"test:text": "node tests/text-cohort/run.mjs && node tests/text-cohort/paint.mjs",
|
|
70
71
|
"test:golden": "vitest run tests/golden --passWithNoTests",
|
|
71
72
|
"golden:emit": "node --experimental-strip-types --no-warnings scripts/emit-golden-cases.mjs",
|
|
72
73
|
"template:emit": "node --experimental-strip-types --no-warnings scripts/emit-template-cases.mjs",
|
|
@@ -82,6 +83,7 @@
|
|
|
82
83
|
"@types/node": "^22.0.0",
|
|
83
84
|
"jsdom": "^30.0.1",
|
|
84
85
|
"pixelmatch": "^6.0.0",
|
|
86
|
+
"playwright-core": "1.48.2",
|
|
85
87
|
"pngjs": "^7.0.0",
|
|
86
88
|
"typescript": "^5.6.0",
|
|
87
89
|
"vite": "^6.0.0",
|