@elyx-design/cli 0.0.1-preview.14303.24b991c07 → 0.0.1-preview.14795.f62799d7f

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.
Files changed (2) hide show
  1. package/README.md +138 -0
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -9,6 +9,14 @@ npm install --global @elyx-design/cli
9
9
  elyx --help
10
10
  ```
11
11
 
12
+ Open a project folder in the matching Elyx app release (development, nightly,
13
+ preview, or public):
14
+
15
+ ```sh
16
+ elyx .
17
+ elyx /path/to/project
18
+ ```
19
+
12
20
  This package provides the JavaScript launcher. The native executable is
13
21
  installed through an optional package selected for the current operating system
14
22
  and architecture.
@@ -43,3 +51,133 @@ native executable.
43
51
 
44
52
  The daemon also compiles rendering, inspection, lint, and scene code from
45
53
  `src/`. Mosaic uses its native font-loading code.
54
+
55
+ The Figma reader and its CLI adapter live in `src/fig/`. Its miniz
56
+ and Zstandard dependencies are also listed in `cpp-vendors.yml` and are only
57
+ configured by the native CLI build. The daemon also builds the reader and
58
+ converter using its own pinned dependencies for sidebar `.fig` imports.
59
+
60
+ ## Building an Elyx model
61
+
62
+ For `.fig` decoding and the `elyx fig inspect` and `elyx fig convert` commands,
63
+ see [the Figma reader and converter](src/fig/README.md).
64
+
65
+ `ElyxLang::ElyxModelBuilder` builds objects from `Model.h` without creating an
66
+ `MSWorld`. It uses `elyxSchema()` to find fields, check units, select the existing
67
+ value codec, and order properties. `build()` transfers the declarations into a
68
+ `ModelValue` containing a `ModelBoard`.
69
+
70
+ Pass an `ElyxModelBuilder::Layer` tree to `addLayer()`. Children keep their input
71
+ order and are declared inside their parent, alongside the `children:` references.
72
+ Names must be unique among siblings; separate parents can reuse a child name.
73
+ The schema determines which layer types accept children.
74
+
75
+ Properties currently support literal lengths, such as frame width and height,
76
+ and a single solid `fill` supplied as an `MSColor`. Color channels, including
77
+ alpha, must be finite values between 0 and 1. The builder validates the fill
78
+ through the schema's shorthand expansion, paint branch, and color codec, then
79
+ keeps the typed color for formatting. Paint lists and paint objects are not yet
80
+ supported.
81
+
82
+ Unknown properties, invalid or duplicate symbols, invalid lengths, unsupported
83
+ property structures, and nesting beyond 512 child levels return an error. A
84
+ failed `addLayer()` leaves the entire document unchanged, even when the error is
85
+ in a descendant. Accepted values are copied; the builder does not omit defaults.
86
+
87
+ The model carries a distinct namespace for each layer's declarations. The
88
+ formatter uses those namespaces to render local child references without an
89
+ external namespace resolver.
90
+
91
+ The schema must outlive the builder. The process-wide `elyxSchema()` does.
92
+
93
+ ## Create a frame with colored children and write it to disk
94
+
95
+ ```cpp
96
+ #include <fstream>
97
+ #include <stdexcept>
98
+ #include <utility>
99
+
100
+ #include "ElyxLang/ElyxFormatter.h"
101
+ #include "ElyxLang/ElyxModelBuilder.h"
102
+ #include "ElyxLang/ElyxSchema.h"
103
+ #include "primitives/MSColor.h"
104
+
105
+ int main() {
106
+ using namespace ElyxLang;
107
+
108
+ ElyxModelBuilder document{Schema::elyxSchema()};
109
+ ElyxModelBuilder::Layer card{
110
+ .kind = ModelBuiltinBase::Frame,
111
+ .name = "card",
112
+ };
113
+ card.properties.add("width", ModelValue{ast::Length::Pixel(320)});
114
+ card.properties.add("height", ModelValue{ast::Length::Pixel(200)});
115
+ card.properties.add("fill", ModelValue{MSColor::White()});
116
+
117
+ ElyxModelBuilder::Layer rectangle{
118
+ .kind = ModelBuiltinBase::Frame,
119
+ .name = "rectangle",
120
+ };
121
+ rectangle.properties.add("left", ModelValue{ast::Length::Pixel(16)});
122
+ rectangle.properties.add("top", ModelValue{ast::Length::Pixel(24)});
123
+ rectangle.properties.add("width", ModelValue{ast::Length::Pixel(80)});
124
+ rectangle.properties.add("height", ModelValue{ast::Length::Pixel(40)});
125
+ rectangle.properties.add("fill", ModelValue{MSColor::Red()});
126
+ card.children.push_back(std::move(rectangle));
127
+
128
+ ElyxModelBuilder::Layer translucent{
129
+ .kind = ModelBuiltinBase::Frame,
130
+ .name = "translucent",
131
+ };
132
+ translucent.properties.add("left", ModelValue{ast::Length::Pixel(128)});
133
+ translucent.properties.add("top", ModelValue{ast::Length::Pixel(24)});
134
+ translucent.properties.add("width", ModelValue{ast::Length::Pixel(80)});
135
+ translucent.properties.add("height", ModelValue{ast::Length::Pixel(40)});
136
+ translucent.properties.add("fill", ModelValue{MSColor::Blue().withAlpha(0.5F)});
137
+ card.children.push_back(std::move(translucent));
138
+
139
+ if (auto result = document.addLayer(card); !result) {
140
+ throw std::runtime_error(result.error());
141
+ }
142
+ auto model = std::move(document).build();
143
+
144
+ pp::DocumentBuilder output;
145
+ pp::PrettyPrinter printer;
146
+ pp::DefaultLayout layout;
147
+ const auto &formatted = printer.pp(output, model);
148
+
149
+ std::ofstream file;
150
+ file.exceptions(std::ios::failbit | std::ios::badbit);
151
+ file.open("card.elyx");
152
+ file << printer.render(formatted, layout);
153
+ file.close();
154
+ }
155
+ ```
156
+
157
+ Additional paint types and references to other scopes are later steps. The Figma
158
+ converter calls this shared language API; the CLI handles arguments and output
159
+ files.
160
+
161
+ ## Layer targets
162
+
163
+ Inspection returns a `target` on component nodes and bounds, hit, and rectangle
164
+ results. It contains `filePath`, `sourceRef`, and `overridePath`; a null target
165
+ means the runtime layer has no reusable source address. Other fields such as
166
+ `symbol`, `ref`, and `path` describe the layer, rather than identifying an exact
167
+ instance occurrence.
168
+
169
+ Use the target's file path as the CLI input, `sourceRef` as inspect's `--ref` or
170
+ render's `--symbol`, and `overridePath` as `--override-path`. For example:
171
+
172
+ ```sh
173
+ elyx inspect component screen.elyx --ref=musicPlayer.track.save
174
+ elyx inspect bounds screen.elyx --ref=card --override-path="'ui.Body.Label"
175
+ elyx render screen.elyx --symbol=card --override-path="'ui.Body.Label" -o label.png
176
+ ```
177
+
178
+ Copy override paths from inspection; their namespace qualifiers distinguish
179
+ imported descendants. Ambiguous source references fail instead of choosing an
180
+ instance. In MCP, pass the returned object as `query.target` to inspect
181
+ bounds/component, `target` to render, or an entry in focus's `targets` array.
182
+ Spatial inspect queries use `query.filePath`. To render a whole document, pass
183
+ `target: {filePath: "screen.elyx"}`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyx-design/cli",
3
- "version": "0.0.1-preview.14303.24b991c07",
3
+ "version": "0.0.1-preview.14795.f62799d7f",
4
4
  "description": "Command-line tools for Elyx",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {
@@ -22,7 +22,7 @@
22
22
  "dist"
23
23
  ],
24
24
  "optionalDependencies": {
25
- "@elyx-design/cli-darwin-arm64": "0.0.1-preview.14303.24b991c07",
26
- "@elyx-design/cli-linux-x64": "0.0.1-preview.14303.24b991c07"
25
+ "@elyx-design/cli-darwin-arm64": "0.0.1-preview.14795.f62799d7f",
26
+ "@elyx-design/cli-linux-x64": "0.0.1-preview.14795.f62799d7f"
27
27
  }
28
28
  }