@routevn/creator-model 1.10.4 → 1.11.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.
Files changed (3) hide show
  1. package/README.md +38 -0
  2. package/package.json +1 -1
  3. package/src/model.js +1225 -35
package/README.md CHANGED
@@ -135,6 +135,44 @@ existing non-folder font:
135
135
  { fontId: ["font-primary", "font-fallback"] }
136
136
  ```
137
137
 
138
+ ## Computed Variables
139
+
140
+ Variables support read-only computed definitions for `string`, `number`,
141
+ `boolean`, and `object` results. The presence of `computed` is the source
142
+ discriminator; computed variables omit stored `scope`, `default`, and `value`
143
+ fields:
144
+
145
+ ```js
146
+ {
147
+ id: "hpPercent",
148
+ type: "variable",
149
+ variableType: "number",
150
+ name: "HP Percent",
151
+ computed: {
152
+ expr: {
153
+ round: [
154
+ {
155
+ mul: [
156
+ {
157
+ div: [
158
+ { var: "variables.hp" },
159
+ { var: "variables.maxHp" },
160
+ ],
161
+ },
162
+ 100,
163
+ ],
164
+ },
165
+ ],
166
+ },
167
+ },
168
+ }
169
+ ```
170
+
171
+ Computed definitions may use a simple `expr` or literal `value`, or ordered
172
+ `branches` with an explicit `default`. Validation enforces the Route Engine
173
+ operator grammar, result types, concrete `variables.*`/`runtime.*` paths,
174
+ declared variable references, and an acyclic computed dependency graph.
175
+
138
176
  ## File Structure
139
177
 
140
178
  ```text
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routevn/creator-model",
3
- "version": "1.10.4",
3
+ "version": "1.11.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",