@liquidcars/atlas-layout 0.1.3 → 0.1.7

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.
package/README.md CHANGED
@@ -24,6 +24,31 @@ Cada entrada del catálogo puede declarar `id`, `aliases` y `canonicalSize`.
24
24
  Una geometría externa desconocida conserva el tamaño de fallback de una caja,
25
25
  de modo que la compilación sigue siendo recuperable si falta un pack.
26
26
 
27
+ Los grids bidimensionales aceptan `plane: "xz" | "xy" | "yz"`. El plano
28
+ predeterminado sigue siendo `xz`; `xy` resulta útil para galerías concebidas
29
+ para una vista frontal.
30
+
31
+ Los layouts `row` aceptan `packing: "preserve" | "compact"`. El modo
32
+ `compact` recompone las bandas creadas por constraints de alineación sobre el
33
+ eje principal y elimina los huecos que dejan las posiciones iniciales.
34
+
35
+ `layout.groups` permite declarar composiciones invisibles de hermanos inmediatos.
36
+ Cada grupo tiene `id`, `members` y un `layout` interno. Las constraints del
37
+ nivel padre pueden referenciar el id del grupo; tras calcular posiciones, el
38
+ compilador elimina el grupo y emite únicamente las entidades reales.
39
+
40
+ Un layout `row` puede distribuir el espacio asignado por un tamaño explícito
41
+ o una constraint de igualdad mediante `justify: "start" | "center" | "end" |
42
+ "space-between" | "space-around" | "space-evenly"`. `padding` define los límites
43
+ interiores y `gap` actúa como separación mínima. Los grupos virtuales se
44
+ recalculan después de recibir su tamaño definitivo.
45
+
46
+ Las entidades con `children` deben declarar `type: container`. Las hojas pueden
47
+ omitir `type` y se normalizan como items. `type: shell` se acepta únicamente
48
+ como alias de compatibilidad. Un contenedor puede no tener geometría o usar una
49
+ primitiva `geo.*`; las geometrías personalizadas de los packs, como `infra.cloud`,
50
+ sólo se permiten en entidades hoja.
51
+
27
52
  Para compilar una fuente YAML durante el build:
28
53
 
29
54
  ```js
@@ -147,4 +172,4 @@ El resultado mantiene `palette`, `theme`, `entities` y `relations`, con `p` y `s
147
172
 
148
173
  El espacio de una celda y el tamaño de la geometría son conceptos distintos. Cuando el layout asigna una celda rectangular a una geometría sin `size` explícito, la figura se centra y se escala uniformemente para caber en el menor volumen compatible; no se estira por separado en `x`, `y` y `z`. Por eso una esfera conserva `s[0] === s[1] === s[2]`, aunque su celda sea rectangular. Un `size` explícito sigue teniendo prioridad y permite al autor solicitar una proporción concreta.
149
174
 
150
- Esta es una primera implementación del motor. `row`, `grid`/`masonry` y `volume` ya producen posiciones deterministas. El algoritmo `graph` está reservado en el contrato y, por ahora, emite `GRAPH_LAYOUT_FALLBACK` y usa `grid`; las restricciones espaciales y la proyección de relaciones entre contenedores se incorporarán en iteraciones posteriores.
175
+ `row`, `grid`/`masonry` y `volume` producen posiciones deterministas. Las constraints de tamaño y alineación, el empaquetado compacto, los grupos virtuales y la distribución `justify` forman parte del contrato estable de autoría. El algoritmo `graph` sigue reservado: por ahora emite `GRAPH_LAYOUT_FALLBACK` y usa `grid`. La proyección y el enrutado avanzado de relaciones entre contenedores permanecen como líneas de desarrollo posteriores.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liquidcars/atlas-layout",
3
- "version": "0.1.3",
3
+ "version": "0.1.7",
4
4
  "description": "Declarative layout compiler for LiquidCars Atlas models",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -21,14 +21,31 @@
21
21
  "./vite": {
22
22
  "import": "./src/vite.js",
23
23
  "default": "./src/vite.js"
24
+ },
25
+ "./spec": {
26
+ "import": "./src/spec.js",
27
+ "default": "./src/spec.js"
24
28
  }
25
29
  },
26
30
  "scripts": {
27
- "test": "node --test test/index.test.mjs"
31
+ "test": "node --test test/index.test.mjs",
32
+ "prepack": "npm test"
28
33
  },
29
- "keywords": ["liquidcars", "atlas", "layout", "3d", "graph", "web-component"],
34
+ "keywords": [
35
+ "liquidcars",
36
+ "atlas",
37
+ "layout",
38
+ "3d",
39
+ "graph",
40
+ "web-component"
41
+ ],
30
42
  "license": "MIT",
31
43
  "dependencies": {
32
44
  "yaml": "^2.8.1"
33
- }
45
+ },
46
+ "files": [
47
+ "README.md",
48
+ "src",
49
+ "spec"
50
+ ]
34
51
  }
@@ -0,0 +1,165 @@
1
+ # ATLAS-LAYOUT-SPEC-v1
2
+
3
+ This document defines the semantic YAML contract consumed by @liquidcars/atlas-layout.
4
+ The executable projection of this contract is packages/atlas-layout/src/spec.js.
5
+
6
+ ## Root model
7
+
8
+ A model may contain version, palette, theme, render, layout, entities and relations.
9
+ Entities may be declared at the root or nested under children. The compiler normalizes
10
+ nested entities to a flat list with parent references.
11
+
12
+ ## Model coordinate system
13
+
14
+ Atlas model space is independent from the camera and from the host application's view.
15
+ The coordinate convention is fixed:
16
+
17
+ - x: left (-) to right (+)
18
+ - y: bottom (-) to top (+)
19
+ - z: back (-) to front (+)
20
+
21
+ Positions, sizes, layout directions and future alignment rules are interpreted in this
22
+ model space. Camera rotation, zoom, pan and projection never change the meaning of a
23
+ model coordinate. The default front view places the camera on the positive z side,
24
+ looking toward the origin.
25
+
26
+ A container's local origin is the reference point for its children. The compiler resolves
27
+ nested positions into model-space output while preserving the authored hierarchy. The
28
+ authoring aliases left, right, bottom, top, back and front may be used for boundary
29
+ terms; they correspond respectively to minX, maxX, minY, maxY, minZ and maxZ.
30
+
31
+ ## Layout units and intrinsic sizing
32
+
33
+ All dimensions are expressed in Atlas world units: geometry dimensions, positions, layout
34
+ gap, padding and explicit size values use the same unit. There is no universal 1 x 1 x 1
35
+ item size. When a leaf has no explicit size, assisted layout uses the selected geometry's
36
+ canonical size; an aspect style changes proportion, not the geometry's semantic identity.
37
+
38
+ Containers are sized from their laid-out contents by default: child bounds plus gap and
39
+ padding determine the required extent. padding: 1 reserves one world unit on every
40
+ content-to-boundary side, so it contributes approximately two units to each occupied
41
+ dimension. gap: 1.2 reserves 1.2 world units between adjacent siblings along the
42
+ layout axis. Authored size is the exception: it is an explicit dimension constraint,
43
+ subject to sizeMode and diagnostics.
44
+
45
+
46
+ ## Entity fields
47
+
48
+ Required: id.
49
+
50
+ Common fields: name, sub, text, type, parent, children, geometry, geometryOptions,
51
+ geometryPalette, style, layout, weight, span, size, sizeMode, p, s, c and radius.
52
+
53
+ An entity with children is a container and must explicitly declare `type: container`.
54
+ A leaf entity may omit `type`, in which case it is normalized as an item. The
55
+ legacy value `type: shell` remains accepted as a compatibility alias for
56
+ `container`, but is not emitted by the compiler or suggested by the editor.
57
+
58
+ Containers may omit geometry or use a built-in primitive such as `geo.box`.
59
+ Custom geometry-pack geometries such as `infra.cloud` and `media.image-box` are
60
+ leaf geometries and cannot be used on containers. The compiler reports these violations
61
+ as fatal diagnostics instead of silently rendering a fallback box.
62
+
63
+ `children` is the nested authoring form. In a flat model, an entity referenced by
64
+ other entities through `parent` is also a container and follows the same rule.
65
+
66
+ geometry is resolved against built-in primitives and registered geometry packs.
67
+ geometryOptions and geometryPalette are namespaced by the selected geometry definition.
68
+ size is an explicit dimension constraint. p and s are calculated layout output and are
69
+ normally omitted from authored Markdown. sizeMode fixed preserves explicit dimensions;
70
+ fit permits assisted layout to use the geometry's canonical size.
71
+
72
+ ## Assisted layout
73
+
74
+ layout.algorithm accepts row, grid, volume or graph. direction accepts x, y or z.
75
+ Grid layouts also accept variant uniform or masonry, optional columns and rows, and
76
+ a plane of xz (the default), xy or yz. Volume layouts additionally accept layers.
77
+ gap and padding are absolute numbers. justify accepts start, center, end,
78
+ space-between, space-around or space-evenly. These modes become distinct when a
79
+ row receives an explicit or constrained size. Distributed modes treat gap as the
80
+ minimum separation; padding defines the inner boundaries.
81
+ For row layouts, packing accepts preserve (the default) or compact. Compact packing
82
+ groups siblings connected by an alignment on the row axis, removes slots vacated by
83
+ those alignments, and reapplies gap between the resulting bands.
84
+
85
+ A layout may declare invisible groups under `layout.groups`. Each group has an `id`,
86
+ a list of immediate sibling `members`, and its own nested `layout`. The compiler
87
+ lays out the members as a temporary composite, permits sibling constraints to reference
88
+ the group id, then removes the group and emits only the real entities. Members must be
89
+ immediate siblings and may belong to only one group at that level. Group ids share the
90
+ layout scope with sibling ids. Groups have no geometry, style, selection state or
91
+ relation endpoints.
92
+
93
+ ```yaml
94
+ layout:
95
+ algorithm: row
96
+ direction: y
97
+ packing: compact
98
+ groups:
99
+ - id: support-layer
100
+ members: [infrastructure, media]
101
+ layout:
102
+ algorithm: row
103
+ direction: x
104
+ justify: space-between
105
+ gap: 2
106
+ constraints:
107
+ - align: [top, support-layer, bottom]
108
+ edges: [left, front]
109
+ ```
110
+
111
+ An entity weight influences its relative allocation. span can explicitly occupy
112
+ columns, rows and layers. A semantic style.aspect may be compact, wide, tall, deep or flat.
113
+
114
+ ## Sibling size and alignment constraints
115
+
116
+ A root model or container may declare `constraints` for its immediate children. Constraint
117
+ references must resolve to siblings in that group; references across parents produce a
118
+ diagnostic and are not applied. Constraints may alternatively be nested under the
119
+ corresponding `layout` object, but sibling-level `constraints` is the canonical form.
120
+
121
+ An equal-size rule lists entity ids under `equal`. `dimensions` accepts one or more of
122
+ `width`, `height` and `depth`; the compiler uses the largest intrinsic extent in the
123
+ group for each requested dimension. The singular `dimension` form is accepted, and
124
+ `edge: width|height|depth` is a compact alias.
125
+
126
+ An alignment rule lists entity ids under `align`. `edge` or `edges` accepts
127
+ `left`, `centerX`, `right`, `bottom`, `centerY`, `top`, `back`,
128
+ `centerZ` and `front`. These names always use model coordinates, never camera
129
+ coordinates. Alignment uses the first listed sibling as the reference.
130
+
131
+ `strength` accepts `preferred` (the default) or `required`. Invalid preferred rules
132
+ produce warnings; invalid required rules produce errors.
133
+
134
+ ```yaml
135
+ constraints:
136
+ - equal: [layer-top, layer-middle, layer-bottom]
137
+ dimensions: [width, height, depth]
138
+ strength: preferred
139
+ - align: [layer-top, layer-middle, layer-bottom]
140
+ edges: [left, front]
141
+ strength: preferred
142
+ ```
143
+
144
+ ## Relations
145
+
146
+ Relations require from and to entity ids. mode is directed, bidirectional or broken.
147
+ The aliases visual, render, type and direction are accepted for compatibility.
148
+ Optional fields include id, label, fromAnchor, toAnchor, priority and layout.
149
+
150
+ ## Rendering
151
+
152
+ palette maps tokens to CSS colours. style.color or c can reference a token or direct
153
+ CSS colour. render can additionally set relationMode, selectionMode, toolbar and
154
+ shellLabels. theme contains background, lighting and ui settings.
155
+
156
+ ## Markdown blocks
157
+
158
+ Atlas Markdown accepts a full atlas or atlas overview fenced block, and split
159
+ atlas-model, atlas-layout, atlas-render and atlas-relations blocks. Named blocks
160
+ use the block name as the model identifier. A document may contain more than one model.
161
+
162
+ ## Compatibility
163
+
164
+ Unknown fields remain available to geometry packs and host applications, but the
165
+ editor only suggests fields defined by this version of the contract.