@nowline/layout 0.2.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 (183) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +103 -0
  3. package/dist/band-scale.d.ts +56 -0
  4. package/dist/band-scale.d.ts.map +1 -0
  5. package/dist/band-scale.js +86 -0
  6. package/dist/band-scale.js.map +1 -0
  7. package/dist/calendar.d.ts +79 -0
  8. package/dist/calendar.d.ts.map +1 -0
  9. package/dist/calendar.js +210 -0
  10. package/dist/calendar.js.map +1 -0
  11. package/dist/capacity.d.ts +72 -0
  12. package/dist/capacity.d.ts.map +1 -0
  13. package/dist/capacity.js +163 -0
  14. package/dist/capacity.js.map +1 -0
  15. package/dist/dsl-utils.d.ts +5 -0
  16. package/dist/dsl-utils.d.ts.map +1 -0
  17. package/dist/dsl-utils.js +28 -0
  18. package/dist/dsl-utils.js.map +1 -0
  19. package/dist/edge-routing.d.ts +89 -0
  20. package/dist/edge-routing.d.ts.map +1 -0
  21. package/dist/edge-routing.js +435 -0
  22. package/dist/edge-routing.js.map +1 -0
  23. package/dist/frame-tab-geometry.d.ts +78 -0
  24. package/dist/frame-tab-geometry.d.ts.map +1 -0
  25. package/dist/frame-tab-geometry.js +115 -0
  26. package/dist/frame-tab-geometry.js.map +1 -0
  27. package/dist/header-card-geometry.d.ts +29 -0
  28. package/dist/header-card-geometry.d.ts.map +1 -0
  29. package/dist/header-card-geometry.js +41 -0
  30. package/dist/header-card-geometry.js.map +1 -0
  31. package/dist/i18n.d.ts +48 -0
  32. package/dist/i18n.d.ts.map +1 -0
  33. package/dist/i18n.js +114 -0
  34. package/dist/i18n.js.map +1 -0
  35. package/dist/include-chrome-geometry.d.ts +86 -0
  36. package/dist/include-chrome-geometry.d.ts.map +1 -0
  37. package/dist/include-chrome-geometry.js +104 -0
  38. package/dist/include-chrome-geometry.js.map +1 -0
  39. package/dist/index.d.ts +11 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +10 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/item-bar-geometry.d.ts +127 -0
  44. package/dist/item-bar-geometry.d.ts.map +1 -0
  45. package/dist/item-bar-geometry.js +173 -0
  46. package/dist/item-bar-geometry.js.map +1 -0
  47. package/dist/lane-utilization.d.ts +90 -0
  48. package/dist/lane-utilization.d.ts.map +1 -0
  49. package/dist/lane-utilization.js +206 -0
  50. package/dist/lane-utilization.js.map +1 -0
  51. package/dist/layout-context.d.ts +143 -0
  52. package/dist/layout-context.d.ts.map +1 -0
  53. package/dist/layout-context.js +8 -0
  54. package/dist/layout-context.js.map +1 -0
  55. package/dist/layout.d.ts +18 -0
  56. package/dist/layout.d.ts.map +1 -0
  57. package/dist/layout.js +1213 -0
  58. package/dist/layout.js.map +1 -0
  59. package/dist/nodes/anchor-node.d.ts +16 -0
  60. package/dist/nodes/anchor-node.d.ts.map +1 -0
  61. package/dist/nodes/anchor-node.js +68 -0
  62. package/dist/nodes/anchor-node.js.map +1 -0
  63. package/dist/nodes/footnote-node.d.ts +10 -0
  64. package/dist/nodes/footnote-node.d.ts.map +1 -0
  65. package/dist/nodes/footnote-node.js +41 -0
  66. package/dist/nodes/footnote-node.js.map +1 -0
  67. package/dist/nodes/group-node.d.ts +29 -0
  68. package/dist/nodes/group-node.d.ts.map +1 -0
  69. package/dist/nodes/group-node.js +187 -0
  70. package/dist/nodes/group-node.js.map +1 -0
  71. package/dist/nodes/include-node.d.ts +16 -0
  72. package/dist/nodes/include-node.d.ts.map +1 -0
  73. package/dist/nodes/include-node.js +117 -0
  74. package/dist/nodes/include-node.js.map +1 -0
  75. package/dist/nodes/item-node.d.ts +51 -0
  76. package/dist/nodes/item-node.d.ts.map +1 -0
  77. package/dist/nodes/item-node.js +108 -0
  78. package/dist/nodes/item-node.js.map +1 -0
  79. package/dist/nodes/marker-geometry.d.ts +22 -0
  80. package/dist/nodes/marker-geometry.d.ts.map +1 -0
  81. package/dist/nodes/marker-geometry.js +38 -0
  82. package/dist/nodes/marker-geometry.js.map +1 -0
  83. package/dist/nodes/milestone-node.d.ts +48 -0
  84. package/dist/nodes/milestone-node.d.ts.map +1 -0
  85. package/dist/nodes/milestone-node.js +210 -0
  86. package/dist/nodes/milestone-node.js.map +1 -0
  87. package/dist/nodes/parallel-node.d.ts +21 -0
  88. package/dist/nodes/parallel-node.d.ts.map +1 -0
  89. package/dist/nodes/parallel-node.js +80 -0
  90. package/dist/nodes/parallel-node.js.map +1 -0
  91. package/dist/nodes/roadmap-node.d.ts +76 -0
  92. package/dist/nodes/roadmap-node.d.ts.map +1 -0
  93. package/dist/nodes/roadmap-node.js +788 -0
  94. package/dist/nodes/roadmap-node.js.map +1 -0
  95. package/dist/nodes/swimlane-node.d.ts +38 -0
  96. package/dist/nodes/swimlane-node.d.ts.map +1 -0
  97. package/dist/nodes/swimlane-node.js +308 -0
  98. package/dist/nodes/swimlane-node.js.map +1 -0
  99. package/dist/renderable.d.ts +44 -0
  100. package/dist/renderable.d.ts.map +1 -0
  101. package/dist/renderable.js +21 -0
  102. package/dist/renderable.js.map +1 -0
  103. package/dist/row-packer.d.ts +125 -0
  104. package/dist/row-packer.d.ts.map +1 -0
  105. package/dist/row-packer.js +169 -0
  106. package/dist/row-packer.js.map +1 -0
  107. package/dist/style-resolution.d.ts +14 -0
  108. package/dist/style-resolution.d.ts.map +1 -0
  109. package/dist/style-resolution.js +191 -0
  110. package/dist/style-resolution.js.map +1 -0
  111. package/dist/themes/dark.d.ts +4 -0
  112. package/dist/themes/dark.d.ts.map +1 -0
  113. package/dist/themes/dark.js +241 -0
  114. package/dist/themes/dark.js.map +1 -0
  115. package/dist/themes/index.d.ts +15 -0
  116. package/dist/themes/index.d.ts.map +1 -0
  117. package/dist/themes/index.js +30 -0
  118. package/dist/themes/index.js.map +1 -0
  119. package/dist/themes/light.d.ts +4 -0
  120. package/dist/themes/light.d.ts.map +1 -0
  121. package/dist/themes/light.js +248 -0
  122. package/dist/themes/light.js.map +1 -0
  123. package/dist/themes/shape.d.ts +194 -0
  124. package/dist/themes/shape.d.ts.map +1 -0
  125. package/dist/themes/shape.js +6 -0
  126. package/dist/themes/shape.js.map +1 -0
  127. package/dist/themes/shared.d.ts +145 -0
  128. package/dist/themes/shared.d.ts.map +1 -0
  129. package/dist/themes/shared.js +310 -0
  130. package/dist/themes/shared.js.map +1 -0
  131. package/dist/time-scale.d.ts +39 -0
  132. package/dist/time-scale.d.ts.map +1 -0
  133. package/dist/time-scale.js +62 -0
  134. package/dist/time-scale.js.map +1 -0
  135. package/dist/types.d.ts +483 -0
  136. package/dist/types.d.ts.map +1 -0
  137. package/dist/types.js +6 -0
  138. package/dist/types.js.map +1 -0
  139. package/dist/view-preset.d.ts +23 -0
  140. package/dist/view-preset.d.ts.map +1 -0
  141. package/dist/view-preset.js +146 -0
  142. package/dist/view-preset.js.map +1 -0
  143. package/dist/working-calendar.d.ts +14 -0
  144. package/dist/working-calendar.d.ts.map +1 -0
  145. package/dist/working-calendar.js +74 -0
  146. package/dist/working-calendar.js.map +1 -0
  147. package/package.json +37 -0
  148. package/src/band-scale.ts +115 -0
  149. package/src/calendar.ts +244 -0
  150. package/src/capacity.ts +191 -0
  151. package/src/dsl-utils.ts +30 -0
  152. package/src/edge-routing.ts +550 -0
  153. package/src/frame-tab-geometry.ts +165 -0
  154. package/src/header-card-geometry.ts +48 -0
  155. package/src/i18n.ts +124 -0
  156. package/src/include-chrome-geometry.ts +156 -0
  157. package/src/index.ts +116 -0
  158. package/src/item-bar-geometry.ts +222 -0
  159. package/src/lane-utilization.ts +259 -0
  160. package/src/layout-context.ts +182 -0
  161. package/src/layout.ts +1446 -0
  162. package/src/nodes/anchor-node.ts +77 -0
  163. package/src/nodes/footnote-node.ts +60 -0
  164. package/src/nodes/group-node.ts +252 -0
  165. package/src/nodes/include-node.ts +168 -0
  166. package/src/nodes/item-node.ts +171 -0
  167. package/src/nodes/marker-geometry.ts +43 -0
  168. package/src/nodes/milestone-node.ts +263 -0
  169. package/src/nodes/parallel-node.ts +101 -0
  170. package/src/nodes/roadmap-node.ts +957 -0
  171. package/src/nodes/swimlane-node.ts +423 -0
  172. package/src/renderable.ts +68 -0
  173. package/src/row-packer.ts +271 -0
  174. package/src/style-resolution.ts +243 -0
  175. package/src/themes/dark.ts +244 -0
  176. package/src/themes/index.ts +36 -0
  177. package/src/themes/light.ts +251 -0
  178. package/src/themes/shape.ts +230 -0
  179. package/src/themes/shared.ts +369 -0
  180. package/src/time-scale.ts +78 -0
  181. package/src/types.ts +607 -0
  182. package/src/view-preset.ts +180 -0
  183. package/src/working-calendar.ts +91 -0
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Lolay, Inc.
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,103 @@
1
+ # @nowline/layout
2
+
3
+ AST → positioned model for the [Nowline](../../) roadmap DSL.
4
+
5
+ `@nowline/layout` consumes the typed AST from [`@nowline/core`](../core) plus its
6
+ `resolveIncludes()` output and produces a deterministic *positioned model*: a tree
7
+ of entities with absolute coordinates, resolved styles (concrete hex colors),
8
+ and all the derived data a renderer needs. The renderer is palette-dumb;
9
+ every color decision lives here.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ pnpm add @nowline/layout @nowline/core
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```ts
20
+ import { createNowlineServices, resolveIncludes } from '@nowline/core';
21
+ import { layoutRoadmap } from '@nowline/layout';
22
+
23
+ const { Nowline } = createNowlineServices();
24
+ // ... parse the source into `file: NowlineFile` via Langium ...
25
+ const resolved = await resolveIncludes(file, '/abs/path/to/roadmap.nowline', {
26
+ services: Nowline,
27
+ });
28
+
29
+ const model = layoutRoadmap(file, resolved, {
30
+ theme: 'light', // 'light' | 'dark'
31
+ width: 1200, // canvas content width (header + timeline)
32
+ today: new Date(), // or a pinned date for deterministic snapshots
33
+ });
34
+
35
+ model.width; // full canvas width
36
+ model.height; // full canvas height
37
+ model.header; // PositionedHeader (with resolved box + logo placement)
38
+ model.timeline; // PositionedTimelineScale
39
+ model.nowline; // PositionedNowline | null (null if `today` outside range)
40
+ model.swimlanes; // PositionedSwimlane[] (recursive)
41
+ model.milestones; // PositionedMilestone[]
42
+ model.edges; // PositionedDependencyEdge[]
43
+ model.footnotes; // PositionedFootnoteArea
44
+ model.includes; // PositionedIncludeRegion[] — one per ResolveResult.isolatedRegions
45
+ ```
46
+
47
+ ## What lives here
48
+
49
+ - **Positioned model types** (`src/types.ts`) — one type per entity in the
50
+ `specs/rendering.md` § The Positioned Model list.
51
+ - **Theme store** (`src/themes/`) — per-theme files (`light.ts`, `dark.ts`) both
52
+ typed by a single `Theme` interface in `shape.ts`. See § Theme store below.
53
+ - **Style resolution** (`src/style-resolution.ts`) — the five-level precedence
54
+ chain (inline > entity style > label style > config defaults > system default)
55
+ baked into concrete hex colors from the selected theme.
56
+ - **Calendar + timeline** (`src/calendar.ts`, `src/timeline.ts`) — duration
57
+ literal resolution, timeline scale, tick placement, and header-position
58
+ branching (`beside` vs `above`).
59
+ - **Sequencing** (`src/sequencing.ts`) — within a swimlane, item start =
60
+ `max(preceding end, latest after: end, 0)`; anchors fix start.
61
+ - **Parallel + group** (`src/parallel.ts`) — parallel children share x-start,
62
+ stack vertically, region width = max child width.
63
+ - **Swimlanes** (`src/swimlanes.ts`) — recursive bands, alternating tint.
64
+ - **Anchors + milestones** (`src/anchors.ts`, `src/milestones.ts`) — diamond
65
+ positions, fixed vs floating, slack arrows, overrun detection.
66
+ - **Dependencies** (`src/dependencies.ts`) — naïve orthogonal Manhattan routing
67
+ with rounded corners; waypoint lists only (renderer draws the polyline).
68
+ - **Footnotes** (`src/footnotes.ts`) — superscripts on items + footnote-area
69
+ below the chart.
70
+ - **Includes** (`src/include-regions.ts`) — one `PositionedIncludeRegion` per
71
+ `ResolveResult.isolatedRegions[]`, rendered as a dashed-bordered region.
72
+ - **Nowline** (`src/nowline.ts`) — today's x on the scale, or `null` if outside
73
+ range.
74
+
75
+ ## Theme store
76
+
77
+ Themes live in `src/themes/` with one file per theme:
78
+
79
+ - `shape.ts` — the `Theme` interface that enumerates every role (DSL entity +
80
+ DSL property + non-DSL roles like `nowline.stroke` and `status.done`).
81
+ - `shared.ts` — values identical across themes today (spacing, radii, shadow
82
+ parameters, text-size scales). Boundary is allowed to move over time.
83
+ - `light.ts`, `dark.ts` — each is `const <name>Theme: Theme = { ... }`. `tsc`
84
+ refuses to compile if either theme omits a role, which is our parity guard.
85
+ - `index.ts` — exports `Theme`, `lightTheme`, `darkTheme`, and
86
+ `themes: { light, dark }`.
87
+
88
+ Adding a new theme = one new file + one line in `index.ts`.
89
+
90
+ ## Determinism
91
+
92
+ Coordinate generation is fully deterministic. Given the same `(file, resolved,
93
+ options)`, `layoutRoadmap()` always returns identical numbers. This is how the
94
+ renderer's snapshot tests stay stable.
95
+
96
+ ## Include resolution
97
+
98
+ Layout accepts a `ResolveResult` from `@nowline/core.resolveIncludes()` rather
99
+ than a merged AST. The `isolatedRegions[]` on the result surface per-file
100
+ isolated rendering data; layout walks them directly, so no AST changes are
101
+ required downstream. Merged includes (`roadmap:merge`, the default) flatten
102
+ into the main positioned model; isolates get their own `PositionedIncludeRegion`
103
+ bounding box with a label, rendered as a dashed region.
@@ -0,0 +1,56 @@
1
+ export interface FixedRowOptions {
2
+ /** Visible height of one row in pixels. */
3
+ bandwidth: number;
4
+ /** Pixels between the top of consecutive rows. Must be >= bandwidth. */
5
+ step: number;
6
+ }
7
+ export interface BandedRangeOptions {
8
+ /** Number of bands. */
9
+ count: number;
10
+ /** [topY, bottomY]. */
11
+ range: [number, number];
12
+ /** Inner padding ratio (0..1) per d3-scale.scaleBand. Defaults to 0. */
13
+ paddingInner?: number;
14
+ /** Outer padding ratio (0..1) per d3-scale.scaleBand. Defaults to 0. */
15
+ paddingOuter?: number;
16
+ }
17
+ export declare class BandScale {
18
+ private readonly bandwidthPx;
19
+ private readonly stepPx;
20
+ private readonly d3?;
21
+ private constructor();
22
+ /**
23
+ * Open-ended row band with a fixed bandwidth + step. Used when
24
+ * the row count is determined by iteration (the v1 swimlane row
25
+ * packer). m2.5c will tighten this once the measure/place tree
26
+ * lets us know row counts ahead of time.
27
+ */
28
+ static fixedRow(opts: FixedRowOptions): BandScale;
29
+ /**
30
+ * Closed-domain band that wraps d3-scale.scaleBand. Use when the
31
+ * full set of band ids is known at construction time (e.g. the
32
+ * top-level swimlane stack). The `forward(id)` API resolves an
33
+ * id to its top-y.
34
+ */
35
+ static forRows(opts: BandedRangeOptions): BandScale;
36
+ /** Visible height of one row. */
37
+ bandwidth(): number;
38
+ /** Row + inter-row gap (top of row N to top of row N+1). */
39
+ step(): number;
40
+ /** Top-y for a band id (only available on `forRows` instances). */
41
+ forward(id: string): number;
42
+ }
43
+ /**
44
+ * Default row band for the v1 layout: bandwidth = 56 px (the legacy
45
+ * bar height = ITEM_ROW_HEIGHT - 8), step = 64 px (the legacy row
46
+ * pitch = ITEM_ROW_HEIGHT). Keeps every existing sample byte-stable.
47
+ *
48
+ * m2.5c will derive these from item style + content measurement
49
+ * instead of pinning them to legacy constants.
50
+ */
51
+ export declare const DEFAULT_ROW_BAND_PX: {
52
+ readonly bandwidth: 56;
53
+ readonly step: 64;
54
+ };
55
+ export declare function defaultRowBand(): BandScale;
56
+ //# sourceMappingURL=band-scale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"band-scale.d.ts","sourceRoot":"","sources":["../src/band-scale.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,eAAe;IAC5B,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IAC/B,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxB,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,SAAS;IAClB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAoB;IAExC,OAAO;IAMP;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,SAAS;IAIjD;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,kBAAkB,GAAG,SAAS;IAUnD,iCAAiC;IACjC,SAAS,IAAI,MAAM;IAInB,4DAA4D;IAC5D,IAAI,IAAI,MAAM;IAId,mEAAmE;IACnE,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;CAY9B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB;;;CAGtB,CAAC;AAEX,wBAAgB,cAAc,IAAI,SAAS,CAE1C"}
@@ -0,0 +1,86 @@
1
+ // BandScale — wraps `d3-scale.scaleBand` for the y-axis row stack.
2
+ //
3
+ // Replaces the magic `ITEM_ROW_HEIGHT = 64` constant with a typed
4
+ // primitive that exposes `bandwidth()` (one row's visible height)
5
+ // and `step()` (row + inter-row gap). m2.5b's job is to land this
6
+ // surface; m2.5c will switch to the measure/place tree where each
7
+ // node returns its own intrinsic height and BandScale becomes the
8
+ // composition primitive parents stack with.
9
+ //
10
+ // `BandScale.forRows({ count, range })` matches the d3-scale.scaleBand
11
+ // constructor (domain = ['0', '1', ..., 'count-1']) but keeps the
12
+ // caller's step/bandwidth fixed when the row count is known up front.
13
+ // The current layout pipeline iterates rows lazily, so we also expose
14
+ // `BandScale.fixedRow({ bandwidth, step })` which doesn't anchor to a
15
+ // finite domain — the swimlane row loop uses this to know
16
+ // `bandwidth()` and `step()` without committing to a row count.
17
+ import { scaleBand } from 'd3-scale';
18
+ export class BandScale {
19
+ bandwidthPx;
20
+ stepPx;
21
+ d3;
22
+ constructor(bandwidth, step, d3) {
23
+ this.bandwidthPx = bandwidth;
24
+ this.stepPx = step;
25
+ this.d3 = d3;
26
+ }
27
+ /**
28
+ * Open-ended row band with a fixed bandwidth + step. Used when
29
+ * the row count is determined by iteration (the v1 swimlane row
30
+ * packer). m2.5c will tighten this once the measure/place tree
31
+ * lets us know row counts ahead of time.
32
+ */
33
+ static fixedRow(opts) {
34
+ return new BandScale(opts.bandwidth, opts.step);
35
+ }
36
+ /**
37
+ * Closed-domain band that wraps d3-scale.scaleBand. Use when the
38
+ * full set of band ids is known at construction time (e.g. the
39
+ * top-level swimlane stack). The `forward(id)` API resolves an
40
+ * id to its top-y.
41
+ */
42
+ static forRows(opts) {
43
+ const ids = Array.from({ length: opts.count }, (_, i) => String(i));
44
+ const d3 = scaleBand()
45
+ .domain(ids)
46
+ .range(opts.range)
47
+ .paddingInner(opts.paddingInner ?? 0)
48
+ .paddingOuter(opts.paddingOuter ?? 0);
49
+ return new BandScale(d3.bandwidth(), d3.step(), d3);
50
+ }
51
+ /** Visible height of one row. */
52
+ bandwidth() {
53
+ return this.bandwidthPx;
54
+ }
55
+ /** Row + inter-row gap (top of row N to top of row N+1). */
56
+ step() {
57
+ return this.stepPx;
58
+ }
59
+ /** Top-y for a band id (only available on `forRows` instances). */
60
+ forward(id) {
61
+ if (!this.d3) {
62
+ throw new Error('BandScale.forward is only available on closed-domain bands (BandScale.forRows)');
63
+ }
64
+ const y = this.d3(id);
65
+ if (y === undefined) {
66
+ throw new Error(`BandScale: unknown band id "${id}"`);
67
+ }
68
+ return y;
69
+ }
70
+ }
71
+ /**
72
+ * Default row band for the v1 layout: bandwidth = 56 px (the legacy
73
+ * bar height = ITEM_ROW_HEIGHT - 8), step = 64 px (the legacy row
74
+ * pitch = ITEM_ROW_HEIGHT). Keeps every existing sample byte-stable.
75
+ *
76
+ * m2.5c will derive these from item style + content measurement
77
+ * instead of pinning them to legacy constants.
78
+ */
79
+ export const DEFAULT_ROW_BAND_PX = {
80
+ bandwidth: 56,
81
+ step: 64,
82
+ };
83
+ export function defaultRowBand() {
84
+ return BandScale.fixedRow(DEFAULT_ROW_BAND_PX);
85
+ }
86
+ //# sourceMappingURL=band-scale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"band-scale.js","sourceRoot":"","sources":["../src/band-scale.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,EAAE;AACF,kEAAkE;AAClE,kEAAkE;AAClE,kEAAkE;AAClE,kEAAkE;AAClE,kEAAkE;AAClE,4CAA4C;AAC5C,EAAE;AACF,uEAAuE;AACvE,kEAAkE;AAClE,sEAAsE;AACtE,sEAAsE;AACtE,sEAAsE;AACtE,0DAA0D;AAC1D,gEAAgE;AAEhE,OAAO,EAAkB,SAAS,EAAE,MAAM,UAAU,CAAC;AAoBrD,MAAM,OAAO,SAAS;IACD,WAAW,CAAS;IACpB,MAAM,CAAS;IACf,EAAE,CAAqB;IAExC,YAAoB,SAAiB,EAAE,IAAY,EAAE,EAAsB;QACvE,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAqB;QACjC,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,IAAwB;QACnC,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACpE,MAAM,EAAE,GAAG,SAAS,EAAU;aACzB,MAAM,CAAC,GAAG,CAAC;aACX,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;aACjB,YAAY,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,CAAC;aACpC,YAAY,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC;QAC1C,OAAO,IAAI,SAAS,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,iCAAiC;IACjC,SAAS;QACL,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED,4DAA4D;IAC5D,IAAI;QACA,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,mEAAmE;IACnE,OAAO,CAAC,EAAU;QACd,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CACX,gFAAgF,CACnF,CAAC;QACN,CAAC;QACD,MAAM,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACtB,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,+BAA+B,EAAE,GAAG,CAAC,CAAC;QAC1D,CAAC;QACD,OAAO,CAAC,CAAC;IACb,CAAC;CACJ;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,SAAS,EAAE,EAAE;IACb,IAAI,EAAE,EAAE;CACF,CAAC;AAEX,MAAM,UAAU,cAAc;IAC1B,OAAO,SAAS,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;AACnD,CAAC"}
@@ -0,0 +1,79 @@
1
+ import type { CalendarBlock, EntityProperty, NowlineFile, SizeDeclaration } from '@nowline/core';
2
+ import type { ResolvedSize } from './types.js';
3
+ export type CalendarMode = 'business' | 'full' | 'custom';
4
+ export interface CalendarConfig {
5
+ mode: CalendarMode;
6
+ daysPerWeek: number;
7
+ daysPerMonth: number;
8
+ daysPerQuarter: number;
9
+ daysPerYear: number;
10
+ }
11
+ export declare function resolveCalendar(file: NowlineFile, customBlock: CalendarBlock | undefined): CalendarConfig;
12
+ export declare function literalToDays(literal: string, cal: CalendarConfig): number;
13
+ /**
14
+ * Convert a `duration:` literal or a `size:NAME` reference into a calendar-
15
+ * resolved day count. Capacity-agnostic — used both for the duration
16
+ * literal lookup in `deriveItemDurationDays` and for the
17
+ * `remaining:` literal normalization in `sequenceItem`. Returns 0 for
18
+ * missing or unresolvable values; callers substitute their own minimum
19
+ * width when the result is zero.
20
+ */
21
+ export declare function resolveDuration(value: string | undefined, sizes: Map<string, ResolvedSize>, cal: CalendarConfig): number;
22
+ /**
23
+ * Derive an item's calendar duration in days from its properties.
24
+ * Precedence (matches specs/dsl.md § "Sizing precedence"):
25
+ *
26
+ * 1. Explicit `duration:LITERAL` wins. The literal IS the calendar
27
+ * duration the bar paints; `size:NAME` (if also present) collapses
28
+ * to a pure annotation rendered as the size chip.
29
+ * 2. Otherwise, `size:NAME` resolves to its size declaration's
30
+ * `effort:` (single-engineer days) and we divide by the item's
31
+ * capacity (default 1) to get the team's calendar duration.
32
+ * 3. With neither, returns 0 — the validator already errors on items
33
+ * missing both `size:` and `duration:`, so this only happens in
34
+ * transient malformed inputs.
35
+ */
36
+ export declare function deriveItemDurationDays(props: EntityProperty[], sizes: Map<string, ResolvedSize>, cal: CalendarConfig): number;
37
+ /**
38
+ * Total work for the item in single-engineer days. Used to normalize a
39
+ * literal `remaining:` value (also single-engineer days per spec) into a
40
+ * 0..1 progress fraction.
41
+ *
42
+ * - sized: `size.effortDays` directly (already per-engineer).
43
+ * - duration-literal'd: `duration_days × capacity`. The literal sets
44
+ * calendar duration; multiplying by the engineer count recovers the
45
+ * equivalent single-engineer effort the lane is consuming.
46
+ *
47
+ * Returns 0 when neither `size:` nor `duration:` is set so callers can
48
+ * skip normalization safely.
49
+ */
50
+ export declare function deriveTotalEffortDays(props: EntityProperty[], sizes: Map<string, ResolvedSize>, cal: CalendarConfig): number;
51
+ /**
52
+ * Format a calendar day count back into the largest unit literal that
53
+ * divides cleanly under the active calendar. Used by the meta line for
54
+ * sized items so the displayed duration reflects the *derived* calendar
55
+ * duration rather than the raw effort literal — `size:m capacity:5`
56
+ * with `effort:1w` paints a 1d bar and the meta should read `M 1d`,
57
+ * not `M 1w`.
58
+ *
59
+ * - Whole-unit folds happen in descending order (`y` → `q` → `m` →
60
+ * `w`); the first one that yields an integer wins so `5d` →
61
+ * `"1w"` and `22d` (business calendar) → `"1m"`.
62
+ * - Anything left over collapses to a `Nd` literal with up to two
63
+ * decimal places, trailing zeros trimmed (`"3d"`, `"1.5d"`,
64
+ * `"1.67d"`). Matches the `DURATION_LITERAL` shape the parser
65
+ * accepts so round-tripping through the renderer reads naturally.
66
+ * - `0` (or anything sub-1d) returns `"0d"` rather than an empty
67
+ * string so callers always get a renderable token.
68
+ */
69
+ export declare function formatDurationDays(days: number, cal: CalendarConfig): string;
70
+ /**
71
+ * Build the layout's `Map<string, ResolvedSize>` once the calendar is
72
+ * known. Skips sizes whose `effort:` literal is missing or unparseable —
73
+ * the validator already errors on those, so layout silently drops them
74
+ * rather than emitting NaN-laden positions.
75
+ */
76
+ export declare function resolveSizes(decls: Map<string, SizeDeclaration>, cal: CalendarConfig): Map<string, ResolvedSize>;
77
+ export declare function daysBetween(from: Date, to: Date): number;
78
+ export declare function addDays(base: Date, days: number): Date;
79
+ //# sourceMappingURL=calendar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../src/calendar.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAIjG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE1D,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,YAAY,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACvB;AAkBD,wBAAgB,eAAe,CAC3B,IAAI,EAAE,WAAW,EACjB,WAAW,EAAE,aAAa,GAAG,SAAS,GACvC,cAAc,CAoBhB;AAKD,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,GAAG,MAAM,CAkB1E;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC3B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,EAChC,GAAG,EAAE,cAAc,GACpB,MAAM,CAIR;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAClC,KAAK,EAAE,cAAc,EAAE,EACvB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,EAChC,GAAG,EAAE,cAAc,GACpB,MAAM,CAUR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CACjC,KAAK,EAAE,cAAc,EAAE,EACvB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,EAChC,GAAG,EAAE,cAAc,GACpB,MAAM,CAUR;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,GAAG,MAAM,CAkB5E;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CACxB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EACnC,GAAG,EAAE,cAAc,GACpB,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAgB3B;AAQD,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,GAAG,MAAM,CAGxD;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAItD"}