@kurot/ui 3.1.0 → 3.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.
@@ -0,0 +1,47 @@
1
+ # BitmapLabel
2
+
3
+ Available in UI 3.2.0 with `@kurot/core ^2.2.0`. Core resolves its published
4
+ @kurot/bitmap-font dependency from npm. UI 3.2.0 is published;
5
+ published UI 3.1.0 does not contain this component. Core 2.1.1 does not contain
6
+ its required BitmapText rendering.
7
+
8
+ UI 3.3.0 retains this API and raises the package's Core minimum to ^2.3.0 for
9
+ RichLabel. During automatic sizing it also uses maxWidth when neither a parent
10
+ width nor an explicit width is present, so wrapped height matches rendering.
11
+ Changing an authored width also invalidates automatic height after layout.
12
+ UI 3.3.0 builds and tests against published Core 2.3.1 without local overrides.
13
+
14
+ ```ts
15
+ import { BitmapLabel } from '@kurot/ui';
16
+
17
+ const label = new BitmapLabel('1,234.56');
18
+ label.font = 'number_font_fnt';
19
+ label.multiline = false;
20
+ label.height = 100;
21
+ group.addChild(label);
22
+ ```
23
+
24
+ `font` accepts a BitmapFont, a configured resource name, or undefined to clear.
25
+ Names resolve through the Core resource singleton. Preloaded names resolve
26
+ synchronously during commitProperties; unloaded names start resource.load.
27
+ Successful name resolution dispatches Event.COMPLETE; failed or incorrectly
28
+ typed resources dispatch IOErrorEvent.IO_ERROR with source/error data.
29
+ Superseded asynchronous requests cannot overwrite a newer font assignment,
30
+ including A-to-B-to-A changes. The resource cache or caller retains ownership.
31
+
32
+ Text assignments dispatch PropertyEvent.PROPERTY_CHANGE for binding. The
33
+ component participates in normal layout, measurement and invalidation and owns
34
+ one BitmapText child. Parent width constraints affect wrapping; measurements do
35
+ not leave temporary width/height constraints on that child. textWidth/textHeight
36
+ report content under the width constraint before height clipping.
37
+
38
+ Properties: text, font, textAlign, verticalAlign, letterSpacing, lineSpacing,
39
+ multiline and smoothing, plus ordinary Component properties. Tint is the ordinary
40
+ DisplayObject tint. Alignments position glyphs without scaling them. Set scaleX
41
+ and scaleY for decorative number sizing. Default multiline=true; explicit false
42
+ keeps the first hard-separated line unwrapped.
43
+
44
+ This initial change exposes a native UI component and supports programmatic
45
+ skins. The ui-document built-in catalog, CLI KUI tag registry, Editor and
46
+ ui-runtime materializers do not yet adopt BitmapLabel. Those require coordinated
47
+ consumer releases; do not assume an installed compiler accepts the XML tag.
@@ -1,9 +1,14 @@
1
1
  # Label text layout and fitting
2
2
 
3
- This contract applies to UI 3.1.0 with Core >= 2.1.0 within Core 2.x. The public
3
+ Introduced in UI 3.1.0 with Core >= 2.1.0, this contract is unchanged in UI 3.2.0,
4
+ which requires Core ^2.2.0. The public
4
5
  `TextFitMode` type is `none | shrink`. Native UI depends only on Core. KUI
5
- authoring uses ui-document 0.9.x and matching CLI/ui-runtime releases; older
6
- consumers must update their dependency ranges before using the new fields.
6
+ authoring introduced fitting metadata in ui-document 0.9.0 and retains it in
7
+ 0.11.0. Published CLI 3.3.0 and ui-runtime 0.8.2 use ui-document `^0.11.0`.
8
+ Runtime 0.8.0's `^0.9.0` and runtime 0.8.1's `^0.10.0` peer ranges exclude
9
+ the current kernel. Label presets are expanded into native properties before
10
+ rendering; their precedence does not change fitting behavior. See the
11
+ [project style contract](../../ui-document/docs/project-styles.md).
7
12
 
8
13
  ## Lines and bounds
9
14
 
@@ -0,0 +1,77 @@
1
+ # RichLabel
2
+
3
+ Native API introduced in UI 3.3.0, requiring Core ^2.3.0. Core 2.3.1 is
4
+ published and installed from npm for this release's build and verification.
5
+
6
+ ```ts
7
+ import { RichLabel } from '@kurot/ui';
8
+
9
+ const label = new RichLabel([
10
+ { text: 'Warning: ', style: { size: 20, bold: true, textColor: 0xff9900 } },
11
+ { text: 'read this before continuing.', style: { size: 20, italic: true } },
12
+ ]);
13
+ label.maxWidth = 240;
14
+ group.addChild(label);
15
+ ```
16
+
17
+ ## Content and ownership
18
+
19
+ RichLabel extends Component independently, not Label. Its only content interface
20
+ is `textFlow: ITextElement[]`, using Core's text/style records. Whole-component
21
+ `text`, `fontFamily`, `size`, `bold`, `italic`, `textColor`, `textFit`, `minFontSize`
22
+ and `textStyle` are not exposed. Label presets do not apply to this component.
23
+
24
+ Runs can specify font family, size, bold, italic, text color, stroke color and
25
+ stroke width. Unspecified fields use the native TextField defaults captured at
26
+ construction. In particular, an unstyled run does not inherit the previous run.
27
+ All runs are laid out continuously; a style boundary does not introduce a word
28
+ boundary or a new line. No HTML or markdown parsing is performed.
29
+
30
+ The component copies runs and their styles on assignment and on reads. Mutating
31
+ an input array or a returned snapshot does not change the component. Reassign
32
+ an edited snapshot to apply it. Assigning [] clears content; assignment dispatches
33
+ PropertyEvent.PROPERTY_CHANGE for `textFlow` after the new content is installed.
34
+
35
+ ## Layout
36
+
37
+ Ordinary Component geometry, layout constraints, visibility and alpha remain
38
+ available, together with these text-layout properties:
39
+
40
+ | Property | Default | Contract |
41
+ | ---------------------- | --------- | ------------------------------------------------------------------------- |
42
+ | multiline | true | False shows the first hard-separated line without width wrapping. |
43
+ | wordWrap | true | Unicode line-break opportunities; false wraps between graphemes. |
44
+ | lineSpacing | 0 | Finite, nonnegative distance between lines. |
45
+ | textAlign | left | left, center or right. |
46
+ | verticalAlign | top | top, middle or bottom. |
47
+ | textWidth / textHeight | Read-only | Complete content metrics under the current width, before height clipping. |
48
+
49
+ Measurement uses parent-assigned width first, then explicit width, then a
50
+ configured maxWidth, otherwise unconstrained width. Automatic height includes
51
+ every wrapped line and inter-line spacing. Each line uses the largest font size
52
+ of its runs, rather than imposing the TextField base size. Hard line separators
53
+ and trailing blank lines follow the Core text contract. Core 2.3.1 corrects the
54
+ base size of unstyled blank runs between styled runs; the API minimum stays 2.3.0. Empty content measures
55
+ 0 × 0; Component minWidth/minHeight can still enlarge its layout bounds.
56
+
57
+ Fixed height clips drawing without discarding content. Alignment positions the
58
+ continuous text block within the assigned bounds. One native TextField renders
59
+ through Canvas 2D and WebGL; measurement never temporarily resizes that field.
60
+ Unchanged content metrics are cached until size/content invalidation or a width
61
+ change.
62
+
63
+ ## Font readiness and integration
64
+
65
+ Load project fonts before measuring where possible. If fonts become ready later,
66
+ call `label.invalidateSize()` to clear both component and native text metrics,
67
+ then allow normal layout validation. RichLabel does not load font files or
68
+ install global font-loading listeners.
69
+
70
+ This release supports native code and programmatic skins. The current
71
+ ui-document catalog, CLI KUI registry, ui-runtime materializer and Editor do not
72
+ yet provide RichLabel authoring or serialization. Their later integration must
73
+ keep textFlow ownership and the separation from ordinary Label presets.
74
+
75
+ See [Core text layout](../../core/docs/text-layout.md) for Unicode wrapping,
76
+ single-line behavior and independent measurement. Run `pnpm test:text-labels`
77
+ after building Core and UI for minified Canvas/WebGL browser verification.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kurot/ui",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
4
4
  "description": "EUI-compatible UI component framework for the Kurot game engine — skin-based components, layouts, data binding, view states",
5
5
  "author": "Kelvin <kyia.x52@gmail.com>",
6
6
  "license": "MIT",
@@ -30,15 +30,17 @@
30
30
  "benchmark:compare": "playwright test --config examples/benchmark/playwright.config.ts",
31
31
  "benchmark:smoke": "UI_BENCHMARK_PROFILE=smoke playwright test --config examples/benchmark/playwright.config.ts",
32
32
  "build:benchmark": "vite --config vite.config.ts build",
33
- "prepublishOnly": "npm run clean && npm run build"
33
+ "prepublishOnly": "npm run clean && npm run build",
34
+ "test:text-labels": "playwright test test/browser --workers=1"
34
35
  },
35
36
  "peerDependencies": {
36
- "@kurot/core": "^2.1.0"
37
+ "@kurot/core": "^2.3.0"
37
38
  },
38
39
  "devDependencies": {
39
- "@kurot/core": "^2.1.0",
40
+ "@kurot/core": "^2.3.1",
40
41
  "@playwright/test": "1.62.1",
41
42
  "@types/node": "^22.0.0",
43
+ "esbuild": "^0.28.2",
42
44
  "happy-dom": "^20.8.9",
43
45
  "typescript": "^5.6.0",
44
46
  "vite": "^8.0.8",