@casmo/tree.js 0.1.1 → 0.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.
Files changed (220) hide show
  1. package/README.md +312 -16
  2. package/dist/apply-Cio2t7CZ.js +285 -0
  3. package/dist/apply-Cio2t7CZ.js.map +1 -0
  4. package/dist/bake/index.d.ts +44 -5
  5. package/dist/bake/index.d.ts.map +1 -1
  6. package/dist/definition/crown-shape.d.ts +9 -0
  7. package/dist/definition/crown-shape.d.ts.map +1 -0
  8. package/dist/definition/defaults.d.ts +15 -1
  9. package/dist/definition/defaults.d.ts.map +1 -1
  10. package/dist/definition/index.d.ts +4 -3
  11. package/dist/definition/index.d.ts.map +1 -1
  12. package/dist/definition/migrations.d.ts +0 -8
  13. package/dist/definition/migrations.d.ts.map +1 -1
  14. package/dist/definition/schema.d.ts.map +1 -1
  15. package/dist/definition/types.d.ts +181 -6
  16. package/dist/definition/types.d.ts.map +1 -1
  17. package/dist/effects/mask.d.ts +3 -3
  18. package/dist/effects/mask.d.ts.map +1 -1
  19. package/dist/effects.js +3 -3
  20. package/dist/effects.js.map +1 -1
  21. package/dist/forest/Forest.d.ts +37 -2
  22. package/dist/forest/Forest.d.ts.map +1 -1
  23. package/dist/forest/nodes.d.ts +6 -1
  24. package/dist/forest/nodes.d.ts.map +1 -1
  25. package/dist/{forest-OX9WvAwh.js → forest-ChEaWJrf.js} +1763 -684
  26. package/dist/forest-ChEaWJrf.js.map +1 -0
  27. package/dist/generator/branches.d.ts +2 -2
  28. package/dist/generator/branches.d.ts.map +1 -1
  29. package/dist/generator/crown.d.ts +28 -0
  30. package/dist/generator/crown.d.ts.map +1 -0
  31. package/dist/generator/fruit.d.ts +28 -0
  32. package/dist/generator/fruit.d.ts.map +1 -0
  33. package/dist/generator/growth.d.ts +1 -1
  34. package/dist/generator/growth.d.ts.map +1 -1
  35. package/dist/generator/index.d.ts +5 -4
  36. package/dist/generator/index.d.ts.map +1 -1
  37. package/dist/generator/leaf-shapes.d.ts +33 -1
  38. package/dist/generator/leaf-shapes.d.ts.map +1 -1
  39. package/dist/generator/mesh.d.ts +10 -2
  40. package/dist/generator/mesh.d.ts.map +1 -1
  41. package/dist/generator/occlusion.d.ts +8 -0
  42. package/dist/generator/occlusion.d.ts.map +1 -0
  43. package/dist/generator/roots.d.ts +16 -0
  44. package/dist/generator/roots.d.ts.map +1 -0
  45. package/dist/generator/trunk.d.ts +16 -2
  46. package/dist/generator/trunk.d.ts.map +1 -1
  47. package/dist/generator/types.d.ts +61 -6
  48. package/dist/generator/types.d.ts.map +1 -1
  49. package/dist/growth/index.d.ts +1 -1
  50. package/dist/growth/index.d.ts.map +1 -1
  51. package/dist/growth/tsl.d.ts +2 -0
  52. package/dist/growth/tsl.d.ts.map +1 -1
  53. package/dist/index.d.ts +6 -3
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +274 -24
  56. package/dist/index.js.map +1 -1
  57. package/dist/materials/crown-nodes.d.ts +20 -0
  58. package/dist/materials/crown-nodes.d.ts.map +1 -0
  59. package/dist/materials/crown-normals.d.ts +17 -0
  60. package/dist/materials/crown-normals.d.ts.map +1 -0
  61. package/dist/materials/ground-tint.d.ts +13 -0
  62. package/dist/materials/ground-tint.d.ts.map +1 -0
  63. package/dist/materials/index.d.ts +13 -1
  64. package/dist/materials/index.d.ts.map +1 -1
  65. package/dist/materials/leaf-translucency-model.d.ts +14 -0
  66. package/dist/materials/leaf-translucency-model.d.ts.map +1 -0
  67. package/dist/materials/leaf-translucency.d.ts +73 -0
  68. package/dist/materials/leaf-translucency.d.ts.map +1 -0
  69. package/dist/materials/material-features.d.ts +43 -0
  70. package/dist/materials/material-features.d.ts.map +1 -0
  71. package/dist/materials/occlusion.d.ts +10 -0
  72. package/dist/materials/occlusion.d.ts.map +1 -0
  73. package/dist/materials/toon.d.ts +18 -1
  74. package/dist/materials/toon.d.ts.map +1 -1
  75. package/dist/names-BE9he6CS.js +713 -0
  76. package/dist/names-BE9he6CS.js.map +1 -0
  77. package/dist/react/Tree.d.ts +5 -2
  78. package/dist/react/Tree.d.ts.map +1 -1
  79. package/dist/react.js +10 -6
  80. package/dist/react.js.map +1 -1
  81. package/dist/season/nodes.d.ts +16 -0
  82. package/dist/season/nodes.d.ts.map +1 -1
  83. package/dist/season/profile.d.ts +26 -0
  84. package/dist/season/profile.d.ts.map +1 -1
  85. package/dist/species/almond.js +223 -0
  86. package/dist/species/almond.js.map +1 -0
  87. package/dist/species/almond.json +210 -0
  88. package/dist/species/apple.js +230 -0
  89. package/dist/species/apple.js.map +1 -0
  90. package/dist/species/apple.json +220 -0
  91. package/dist/species/ash.js +187 -0
  92. package/dist/species/ash.js.map +1 -0
  93. package/dist/species/ash.json +177 -0
  94. package/dist/species/beech.js +174 -0
  95. package/dist/species/beech.js.map +1 -0
  96. package/dist/species/beech.json +167 -0
  97. package/dist/species/birch.js +170 -0
  98. package/dist/species/birch.js.map +1 -0
  99. package/dist/species/birch.json +163 -0
  100. package/dist/species/catalog.d.ts +61 -0
  101. package/dist/species/catalog.d.ts.map +1 -0
  102. package/dist/species/cedar.js +169 -0
  103. package/dist/species/cedar.js.map +1 -0
  104. package/dist/species/cedar.json +168 -0
  105. package/dist/species/cherry.js +237 -0
  106. package/dist/species/cherry.js.map +1 -0
  107. package/dist/species/cherry.json +224 -0
  108. package/dist/species/chestnut.js +230 -0
  109. package/dist/species/chestnut.js.map +1 -0
  110. package/dist/species/chestnut.json +220 -0
  111. package/dist/species/douglas-fir.js +174 -0
  112. package/dist/species/douglas-fir.js.map +1 -0
  113. package/dist/species/douglas-fir.json +170 -0
  114. package/dist/species/elm.js +173 -0
  115. package/dist/species/elm.js.map +1 -0
  116. package/dist/species/elm.json +163 -0
  117. package/dist/species/hemlock.js +175 -0
  118. package/dist/species/hemlock.js.map +1 -0
  119. package/dist/species/hemlock.json +171 -0
  120. package/dist/species/hickory.js +200 -0
  121. package/dist/species/hickory.js.map +1 -0
  122. package/dist/species/hickory.json +192 -0
  123. package/dist/species/index.d.ts +10 -0
  124. package/dist/species/index.d.ts.map +1 -0
  125. package/dist/species/juniper.js +158 -0
  126. package/dist/species/juniper.js.map +1 -0
  127. package/dist/species/juniper.json +154 -0
  128. package/dist/species/loaders.d.ts +7 -0
  129. package/dist/species/loaders.d.ts.map +1 -0
  130. package/dist/species/mahogany.js +201 -0
  131. package/dist/species/mahogany.js.map +1 -0
  132. package/dist/species/mahogany.json +196 -0
  133. package/dist/species/maple.js +177 -0
  134. package/dist/species/maple.js.map +1 -0
  135. package/dist/species/maple.json +171 -0
  136. package/dist/species/oak.js +220 -0
  137. package/dist/species/oak.js.map +1 -0
  138. package/dist/species/oak.json +212 -0
  139. package/dist/species/olive.js +189 -0
  140. package/dist/species/olive.js.map +1 -0
  141. package/dist/species/olive.json +181 -0
  142. package/dist/species/peach.js +223 -0
  143. package/dist/species/peach.js.map +1 -0
  144. package/dist/species/peach.json +210 -0
  145. package/dist/species/pear.js +213 -0
  146. package/dist/species/pear.js.map +1 -0
  147. package/dist/species/pear.json +200 -0
  148. package/dist/species/pine.js +163 -0
  149. package/dist/species/pine.js.map +1 -0
  150. package/dist/species/pine.json +162 -0
  151. package/dist/species/plum.js +237 -0
  152. package/dist/species/plum.js.map +1 -0
  153. package/dist/species/plum.json +224 -0
  154. package/dist/species/red-oak.js +220 -0
  155. package/dist/species/red-oak.js.map +1 -0
  156. package/dist/species/red-oak.json +212 -0
  157. package/dist/species/redwood.js +174 -0
  158. package/dist/species/redwood.js.map +1 -0
  159. package/dist/species/redwood.json +170 -0
  160. package/dist/species/sequoia.js +167 -0
  161. package/dist/species/sequoia.js.map +1 -0
  162. package/dist/species/sequoia.json +166 -0
  163. package/dist/species/spruce.js +170 -0
  164. package/dist/species/spruce.js.map +1 -0
  165. package/dist/species/spruce.json +166 -0
  166. package/dist/species/teak.js +166 -0
  167. package/dist/species/teak.js.map +1 -0
  168. package/dist/species/teak.json +157 -0
  169. package/dist/species/types.d.ts +65 -0
  170. package/dist/species/types.d.ts.map +1 -0
  171. package/dist/species/walnut.js +220 -0
  172. package/dist/species/walnut.js.map +1 -0
  173. package/dist/species/walnut.json +212 -0
  174. package/dist/species/white-oak.js +213 -0
  175. package/dist/species/white-oak.js.map +1 -0
  176. package/dist/species/white-oak.json +208 -0
  177. package/dist/species.js +160 -0
  178. package/dist/species.js.map +1 -0
  179. package/dist/styles/apply.d.ts +12 -0
  180. package/dist/styles/apply.d.ts.map +1 -0
  181. package/dist/styles/low-poly/index.d.ts +1 -1
  182. package/dist/styles/low-poly/index.d.ts.map +1 -1
  183. package/dist/styles/low-poly.js +13 -10
  184. package/dist/styles/low-poly.js.map +1 -1
  185. package/dist/styles/material-features.d.ts +27 -0
  186. package/dist/styles/material-features.d.ts.map +1 -0
  187. package/dist/styles/names.d.ts +28 -0
  188. package/dist/styles/names.d.ts.map +1 -0
  189. package/dist/styles/realistic/index.d.ts +3 -8
  190. package/dist/styles/realistic/index.d.ts.map +1 -1
  191. package/dist/styles/realistic/textures.d.ts +20 -0
  192. package/dist/styles/realistic/textures.d.ts.map +1 -0
  193. package/dist/styles/realistic.js +14 -18
  194. package/dist/styles/realistic.js.map +1 -1
  195. package/dist/styles/registry.d.ts +2 -13
  196. package/dist/styles/registry.d.ts.map +1 -1
  197. package/dist/styles/stylized/index.d.ts +1 -1
  198. package/dist/styles/stylized/index.d.ts.map +1 -1
  199. package/dist/styles/stylized.js +13 -10
  200. package/dist/styles/stylized.js.map +1 -1
  201. package/dist/styles/types.d.ts +16 -2
  202. package/dist/styles/types.d.ts.map +1 -1
  203. package/dist/textures/realistic/bark-fibrous-normal.png +0 -0
  204. package/dist/textures/realistic/bark-fibrous.png +0 -0
  205. package/dist/textures/realistic/bark-papery-normal.png +0 -0
  206. package/dist/textures/realistic/bark-papery.png +0 -0
  207. package/dist/textures/realistic/bark-plated-normal.png +0 -0
  208. package/dist/textures/realistic/bark-plated.png +0 -0
  209. package/dist/textures/realistic/bark-smooth-normal.png +0 -0
  210. package/dist/textures/realistic/bark-smooth.png +0 -0
  211. package/dist/textures/realistic/leaf-compound.png +0 -0
  212. package/dist/textures/realistic/leaf-lobed.png +0 -0
  213. package/dist/textures/realistic/leaf-palmate.png +0 -0
  214. package/dist/textures/realistic/scale.png +0 -0
  215. package/dist/tree/Tree.d.ts +34 -5
  216. package/dist/tree/Tree.d.ts.map +1 -1
  217. package/package.json +9 -2
  218. package/dist/forest-OX9WvAwh.js.map +0 -1
  219. package/dist/types-BZjHhNz7.js +0 -20
  220. package/dist/types-BZjHhNz7.js.map +0 -1
@@ -0,0 +1,285 @@
1
+ import { c as extendDefinition, i as styleShading, o as materialFeaturesOf, r as styleOfShading, u as parseDefinition } from "./names-BE9he6CS.js";
2
+ // src/styles/realistic/textures.ts
3
+ /**
4
+ * The realistic Style's texture files, as relative URLs (resolved against the texture base path).
5
+ * All made by scripts/generate-textures.mjs. `bark`/`barkNormal` are the furrowed pair, `leaf` the
6
+ * broad card and `needles` the needle card (the generic broadleaf / conifer use these).
7
+ */
8
+ var TEXTURES = {
9
+ bark: "realistic/bark.png",
10
+ barkNormal: "realistic/bark-normal.png",
11
+ leaf: "realistic/leaf.png",
12
+ needles: "realistic/needles.png"
13
+ };
14
+ /** The alpha-cut leaf card texture for each Leaf Type. */
15
+ var LEAF_TEXTURES = {
16
+ broad: TEXTURES.leaf,
17
+ lobed: "realistic/leaf-lobed.png",
18
+ palmate: "realistic/leaf-palmate.png",
19
+ compound: "realistic/leaf-compound.png",
20
+ needle: TEXTURES.needles,
21
+ scale: "realistic/scale.png"
22
+ };
23
+ /** The colour + normal map pair for each Bark Type. */
24
+ var BARK_TEXTURES = {
25
+ furrowed: {
26
+ map: TEXTURES.bark,
27
+ normalMap: TEXTURES.barkNormal
28
+ },
29
+ smooth: {
30
+ map: "realistic/bark-smooth.png",
31
+ normalMap: "realistic/bark-smooth-normal.png"
32
+ },
33
+ papery: {
34
+ map: "realistic/bark-papery.png",
35
+ normalMap: "realistic/bark-papery-normal.png"
36
+ },
37
+ fibrous: {
38
+ map: "realistic/bark-fibrous.png",
39
+ normalMap: "realistic/bark-fibrous-normal.png"
40
+ },
41
+ plated: {
42
+ map: "realistic/bark-plated.png",
43
+ normalMap: "realistic/bark-plated-normal.png"
44
+ }
45
+ };
46
+ // src/styles/apply.ts
47
+ var isNeedleLike = (type) => type === "needle" || type === "scale";
48
+ var untexturedLeaf = {
49
+ roughness: 1,
50
+ map: null,
51
+ alphaTest: .5
52
+ };
53
+ var untexturedBark = () => ({
54
+ roughness: 1,
55
+ map: null,
56
+ normalMap: null
57
+ });
58
+ var LOOKS = {
59
+ "low-poly": {
60
+ trunk: {
61
+ sides: 5,
62
+ sections: 4,
63
+ flareSections: 2
64
+ },
65
+ branches: [{
66
+ sides: 4,
67
+ sections: 2
68
+ }, {
69
+ sides: 3,
70
+ sections: 1
71
+ }],
72
+ bark: untexturedBark,
73
+ fruitSides: 4,
74
+ roots: {
75
+ sides: 3,
76
+ sections: 2
77
+ },
78
+ leaf: (type) => isNeedleLike(type) ? {
79
+ shape: "needle",
80
+ perDensity: 14,
81
+ sizeScale: 1.86,
82
+ material: untexturedLeaf
83
+ } : {
84
+ shape: "clump",
85
+ perDensity: 4,
86
+ sizeScale: 2.86,
87
+ material: untexturedLeaf
88
+ }
89
+ },
90
+ stylized: {
91
+ trunk: {
92
+ sides: 10,
93
+ sections: 8,
94
+ flareSections: 3
95
+ },
96
+ branches: [
97
+ {
98
+ sides: 6,
99
+ sections: 3
100
+ },
101
+ {
102
+ sides: 4,
103
+ sections: 1
104
+ },
105
+ {
106
+ sides: 3,
107
+ sections: 1
108
+ }
109
+ ],
110
+ bark: untexturedBark,
111
+ fruitSides: 6,
112
+ roots: {
113
+ sides: 6,
114
+ sections: 4
115
+ },
116
+ leaf: (type) => isNeedleLike(type) ? {
117
+ shape: "puff",
118
+ perDensity: 8,
119
+ sizeScale: 1.7,
120
+ material: untexturedLeaf
121
+ } : {
122
+ shape: "puff",
123
+ perDensity: 4,
124
+ sizeScale: 3.14,
125
+ material: untexturedLeaf
126
+ }
127
+ },
128
+ realistic: {
129
+ trunk: {
130
+ sides: 12,
131
+ sections: 10,
132
+ flareSections: 3
133
+ },
134
+ branches: [
135
+ {
136
+ sides: 8,
137
+ sections: 6
138
+ },
139
+ {
140
+ sides: 5,
141
+ sections: 4
142
+ },
143
+ {
144
+ sides: 3,
145
+ sections: 2
146
+ }
147
+ ],
148
+ bark: (type) => ({
149
+ roughness: .95,
150
+ ...BARK_TEXTURES[type]
151
+ }),
152
+ fruitSides: 9,
153
+ roots: {
154
+ sides: 8,
155
+ sections: 6
156
+ },
157
+ leaf: (type) => isNeedleLike(type) ? {
158
+ shape: "card",
159
+ perDensity: 120,
160
+ sizeScale: 1.7,
161
+ material: {
162
+ roughness: .7,
163
+ map: LEAF_TEXTURES[type],
164
+ alphaTest: .4
165
+ }
166
+ } : {
167
+ shape: "card",
168
+ perDensity: 80,
169
+ sizeScale: 2.2,
170
+ material: {
171
+ roughness: .65,
172
+ map: LEAF_TEXTURES[type],
173
+ alphaTest: .4
174
+ }
175
+ }
176
+ }
177
+ };
178
+ /** `{ [key]: value }` for an optional block that is present, `{}` when it is absent (to spread). */
179
+ function present(key, value) {
180
+ return value === void 0 ? {} : { [key]: value };
181
+ }
182
+ function fromSpecies(species) {
183
+ const { id, name, trunk, branches, season, wind, variation, fruit, roots, foliage, bark } = species;
184
+ return {
185
+ base: {
186
+ schemaVersion: 3,
187
+ name,
188
+ species: id,
189
+ trunk,
190
+ branches,
191
+ season,
192
+ wind,
193
+ variation,
194
+ sculpts: [],
195
+ ...present("fruit", fruit),
196
+ ...present("roots", roots)
197
+ },
198
+ foliage,
199
+ bark,
200
+ features: {}
201
+ };
202
+ }
203
+ function fromDefinition(input) {
204
+ const definition = parseDefinition(input);
205
+ const { leaves, materials, ...base } = definition;
206
+ const leafType = leaves.type ?? (leaves.shape === "needle" || /needle/.test(materials.leaf.map ?? "") ? "needle" : "broad");
207
+ const source = LOOKS[styleOfShading(materials.shading)].leaf(leafType);
208
+ return {
209
+ base,
210
+ foliage: {
211
+ type: leafType,
212
+ density: leaves.count / source.perDensity,
213
+ size: leaves.size / source.sizeScale,
214
+ sizeVariation: leaves.sizeVariation,
215
+ start: leaves.start,
216
+ angle: leaves.angle
217
+ },
218
+ bark: {
219
+ type: materials.bark.type ?? "furrowed",
220
+ color: materials.bark.color,
221
+ ...present("groundTint", materials.bark.groundTint)
222
+ },
223
+ features: materialFeaturesOf(definition)
224
+ };
225
+ }
226
+ function draw(name, { base, foliage, bark, features }) {
227
+ const look = LOOKS[name];
228
+ const leaf = look.leaf(foliage.type);
229
+ const fruit = base.fruit;
230
+ const roots = base.roots;
231
+ return parseDefinition({
232
+ ...base,
233
+ ...present("fruit", fruit && {
234
+ ...fruit,
235
+ sides: look.fruitSides
236
+ }),
237
+ ...present("roots", roots && {
238
+ ...roots,
239
+ ...look.roots
240
+ }),
241
+ trunk: {
242
+ ...base.trunk,
243
+ ...look.trunk
244
+ },
245
+ branches: base.branches.map((level, i) => ({
246
+ ...level,
247
+ ...look.branches[Math.min(i, look.branches.length - 1)]
248
+ })),
249
+ leaves: {
250
+ type: foliage.type,
251
+ count: Math.round(foliage.density * leaf.perDensity),
252
+ shape: leaf.shape,
253
+ size: foliage.size * leaf.sizeScale,
254
+ sizeVariation: foliage.sizeVariation,
255
+ start: foliage.start,
256
+ angle: foliage.angle
257
+ },
258
+ materials: {
259
+ shading: styleShading(name),
260
+ bark: {
261
+ type: bark.type,
262
+ color: bark.color,
263
+ ...look.bark(bark.type),
264
+ ...present("groundTint", bark.groundTint)
265
+ },
266
+ leaf: {
267
+ ...leaf.material,
268
+ ...present("crownNormals", features.crownNormals),
269
+ ...present("translucency", features.translucency)
270
+ },
271
+ ...present("occlusion", features.occlusion)
272
+ }
273
+ });
274
+ }
275
+ /**
276
+ * Applies a built-in Style's look to a Species or a Tree Definition (see `TreeStyle.apply`).
277
+ * Pure: never mutates its inputs.
278
+ */
279
+ function applyStyle(name, source, overrides) {
280
+ const definition = draw(name, "schemaVersion" in source ? fromDefinition(source) : fromSpecies(source));
281
+ return overrides ? extendDefinition(definition, overrides) : definition;
282
+ }
283
+ export { TEXTURES as i, BARK_TEXTURES as n, LEAF_TEXTURES as r, applyStyle as t };
284
+
285
+ //# sourceMappingURL=apply-Cio2t7CZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-Cio2t7CZ.js","names":[],"sources":["../src/styles/realistic/textures.ts","../src/styles/apply.ts"],"sourcesContent":["import type { BarkType, LeafType } from '../../definition/types';\n\n/**\n * The realistic Style's texture files, as relative URLs (resolved against the texture base path).\n * All made by scripts/generate-textures.mjs. `bark`/`barkNormal` are the furrowed pair, `leaf` the\n * broad card and `needles` the needle card (the generic broadleaf / conifer use these).\n */\nexport const TEXTURES = {\n bark: 'realistic/bark.png',\n barkNormal: 'realistic/bark-normal.png',\n leaf: 'realistic/leaf.png',\n needles: 'realistic/needles.png',\n} as const;\n\n/** The alpha-cut leaf card texture for each Leaf Type. */\nexport const LEAF_TEXTURES: Readonly<Record<LeafType, string>> = {\n broad: TEXTURES.leaf,\n lobed: 'realistic/leaf-lobed.png',\n palmate: 'realistic/leaf-palmate.png',\n compound: 'realistic/leaf-compound.png',\n needle: TEXTURES.needles,\n scale: 'realistic/scale.png',\n};\n\n/** The colour + normal map pair for each Bark Type. */\nexport const BARK_TEXTURES: Readonly<Record<BarkType, { map: string; normalMap: string }>> = {\n furrowed: { map: TEXTURES.bark, normalMap: TEXTURES.barkNormal },\n smooth: { map: 'realistic/bark-smooth.png', normalMap: 'realistic/bark-smooth-normal.png' },\n papery: { map: 'realistic/bark-papery.png', normalMap: 'realistic/bark-papery-normal.png' },\n fibrous: { map: 'realistic/bark-fibrous.png', normalMap: 'realistic/bark-fibrous-normal.png' },\n plated: { map: 'realistic/bark-plated.png', normalMap: 'realistic/bark-plated-normal.png' },\n};\n","// Style.apply (ADR 0005): a Style turns a Style-neutral Species (or an existing Tree Definition)\n// into a complete Tree Definition by choosing only the look: shading, polygon detail, how the\n// Leaf Type and Bark Type are drawn, and textures. Shape fields pass through untouched.\nimport { extendDefinition, parseDefinition, type DefinitionPatch } from '../definition/parse';\nimport {\n CURRENT_SCHEMA_VERSION,\n type BarkMaterialDefinition,\n type MaterialFeatures,\n type BarkType,\n type LeafMaterialDefinition,\n type LeafShape,\n type LeafType,\n type TreeDefinition,\n type TreeDefinitionInput,\n} from '../definition/types';\nimport type { SpeciesBarkDefinition, SpeciesDefinition, SpeciesFoliageDefinition } from '../species/types';\nimport { styleOfShading, styleShading, type StyleName } from './names';\nimport { materialFeaturesOf } from './material-features';\nimport { BARK_TEXTURES, LEAF_TEXTURES } from './realistic/textures';\n\n/** Polygon detail of one tree part. */\ninterface Detail {\n sides: number;\n sections: number;\n}\n\n/** How a Style draws one Leaf Type. */\ninterface LeafLook {\n shape: LeafShape;\n /** Leaves per terminal branch at density 1 (count = round(density × this)). */\n perDensity: number;\n /** Leaf size = the Species' real leaf-spray size × this. */\n sizeScale: number;\n material: LeafMaterialDefinition;\n}\n\n/** The trunk's detail, plus the extra rings in its Root Flare (`trunk.flareSections`). */\ninterface TrunkDetail extends Detail {\n flareSections: number;\n}\n\n/** Everything a Style decides about a tree: its look (its shading is in names.ts). */\ninterface StyleLook {\n trunk: TrunkDetail;\n /** Detail per branch level; deeper levels reuse the last entry. */\n branches: Detail[];\n bark(type: BarkType): Omit<BarkMaterialDefinition, 'type' | 'color'>;\n leaf(type: LeafType): LeafLook;\n /** Faces around each Fruit (`fruit.sides`): few flat facets in low-poly, smooth in the others. */\n fruitSides: number;\n /** Detail of each Root (`roots.sides`, `roots.sections`). */\n roots: Detail;\n}\n\nconst isNeedleLike = (type: LeafType) => type === 'needle' || type === 'scale';\nconst untexturedLeaf: LeafMaterialDefinition = { roughness: 1, map: null, alphaTest: 0.5 };\nconst untexturedBark = () => ({ roughness: 1, map: null, normalMap: null });\n\n// Low-poly and stylized are calibrated so a Species with density 0.5 and leaf-spray size 0.35 m comes\n// out close to each Style's own broadleaf / conifer Definitions. Realistic draws far more (cheap, 2\n// triangle) cards per twig than its own Definitions: a Species has fewer twigs than the realistic\n// generic trees (the low-poly and stylized triangle budgets cap them at about 40-90), so the cards\n// have to fill the crown. Deeper branch levels get little detail (twigs are thin and many).\nconst LOOKS = {\n 'low-poly': {\n trunk: { sides: 5, sections: 4, flareSections: 2 },\n branches: [{ sides: 4, sections: 2 }, { sides: 3, sections: 1 }],\n bark: untexturedBark,\n fruitSides: 4,\n roots: { sides: 3, sections: 2 },\n leaf: (type) =>\n isNeedleLike(type)\n ? { shape: 'needle', perDensity: 14, sizeScale: 1.86, material: untexturedLeaf }\n : { shape: 'clump', perDensity: 4, sizeScale: 2.86, material: untexturedLeaf },\n },\n stylized: {\n trunk: { sides: 10, sections: 8, flareSections: 3 },\n branches: [{ sides: 6, sections: 3 }, { sides: 4, sections: 1 }, { sides: 3, sections: 1 }],\n bark: untexturedBark,\n fruitSides: 6,\n roots: { sides: 6, sections: 4 },\n // All puffs; smaller and denser for needle / scale foliage.\n leaf: (type) =>\n isNeedleLike(type)\n ? { shape: 'puff', perDensity: 8, sizeScale: 1.7, material: untexturedLeaf }\n : { shape: 'puff', perDensity: 4, sizeScale: 3.14, material: untexturedLeaf },\n },\n realistic: {\n trunk: { sides: 12, sections: 10, flareSections: 3 },\n branches: [{ sides: 8, sections: 6 }, { sides: 5, sections: 4 }, { sides: 3, sections: 2 }],\n // A texture per Bark Type and per Leaf Type (scripts/generate-textures.mjs).\n bark: (type) => ({ roughness: 0.95, ...BARK_TEXTURES[type] }),\n fruitSides: 9,\n roots: { sides: 8, sections: 6 },\n leaf: (type) =>\n isNeedleLike(type)\n ? { shape: 'card', perDensity: 120, sizeScale: 1.7, material: { roughness: 0.7, map: LEAF_TEXTURES[type], alphaTest: 0.4 } }\n : { shape: 'card', perDensity: 80, sizeScale: 2.2, material: { roughness: 0.65, map: LEAF_TEXTURES[type], alphaTest: 0.4 } },\n },\n} satisfies Record<StyleName, StyleLook>;\n\n/** What `Style.apply` accepts: a Species, or a Tree Definition to re-style. */\nexport type StyleSource = SpeciesDefinition | TreeDefinition | TreeDefinitionInput;\n\n/** `{ [key]: value }` for an optional block that is present, `{}` when it is absent (to spread). */\nfunction present<K extends string, V>(key: K, value: V | undefined): { [P in K]?: V } {\n return value === undefined ? {} : ({ [key]: value } as { [P in K]?: V });\n}\n\n/** The Style-neutral content of a source: every non-look field, plus foliage and bark. */\ninterface Neutral {\n /** Definition fields that pass through (shape, Season, Wind, Sculpts, Fruit, Roots, ...). */\n base: Record<string, unknown> & { trunk: object; branches: object[] };\n foliage: SpeciesFoliageDefinition;\n /** A Definition's Ground Tint passes through too: it is not part of a Style's look. */\n bark: SpeciesBarkDefinition & Pick<BarkMaterialDefinition, 'groundTint'>;\n /** A Definition's Material Features pass through too (ADR 0008): they are the app's choice, never a Style's. */\n features: MaterialFeatures;\n}\n\nfunction fromSpecies(species: SpeciesDefinition): Neutral {\n const { id, name, trunk, branches, season, wind, variation, fruit, roots, foliage, bark } = species;\n return {\n base: {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name,\n species: id,\n trunk,\n branches,\n season,\n wind,\n variation,\n sculpts: [],\n ...present('fruit', fruit),\n ...present('roots', roots),\n },\n foliage,\n bark,\n features: {},\n };\n}\n\nfunction fromDefinition(input: TreeDefinition | TreeDefinitionInput): Neutral {\n const definition = parseDefinition(input);\n const { leaves, materials, ...base } = definition;\n // Definitions not made by `apply` carry no Leaf / Bark Type: guess them from how they are drawn.\n const leafType = leaves.type ?? (leaves.shape === 'needle' || /needle/.test(materials.leaf.map ?? '') ? 'needle' : 'broad');\n const source = LOOKS[styleOfShading(materials.shading)].leaf(leafType);\n return {\n base,\n foliage: {\n type: leafType,\n density: leaves.count / source.perDensity,\n size: leaves.size / source.sizeScale,\n sizeVariation: leaves.sizeVariation,\n start: leaves.start,\n angle: leaves.angle,\n },\n bark: {\n type: materials.bark.type ?? 'furrowed',\n color: materials.bark.color,\n ...present('groundTint', materials.bark.groundTint),\n },\n features: materialFeaturesOf(definition),\n };\n}\n\nfunction draw(name: StyleName, { base, foliage, bark, features }: Neutral): TreeDefinition {\n const look: StyleLook = LOOKS[name];\n const leaf = look.leaf(foliage.type);\n const fruit = base.fruit as TreeDefinition['fruit'];\n const roots = base.roots as TreeDefinition['roots'];\n return parseDefinition({\n ...base,\n ...present('fruit', fruit && { ...fruit, sides: look.fruitSides }),\n ...present('roots', roots && { ...roots, ...look.roots }),\n trunk: { ...base.trunk, ...look.trunk },\n branches: base.branches.map((level, i) => ({ ...level, ...look.branches[Math.min(i, look.branches.length - 1)] })),\n leaves: {\n type: foliage.type,\n count: Math.round(foliage.density * leaf.perDensity),\n shape: leaf.shape,\n size: foliage.size * leaf.sizeScale,\n sizeVariation: foliage.sizeVariation,\n start: foliage.start,\n angle: foliage.angle,\n },\n materials: {\n shading: styleShading(name),\n bark: { type: bark.type, color: bark.color, ...look.bark(bark.type), ...present('groundTint', bark.groundTint) },\n leaf: { ...leaf.material, ...present('crownNormals', features.crownNormals), ...present('translucency', features.translucency) },\n ...present('occlusion', features.occlusion),\n },\n });\n}\n\n/**\n * Applies a built-in Style's look to a Species or a Tree Definition (see `TreeStyle.apply`).\n * Pure: never mutates its inputs.\n */\nexport function applyStyle(name: StyleName, source: StyleSource, overrides?: DefinitionPatch): TreeDefinition {\n const neutral = 'schemaVersion' in source ? fromDefinition(source) : fromSpecies(source);\n const definition = draw(name, neutral);\n return overrides ? extendDefinition(definition, overrides) : definition;\n}\n"],"mappings":";;;;;;;AAOA,IAAa,WAAW;CACtB,MAAM;CACN,YAAY;CACZ,MAAM;CACN,SAAS;AACX;;AAGA,IAAa,gBAAoD;CAC/D,OAAO,SAAS;CAChB,OAAO;CACP,SAAS;CACT,UAAU;CACV,QAAQ,SAAS;CACjB,OAAO;AACT;;AAGA,IAAa,gBAAgF;CAC3F,UAAU;EAAE,KAAK,SAAS;EAAM,WAAW,SAAS;CAAW;CAC/D,QAAQ;EAAE,KAAK;EAA6B,WAAW;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AAE;GAC/H,GAAG,QAAQ,aAAa,SAAS,SAAS;EAC5C;CACF,CAAC;AACH;;;;;AAMA,SAAgB,WAAW,MAAiB,QAAqB,WAA6C;CAE5G,MAAM,aAAa,KAAK,MADR,mBAAmB,SAAS,eAAe,MAAM,IAAI,YAAY,MAAM,CAClD;CACrC,OAAO,YAAY,iBAAiB,YAAY,SAAS,IAAI;AAC/D"}
@@ -1,23 +1,62 @@
1
1
  import { Group } from 'three/webgpu';
2
+ import type { TranslucencyDefinition } from '../definition';
3
+ import { type CrownVolume } from '../generator';
2
4
  import type { Tree } from '../tree';
3
5
  /**
4
6
  * Baked Tree: one tree frozen at a Seed, Growth and Season as plain static geometry with
5
- * standard PBR materials (`MeshStandardMaterial`, no node materials, no custom attributes), for
6
- * glTF export and other tools. Growth and Season are evaluated on the CPU with the same models the
7
- * shaders run (`growPositions`, `leafSeason`); Wind is left out (a Baked Tree stands still).
7
+ * standard PBR materials (`MeshStandardMaterial`, no node materials), for glTF export and other tools.
8
+ * Growth and Season are evaluated on the CPU with the same models the shaders run (`growPositions`,
9
+ * `leafSeason`, `fruitSeason`); Wind is left out (a Baked Tree stands still).
10
+ *
11
+ * Material Features (ADR 0008) are baked into standard glTF channels: Crown Normals blended into the normals,
12
+ * Structural Occlusion as a `_occlusion` attribute (glTF `_OCCLUSION`, strength already applied; optionally also in the vertex
13
+ * colours), Leaf Translucency as `KHR_materials_diffuse_transmission` (written by `exportBakedTree`),
14
+ * and the settings with the Crown Volume in `userData.treejs` of the leaf and bark materials (glTF
15
+ * `extras`). With no Material Feature set, the result is exactly as without them.
8
16
  */
9
17
  /** Growth and Season to bake at; each defaults to the tree's current value. */
10
18
  export interface BakeOptions {
11
19
  growth?: number;
12
20
  season?: number;
21
+ /**
22
+ * With Structural Occlusion (`materials.occlusion`): also multiply the occlusion into the vertex
23
+ * colours (`COLOR_0`), for engines that only read vertex colours. It then darkens direct light too.
24
+ * Default false: `COLOR_0` is as without the feature, and the occlusion is only in `_OCCLUSION`.
25
+ */
26
+ occlusionInVertexColors?: boolean;
13
27
  }
14
28
  /**
15
29
  * Freezes a tree at a Growth and Season (default: the tree's own) into a static `Group` of
16
- * meshes `wood` and `leaves` (a mesh with nothing to show is left out) with standard PBR
17
- * materials: no node materials, no Growth/Season/Wind attributes, no animation. The result is
30
+ * meshes `wood`, `leaves` and `fruit` (a mesh with nothing to show is left out) with standard PBR
31
+ * materials: no node materials, no Growth/Season/Wind attributes, no animation. Material Features
32
+ * are baked in (see the top of this module). The result is
18
33
  * independent of `tree`; call `disposeBakedTree` when done with it.
19
34
  */
20
35
  export declare function bakeTree(tree: Tree, options?: BakeOptions): Group;
36
+ /**
37
+ * The `treejs` object in the extras of the baked leaf and bark materials: the Material Feature
38
+ * settings and the Crown Volume, for engines that rebuild the effects in their own shaders. The Crown
39
+ * Volume is in the Baked Tree's space (scaled by its Growth, like the geometry). Null when the tree has
40
+ * no Material Feature, so its glTF is as without them.
41
+ */
42
+ export interface MaterialFeatureExtras {
43
+ /** Crown Normals amount; the baked `NORMAL` already has them blended in. */
44
+ crownNormals?: number;
45
+ /** Leaf Translucency settings (also written as `KHR_materials_diffuse_transmission`). */
46
+ translucency?: TranslucencyDefinition;
47
+ occlusion?: {
48
+ /** The Structural Occlusion strength the tree had. */
49
+ strength: number;
50
+ /**
51
+ * Always true: the baked `_OCCLUSION` is final, `mix(1, aOcclusion, strength)`, with the strength
52
+ * already applied. Use it as AO as it is; do not apply `strength` again.
53
+ */
54
+ strengthApplied: true;
55
+ /** Whether `COLOR_0` is also multiplied by `_OCCLUSION` (`occlusionInVertexColors`). */
56
+ inVertexColors: boolean;
57
+ };
58
+ crown: CrownVolume;
59
+ }
21
60
  /** Frees the geometries, materials and texture copies of a baked tree. */
22
61
  export declare function disposeBakedTree(baked: Group): void;
23
62
  export interface ExportBakedTreeOptions extends BakeOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bake/index.ts"],"names":[],"mappings":"AAA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M,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AACnI,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Keyframe } from './types';
2
+ /**
3
+ * The conifer cone as a Crown Shape length curve for a branch level starting at `start`: full length
4
+ * at `start`, shrinking linearly to a tenth of it near the trunk tip, never below a tenth (the v2
5
+ * generator's `max(0.1, (1 - t) / (1 - start))`). Written by the v2 -> v3 migration and used by every
6
+ * Style's own conifer.
7
+ */
8
+ export declare function coneCurve(start: number): Keyframe<number>[];
9
+ //# sourceMappingURL=crown-shape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crown-shape.d.ts","sourceRoot":"","sources":["../../src/definition/crown-shape.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAKxC;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,EAAE,CAO3D"}
@@ -1,6 +1,20 @@
1
- import { type BranchLevelDefinition, type TreeDefinition } from './types';
1
+ import { type BranchLevelDefinition, type FruitDefinition, type GroundTintDefinition, type HexColor, type Keyframe, type OcclusionDefinition, type RootsDefinition, type TranslucencyDefinition, type TreeDefinition } from './types';
2
2
  /** Defaults for one branching level; fills fields missing from a partial `branches[i]`. */
3
3
  export declare const DEFAULT_BRANCH_LEVEL: BranchLevelDefinition;
4
+ /** Defaults for the fields of a `fruit` block (a Definition has no Fruit unless it has the block). */
5
+ export declare const DEFAULT_FRUIT: FruitDefinition;
6
+ /** Defaults for the fields of a `roots` block (a Definition has no Roots unless it has the block). */
7
+ export declare const DEFAULT_ROOTS: RootsDefinition;
8
+ /** Defaults for the fields of a `materials.bark.groundTint` block (no Ground Tint unless it has the block). */
9
+ export declare const DEFAULT_GROUND_TINT: GroundTintDefinition;
10
+ /** Defaults for the fields of a partial `materials.leaf.translucency` block (no Leaf Translucency unless it has the block). */
11
+ export declare const DEFAULT_TRANSLUCENCY: TranslucencyDefinition;
12
+ /** Defaults for the fields of a partial `materials.occlusion` block (no Structural Occlusion unless it has the block). */
13
+ export declare const DEFAULT_OCCLUSION: OcclusionDefinition;
14
+ /** Fruit amount when the Season Profile has no `fruit` track: all Fruit at full size all year. */
15
+ export declare const DEFAULT_FRUIT_AMOUNT: Keyframe<number>[];
16
+ /** Fruit colour when the Season Profile has no `fruitColor` track. */
17
+ export declare const DEFAULT_FRUIT_COLOR: Keyframe<HexColor>[];
4
18
  /**
5
19
  * The documented defaults: a small broadleaf tree with two branching levels.
6
20
  * Anything a Definition leaves out is taken from here.
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/definition/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,qBAAqB,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAElG,2FAA2F;AAC3F,eAAO,MAAM,oBAAoB,EAAE,qBAelC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,cAqDhC,CAAC"}
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/definition/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACpB,MAAM,SAAS,CAAC;AAEjB,2FAA2F;AAC3F,eAAO,MAAM,oBAAoB,EAAE,qBAelC,CAAC;AAEF,sGAAsG;AACtG,eAAO,MAAM,aAAa,EAAE,eAM3B,CAAC;AAEF,sGAAsG;AACtG,eAAO,MAAM,aAAa,EAAE,eAO3B,CAAC;AAEF,+GAA+G;AAC/G,eAAO,MAAM,mBAAmB,EAAE,oBAIjC,CAAC;AAEF,+HAA+H;AAC/H,eAAO,MAAM,oBAAoB,EAAE,sBAIlC,CAAC;AAEF,0HAA0H;AAC1H,eAAO,MAAM,iBAAiB,EAAE,mBAE/B,CAAC;AAEF,kGAAkG;AAClG,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAyB,CAAC;AAE7E,sEAAsE;AACtE,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAiC,CAAC;AAEtF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,cAoDhC,CAAC"}
@@ -1,5 +1,6 @@
1
- export { CURRENT_SCHEMA_VERSION, MAX_BRANCH_LEVELS } from './types';
2
- export type { TreeDefinition, TreeDefinitionInput, DeepPartial, HexColor, Vec3Tuple, TreeForm, TrunkDefinition, BranchLevelDefinition, LeafShape, LeavesDefinition, Shading, MaterialsDefinition, BarkMaterialDefinition, LeafMaterialDefinition, Keyframe, SeasonProfileDefinition, WindResponseDefinition, VariationDefinition, Sculpt, DeleteSculpt, MoveSculpt, LeavesSculpt, } from './types';
3
- export { DEFAULT_DEFINITION, DEFAULT_BRANCH_LEVEL } from './defaults';
1
+ export { BARK_TYPES, CURRENT_SCHEMA_VERSION, FRUIT_TYPES, LEAF_TYPES, MAX_BRANCH_LEVELS } from './types';
2
+ export type { TreeDefinition, TreeDefinitionInput, DeepPartial, HexColor, Vec3Tuple, TreeForm, TrunkDefinition, BranchLevelDefinition, LeafShape, LeafType, BarkType, LeavesDefinition, FruitType, FruitDefinition, RootsDefinition, Shading, MaterialsDefinition, BarkMaterialDefinition, GroundTintDefinition, LeafMaterialDefinition, MaterialFeatures, TranslucencyDefinition, OcclusionDefinition, Keyframe, SeasonProfileDefinition, WindResponseDefinition, VariationDefinition, Sculpt, DeleteSculpt, MoveSculpt, LeavesSculpt, } from './types';
3
+ export { coneCurve } from './crown-shape';
4
+ export { DEFAULT_DEFINITION, DEFAULT_BRANCH_LEVEL, DEFAULT_FRUIT, DEFAULT_GROUND_TINT, DEFAULT_OCCLUSION, DEFAULT_ROOTS, DEFAULT_TRANSLUCENCY, DEFAULT_FRUIT_AMOUNT, DEFAULT_FRUIT_COLOR } from './defaults';
4
5
  export { parseDefinition, extendDefinition, fetchDefinition, TreeDefinitionError, type DefinitionPatch, } from './parse';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACpE,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,eAAe,EACf,qBAAqB,EACrB,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,QAAQ,EACR,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,MAAM,EACN,YAAY,EACZ,UAAU,EACV,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,KAAK,eAAe,GACrB,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACzG,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,eAAe,EACf,qBAAqB,EACrB,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,eAAe,EACf,OAAO,EACP,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,EACnB,QAAQ,EACR,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,MAAM,EACN,YAAY,EACZ,UAAU,EACV,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,aAAa,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,aAAa,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7M,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,KAAK,eAAe,GACrB,MAAM,SAAS,CAAC"}
@@ -1,11 +1,3 @@
1
- /**
2
- * Schema migrations. `MIGRATIONS[n]` turns a raw (unvalidated) schemaVersion `n` object into
3
- * a raw schemaVersion `n + 1` object. Migrations run in order before defaults and validation,
4
- * so they only need to move/rename what changed; missing fields are defaulted afterwards.
5
- *
6
- * To change the format: bump CURRENT_SCHEMA_VERSION, add `MIGRATIONS[old]`, and add a
7
- * fixture in test/fixtures/definition-v<old>.json with a test.
8
- */
9
1
  type Raw = Record<string, unknown>;
10
2
  export declare const MIGRATIONS: Record<number, (input: Raw) => Raw>;
11
3
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/definition/migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEnC,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAgB1D,CAAC"}
1
+ {"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/definition/migrations.ts"],"names":[],"mappings":"AAWA,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEnC,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAmC1D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/definition/schema.ts"],"names":[],"mappings":"AACA,OAAO,EASL,KAAK,cAAc,EACpB,MAAM,SAAS,CAAC;AAEjB,6GAA6G;AAC7G,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBACX,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK3C;AAYD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEjE;AA+JD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,cAAc,CAE/E"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/definition/schema.ts"],"names":[],"mappings":"AASA,OAAO,EAsBL,KAAK,cAAc,EAEpB,MAAM,SAAS,CAAC;AAEjB,6GAA6G;AAC7G,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBACX,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK3C;AAYD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEjE;AAuOD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,cAAc,CAE/E"}