uxml-preview 0.2.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/CHANGELOG.md +69 -0
- package/README.md +22 -18
- package/dist/index.d.ts +12 -2
- package/dist/index.js +554 -533
- package/dist/known-divergences.d.ts +36 -0
- package/dist/model/types.d.ts +6 -1
- package/dist/render/css-map.d.ts +10 -1
- package/dist/unity-project/index.d.ts +14 -0
- package/dist/unity-project/index.js +41 -0
- package/package.json +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,74 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.0 — Unreleased
|
|
4
|
+
|
|
5
|
+
Four fixes the VSCode extension (`vscode-uxml-preview`) hit while consuming
|
|
6
|
+
this package as a dependency — not speculative additions.
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- **`KNOWN_DIVERGENCES`** gives a host something to tell apart "a limit we
|
|
11
|
+
know about" from "a bug". Three entries, and the kinds carry the
|
|
12
|
+
distinction that matters. Font metrics move with the platform, so the
|
|
13
|
+
difference cannot be reproduced here at all. Unity's rule for a wrap
|
|
14
|
+
container's height is simply not specified, so there is nothing to match
|
|
15
|
+
yet. And the Yoga vendored in UI Toolkit resolves a main-axis percentage
|
|
16
|
+
against an indefinite parent differently from the one this package depends
|
|
17
|
+
on — that one reproduces perfectly every time; it just cannot be fixed
|
|
18
|
+
from inside this repository. The 1px case is deliberately absent: that is
|
|
19
|
+
the golden tests' judgement parameter, not a limit of the renderer, and a
|
|
20
|
+
host showing it would read as a defect.
|
|
21
|
+
- **`uxml-preview/unity-project`**, a Node-only subpath exporting
|
|
22
|
+
`buildGuidIndex(projectRoot)`. Builds a GUID → absolute-path index from a
|
|
23
|
+
Unity project's `.meta` files, for the case where an asset reference's path
|
|
24
|
+
has gone stale but its GUID is still good. Skips `Library/`, `Temp/`,
|
|
25
|
+
`obj/`, `.git/`, and any `.meta` file it cannot read. Kept out of the main
|
|
26
|
+
entry point because it uses `node:fs` and the main entry must stay
|
|
27
|
+
browser-safe.
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- **`resolveAsset` now receives a second argument, `form: 'url' | 'resource'`**,
|
|
32
|
+
telling `url("...")` and `resource("...")` background-image references
|
|
33
|
+
apart. They resolve differently — `url()` is a path, `resource()` is a
|
|
34
|
+
Unity Resources-folder name — and a host that resolved both the same way
|
|
35
|
+
before this had no way to know which one it was looking at.
|
|
36
|
+
**Non-breaking**: existing `(path) => ...` implementations keep working
|
|
37
|
+
unchanged: `form` is an additional argument, not a replacement one.
|
|
38
|
+
|
|
39
|
+
### Fixed
|
|
40
|
+
|
|
41
|
+
- `UxmlDocument.warnings` and `RenderResult.warnings` doc comments corrected.
|
|
42
|
+
The former said it covers "malformed input" only; it also carries
|
|
43
|
+
`'import-unresolved'` for an unreadable `<Style src="…">` or `@import`. The
|
|
44
|
+
latter said it is distinct from the former on that same wrong premise.
|
|
45
|
+
Comment-only — no behavior changed.
|
|
46
|
+
|
|
47
|
+
### Docs
|
|
48
|
+
|
|
49
|
+
- **`docs/accuracy.md`'s published figures were stale**: two comparable cases
|
|
50
|
+
(`state-vs-id`, `state-vs-inline`) were merged after the doc's numbers were
|
|
51
|
+
last written, and nothing caught it. Recomputed from a live run rather than
|
|
52
|
+
trusted: **548 / 564 values (97.2%)**, **31 / 33 cases matching**, **33 / 33**
|
|
53
|
+
Unity baseline coverage — up from the stale 532/548, 29/31, 31/31. Mirrored
|
|
54
|
+
into `README.md` (both languages) and `docs/uss-vs-css.md`/`.ko.md`.
|
|
55
|
+
`docs/accuracy.en.md` was updated too but is not machine-checked (see next).
|
|
56
|
+
- **Added a regression guard**: `tests/golden/golden.test.ts` now has
|
|
57
|
+
`matches the figures published in docs/accuracy.md`, which recomputes the
|
|
58
|
+
three headline numbers from the actual case set and fails if
|
|
59
|
+
`docs/accuracy.md` says anything else — including failing (not skipping) if
|
|
60
|
+
it cannot find a row to check, so the guard can't be silently defeated by a
|
|
61
|
+
table-format change. This is the third time this specific number went stale
|
|
62
|
+
publicly (`docs/accuracy.md` itself already records the first two); the doc
|
|
63
|
+
fix alone would only prevent a third, not a fourth.
|
|
64
|
+
- Left unfixed and flagged in `docs/accuracy.md`/`accuracy.en.md`: the
|
|
65
|
+
"which controls this covers" breakdown table (`Button`/`ScrollView`/etc.
|
|
66
|
+
row counts) was already internally inconsistent before this change
|
|
67
|
+
(17+1+6+5+1 = 30, not the stated 31) and is not machine-checked. Recomputing
|
|
68
|
+
it requires a counting rule that is not written down anywhere; a guess
|
|
69
|
+
risked swapping one wrong number for another, so it was left alone and
|
|
70
|
+
called out inline instead.
|
|
71
|
+
|
|
3
72
|
## 0.2.0 — 2026-08-06
|
|
4
73
|
|
|
5
74
|
Five controls instead of three, a representative screen measured end to end
|
package/README.md
CHANGED
|
@@ -25,12 +25,14 @@ stylesheet comes out wrong.</sub>
|
|
|
25
25
|
npm install uxml-preview
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
> **v0.
|
|
29
|
-
> `
|
|
28
|
+
> **v0.2.0 — early release.** Five controls (`VisualElement`, `Label`, `Button`,
|
|
29
|
+
> `Image`, `ScrollView`), everything else drawn as a plain box with a warning,
|
|
30
|
+
> and a support matrix that says plainly what has not been measured.
|
|
30
31
|
> Read [what is not verified yet](#what-is-not-verified-yet) before relying on it.
|
|
31
32
|
>
|
|
32
|
-
> **v0.
|
|
33
|
-
>
|
|
33
|
+
> **v0.2.0 — 초기 릴리스입니다.** 컨트롤 5종(`VisualElement`, `Label`, `Button`,
|
|
34
|
+
> `Image`, `ScrollView`)이고, 나머지는 경고와 함께 일반 박스로 그립니다.
|
|
35
|
+
> 검증되지 않은 부분은 지원 범위표에 그대로 적어뒀습니다. 쓰시기 전에
|
|
34
36
|
> [아직 검증되지 않은 것](#아직-검증되지-않은-것)을 먼저 봐주세요.
|
|
35
37
|
|
|
36
38
|
---
|
|
@@ -45,8 +47,8 @@ directly in a web browser. It uses **Yoga** — the same layout engine Unity UI
|
|
|
45
47
|
itself uses — compiled to WebAssembly, so results match the Unity Editor rather than
|
|
46
48
|
approximating it.
|
|
47
49
|
|
|
48
|
-
Measured against Unity 6000.0.40f1: **
|
|
49
|
-
across
|
|
50
|
+
Measured against Unity 6000.0.40f1: **548 of 564 element coordinates identical**
|
|
51
|
+
across 33 layout cases, including a full working screen. Ten of the sixteen
|
|
50
52
|
differences are font metrics rather than layout — a browser cannot measure
|
|
51
53
|
Unity's font asset. All sixteen are named in
|
|
52
54
|
[`docs/accuracy.en.md`](docs/accuracy.en.md).
|
|
@@ -95,8 +97,9 @@ That broken feedback loop is what this library fixes.
|
|
|
95
97
|
| 3 | USS style resolver | ✅ |
|
|
96
98
|
| 4 | Yoga layout + DOM painting | ✅ |
|
|
97
99
|
| 5 | Golden tests against Unity | ✅ |
|
|
98
|
-
| 6 | **v0.1 release** |
|
|
99
|
-
| 7
|
|
100
|
+
| 6 | **v0.1 release** | ✅ |
|
|
101
|
+
| 7 | **v0.2 — ScrollView, Image, states, a measured screen** | ✅ |
|
|
102
|
+
| 8+ | Editing layer, tool integration | ⬜ |
|
|
100
103
|
|
|
101
104
|
Full plan: [`docs/ROADMAP.md`](docs/ROADMAP.md)
|
|
102
105
|
|
|
@@ -207,12 +210,12 @@ Checked by comparing element geometry against the Unity Editor, case by case.
|
|
|
207
210
|
Geometry rather than pixels: Unity draws text with its own font asset and a
|
|
208
211
|
browser does not, so a pixel diff would measure the font more than the layout.
|
|
209
212
|
|
|
210
|
-
Measured against Unity on 2026-08-
|
|
213
|
+
Measured against Unity on 2026-08-06, over 33 cases and 141 elements:
|
|
211
214
|
|
|
212
215
|
| | |
|
|
213
216
|
|---|---|
|
|
214
|
-
| Cases matching exactly | **
|
|
215
|
-
| Values within 0.5px | **
|
|
217
|
+
| Cases matching exactly | **31 / 33** |
|
|
218
|
+
| Values within 0.5px | **548 / 564 (97.2%)** |
|
|
216
219
|
|
|
217
220
|
The sixteen divergences are four different things, and the distinction matters
|
|
218
221
|
more than the ratio: **ten are text metrics**, three are 1px, two are a
|
|
@@ -243,7 +246,7 @@ as nested flex, and computed values have to be resolved to fixed numbers or
|
|
|
243
246
|
calculated in C#.
|
|
244
247
|
|
|
245
248
|
**How close is the output to Unity?**
|
|
246
|
-
|
|
249
|
+
548 of 564 element coordinates identical against Unity 6000.0.40f1, across 33
|
|
247
250
|
layout cases including a complete inventory screen. Geometry is compared rather
|
|
248
251
|
than screenshots, because Unity draws text with its own font asset — which is
|
|
249
252
|
also why ten of the sixteen differences are font metrics rather than layout.
|
|
@@ -277,8 +280,8 @@ Apache-2.0
|
|
|
277
280
|
**Yoga**를 WebAssembly로 그대로 사용하기 때문에, 결과를 "비슷하게 흉내내는" 것이 아니라
|
|
278
281
|
유니티 에디터와 일치시킵니다.
|
|
279
282
|
|
|
280
|
-
Unity 6000.0.40f1과 대조한 결과, 실무형 화면을 포함한 레이아웃 케이스
|
|
281
|
-
**요소 좌표
|
|
283
|
+
Unity 6000.0.40f1과 대조한 결과, 실무형 화면을 포함한 레이아웃 케이스 33개에서
|
|
284
|
+
**요소 좌표 564개 중 548개가 일치**합니다. 어긋난 16개 중 **10개는 레이아웃이 아니라
|
|
282
285
|
폰트 메트릭** 차이입니다 — 브라우저는 유니티 폰트 에셋을 잴 수 없습니다.
|
|
283
286
|
16개 전부 [`docs/accuracy.md`](docs/accuracy.md)에 이름과 사유를 적어뒀습니다.
|
|
284
287
|
|
|
@@ -325,8 +328,9 @@ Unity 6000.0.40f1과 대조한 결과, 실무형 화면을 포함한 레이아
|
|
|
325
328
|
| 3 | USS 스타일 리졸버 | ✅ |
|
|
326
329
|
| 4 | Yoga 레이아웃 + DOM 페인팅 | ✅ |
|
|
327
330
|
| 5 | 유니티 대조 골든 테스트 | ✅ |
|
|
328
|
-
| 6 | **v0.1 공개** |
|
|
329
|
-
| 7
|
|
331
|
+
| 6 | **v0.1 공개** | ✅ |
|
|
332
|
+
| 7 | **v0.2 — ScrollView·Image·상태, 대표 화면 대조** | ✅ |
|
|
333
|
+
| 8+ | 편집 레이어, 도구 통합 | ⬜ |
|
|
330
334
|
|
|
331
335
|
전체 계획: [`docs/ROADMAP.md`](docs/ROADMAP.md)
|
|
332
336
|
|
|
@@ -410,8 +414,8 @@ pnpm build
|
|
|
410
414
|
계산이 필요한 값은 고정값으로 풀거나 C#에서 계산해야 합니다.
|
|
411
415
|
|
|
412
416
|
**유니티와 얼마나 같나요?**
|
|
413
|
-
Unity 6000.0.40f1 기준, 인벤토리 화면 전체를 포함한 레이아웃 케이스
|
|
414
|
-
**요소 좌표
|
|
417
|
+
Unity 6000.0.40f1 기준, 인벤토리 화면 전체를 포함한 레이아웃 케이스 33개에서
|
|
418
|
+
**요소 좌표 564개 중 548개 일치**입니다. 스크린샷이 아니라 좌표를 비교하는데,
|
|
415
419
|
유니티가 자기 폰트 에셋으로 글자를 그리기 때문입니다 — 그리고 그 사실 때문에
|
|
416
420
|
불일치 16개 중 **10개가 레이아웃이 아니라 폰트 메트릭**입니다. 전부
|
|
417
421
|
[`docs/accuracy.md`](docs/accuracy.md)에 이름이 적혀 있습니다.
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ 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
|
*
|
|
@@ -57,8 +59,15 @@ export interface RenderOptions {
|
|
|
57
59
|
* USS background images look like `url("project://database/Assets/foo.png")`
|
|
58
60
|
* or `resource("foo")`. Browsers cannot load these, so the host application
|
|
59
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.
|
|
60
69
|
*/
|
|
61
|
-
resolveAsset?: (path: string) => string | null;
|
|
70
|
+
resolveAsset?: (path: string, form: 'url' | 'resource') => string | null;
|
|
62
71
|
/** Panel size in pixels. Defaults to the container's client size. */
|
|
63
72
|
size?: {
|
|
64
73
|
width: number;
|
|
@@ -94,7 +103,8 @@ export interface RenderResult {
|
|
|
94
103
|
/**
|
|
95
104
|
* Everything the renderer could not honour: unsupported controls, properties,
|
|
96
105
|
* selectors and units, plus unresolved assets. Distinct from
|
|
97
|
-
* `UxmlDocument.warnings`, which
|
|
106
|
+
* `UxmlDocument.warnings`, which covers malformed input and unresolved
|
|
107
|
+
* `<Style src="…">` / `@import` references rather than render-time support.
|
|
98
108
|
*/
|
|
99
109
|
warnings: readonly Warning[];
|
|
100
110
|
/** Painted element per model node. Lets a host map a click back to the tree. */
|