uxml-preview 0.1.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,55 @@
1
+ # Third-party notices
2
+
3
+ `uxml-preview` itself is Apache-2.0 (see `LICENSE`). This file covers software
4
+ redistributed **inside build output**, which carries its own obligations.
5
+
6
+ ## Where this applies
7
+
8
+ | Artifact | Bundles third-party code? | Notice required |
9
+ |---|---|---|
10
+ | npm package (`dist/`) | No — `yoga-layout` is an external dependency the consumer installs | No |
11
+ | Playground site (`dist-site/`) | **Yes** — `yoga-layout`, including its WebAssembly binary, is inlined | **Yes** |
12
+
13
+ The published playground is a single self-contained bundle, so it redistributes
14
+ `yoga-layout`. MIT requires the copyright notice and permission notice to travel
15
+ with such copies, which is what this file is for; the site build also emits a
16
+ banner pointing here.
17
+
18
+ ## yoga-layout
19
+
20
+ - Version: 3.2.1
21
+ - Upstream: https://github.com/facebook/yoga
22
+ - Declared license: MIT (`"license": "MIT"` in its `package.json`; every shipped
23
+ source file carries the Meta copyright header below)
24
+
25
+ > Note: the published npm package does not include a `LICENSE` file. The
26
+ > permission notice below is the standard MIT text, matching the license the
27
+ > package declares and the header its sources carry.
28
+
29
+ ```
30
+ Copyright (c) Meta Platforms, Inc. and affiliates.
31
+
32
+ Permission is hereby granted, free of charge, to any person obtaining a copy
33
+ of this software and associated documentation files (the "Software"), to deal
34
+ in the Software without restriction, including without limitation the rights
35
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
36
+ copies of the Software, and to permit persons to whom the Software is
37
+ furnished to do so, subject to the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be included in all
40
+ copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
47
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
48
+ SOFTWARE.
49
+ ```
50
+
51
+ ## Build and test tooling
52
+
53
+ Vite, Vitest, TypeScript, jsdom, pixelmatch and pngjs are development
54
+ dependencies. They are not redistributed in either artifact above, so they carry
55
+ no notice obligation here.
@@ -0,0 +1,10 @@
1
+ import { ElementNode } from '../model/types';
2
+ export interface ControlSpec {
3
+ /** Renders the `text` attribute as its content. */
4
+ hasText: boolean;
5
+ }
6
+ /** The document container. Not a control, but it is the panel's root box. */
7
+ export declare const ROOT_LOCAL_NAME = "UXML";
8
+ export declare function controlFor(node: ElementNode): ControlSpec | null;
9
+ export declare function isRoot(node: ElementNode): boolean;
10
+ export declare function supportedControlNames(): string[];
@@ -0,0 +1,110 @@
1
+ import { NodeId, UxmlDocument, Warning } from './model/types';
2
+ import { LayoutBox, MeasureText } from './layout/yoga';
3
+ /**
4
+ * uxml-preview — public API surface.
5
+ *
6
+ * Phase 1: the document model is defined (src/model/types.ts). The functions
7
+ * below are still signatures only; implementations land in Phases 2–4.
8
+ * See docs/ROADMAP.md.
9
+ */
10
+ export type { Span, SourceRef, NodeId, ElementName, Attribute, ElementSpans, ElementNode, Combinator, SimpleSelector, SelectorPart, Selector, Declaration, Rule, SheetItem, StyleSheet, WarningKind, Warning, UxmlDocument, StyleOrigin, } from './model/types';
11
+ export { loadLayoutEngine, isLayoutEngineReady, liveNodeCount } from './layout/yoga';
12
+ export type { LayoutBox, MeasureText, TextContext, TextMetrics } from './layout/yoga';
13
+ export { createDefaultMeasureText } from './render/measure';
14
+ export { NODE_ATTRIBUTE } from './render/paint';
15
+ export { supportedControlNames } from './controls/registry';
16
+ export { resolveStyles, explainProperty } from './style/resolve';
17
+ export type { Candidate, ComputedStyle, ComputedValue, ResolveOptions, ResolveResult, } from './style/resolve';
18
+ export type { Specificity } from './style/specificity';
19
+ export { isInherited } from './style/properties';
20
+ /**
21
+ * Parse UXML and USS text into a document model.
22
+ *
23
+ * Never throws on unsupported input: unknown controls, properties and selectors
24
+ * are kept verbatim so they survive `serialize`. Only malformed text produces a
25
+ * warning here — whether something can be *rendered* is decided downstream.
26
+ */
27
+ export interface ParseOptions {
28
+ /**
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
+ * simply do not participate.
32
+ *
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
+ */
36
+ resolveImport?: (url: string) => string | null;
37
+ }
38
+ export declare function parse(uxml: string, uss?: string, options?: ParseOptions): UxmlDocument;
39
+ /**
40
+ * Serialize a document model back to UXML and USS text.
41
+ *
42
+ * Ensures: for a document with no edits, the output is byte-identical to the
43
+ * input — untouched nodes are re-emitted by slicing `UxmlDocument.source`
44
+ * rather than being regenerated. After an edit, only the edited region changes.
45
+ */
46
+ export declare function serialize(doc: UxmlDocument): {
47
+ uxml: string;
48
+ uss: string;
49
+ };
50
+ export interface RenderOptions {
51
+ /**
52
+ * Resolves Unity asset references to something a browser can load.
53
+ *
54
+ * USS background images look like `url("project://database/Assets/foo.png")`
55
+ * or `resource("foo")`. Browsers cannot load these, so the host application
56
+ * must map them to real URLs. Return `null` to draw a placeholder instead.
57
+ */
58
+ resolveAsset?: (path: string) => string | null;
59
+ /** Panel size in pixels. Defaults to the container's client size. */
60
+ size?: {
61
+ width: number;
62
+ height: number;
63
+ };
64
+ /**
65
+ * Measures a control's text.
66
+ *
67
+ * The default uses a canvas, whose metrics move with the platform and the
68
+ * installed fonts. Anything that needs a reproducible result — golden tests
69
+ * above all — should supply its own.
70
+ */
71
+ measureText?: MeasureText;
72
+ /** Pseudo-classes to render as active, e.g. `new Set(['hover'])`. */
73
+ activeStates?: ReadonlySet<string>;
74
+ }
75
+ export interface RenderResult {
76
+ /**
77
+ * Everything the renderer could not honour: unsupported controls, properties,
78
+ * selectors and units, plus unresolved assets. Distinct from
79
+ * `UxmlDocument.warnings`, which only covers malformed input.
80
+ */
81
+ warnings: readonly Warning[];
82
+ /** Painted element per model node. Lets a host map a click back to the tree. */
83
+ elements: ReadonlyMap<NodeId, HTMLElement>;
84
+ /**
85
+ * What Yoga computed, in panel coordinates, before any of it became CSS.
86
+ *
87
+ * Exposed because a layout bug has two possible homes — the Yoga mapping or
88
+ * the painting — and CLAUDE.md's rule is to read both rather than guess.
89
+ * Golden tests compare these numbers rather than pixels.
90
+ */
91
+ boxes: ReadonlyMap<NodeId, LayoutBox>;
92
+ /**
93
+ * Deps/Effects: frees the Yoga node tree (`freeRecursive`) and removes the
94
+ * generated DOM from the container.
95
+ *
96
+ * Requires: must be called before re-rendering into the same container. Yoga
97
+ * nodes are WASM handles and are not garbage collected.
98
+ */
99
+ dispose(): void;
100
+ }
101
+ /**
102
+ * Purpose: draw a document into a container element.
103
+ * Deps/Effects: replaces the container's children and allocates Yoga nodes.
104
+ * Call `dispose()` on the result before rendering again.
105
+ * Requires: `await loadLayoutEngine()` once, first. Yoga is WebAssembly and
106
+ * cannot be loaded synchronously; keeping that await out here is
107
+ * what lets this function stay synchronous, which the playground
108
+ * and the golden tests both want.
109
+ */
110
+ export declare function render(doc: UxmlDocument, container: HTMLElement, options?: RenderOptions): RenderResult;