@flyingrobots/bijou 3.0.0 → 4.0.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 (110) hide show
  1. package/LICENSE +159 -21
  2. package/README.md +100 -13
  3. package/dist/adapters/test/clock.d.ts +36 -0
  4. package/dist/adapters/test/clock.d.ts.map +1 -0
  5. package/dist/adapters/test/clock.js +132 -0
  6. package/dist/adapters/test/clock.js.map +1 -0
  7. package/dist/adapters/test/index.d.ts +8 -1
  8. package/dist/adapters/test/index.d.ts.map +1 -1
  9. package/dist/adapters/test/index.js +20 -2
  10. package/dist/adapters/test/index.js.map +1 -1
  11. package/dist/adapters/test/io.d.ts +3 -0
  12. package/dist/adapters/test/io.d.ts.map +1 -1
  13. package/dist/adapters/test/io.js +5 -4
  14. package/dist/adapters/test/io.js.map +1 -1
  15. package/dist/core/ansi.d.ts +2 -0
  16. package/dist/core/ansi.d.ts.map +1 -1
  17. package/dist/core/ansi.js +2 -0
  18. package/dist/core/ansi.js.map +1 -1
  19. package/dist/core/clock.d.ts +12 -0
  20. package/dist/core/clock.d.ts.map +1 -0
  21. package/dist/core/clock.js +59 -0
  22. package/dist/core/clock.js.map +1 -0
  23. package/dist/core/components/alert-v3.d.ts +7 -0
  24. package/dist/core/components/alert-v3.d.ts.map +1 -0
  25. package/dist/core/components/alert-v3.js +37 -0
  26. package/dist/core/components/alert-v3.js.map +1 -0
  27. package/dist/core/components/alert.d.ts +2 -0
  28. package/dist/core/components/alert.d.ts.map +1 -1
  29. package/dist/core/components/alert.js +1 -1
  30. package/dist/core/components/alert.js.map +1 -1
  31. package/dist/core/components/box-v3.d.ts +9 -2
  32. package/dist/core/components/box-v3.d.ts.map +1 -1
  33. package/dist/core/components/box-v3.js +78 -21
  34. package/dist/core/components/box-v3.js.map +1 -1
  35. package/dist/core/components/box.d.ts +7 -0
  36. package/dist/core/components/box.d.ts.map +1 -1
  37. package/dist/core/components/box.js +13 -7
  38. package/dist/core/components/box.js.map +1 -1
  39. package/dist/core/components/index.d.ts +6 -0
  40. package/dist/core/components/index.d.ts.map +1 -1
  41. package/dist/core/components/index.js +4 -0
  42. package/dist/core/components/index.js.map +1 -1
  43. package/dist/core/components/log.d.ts.map +1 -1
  44. package/dist/core/components/log.js +4 -3
  45. package/dist/core/components/log.js.map +1 -1
  46. package/dist/core/components/overflow.d.ts +3 -0
  47. package/dist/core/components/overflow.d.ts.map +1 -0
  48. package/dist/core/components/overflow.js +33 -0
  49. package/dist/core/components/overflow.js.map +1 -0
  50. package/dist/core/components/progress.d.ts.map +1 -1
  51. package/dist/core/components/progress.js +3 -1
  52. package/dist/core/components/progress.js.map +1 -1
  53. package/dist/core/components/separator-v3.d.ts +7 -0
  54. package/dist/core/components/separator-v3.d.ts.map +1 -0
  55. package/dist/core/components/separator-v3.js +46 -0
  56. package/dist/core/components/separator-v3.js.map +1 -0
  57. package/dist/core/components/spinner.d.ts.map +1 -1
  58. package/dist/core/components/spinner.js +3 -1
  59. package/dist/core/components/spinner.js.map +1 -1
  60. package/dist/core/components/surface-text.d.ts +14 -0
  61. package/dist/core/components/surface-text.d.ts.map +1 -0
  62. package/dist/core/components/surface-text.js +95 -0
  63. package/dist/core/components/surface-text.js.map +1 -0
  64. package/dist/core/components/table-v3.d.ts +11 -0
  65. package/dist/core/components/table-v3.d.ts.map +1 -0
  66. package/dist/core/components/table-v3.js +148 -0
  67. package/dist/core/components/table-v3.js.map +1 -0
  68. package/dist/core/components/table.d.ts +2 -1
  69. package/dist/core/components/table.d.ts.map +1 -1
  70. package/dist/core/components/table.js +40 -11
  71. package/dist/core/components/table.js.map +1 -1
  72. package/dist/core/components/timer.d.ts.map +1 -1
  73. package/dist/core/components/timer.js +11 -9
  74. package/dist/core/components/timer.js.map +1 -1
  75. package/dist/core/components/types.d.ts +4 -0
  76. package/dist/core/components/types.d.ts.map +1 -1
  77. package/dist/core/render/differ.d.ts +3 -3
  78. package/dist/core/render/differ.d.ts.map +1 -1
  79. package/dist/core/render/differ.js +33 -14
  80. package/dist/core/render/differ.js.map +1 -1
  81. package/dist/core/runtime-viewport.d.ts +34 -0
  82. package/dist/core/runtime-viewport.d.ts.map +1 -0
  83. package/dist/core/runtime-viewport.js +74 -0
  84. package/dist/core/runtime-viewport.js.map +1 -0
  85. package/dist/core/text/index.d.ts +1 -0
  86. package/dist/core/text/index.d.ts.map +1 -1
  87. package/dist/core/text/index.js +1 -0
  88. package/dist/core/text/index.js.map +1 -1
  89. package/dist/core/text/wrap.d.ts +11 -0
  90. package/dist/core/text/wrap.d.ts.map +1 -0
  91. package/dist/core/text/wrap.js +90 -0
  92. package/dist/core/text/wrap.js.map +1 -0
  93. package/dist/factory.d.ts +3 -0
  94. package/dist/factory.d.ts.map +1 -1
  95. package/dist/factory.js +3 -0
  96. package/dist/factory.js.map +1 -1
  97. package/dist/index.d.ts +5 -4
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/index.js +4 -3
  100. package/dist/index.js.map +1 -1
  101. package/dist/ports/clock.d.ts +29 -0
  102. package/dist/ports/clock.d.ts.map +1 -0
  103. package/dist/ports/clock.js +2 -0
  104. package/dist/ports/clock.js.map +1 -0
  105. package/dist/ports/context.d.ts +3 -0
  106. package/dist/ports/context.d.ts.map +1 -1
  107. package/dist/ports/index.d.ts +1 -0
  108. package/dist/ports/index.d.ts.map +1 -1
  109. package/dist/ports/index.js.map +1 -1
  110. package/package.json +3 -3
package/LICENSE CHANGED
@@ -1,21 +1,159 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Flying Robots
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
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, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
13
+ owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities
16
+ that control, are controlled by, or are under common control with that entity.
17
+ For the purposes of this definition, "control" means (i) the power, direct or
18
+ indirect, to cause the direction or management of such entity, whether by
19
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20
+ outstanding shares, or (iii) beneficial ownership of such entity.
21
+
22
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
23
+ permissions granted by this License.
24
+
25
+ "Source" form shall mean the preferred form for making modifications, including
26
+ but not limited to software source code, documentation source, and configuration
27
+ files.
28
+
29
+ "Object" form shall mean any form resulting from mechanical transformation or
30
+ translation of a Source form, including but not limited to compiled object code,
31
+ generated documentation, and conversions to other media types.
32
+
33
+ "Work" shall mean the work of authorship, whether in Source or Object form, made
34
+ available under the License, as indicated by a copyright notice that is included
35
+ in or attached to the work (an example is provided in the Appendix below).
36
+
37
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
38
+ is based on (or derived from) the Work and for which the editorial revisions,
39
+ annotations, elaborations, or other modifications represent, as a whole, an
40
+ original work of authorship. For the purposes of this License, Derivative Works
41
+ shall not include works that remain separable from, or merely link (or bind by
42
+ name) to the interfaces of, the Work and Derivative Works thereof.
43
+
44
+ "Contribution" shall mean any work of authorship, including the original version
45
+ of the Work and any modifications or additions to that Work or Derivative Works
46
+ thereof, that is intentionally submitted to Licensor for inclusion in the Work
47
+ by the copyright owner or by an individual or Legal Entity authorized to submit
48
+ on behalf of the copyright owner. For the purposes of this definition,
49
+ "submitted" means any form of electronic, verbal, or written communication sent
50
+ to the Licensor or its representatives, including but not limited to
51
+ communication on electronic mailing lists, source code control systems, and
52
+ issue tracking systems that are managed by, or on behalf of, the Licensor for
53
+ the purpose of discussing and improving the Work, but excluding communication
54
+ that is conspicuously marked or otherwise designated in writing by the copyright
55
+ owner as "Not a Contribution."
56
+
57
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
58
+ of whom a Contribution has been received by Licensor and subsequently
59
+ incorporated within the Work.
60
+
61
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
62
+ License, each Contributor hereby grants to You a perpetual, worldwide,
63
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
64
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
65
+ sublicense, and distribute the Work and such Derivative Works in Source or
66
+ Object form.
67
+
68
+ 3. Grant of Patent License. Subject to the terms and conditions of this License,
69
+ each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
70
+ no-charge, royalty-free, irrevocable (except as stated in this section) patent
71
+ license to make, have made, use, offer to sell, sell, import, and otherwise
72
+ transfer the Work, where such license applies only to those patent claims
73
+ licensable by such Contributor that are necessarily infringed by their
74
+ Contribution(s) alone or by combination of their Contribution(s) with the Work
75
+ to which such Contribution(s) was submitted. If You institute patent litigation
76
+ against any entity (including a cross-claim or counterclaim in a lawsuit)
77
+ alleging that the Work or a Contribution incorporated within the Work
78
+ constitutes direct or contributory patent infringement, then any patent licenses
79
+ granted to You under this License for that Work shall terminate as of the date
80
+ such litigation is filed.
81
+
82
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
83
+ Derivative Works thereof in any medium, with or without modifications, and in
84
+ Source or Object form, provided that You meet the following conditions:
85
+
86
+ (a) You must give any other recipients of the Work or Derivative Works a copy of
87
+ this License; and
88
+
89
+ (b) You must cause any modified files to carry prominent notices stating that You
90
+ changed the files; and
91
+
92
+ (c) You must retain, in the Source form of any Derivative Works that You
93
+ distribute, all copyright, patent, trademark, and attribution notices from the
94
+ Source form of the Work, excluding those notices that do not pertain to any part
95
+ of the Derivative Works; and
96
+
97
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then
98
+ any Derivative Works that You distribute must include a readable copy of the
99
+ attribution notices contained within such NOTICE file, excluding those notices
100
+ that do not pertain to any part of the Derivative Works, in at least one of the
101
+ following places: within a NOTICE text file distributed as part of the
102
+ Derivative Works; within the Source form or documentation, if provided along
103
+ with the Derivative Works; or, within a display generated by the Derivative
104
+ Works, if and wherever such third-party notices normally appear. The contents of
105
+ the NOTICE file are for informational purposes only and do not modify the
106
+ License. You may add Your own attribution notices within Derivative Works that
107
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
108
+ provided that such additional attribution notices cannot be construed as
109
+ modifying the License.
110
+
111
+ You may add Your own copyright statement to Your modifications and may provide
112
+ additional or different license terms and conditions for use, reproduction, or
113
+ distribution of Your modifications, or for any such Derivative Works as a whole,
114
+ provided Your use, reproduction, and distribution of the Work otherwise complies
115
+ with the conditions stated in this License.
116
+
117
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
118
+ Contribution intentionally submitted for inclusion in the Work by You to the
119
+ Licensor shall be under the terms and conditions of this License, without any
120
+ additional terms or conditions. Notwithstanding the above, nothing herein shall
121
+ supersede or modify the terms of any separate license agreement you may have
122
+ executed with Licensor regarding such Contributions.
123
+
124
+ 6. Trademarks. This License does not grant permission to use the trade names,
125
+ trademarks, service marks, or product names of the Licensor, except as required
126
+ for reasonable and customary use in describing the origin of the Work and
127
+ reproducing the content of the NOTICE file.
128
+
129
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
130
+ writing, Licensor provides the Work (and each Contributor provides its
131
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
132
+ KIND, either express or implied, including, without limitation, any warranties
133
+ or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
134
+ PARTICULAR PURPOSE. You are solely responsible for determining the
135
+ appropriateness of using or redistributing the Work and assume any risks
136
+ associated with Your exercise of permissions under this License.
137
+
138
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
139
+ tort (including negligence), contract, or otherwise, unless required by
140
+ applicable law (such as deliberate and grossly negligent acts) or agreed to in
141
+ writing, shall any Contributor be liable to You for damages, including any
142
+ direct, indirect, special, incidental, or consequential damages of any
143
+ character arising as a result of this License or out of the use or inability to
144
+ use the Work (including but not limited to damages for loss of goodwill, work
145
+ stoppage, computer failure or malfunction, or any and all other commercial
146
+ damages or losses), even if such Contributor has been advised of the
147
+ possibility of such damages.
148
+
149
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or
150
+ Derivative Works thereof, You may choose to offer, and charge a fee for,
151
+ acceptance of support, warranty, indemnity, or other liability obligations
152
+ and/or rights consistent with this License. However, in accepting such
153
+ obligations, You may act only on Your own behalf and on Your sole
154
+ responsibility, not on behalf of any other Contributor, and only if You agree to
155
+ indemnify, defend, and hold each Contributor harmless for any liability incurred
156
+ by, or claims asserted against, such Contributor by reason of your accepting any
157
+ such warranty or additional liability.
158
+
159
+ END OF TERMS AND CONDITIONS
package/README.md CHANGED
@@ -8,7 +8,8 @@ The pure, zero-dependency core of Bijou.
8
8
 
9
9
  - **Truthful core/runtime split** — the core package remains the right place for CLIs, prompts, logs, and portable terminal output, while `@flyingrobots/bijou-tui` owns the high-fidelity fullscreen runtime.
10
10
  - **Surface primitives without abandoning strings** — V3 adds serious surface/layout infrastructure to the core package, but `3.0.0` does not pretend every component is now surface-native. String-oriented helpers remain first-class where they fit the toolkit identity.
11
- - **Explicit compatibility boundaries** — when you mix surface-native helpers with legacy string APIs, you cross that seam explicitly with `surfaceToString(surface, ctx.style)`.
11
+ - **Surface-first companions for common V3 chrome** — `boxSurface`, `headerBoxSurface`, `separatorSurface`, `alertSurface`, and `tableSurface` let runtime apps stay on the `Surface` path for the most common layout and status primitives.
12
+ - **Explicit core/runtime boundaries** — when you move `Surface` output back into string-first core APIs, you do it explicitly with `surfaceToString(surface, ctx.style)`.
12
13
  - **Same hexagonal core** — ports, themes, output-mode detection, and test adapters remain pure and dependency-free.
13
14
 
14
15
  ## Install
@@ -21,14 +22,21 @@ npm install @flyingrobots/bijou @flyingrobots/bijou-node
21
22
 
22
23
  ```typescript
23
24
  import { initDefaultContext } from '@flyingrobots/bijou-node';
24
- import { box, headerBox, gradientText, table } from '@flyingrobots/bijou';
25
+ import { badge, boxSurface, tableSurface } from '@flyingrobots/bijou';
25
26
 
26
27
  // Initialize Node.js adapters (auto-detects TTY, CI, NO_COLOR)
27
- initDefaultContext();
28
-
29
- // Use components
30
- console.log(headerBox('My CLI', { detail: 'v1.0.0' }));
31
- console.log(box('Hello, world!'));
28
+ const ctx = initDefaultContext();
29
+
30
+ const panel = boxSurface(
31
+ tableSurface({
32
+ columns: [{ header: 'Service' }, { header: 'Status' }],
33
+ rows: [['api', badge('LIVE', { variant: 'success', ctx })]],
34
+ ctx,
35
+ }),
36
+ { title: 'Runtime', padding: { top: 1, bottom: 1, left: 2, right: 2 }, ctx },
37
+ );
38
+
39
+ // Return `panel` from a V3 `view()` function or framed pane renderer.
32
40
  ```
33
41
 
34
42
  ## Features Breakdown
@@ -40,22 +48,101 @@ console.log(box('Hello, world!'));
40
48
  - **Theme system**: preset themes + DTCG-compatible custom token loading via `BIJOU_THEME`.
41
49
  - **Test adapters**: deterministic test context and assertion helpers for mock-free component testing.
42
50
 
51
+ ## Design guidance
52
+
53
+ For the system-level guidance behind the component catalog, see:
54
+
55
+ - [`../../docs/design-system/README.md`](../../docs/design-system/README.md)
56
+ - [`../../docs/design-system/foundations.md`](../../docs/design-system/foundations.md)
57
+ - [`../../docs/design-system/patterns.md`](../../docs/design-system/patterns.md)
58
+ - [`../../docs/design-system/component-families.md`](../../docs/design-system/component-families.md)
59
+
60
+ Those docs answer the questions the API reference cannot:
61
+
62
+ - when to use a family
63
+ - when not to use it
64
+ - which variation is semantic versus render-path versus interaction-layer
65
+ - what belongs in core Bijou versus `@flyingrobots/bijou-tui`
66
+
67
+ ## Choosing Component Families
68
+
69
+ ### Status and feedback
70
+
71
+ - Use `badge()` when status is compact and belongs inline with another object.
72
+ - Use `note()` when the user needs explanation without urgency.
73
+ - Use `alert()` when the message should persist inside the page or document flow.
74
+ - Move to `@flyingrobots/bijou-tui` notifications when stacking, placement, actions, or history matter.
75
+
76
+ ### Selection and prompts
77
+
78
+ - Use `select()` when the user is choosing one stored value from a short, stable set.
79
+ - Use `filter()` when the user is still choosing one stored value, but search and narrowing are the real job.
80
+ - Use `multiselect()` when the user is building a lasting set, not firing one-off commands.
81
+ - Use `confirm()` only when the decision is genuinely binary.
82
+ - Move to `commandPaletteSurface()` in `@flyingrobots/bijou-tui` when the outcome is an action or navigation command instead of stored form state.
83
+
84
+ ### Tables and inspection
85
+
86
+ - Use `table()` when row/column comparison is the main job and string output is still the right endpoint.
87
+ - Use `tableSurface()` when the job is still passive comparison, but your V3 app is already composing `Surface` output.
88
+ - Use `navigableTable()` from `@flyingrobots/bijou-tui` when the user needs keyboard-owned row or cell inspection instead of passive reading.
89
+
90
+ ### Hierarchy and chronology
91
+
92
+ - Use `tree()` when parent/child nesting is the main thing the reader needs to understand.
93
+ - Use `timeline()` when chronology is the actual reading path.
94
+ - Move to `dag()` when dependency or causal flow matters more than simple order or nesting.
95
+ - Use `dagSlice()` when a local neighborhood or ancestor/descendant chain is the honest scope.
96
+ - Use `dagStats()` when graph health or structural summary matters more than visual shape.
97
+
98
+ ### Wayfinding and progress
99
+
100
+ - Use `breadcrumb()` when path context helps explain the current location.
101
+ - Use `paginator()` when compact position-in-sequence feedback is enough.
102
+ - Use `stepper()` when the user is progressing through ordered stages rather than switching among peers.
103
+
104
+ ### Containment and formatted content
105
+
106
+ - Use `box()` when a region needs visible containment or comparison against sibling panels.
107
+ - Use `headerBox()` when that same region also needs a compact title and detail line.
108
+ - Use `markdown()` for bounded help, reference, and release-note prose that should lower honestly across rich, pipe, and accessible output.
109
+ - Avoid turning every subsection into a box or using markdown as a substitute layout engine for full application chrome.
110
+
111
+ ### Loading, links, and expressive moments
112
+
113
+ - Use `skeleton()` for short-lived placeholders when the final content shape is known.
114
+ - Use `hyperlink()` when the destination itself should remain explicit and trustworthy in terminal output.
115
+ - Use `kbd()` for local inline shortcut cues; use shell help in `@flyingrobots/bijou-tui` when the user needs a broader keybinding reference.
116
+ - Use `gradientText()` and `loadRandomLogo()` sparingly for splash, docs, and celebratory moments rather than routine workspace chrome.
117
+
118
+ ### Progress and custom primitives
119
+
120
+ - Use `progressBar()` when completion can be estimated honestly.
121
+ - Use `spinnerFrame()` or `createSpinner()` when the task is active but indeterminate.
122
+ - Use `renderByMode()` when you are authoring an app-specific primitive that must stay truthful across rich, pipe, and accessible output.
123
+
43
124
  ## Components
44
125
 
45
126
  ### Layout
46
- `box()`, `headerBox()`, `separator()` — unicode box-drawing with automatic ASCII fallback.
127
+ `box()`, `headerBox()`, `separator()` plus `boxSurface()`, `headerBoxSurface()`, `separatorSurface()` string-first helpers and surface-native companions for layout chrome.
47
128
 
48
129
  ### Elements
49
- `badge()`, `alert()`, `kbd()`, `skeleton()` — status indicators and UI primitives.
130
+ `badge()`, `alert()`, `alertSurface()`, `kbd()`, `skeleton()`, `hyperlink()`inline status, in-flow status blocks, loading placeholders, trusted links, and UI primitives.
50
131
 
51
132
  ### Data
52
- `table()`, `tree()`, `accordion()`, `timeline()`, `dag()`, `dagSlice()`, `dagLayout()`, `dagStats()` — structured data display, DAG rendering with `DagSource` adapter, and graph statistics.
133
+ `table()`, `tableSurface()`, `tree()`, `accordion()`, `timeline()`, `dag()`, `dagSlice()`, `dagLayout()`, `dagStats()` — passive comparison and structured data display, DAG rendering with `DagSource` adapter, and graph statistics.
134
+
135
+ ### Documents
136
+ `markdown()` — structured terminal prose for help, readmes, and reference content with mode-aware lowering.
53
137
 
54
138
  ### Navigation
55
139
  `tabs()`, `breadcrumb()`, `stepper()`, `paginator()` — wayfinding components.
56
140
 
57
141
  ### Animation & Progress
58
- `spinner()`, `progressBar()`, `gradientText()` — live-updating output with color gradients.
142
+ `spinnerFrame()`, `createSpinner()`, `progressBar()`, `createProgressBar()`, `createAnimatedProgressBar()`, `gradientText()`, `loadRandomLogo()`determinate and indeterminate progress, live-updating output, expressive gradients, and branded ASCII moments.
143
+
144
+ ### Authoring helpers
145
+ `renderByMode()` — mode-aware helper for app-authored primitives that need honest rich/pipe/accessible lowering.
59
146
 
60
147
  ### Forms
61
148
  `input()`, `select()`, `multiselect()`, `confirm()`, `group()`, `wizard()`, `textarea()`, `filter()` — interactive prompts with validation that degrade to numbered-list selection in pipe/CI modes.
@@ -98,7 +185,7 @@ const result = box('hello', { ctx });
98
185
  ```
99
186
 
100
187
  See [GUIDE.md](./GUIDE.md) for more on testing, theming, and component usage.
101
- For upgrading existing apps, see the monorepo migration guide at [`../../docs/MIGRATING_TO_V3.md`](../../docs/MIGRATING_TO_V3.md).
188
+ For upgrading existing apps, see the monorepo migration guide at [`../../docs/MIGRATING_TO_V4.md`](../../docs/MIGRATING_TO_V4.md).
102
189
 
103
190
  ## Related Packages
104
191
 
@@ -107,7 +194,7 @@ For upgrading existing apps, see the monorepo migration guide at [`../../docs/MI
107
194
 
108
195
  ## License
109
196
 
110
- MIT
197
+ Apache-2.0
111
198
 
112
199
  ---
113
200
 
@@ -0,0 +1,36 @@
1
+ import type { ClockPort } from '../../ports/clock.js';
2
+ /**
3
+ * Configuration for {@link mockClock}.
4
+ */
5
+ export interface MockClockOptions {
6
+ /** Initial wall-clock time in milliseconds since the Unix epoch. */
7
+ nowMs?: number;
8
+ }
9
+ /**
10
+ * Deterministic in-memory clock for tests.
11
+ *
12
+ * Supports manual time advancement, interval/timeout scheduling, and queued
13
+ * microtasks without touching global timers.
14
+ */
15
+ export interface MockClock extends ClockPort {
16
+ /** Advance time and run all due timers/microtasks. */
17
+ advanceBy(ms: number): void;
18
+ /** Advance time while flushing native Promise continuations between timer chunks. */
19
+ advanceByAsync(ms: number): Promise<void>;
20
+ /** Run all queued microtasks without advancing wall-clock time. */
21
+ flushMicrotasks(): void;
22
+ /**
23
+ * Run all currently scheduled non-recurring timers to completion.
24
+ *
25
+ * Throws when an interval remains active after being given a chance to run,
26
+ * because recurring timers cannot be drained to completion automatically.
27
+ */
28
+ runAll(): void;
29
+ }
30
+ /**
31
+ * Create a deterministic {@link ClockPort} for unit and integration tests.
32
+ *
33
+ * The returned clock is manually driven through `advanceBy()` and `runAll()`.
34
+ */
35
+ export declare function mockClock(options?: MockClockOptions): MockClock;
36
+ //# sourceMappingURL=clock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clock.d.ts","sourceRoot":"","sources":["../../../src/adapters/test/clock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGtD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAUD;;;;;GAKG;AACH,MAAM,WAAW,SAAU,SAAQ,SAAS;IAC1C,sDAAsD;IACtD,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,qFAAqF;IACrF,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,mEAAmE;IACnE,eAAe,IAAI,IAAI,CAAC;IACxB;;;;;OAKG;IACH,MAAM,IAAI,IAAI,CAAC;CAChB;AAOD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,SAAS,CAsInE"}
@@ -0,0 +1,132 @@
1
+ function normalizeDelay(ms) {
2
+ if (!Number.isFinite(ms))
3
+ return 0;
4
+ return Math.max(0, Math.floor(ms));
5
+ }
6
+ /**
7
+ * Create a deterministic {@link ClockPort} for unit and integration tests.
8
+ *
9
+ * The returned clock is manually driven through `advanceBy()` and `runAll()`.
10
+ */
11
+ export function mockClock(options = {}) {
12
+ let nowMs = options.nowMs ?? 0;
13
+ let nextId = 1;
14
+ const microtasks = [];
15
+ const tasks = [];
16
+ function sortTasks() {
17
+ tasks.sort((a, b) => a.at - b.at || a.id - b.id);
18
+ }
19
+ function disposeTask(id) {
20
+ const task = tasks.find((candidate) => candidate.id === id);
21
+ if (task) {
22
+ task.disposed = true;
23
+ }
24
+ }
25
+ function createHandle(id) {
26
+ return {
27
+ dispose() {
28
+ disposeTask(id);
29
+ },
30
+ };
31
+ }
32
+ function runQueuedMicrotasks() {
33
+ while (microtasks.length > 0) {
34
+ const pending = microtasks.splice(0, microtasks.length);
35
+ for (const callback of pending) {
36
+ callback();
37
+ }
38
+ }
39
+ }
40
+ function runNextTask(targetMs) {
41
+ sortTasks();
42
+ const next = tasks.find((task) => !task.disposed && task.at <= targetMs);
43
+ if (next === undefined)
44
+ return false;
45
+ nowMs = next.at;
46
+ if (next.intervalMs === null) {
47
+ next.disposed = true;
48
+ }
49
+ else {
50
+ next.at = nowMs + next.intervalMs;
51
+ }
52
+ next.callback();
53
+ runQueuedMicrotasks();
54
+ return true;
55
+ }
56
+ return {
57
+ now() {
58
+ return nowMs;
59
+ },
60
+ date(ms) {
61
+ return new Date(ms ?? nowMs);
62
+ },
63
+ setTimeout(callback, ms) {
64
+ const id = nextId++;
65
+ tasks.push({
66
+ id,
67
+ at: nowMs + normalizeDelay(ms),
68
+ callback,
69
+ intervalMs: null,
70
+ disposed: false,
71
+ });
72
+ sortTasks();
73
+ return createHandle(id);
74
+ },
75
+ setInterval(callback, ms) {
76
+ const intervalMs = Math.max(1, normalizeDelay(ms));
77
+ const id = nextId++;
78
+ tasks.push({
79
+ id,
80
+ at: nowMs + intervalMs,
81
+ callback,
82
+ intervalMs,
83
+ disposed: false,
84
+ });
85
+ sortTasks();
86
+ return createHandle(id);
87
+ },
88
+ queueMicrotask(callback) {
89
+ microtasks.push(callback);
90
+ },
91
+ advanceBy(ms) {
92
+ const targetMs = nowMs + normalizeDelay(ms);
93
+ runQueuedMicrotasks();
94
+ while (runNextTask(targetMs)) {
95
+ // Keep draining until there are no more timers due at or before targetMs.
96
+ }
97
+ nowMs = targetMs;
98
+ runQueuedMicrotasks();
99
+ },
100
+ async advanceByAsync(ms) {
101
+ const targetMs = nowMs + normalizeDelay(ms);
102
+ await Promise.resolve();
103
+ while (nowMs < targetMs) {
104
+ sortTasks();
105
+ const next = tasks.find((task) => !task.disposed && task.at <= targetMs);
106
+ const nextAt = next?.at ?? Math.min(targetMs, nowMs + 1);
107
+ this.advanceBy(Math.max(0, nextAt - nowMs));
108
+ await Promise.resolve();
109
+ }
110
+ await Promise.resolve();
111
+ },
112
+ flushMicrotasks() {
113
+ runQueuedMicrotasks();
114
+ },
115
+ runAll() {
116
+ runQueuedMicrotasks();
117
+ while (true) {
118
+ sortTasks();
119
+ const next = tasks.find((task) => !task.disposed);
120
+ if (next === undefined)
121
+ break;
122
+ this.advanceBy(Math.max(0, next.at - nowMs));
123
+ sortTasks();
124
+ const remaining = tasks.filter((task) => !task.disposed);
125
+ if (remaining.length > 0 && remaining.every((task) => task.intervalMs !== null)) {
126
+ throw new Error('mockClock.runAll() cannot drain active interval timers; dispose them or advance time manually.');
127
+ }
128
+ }
129
+ },
130
+ };
131
+ }
132
+ //# sourceMappingURL=clock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clock.js","sourceRoot":"","sources":["../../../src/adapters/test/clock.ts"],"names":[],"mappings":"AAyCA,SAAS,cAAc,CAAC,EAAU;IAChC,IAAI,CAAC,MAAM,CAAC,Q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O,EAAE,CAAC;YAC1B,CAAC;YACD,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QAC1B,CAAC;QAED,eAAe;YACb,mBAAmB,EAAE,CAAC;QACxB,CAAC;QAED,MAAM;YACJ,mBAAmB,EAAE,CAAC;YACtB,OAAO,IAAI,EAAE,CAAC;gBACZ,SAAS,EAAE,CAAC;gBACZ,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAClD,IAAI,IAAI,KAAK,SAAS;oBAAE,MAAM;gBAC9B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;gBAC7C,SAAS,EAAE,CAAC;gBACZ,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACzD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,EAAE,CAAC;oBAChF,MAAM,IAAI,KAAK,CACb,gGAAgG,CACjG,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -11,10 +11,13 @@ import type { BijouContext } from '../../ports/context.js';
11
11
  import type { OutputMode, ColorScheme } from '../../core/detect/tty.js';
12
12
  import { type MockRuntimeOptions } from './runtime.js';
13
13
  import { type MockIOOptions, type MockIO } from './io.js';
14
+ import { type MockClockOptions, type MockClock } from './clock.js';
15
+ import type { ClockPort } from '../../ports/clock.js';
14
16
  import type { StylePort } from '../../ports/style.js';
15
17
  import type { Theme } from '../../core/theme/tokens.js';
16
18
  export { mockRuntime, type MockRuntimeOptions } from './runtime.js';
17
19
  export { mockIO, type MockIOOptions, type MockIO } from './io.js';
20
+ export { mockClock, type MockClockOptions, type MockClock } from './clock.js';
18
21
  export { plainStyle } from './style.js';
19
22
  export { auditStyle, type StyledCall, type AuditStylePort } from './audit-style.js';
20
23
  export { expectNoAnsi, expectNoAnsiSgr, expectContainsAnsi, expectHiddenCursor, expectShownCursor, expectWritten, } from './assertions.js';
@@ -30,6 +33,8 @@ export interface TestContextOptions {
30
33
  io?: MockIOOptions;
31
34
  /** Theme to resolve. Defaults to `CYAN_MAGENTA`. */
32
35
  theme?: Theme;
36
+ /** Clock override for deterministic time/scheduling. */
37
+ clock?: MockClockOptions | MockClock | ClockPort;
33
38
  /** Output mode. Defaults to `'interactive'`. */
34
39
  mode?: OutputMode;
35
40
  /** Whether to strip color from the resolved theme. Defaults to `false`. */
@@ -52,7 +57,9 @@ export interface TestContext extends BijouContext {
52
57
  *
53
58
  * Assemble a {@link mockRuntime}, {@link mockIO}, and {@link plainStyle}
54
59
  * together with a resolved theme so tests can exercise bijou components
55
- * without touching real terminals or filesystems.
60
+ * without touching real terminals or filesystems. When a clock override is
61
+ * provided, the same scheduler is threaded through the mock I/O adapter so
62
+ * interactive runtime tests can stay fully deterministic.
56
63
  *
57
64
  * @param options - Optional overrides for runtime, I/O, theme, mode, and color.
58
65
  * @returns A {@link TestContext} ready for use in tests.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/test/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAe,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAU,KAAK,aAAa,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,E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,kBAAkB;IACjC,sEAAsE;IACtE,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,wEAAwE;IACxE,EAAE,CAAC,EAAE,aAAa,CAAC;IACnB,oDAAoD;IACpD,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,wDAAwD;IACxD,KAAK,CAAC,EAAE,gBAAgB,GAAG,SAAS,GAAG,SAAS,CAAC;IACjD,gDAAgD;IAChD,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0EAA0E;IAC1E,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,8DAA8D;IAC9D,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AASD;;;GAGG;AACH,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC/C,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,kBAAuB,GAAG,WAAW,CAyB/E"}
@@ -1,30 +1,47 @@
1
1
  import { mockRuntime } from './runtime.js';
2
2
  import { mockIO } from './io.js';
3
+ import { mockClock } from './clock.js';
3
4
  import { plainStyle } from './style.js';
4
5
  import { createResolved } from '../../core/theme/resolve.js';
5
6
  import { CYAN_MAGENTA } from '../../core/theme/presets.js';
6
7
  import { createThemeAccessors } from '../../core/theme/accessors.js';
7
8
  import { createTokenGraph } from '../../core/theme/graph.js';
9
+ import { systemClock } from '../../core/clock.js';
8
10
  export { mockRuntime } from './runtime.js';
9
11
  export { mockIO } from './io.js';
12
+ export { mockClock } from './clock.js';
10
13
  export { plainStyle } from './style.js';
11
14
  export { auditStyle } from './audit-style.js';
12
15
  export { expectNoAnsi, expectNoAnsiSgr, expectContainsAnsi, expectHiddenCursor, expectShownCursor, expectWritten, } from './assertions.js';
13
16
  export { COLOR_OPTIONS, FRUIT_OPTIONS, MANY_OPTIONS } from './fixtures.js';
14
17
  export { _resetDefaultContextForTesting } from '../../context.js';
18
+ function isClockPort(value) {
19
+ return typeof value === 'object'
20
+ && value !== null
21
+ && 'now' in value
22
+ && typeof value.now === 'function';
23
+ }
15
24
  /**
16
25
  * Create a fully-wired {@link BijouContext} for unit and integration tests.
17
26
  *
18
27
  * Assemble a {@link mockRuntime}, {@link mockIO}, and {@link plainStyle}
19
28
  * together with a resolved theme so tests can exercise bijou components
20
- * without touching real terminals or filesystems.
29
+ * without touching real terminals or filesystems. When a clock override is
30
+ * provided, the same scheduler is threaded through the mock I/O adapter so
31
+ * interactive runtime tests can stay fully deterministic.
21
32
  *
22
33
  * @param options - Optional overrides for runtime, I/O, theme, mode, and color.
23
34
  * @returns A {@link TestContext} ready for use in tests.
24
35
  */
25
36
  export function createTestContext(options = {}) {
26
37
  const runtime = mockRuntime(options.runtime);
27
- const io = mockIO(options.io);
38
+ const requestedClock = options.clock ?? options.io?.clock;
39
+ const clock = requestedClock === undefined
40
+ ? systemClock()
41
+ : (isClockPort(requestedClock) ? requestedClock : mockClock(requestedClock));
42
+ const io = mockIO(options.io?.clock === undefined
43
+ ? { ...(options.io ?? {}), clock }
44
+ : options.io);
28
45
  const style = options.style ?? plainStyle();
29
46
  const theme = createResolved(options.theme ?? CYAN_MAGENTA, options.noColor ?? false, options.colorScheme ?? 'dark');
30
47
  const tokenGraph = createTokenGraph((options.theme ?? CYAN_MAGENTA));
@@ -34,6 +51,7 @@ export function createTestContext(options = {}) {
34
51
  mode,
35
52
  runtime,
36
53
  io,
54
+ clock,
37
55
  style,
38
56
  tokenGraph,
39
57
  resolveBCSS: () => ({}),
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/test/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAA2B,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,MAAM,EAAmC,MAAM,SAAS,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAA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