uxml-preview 0.5.1 → 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 +126 -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/dist/index.d.ts +14 -0
- package/dist/index.js +1631 -1364
- package/dist/layout/yoga.d.ts +11 -0
- package/dist/model/types.d.ts +18 -4
- package/dist/render/css-map.d.ts +15 -0
- 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 +2 -0
- package/dist/render/visibility.d.ts +20 -0
- package/dist/style/registry.d.ts +5 -1
- package/dist/style/resolve.d.ts +9 -2
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,127 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.0 — 2026-10-16
|
|
4
|
+
|
|
5
|
+
Diagnostics that say what Unity does instead, text measured the way Unity
|
|
6
|
+
measures it, fonts, and `aspect-ratio`. A minor version in 0.x because drawn
|
|
7
|
+
output changes (text height, `:enabled`, letter/word spacing, `aspect-ratio`)
|
|
8
|
+
and the published accuracy figures move. No type is removed and no
|
|
9
|
+
`WarningKind` is added; every new field is optional.
|
|
10
|
+
|
|
11
|
+
### Accuracy — previous and new figures
|
|
12
|
+
|
|
13
|
+
| Set | 0.5.1 | 0.6.0 | Why |
|
|
14
|
+
|---|---:|---:|---|
|
|
15
|
+
| Base coordinates (Unity 6000.0.40f1) | 660 / 676 | 660 / 676 | unchanged: the three text-measuring cases are excluded from it, and of its 16 mismatches the 9 caused by text are widths and x. `ItemDesc.height` has a fixed height and shrinks for a theme reason (Unity gives Labels `flex-shrink: 0`), so text height cannot reach it |
|
|
16
|
+
| Template cohort (6000.0.40f1) | 200 / 220 | 215 / 220 | text height from FaceInfo removed 14 Label heights and the `y` they pushed |
|
|
17
|
+
| Text cohort (new; Chromium vs Unity 6.3) | — | lines 60/60, height 52/60, width 60/60, boundary 79/80 | see `docs/accuracy.md`; none unexplained |
|
|
18
|
+
| 6.3 re-dump of the golden set | — | 1012 / 1012 equal to a 6000.0 dump of the same day | every golden case lays out the same on 6000.3.25f1. Against the committed 2026-08-12 baselines nine values differ, all the known `inventory` footer 1px |
|
|
19
|
+
|
|
20
|
+
### Behavior changes
|
|
21
|
+
|
|
22
|
+
- **Text height follows Unity.** `ceil(lines × size × (ascent − descent) /
|
|
23
|
+
pointSize)`, from the FaceInfo Unity reports, plus paragraph spacing. The
|
|
24
|
+
default (editor Inter) gives 12px → 15, 20px → 25 where 0.5.1 gave
|
|
25
|
+
14.4 / 24. A multi-line block is rounded once, not per line.
|
|
26
|
+
- **`letter-spacing` / `word-spacing` are not CSS px.** Unity widens by
|
|
27
|
+
value × font size / 100 per gap; measured and drawn that way.
|
|
28
|
+
`-unity-paragraph-spacing` is measured and drawn.
|
|
29
|
+
- **`:enabled` applies automatically** to every element that is not disabled
|
|
30
|
+
(measured on 6000.0.40f1 and 6000.3.25f1). A screen with `:enabled` rules
|
|
31
|
+
draws differently.
|
|
32
|
+
- **`aspect-ratio` is laid out** (Unity 6.3+); it matched Unity 52/52 on the
|
|
33
|
+
measured case.
|
|
34
|
+
- A Label's text is measured decoded (`&`, ` `), as it is drawn.
|
|
35
|
+
- **Spaces are measured the way Unity 6.3 LTS lays them out.** Under
|
|
36
|
+
`normal` and `nowrap`, a run of spaces measures as one and leading spaces
|
|
37
|
+
as none; `pre` and `pre-wrap` keep them. Measured at 20px
|
|
38
|
+
(`tests/layout/unity/<version>/probe-editor/spaces.json`,
|
|
39
|
+
`spaces-prewrap.json`). Unity 6000.0 does not collapse them; the preview
|
|
40
|
+
follows 6.3. Trailing spaces are not measured; they follow CSS, which is
|
|
41
|
+
what the browser paints. 0.5.1 measured every space as written.
|
|
42
|
+
- Painted letter spacing matches measured spacing: no spacing beside a
|
|
43
|
+
space (advanced generator) and none after the last character.
|
|
44
|
+
- `-unity-text-generator` (`standard` / `advanced`) is measured and painted,
|
|
45
|
+
and no longer raises a `not-rendered` warning with `affectsLayout`.
|
|
46
|
+
- A border width in an unsupported unit is reported once, not twice.
|
|
47
|
+
- New warnings, all `unsupported-property` with `reason: 'invalid-value'`
|
|
48
|
+
unless noted: `hsl()`, `cubic-bezier()`, `opacity` in `%`, `inherit`.
|
|
49
|
+
`linear-gradient()` keeps `not-uss` and says Unity shows its warning icon.
|
|
50
|
+
- Text drawn with the default font (no `-unity-font-definition`) that
|
|
51
|
+
contains Hangul, Han or Kana warns: `unsupported-property` with the new
|
|
52
|
+
reason `font-fallback` and `subject.missingGlyphs`. Inter has no such
|
|
53
|
+
glyphs; Unity draws them with a fallback font, measured 1–4px taller.
|
|
54
|
+
- `states` keys that match nothing, contain a state pseudo-class, or list a
|
|
55
|
+
state Unity never sets now warn: `unsupported-selector` with
|
|
56
|
+
`subject.problem`.
|
|
57
|
+
|
|
58
|
+
### New, all optional
|
|
59
|
+
|
|
60
|
+
- `Warning.nodes` — every element a declaration's rule matched.
|
|
61
|
+
- `at.url` / `at.from` on USS locations — the arguments `resolveImport`
|
|
62
|
+
received for that sheet, so `at.sheet` can be mapped without the expanded
|
|
63
|
+
document.
|
|
64
|
+
- `subject.unityEffect` — `unstyled-from-here` (Unity's style updater throws:
|
|
65
|
+
`hsl()` on 6000.3, `cubic-bezier()`,
|
|
66
|
+
`filter` on 6000.0 — measured: the element with the value and every element after it in the panel lose their style, elements before it keep theirs; hence `unstyled-from-here`) or `file-inline-dropped` (one bad inline value drops
|
|
67
|
+
every inline style in that UXML file), with the Unity versions measured.
|
|
68
|
+
- `subject.problem` / `subject.state` on `states-key`; `subject.role: 'font'`
|
|
69
|
+
on `asset`.
|
|
70
|
+
- `RenderResult.document`, `.styles`, `.partStyles` — the expanded tree and
|
|
71
|
+
the cascade `render()` drew with.
|
|
72
|
+
- `classifyVisibility(result)` — hidden / emptied / collapsed / shown, ported
|
|
73
|
+
from uxml-author.
|
|
74
|
+
- `RenderOptions.resolveFont(path, form)` → family, or `{ family, faceInfo }`,
|
|
75
|
+
or `null`. `TextContext` gains `fontFamily`, `faceInfo`, `letterSpacing`,
|
|
76
|
+
`wordSpacing`, `paragraphSpacing`, `textGenerator`.
|
|
77
|
+
- `textHeight`, `EDITOR_DEFAULT_FACE_INFO`, `FaceInfo`.
|
|
78
|
+
|
|
79
|
+
### For consumers
|
|
80
|
+
|
|
81
|
+
- A `states-key` warning no longer always means "this key is unusable":
|
|
82
|
+
read `subject.problem` (absent = unusable selector). uxml-author master
|
|
83
|
+
assumes the 0.5.1 meaning.
|
|
84
|
+
- `aspect-ratio`, `letter-spacing`, `word-spacing` and
|
|
85
|
+
`-unity-paragraph-spacing` are now laid out, so they no longer raise a
|
|
86
|
+
`not-rendered` warning with `affectsLayout`. Tests that used one of them as
|
|
87
|
+
the example of a layout gap need another; `-unity-text-auto-size` still is
|
|
88
|
+
one. Against this build, uxml-author master fails 16 tests (states keys,
|
|
89
|
+
the `aspect-ratio` layout-gap fixtures, its bundle-size note) and
|
|
90
|
+
vscode-uxml-preview main fails 1 (`letter-spacing` as the layout-gap
|
|
91
|
+
fixture); its typecheck is clean. All are consumer-side updates, none a
|
|
92
|
+
core regression. Neither consumer picks up 0.6.0 automatically
|
|
93
|
+
(uxml-author bundles its core; the extension depends on `^0.5.1`).
|
|
94
|
+
- **A new `reason`, `font-fallback`.** `reason` is an open set and this is the
|
|
95
|
+
first value added to it. uxml-author master sends any `reason` it does not
|
|
96
|
+
know to `other`, which fails the run (exit 1), so a Korean UXML with no
|
|
97
|
+
font set would fail there until the skill learns it. It is not
|
|
98
|
+
`not-rendered`, so it never meets the skill's exit-3 condition
|
|
99
|
+
(`not-rendered` + `affectsLayout`). `docs/backlog.md` has the skill-side
|
|
100
|
+
note.
|
|
101
|
+
- Messages changed for the inline unsupported unit and `linear-gradient()`;
|
|
102
|
+
match on `reason`/`subject`, not text.
|
|
103
|
+
|
|
104
|
+
### Tools
|
|
105
|
+
|
|
106
|
+
- `pnpm test:text` runs the text cohort in a real Chromium
|
|
107
|
+
(`UXML_TEXT_CHROMIUM`, `UXML_TEXT_FONTS`); it fails, never skips, when it
|
|
108
|
+
cannot run. `playwright-core` is a new devDependency.
|
|
109
|
+
|
|
110
|
+
### Playground and documentation
|
|
111
|
+
|
|
112
|
+
- The playground shows each warning's `reason` as a badge and what its
|
|
113
|
+
`subject` says — the Unity versions an `unityEffect` was measured on, the
|
|
114
|
+
missing script, the property to write instead, whether coordinates may
|
|
115
|
+
differ. New examples: Unity text height and spacing with a fallback-font
|
|
116
|
+
warning, `aspect-ratio`, and values Unity cannot apply.
|
|
117
|
+
- README split into `README.md` and `README.ko.md`, plus Japanese
|
|
118
|
+
(`README.ja.md`) and Simplified Chinese (`README.zh-CN.md`), with absolute links (npm
|
|
119
|
+
shows the README without `docs/`). Its figures are checked against a live
|
|
120
|
+
recomputation, as `docs/accuracy.md`'s are.
|
|
121
|
+
- New `docs/api.md` / `docs/api.en.md`; the warning contract moved there from
|
|
122
|
+
`docs/supported.md`. The Korean and English pages of `supported`,
|
|
123
|
+
`accuracy` and `uss-vs-css` now carry the same content.
|
|
124
|
+
|
|
3
125
|
## 0.5.1 — 2026-10-13
|
|
4
126
|
|
|
5
127
|
A cleanup release: nothing drawn changes except where a Unity dump said it was
|
|
@@ -390,12 +512,12 @@ of the sixteen differences are font metrics rather than layout** — both engine
|
|
|
390
512
|
shrink the same box for the same reason, and only the ruler differs. Three more
|
|
391
513
|
are 1px, two are the `yoga-layout` version difference already known in 0.1.0, and
|
|
392
514
|
**one is genuinely unresolved**. All sixteen are named in
|
|
393
|
-
[`docs/accuracy.en.md`](docs/accuracy.en.md).
|
|
515
|
+
[`docs/accuracy.en.md`](https://github.com/ReuHomi/uxml-preview/blob/main/docs/accuracy.en.md).
|
|
394
516
|
|
|
395
517
|
Colour, borders and corners are held by a CSS-declaration regression baseline
|
|
396
518
|
(`tests/render/visual.test.ts`), which detects our own drift and is not evidence
|
|
397
519
|
of agreement with Unity. That comparison is a one-time eye check, recorded with
|
|
398
|
-
both screenshots in [`docs/visual-check.md`](docs/visual-check.md).
|
|
520
|
+
both screenshots in [`docs/visual-check.md`](https://github.com/ReuHomi/uxml-preview/blob/main/docs/visual-check.md).
|
|
399
521
|
|
|
400
522
|
### Known limitations
|
|
401
523
|
|
|
@@ -420,7 +542,7 @@ back unchanged.
|
|
|
420
542
|
Measured against **Unity 6000.0.40f1** across 18 layout cases and 61 elements:
|
|
421
543
|
**242 of 244 element coordinates identical** (0.5px tolerance; the matching 17
|
|
422
544
|
cases agree exactly, not merely within tolerance). Procedure and per-case
|
|
423
|
-
figures in [`docs/accuracy.en.md`](docs/accuracy.en.md).
|
|
545
|
+
figures in [`docs/accuracy.en.md`](https://github.com/ReuHomi/uxml-preview/blob/main/docs/accuracy.en.md).
|
|
424
546
|
|
|
425
547
|
Round-trip is byte-exact on all 15 fixtures — comments, attribute order,
|
|
426
548
|
entity encodings, CRLF line endings, mixed indentation, unsupported controls.
|
|
@@ -433,7 +555,7 @@ entity encodings, CRLF line endings, mixed indentation, unsupported controls.
|
|
|
433
555
|
- Cascade: specificity, source order, inheritance, inline styles, `var()`
|
|
434
556
|
custom properties, shorthand expansion
|
|
435
557
|
- Layout: the flex family, sizing, box model, positioning
|
|
436
|
-
- Full matrix: [`docs/supported.en.md`](docs/supported.en.md)
|
|
558
|
+
- Full matrix: [`docs/supported.en.md`](https://github.com/ReuHomi/uxml-preview/blob/main/docs/supported.en.md)
|
|
437
559
|
|
|
438
560
|
### Known limitations
|
|
439
561
|
|
package/README.ja.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# uxml-preview
|
|
2
|
+
|
|
3
|
+
*[English](https://github.com/ReuHomi/uxml-preview/blob/main/README.md) · [한국어](https://github.com/ReuHomi/uxml-preview/blob/main/README.ko.md) · 日本語 · [简体中文](https://github.com/ReuHomi/uxml-preview/blob/main/README.zh-CN.md)*
|
|
4
|
+
|
|
5
|
+
**Unity UI Toolkit の UXML/USS を、Unity エディタなしでブラウザ上に描画します。レイアウトには
|
|
6
|
+
UI Toolkit 自身が使用する Yoga エンジンを採用し、描画結果は実際の Unity と突き合わせて検証しています。**
|
|
7
|
+
|
|
8
|
+
[](https://reuhomi.github.io/uxml-preview/)
|
|
9
|
+
|
|
10
|
+
### ▶ [プレイグラウンドを開く](https://reuhomi.github.io/uxml-preview/)
|
|
11
|
+
|
|
12
|
+
手元の `.uxml` と `.uss` を貼り付けるか、サンプルを開いて試せます。ファイルはどこにも
|
|
13
|
+
アップロードされず、すべてページ内で動作します。
|
|
14
|
+
|
|
15
|
+
[](https://github.com/ReuHomi/uxml-preview/actions/workflows/ci.yml)
|
|
16
|
+
[](https://github.com/ReuHomi/uxml-preview/actions/workflows/pages.yml)
|
|
17
|
+
[](https://github.com/ReuHomi/uxml-preview/blob/main/LICENSE)
|
|
18
|
+
|
|
19
|
+
## 検証方法
|
|
20
|
+
|
|
21
|
+
- **座標:** 完成画面1件を含む40個のレイアウトケースにおいて、要素の座標値 660 / 676 が Unity 6000.0.40f1 と一致しています。[すべての差異とその内訳 →](https://github.com/ReuHomi/uxml-preview/blob/main/docs/accuracy.en.md) 同じケースを Unity 6.3(6000.3.25f1)で再ダンプしたところ、同日に取得した 6000.0.40f1 のダンプとすべての配置が一致しました。[6.3 での再測定 →](https://github.com/ReuHomi/uxml-preview/blob/main/docs/accuracy.en.md#unity-63-lts-re-measurement-2026-10-15)
|
|
22
|
+
- **テキスト:** 実際のブラウザで描画し、Unity 6000.3.25f1 と Label 単位で比較しました。行数 60 / 60、高さ 52 / 60、幅 60 / 60(誤差 1px または 1% 以内)。高さが異なるケースはすべて、ハングルを含まない欧文フォント Inter で韓国語、または韓国語と欧文が混在するテキストを指定したものです。Unity はこれをフォールバックフォントで描画しますが、本プレビューではまさにその状況を警告として通知します。[テキスト検証セット →](https://github.com/ReuHomi/uxml-preview/blob/main/docs/accuracy.en.md#text-cohort-separate-set-measured-2026-10-16)
|
|
23
|
+
- **Unity バージョン:** 基準バージョンは Unity 6.3 LTS です。USS プロパティかどうかの判定は Unity 公式のプロパティ一覧(6.6 まで)に基づいており、6.7 は LTS になるまでサポート対象外です。[サポート範囲 →](https://github.com/ReuHomi/uxml-preview/blob/main/docs/supported.en.md)
|
|
24
|
+
- **一致しない箇所は見過ごさず、警告として報告します。** 未サポートのコントロール・プロパティ・値は、その理由とともに(測定済みの場合は Unity 側が代わりにどう振る舞うかも含めて)警告として返されます。[警告について →](https://github.com/ReuHomi/uxml-preview/blob/main/docs/api.en.md#warnings)
|
|
25
|
+
|
|
26
|
+
## 3つの使い方
|
|
27
|
+
|
|
28
|
+
| 用途 | 推奨ツール |
|
|
29
|
+
|---|---|
|
|
30
|
+
| **画面をデザインする** | ブラウザ上の[プレイグラウンド](https://reuhomi.github.io/uxml-preview/)、またはプロジェクトファイルの隣で使える [UXML Preview for VS Code](https://github.com/ReuHomi/vscode-uxml-preview) |
|
|
31
|
+
| **AI エージェントに UI を書かせる** | [uxml-author](https://github.com/ReuHomi/uxml-author) — UXML/USS を記述し、本ライブラリで描画・結果確認まで行ってから出力するスキル |
|
|
32
|
+
| **ツールを開発する** | 本ライブラリ:`npm install uxml-preview`、詳細は [API ドキュメント](https://github.com/ReuHomi/uxml-preview/blob/main/docs/api.en.md) |
|
|
33
|
+
|
|
34
|
+
## インストール
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install uxml-preview
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
ツール類には Node 22 以降が必要です。描画には DOM 環境(ブラウザ、またはテスト環境では
|
|
41
|
+
happy-dom / jsdom)が必要です。
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { loadLayoutEngine, parse, render, serialize } from 'uxml-preview';
|
|
45
|
+
|
|
46
|
+
await loadLayoutEngine(); // Yoga は WebAssembly のため、最初に1回読み込む
|
|
47
|
+
|
|
48
|
+
const doc = parse(uxmlText, ussText); // テキスト → モデル
|
|
49
|
+
const view = render(doc, container, { // モデル → 画面
|
|
50
|
+
size: { width: 1280, height: 720 }, // ウィンドウではなくパネルのサイズ
|
|
51
|
+
resolveAsset: (path, form) => myAssetUrl(path, form), // project://… → URL(なければ null)
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
for (const w of view.warnings) console.log(w.reason ?? w.kind, w.message);
|
|
55
|
+
|
|
56
|
+
view.dispose(); // Yoga ノードはガベージコレクションされないため明示的に解放
|
|
57
|
+
const { uxml, uss } = serialize(doc); // 未編集なら入力とバイト単位で一致
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## ドキュメント
|
|
61
|
+
|
|
62
|
+
- [USS は CSS ではない](https://github.com/ReuHomi/uxml-preview/blob/main/docs/uss-vs-css.md)(英語) — CSS から移植したスタイルシートが意図通りにならない違いを実例付きで解説
|
|
63
|
+
- [サポート範囲](https://github.com/ReuHomi/uxml-preview/blob/main/docs/supported.en.md)(英語) — コントロール、プロパティ、ステート、バージョン、およびそれぞれの検証範囲
|
|
64
|
+
- [精度](https://github.com/ReuHomi/uxml-preview/blob/main/docs/accuracy.en.md)(英語) — すべての数値、測定方法、既知の差異一覧
|
|
65
|
+
- [API](https://github.com/ReuHomi/uxml-preview/blob/main/docs/api.en.md)(英語) — `parse`、`render`、`serialize`、各種フック、警告、`classifyVisibility`
|
|
66
|
+
- [変更履歴](https://github.com/ReuHomi/uxml-preview/blob/main/CHANGELOG.md)(英語)
|
|
67
|
+
- [目視比較](https://github.com/ReuHomi/uxml-preview/blob/main/docs/visual-check.md)(韓国語) — 色や質感を Unity と並べて比較した単発の検証記録(2026-08)
|
|
68
|
+
|
|
69
|
+
## 開発
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pnpm install
|
|
73
|
+
pnpm dev # プレイグラウンドを起動
|
|
74
|
+
pnpm test # ブラウザや Unity なしで動作する全テスト
|
|
75
|
+
pnpm test:text # テキスト検証セット(実際の Chromium 上で実行、docs/accuracy.en.md 参照)
|
|
76
|
+
pnpm build
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Unity 側のリファレンス値を再生成するには Unity のインストールが必要です。手順は
|
|
80
|
+
[精度ドキュメント](https://github.com/ReuHomi/uxml-preview/blob/main/docs/accuracy.en.md#producing-the-ground-truth)にあります。
|
|
81
|
+
|
|
82
|
+
## ライセンス
|
|
83
|
+
|
|
84
|
+
Apache-2.0
|
package/README.ko.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# uxml-preview
|
|
2
|
+
|
|
3
|
+
*[English](https://github.com/ReuHomi/uxml-preview/blob/main/README.md) · 한국어 · [日本語](https://github.com/ReuHomi/uxml-preview/blob/main/README.ja.md) · [简体中文](https://github.com/ReuHomi/uxml-preview/blob/main/README.zh-CN.md)*
|
|
4
|
+
|
|
5
|
+
**Unity UI Toolkit의 UXML/USS를 Unity 에디터 없이 브라우저에서 그립니다. 배치는 UI Toolkit이
|
|
6
|
+
쓰는 엔진인 Yoga가 하고, 결과는 Unity와 대조해 측정했습니다.**
|
|
7
|
+
|
|
8
|
+
[](https://reuhomi.github.io/uxml-preview/)
|
|
9
|
+
|
|
10
|
+
### ▶ [놀이터 열기](https://reuhomi.github.io/uxml-preview/)
|
|
11
|
+
|
|
12
|
+
`.uxml`과 `.uss`를 붙여 넣거나 예제를 여세요. 아무것도 업로드되지 않고 페이지 안에서만
|
|
13
|
+
돕니다.
|
|
14
|
+
|
|
15
|
+
[](https://github.com/ReuHomi/uxml-preview/actions/workflows/ci.yml)
|
|
16
|
+
[](https://github.com/ReuHomi/uxml-preview/actions/workflows/pages.yml)
|
|
17
|
+
[](https://github.com/ReuHomi/uxml-preview/blob/main/LICENSE)
|
|
18
|
+
|
|
19
|
+
## 어떻게 확인했나
|
|
20
|
+
|
|
21
|
+
- **좌표:** 완성된 화면 하나를 포함한 배치 케이스 40개에서, 요소 좌표 값 660 / 676이 Unity 6000.0.40f1과 같습니다. [다른 곳은 전부 이름을 붙여 적었습니다 →](https://github.com/ReuHomi/uxml-preview/blob/main/docs/accuracy.md) 같은 케이스를 Unity 6.3(6000.3.25f1)에서 다시 덤프했더니, 같은 날 다시 뜬 6000.0.40f1 덤프와 배치가 모두 같았습니다. [6.3 재측정 →](https://github.com/ReuHomi/uxml-preview/blob/main/docs/accuracy.md#unity-63-lts-재측정-2026-10-15)
|
|
22
|
+
- **텍스트:** 실제 브라우저에서 그려 Unity 6000.3.25f1과 Label 단위로 대조했습니다. 줄 수 60 / 60, 높이 52 / 60, 너비 60 / 60(1px 또는 1% 이내). 높이가 다른 것은 모두 라틴 글꼴 Inter로 쓴 한글·혼합 문장입니다 — Inter에 한글이 없어 Unity가 대체 폰트로 그리고, 미리보기는 바로 그 경우에 경고합니다. [텍스트 코호트 →](https://github.com/ReuHomi/uxml-preview/blob/main/docs/accuracy.md#텍스트-코호트-별도-검증-세트-2026-10-16-측정)
|
|
23
|
+
- **Unity 버전:** 기준은 Unity 6.3 LTS입니다. USS 속성인지는 Unity 공식 속성표(6.6까지)로 판정하고, 6.7은 LTS가 나올 때까지 지원하지 않습니다. [지원 범위 →](https://github.com/ReuHomi/uxml-preview/blob/main/docs/supported.md)
|
|
24
|
+
- **맞지 않는 곳은 조용히 넘기지 않고 경고로 알립니다.** 지원하지 않는 컨트롤·속성·값은 이유와 함께, 측정한 경우에는 Unity가 대신 어떻게 하는지까지 경고로 돌아옵니다. [경고 →](https://github.com/ReuHomi/uxml-preview/blob/main/docs/api.md#경고)
|
|
25
|
+
|
|
26
|
+
## 쓰는 방법 세 가지
|
|
27
|
+
|
|
28
|
+
| 이런 분이라면 | 이것을 |
|
|
29
|
+
|---|---|
|
|
30
|
+
| **화면을 디자인한다** | 브라우저의 [놀이터](https://reuhomi.github.io/uxml-preview/), 또는 프로젝트 파일 옆에서 [UXML Preview for VS Code](https://github.com/ReuHomi/vscode-uxml-preview) |
|
|
31
|
+
| **AI 에이전트에게 UI를 맡긴다** | [uxml-author](https://github.com/ReuHomi/uxml-author) — UXML/USS를 쓰고, 이 라이브러리로 그려 결과를 확인한 뒤 넘겨주는 스킬 |
|
|
32
|
+
| **도구를 만든다** | 이 라이브러리: `npm install uxml-preview`, 그다음 [API](https://github.com/ReuHomi/uxml-preview/blob/main/docs/api.md) |
|
|
33
|
+
|
|
34
|
+
## 설치
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install uxml-preview
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
도구 쪽은 Node 22 이상입니다. 그리려면 DOM이 필요합니다(브라우저, 또는 테스트에서는
|
|
41
|
+
happy-dom·jsdom).
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { loadLayoutEngine, parse, render, serialize } from 'uxml-preview';
|
|
45
|
+
|
|
46
|
+
await loadLayoutEngine(); // Yoga는 WebAssembly라 처음에 한 번 불러온다
|
|
47
|
+
|
|
48
|
+
const doc = parse(uxmlText, ussText); // 텍스트 → 모델
|
|
49
|
+
const view = render(doc, container, { // 모델 → 화면
|
|
50
|
+
size: { width: 1280, height: 720 }, // 창이 아니라 패널 크기
|
|
51
|
+
resolveAsset: (path, form) => myAssetUrl(path, form), // project://… → URL, 없으면 null
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
for (const w of view.warnings) console.log(w.reason ?? w.kind, w.message);
|
|
55
|
+
|
|
56
|
+
view.dispose(); // Yoga 노드는 가비지 컬렉션되지 않는다
|
|
57
|
+
const { uxml, uss } = serialize(doc); // 고치지 않았으면 입력과 바이트 단위로 같다
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 문서
|
|
61
|
+
|
|
62
|
+
- [USS는 CSS가 아니다](https://github.com/ReuHomi/uxml-preview/blob/main/docs/uss-vs-css.ko.md) — 옮겨 온 스타일시트가 틀어지는 차이들, 예제와 함께
|
|
63
|
+
- [지원 범위](https://github.com/ReuHomi/uxml-preview/blob/main/docs/supported.md) — 컨트롤·속성·상태·버전, 그리고 각각 어디까지 확인했는지
|
|
64
|
+
- [정확도](https://github.com/ReuHomi/uxml-preview/blob/main/docs/accuracy.md) — 모든 수치, 잰 방법, 알려진 차이 전부
|
|
65
|
+
- [API](https://github.com/ReuHomi/uxml-preview/blob/main/docs/api.md) — `parse`, `render`, `serialize`, 훅, 경고, `classifyVisibility`
|
|
66
|
+
- [변경 기록](https://github.com/ReuHomi/uxml-preview/blob/main/CHANGELOG.md) (영문)
|
|
67
|
+
- [육안 대조](https://github.com/ReuHomi/uxml-preview/blob/main/docs/visual-check.md) — 색과 질감을 Unity와 나란히 놓고 본 1회 기록(2026-08)
|
|
68
|
+
|
|
69
|
+
## 개발
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pnpm install
|
|
73
|
+
pnpm dev # 놀이터
|
|
74
|
+
pnpm test # 브라우저·Unity 없이 도는 전부
|
|
75
|
+
pnpm test:text # 텍스트 코호트, 실제 Chromium에서 (docs/accuracy.md)
|
|
76
|
+
pnpm build
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Unity 쪽 기준값을 다시 만들려면 Unity가 필요합니다. 절차는
|
|
80
|
+
[정확도](https://github.com/ReuHomi/uxml-preview/blob/main/docs/accuracy.md#기준값-만드는-법)에 있습니다.
|
|
81
|
+
|
|
82
|
+
## 라이선스
|
|
83
|
+
|
|
84
|
+
Apache-2.0
|