headson 0.5.4__tar.gz → 0.6.1__tar.gz
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.
Potentially problematic release.
This version of headson might be problematic. Click here for more details.
- {headson-0.5.4 → headson-0.6.1}/Cargo.lock +1 -1
- {headson-0.5.4 → headson-0.6.1}/Cargo.toml +1 -1
- {headson-0.5.4 → headson-0.6.1}/PKG-INFO +2 -2
- {headson-0.5.4 → headson-0.6.1}/README.md +1 -1
- headson-0.6.1/docs/assets/logo.svg +83 -0
- headson-0.6.1/docs/assets/tapes/demo.gif +0 -0
- {headson-0.5.4 → headson-0.6.1}/pyproject.toml +1 -1
- {headson-0.5.4 → headson-0.6.1}/python/Cargo.lock +2 -2
- {headson-0.5.4 → headson-0.6.1}/python/Cargo.toml +1 -1
- {headson-0.5.4 → headson-0.6.1}/python/src/lib.rs +2 -2
- {headson-0.5.4 → headson-0.6.1}/src/json_ingest/samplers/default.rs +0 -2
- {headson-0.5.4 → headson-0.6.1}/src/lib.rs +18 -6
- {headson-0.5.4 → headson-0.6.1}/src/main.rs +41 -6
- headson-0.6.1/src/serialization/color.rs +113 -0
- {headson-0.5.4 → headson-0.6.1}/src/serialization/fileset.rs +2 -2
- {headson-0.5.4 → headson-0.6.1}/src/serialization/mod.rs +248 -41
- headson-0.6.1/src/serialization/output.rs +98 -0
- headson-0.6.1/src/serialization/snapshots/headson__serialization__tests__array_omitted_js_head.snap +9 -0
- headson-0.6.1/src/serialization/snapshots/headson__serialization__tests__array_omitted_js_tail.snap +9 -0
- headson-0.6.1/src/serialization/snapshots/headson__serialization__tests__array_omitted_pseudo_head.snap +9 -0
- headson-0.6.1/src/serialization/snapshots/headson__serialization__tests__array_omitted_pseudo_tail.snap +9 -0
- headson-0.6.1/src/serialization/snapshots/headson__serialization__tests__inline_open_array_in_object_json.snap +10 -0
- headson-0.6.1/src/serialization/templates/core.rs +124 -0
- headson-0.6.1/src/serialization/templates/js.rs +75 -0
- headson-0.6.1/src/serialization/templates/json.rs +29 -0
- headson-0.6.1/src/serialization/templates/mod.rs +53 -0
- headson-0.6.1/src/serialization/templates/pseudo.rs +69 -0
- headson-0.6.1/src/serialization/types.rs +41 -0
- headson-0.6.1/src/utils/json.rs +11 -0
- headson-0.5.4/docs/assets/logo.svg +0 -70
- headson-0.5.4/docs/assets/tapes/demo.gif +0 -0
- headson-0.5.4/src/serialization/templates/core.rs +0 -92
- headson-0.5.4/src/serialization/templates/js.rs +0 -83
- headson-0.5.4/src/serialization/templates/json.rs +0 -22
- headson-0.5.4/src/serialization/templates/mod.rs +0 -45
- headson-0.5.4/src/serialization/templates/pseudo.rs +0 -60
- headson-0.5.4/src/serialization/types.rs +0 -18
- headson-0.5.4/src/utils/json.rs +0 -6
- {headson-0.5.4 → headson-0.6.1}/JSONTestSuite/LICENSE +0 -0
- {headson-0.5.4 → headson-0.6.1}/JSONTestSuite/README.md +0 -0
- {headson-0.5.4 → headson-0.6.1}/LICENSE +0 -0
- {headson-0.5.4 → headson-0.6.1}/docs/assets/algorithm.svg +0 -0
- {headson-0.5.4 → headson-0.6.1}/docs/assets/logo.png +0 -0
- {headson-0.5.4 → headson-0.6.1}/python/README.md +0 -0
- {headson-0.5.4 → headson-0.6.1}/python/headson/__init__.py +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/json_ingest/builder.rs +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/json_ingest/mod.rs +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/json_ingest/samplers/head.rs +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/json_ingest/samplers/mod.rs +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/json_ingest/samplers/tail.rs +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/order/build.rs +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/order/mod.rs +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/order/scoring.rs +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/order/snapshots/headson__order__build__tests__order_empty_array_order.snap +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/order/snapshots/headson__order__build__tests__order_single_string_array_order.snap +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/order/types.rs +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/serialization/snapshots/headson__serialization__tests__arena_render_empty.snap +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/serialization/snapshots/headson__serialization__tests__arena_render_single.snap +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/snapshots/headson__order__tests__order_empty_array_order.snap +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/snapshots/headson__order__tests__order_single_string_array_order.snap +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/snapshots/headson__order__tests__pq_empty_array_queue.snap +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/snapshots/headson__order__tests__pq_single_string_array_queue.snap +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/snapshots/headson__queue__tests__pq_empty_array_queue.snap +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/snapshots/headson__queue__tests__pq_single_string_array_queue.snap +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/snapshots/headson__tree__tests__build_tree_empty.snap +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/snapshots/headson__tree__tests__build_tree_single.snap +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/utils/graph.rs +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/utils/mod.rs +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/utils/search.rs +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/utils/text.rs +0 -0
- {headson-0.5.4 → headson-0.6.1}/src/utils/tree_arena.rs +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: headson
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.1
|
|
4
4
|
Classifier: Programming Language :: Python
|
|
5
5
|
Classifier: Programming Language :: Python :: 3
|
|
6
6
|
Classifier: Programming Language :: Rust
|
|
@@ -14,7 +14,7 @@ Requires-Python: >=3.10
|
|
|
14
14
|
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
15
15
|
|
|
16
16
|
<h1 align="center">
|
|
17
|
-
<img src="https://raw.githubusercontent.com/kantord/headson/main/docs/assets/logo.svg" alt="headson" width="
|
|
17
|
+
<img src="https://raw.githubusercontent.com/kantord/headson/main/docs/assets/logo.svg" alt="headson" width="221" />
|
|
18
18
|
</h1>
|
|
19
19
|
<p align="center">
|
|
20
20
|
<img src="https://raw.githubusercontent.com/kantord/headson/main/docs/assets/tapes/demo.gif" alt="Terminal demo" width="1560" height="900" />
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<h1 align="center">
|
|
2
|
-
<img src="https://raw.githubusercontent.com/kantord/headson/main/docs/assets/logo.svg" alt="headson" width="
|
|
2
|
+
<img src="https://raw.githubusercontent.com/kantord/headson/main/docs/assets/logo.svg" alt="headson" width="221" />
|
|
3
3
|
</h1>
|
|
4
4
|
<p align="center">
|
|
5
5
|
<img src="https://raw.githubusercontent.com/kantord/headson/main/docs/assets/tapes/demo.gif" alt="Terminal demo" width="1560" height="900" />
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
3
|
+
|
|
4
|
+
<svg
|
|
5
|
+
width="631"
|
|
6
|
+
height="120"
|
|
7
|
+
viewBox="0 0 10.660864 2.0288198"
|
|
8
|
+
version="1.1"
|
|
9
|
+
id="svg1"
|
|
10
|
+
inkscape:version="1.4.2 (ebf0e940d0, 2025-05-08)"
|
|
11
|
+
sodipodi:docname="logo.svg"
|
|
12
|
+
inkscape:export-filename="logo.png"
|
|
13
|
+
inkscape:export-xdpi="500"
|
|
14
|
+
inkscape:export-ydpi="500"
|
|
15
|
+
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
16
|
+
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
17
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
18
|
+
xmlns:svg="http://www.w3.org/2000/svg">
|
|
19
|
+
<sodipodi:namedview
|
|
20
|
+
id="namedview1"
|
|
21
|
+
pagecolor="#ffffff"
|
|
22
|
+
bordercolor="#000000"
|
|
23
|
+
borderopacity="0.25"
|
|
24
|
+
inkscape:showpageshadow="2"
|
|
25
|
+
inkscape:pageopacity="0.0"
|
|
26
|
+
inkscape:pagecheckerboard="0"
|
|
27
|
+
inkscape:deskcolor="#d1d1d1"
|
|
28
|
+
inkscape:document-units="mm"
|
|
29
|
+
inkscape:zoom="27.623569"
|
|
30
|
+
inkscape:cx="29.449489"
|
|
31
|
+
inkscape:cy="-1.8100485"
|
|
32
|
+
inkscape:window-width="3840"
|
|
33
|
+
inkscape:window-height="2124"
|
|
34
|
+
inkscape:window-x="1080"
|
|
35
|
+
inkscape:window-y="748"
|
|
36
|
+
inkscape:window-maximized="1"
|
|
37
|
+
inkscape:current-layer="text1"
|
|
38
|
+
inkscape:export-bgcolor="#ffffffff" />
|
|
39
|
+
<defs
|
|
40
|
+
id="defs1">
|
|
41
|
+
<style
|
|
42
|
+
type="text/css"
|
|
43
|
+
id="style1"><![CDATA[
|
|
44
|
+
.wordmark { fill: #000000; }
|
|
45
|
+
.wordmark .primary { fill: #000000; }
|
|
46
|
+
.accent { fill: #ff0000; }
|
|
47
|
+
@media (prefers-color-scheme: dark) {
|
|
48
|
+
.wordmark { fill: #ffffff; }
|
|
49
|
+
.wordmark .primary { fill: #ffffff; }
|
|
50
|
+
}
|
|
51
|
+
]]></style>
|
|
52
|
+
</defs>
|
|
53
|
+
<g
|
|
54
|
+
inkscape:label="Layer 1"
|
|
55
|
+
inkscape:groupmode="layer"
|
|
56
|
+
id="layer1"
|
|
57
|
+
transform="translate(-66.186972,-133.80171)">
|
|
58
|
+
<g
|
|
59
|
+
id="text1"
|
|
60
|
+
class="wordmark"
|
|
61
|
+
style="font-size:3.175px;stroke-width:0.244"
|
|
62
|
+
aria-label="head{…}son">
|
|
63
|
+
<g
|
|
64
|
+
id="text2"
|
|
65
|
+
class="accent"
|
|
66
|
+
style="font-size:2.11667px;font-family:'Roboto Mono';-inkscape-font-specification:'Roboto Mono'"
|
|
67
|
+
aria-label="head{…}son">
|
|
68
|
+
<path class="primary"
|
|
69
|
+
style="font-family:Roboto;-inkscape-font-specification:Roboto;opacity:1"
|
|
70
|
+
d="m 66.378175,133.86475 v 1.58751 h -0.191203 v -1.58751 z m -0.04547,0.98599 -0.07958,-0.003 q 0.001,-0.11472 0.03411,-0.21187 0.03307,-0.0982 0.09302,-0.17054 0.05994,-0.0723 0.142628,-0.11162 0.08372,-0.0403 0.185001,-0.0403 0.08268,0 0.148829,0.0227 0.06615,0.0217 0.112655,0.0703 0.04754,0.0486 0.07235,0.12609 0.0248,0.0765 0.0248,0.18707 v 0.73278 H 66.87427 v -0.73484 q 0,-0.0879 -0.02584,-0.14056 -0.02584,-0.0538 -0.07545,-0.0775 -0.04961,-0.0248 -0.121957,-0.0248 -0.07131,0 -0.130224,0.03 -0.05788,0.03 -0.100253,0.0827 -0.04134,0.0527 -0.06511,0.12092 -0.02274,0.0672 -0.02274,0.14263 z m 1.484149,0.62219 q -0.116788,0 -0.211873,-0.0393 -0.09405,-0.0403 -0.162264,-0.11265 -0.06718,-0.0724 -0.103353,-0.17157 -0.03617,-0.0992 -0.03617,-0.21704 v -0.0434 q 0,-0.13642 0.04031,-0.24288 0.04031,-0.10749 0.109554,-0.1819 0.06925,-0.0744 0.157096,-0.11265 0.08785,-0.0383 0.181902,-0.0383 0.119889,0 0.206706,0.0413 0.08785,0.0413 0.143661,0.11575 0.05581,0.0734 0.08268,0.17363 0.02687,0.0992 0.02687,0.21705 v 0.0858 h -0.835093 v -0.15606 h 0.64389 v -0.0145 q -0.0041,-0.0744 -0.03101,-0.1447 -0.02584,-0.0703 -0.08268,-0.11575 -0.05684,-0.0455 -0.155029,-0.0455 -0.06511,0 -0.11989,0.0279 -0.05478,0.0269 -0.09405,0.0806 -0.03927,0.0537 -0.06098,0.13126 -0.0217,0.0775 -0.0217,0.1788 v 0.0434 q 0,0.0796 0.0217,0.14986 0.02274,0.0693 0.06511,0.12196 0.04341,0.0527 0.104387,0.0827 0.06201,0.03 0.14056,0.03 0.101286,0 0.171566,-0.0413 0.07028,-0.0413 0.12299,-0.11059 l 0.115755,0.092 q -0.03617,0.0548 -0.09198,0.10438 -0.05581,0.0496 -0.137459,0.0806 -0.08062,0.031 -0.191204,0.031 z m 1.317752,-0.21188 v -0.57567 q 0,-0.0662 -0.02687,-0.11473 -0.02584,-0.0496 -0.07855,-0.0765 -0.05271,-0.0269 -0.130225,-0.0269 -0.07235,0 -0.127124,0.0248 -0.05374,0.0248 -0.08475,0.0651 -0.02997,0.0403 -0.02997,0.0868 h -0.191203 q 0,-0.0599 0.03101,-0.11885 0.031,-0.0589 0.08888,-0.10645 0.05891,-0.0486 0.14056,-0.0765 0.08268,-0.0289 0.183969,-0.0289 0.121956,0 0.214974,0.0413 0.09405,0.0413 0.146761,0.12505 0.05374,0.0827 0.05374,0.20774 v 0.5209 q 0,0.0558 0.0093,0.11886 0.01033,0.063 0.02997,0.10852 v 0.0165 h -0.199471 q -0.01447,-0.0331 -0.02274,-0.0879 -0.0083,-0.0558 -0.0083,-0.10336 z m 0.03307,-0.48679 0.0021,0.13436 h -0.19327 q -0.08165,0 -0.145728,0.0134 -0.06408,0.0124 -0.107487,0.0382 -0.04341,0.0258 -0.06615,0.0651 -0.02274,0.0382 -0.02274,0.0899 0,0.0527 0.02377,0.0961 0.02377,0.0434 0.07131,0.0692 0.04858,0.0248 0.118856,0.0248 0.08785,0 0.155029,-0.0372 0.06718,-0.0372 0.106454,-0.091 0.04031,-0.0537 0.04341,-0.10439 l 0.08165,0.092 q -0.0072,0.0434 -0.03927,0.0961 -0.03204,0.0527 -0.08578,0.10129 -0.05271,0.0475 -0.126091,0.0796 -0.07235,0.031 -0.163297,0.031 -0.113689,0 -0.199472,-0.0444 -0.08475,-0.0444 -0.132292,-0.11885 -0.04651,-0.0754 -0.04651,-0.16847 0,-0.0899 0.03514,-0.15813 0.03514,-0.0692 0.101286,-0.11472 0.06615,-0.0465 0.159164,-0.0703 0.09302,-0.0238 0.20774,-0.0238 z m 1.163754,0.46095 v -1.37046 h 0.192237 v 1.58751 h -0.1757 z m -0.75241,-0.32969 v -0.0217 q 0,-0.12815 0.03101,-0.23254 0.03204,-0.10542 0.08992,-0.18087 0.05891,-0.0755 0.139527,-0.11575 0.08165,-0.0413 0.181901,-0.0413 0.10542,0 0.183969,0.0372 0.07958,0.0362 0.134359,0.10646 0.05581,0.0692 0.08785,0.16743 0.03204,0.0982 0.04444,0.22221 v 0.0951 q -0.01137,0.12299 -0.04444,0.22118 -0.03204,0.0982 -0.08785,0.16743 -0.05478,0.0693 -0.134359,0.10645 -0.07958,0.0362 -0.186036,0.0362 -0.09819,0 -0.179834,-0.0424 -0.08061,-0.0424 -0.139527,-0.11885 -0.05788,-0.0765 -0.08992,-0.17984 -0.03101,-0.10439 -0.03101,-0.22634 z m 0.192237,-0.0217 v 0.0217 q 0,0.0837 0.01654,0.15709 0.01757,0.0734 0.05374,0.1292 0.03617,0.0558 0.09198,0.0879 0.05581,0.031 0.133326,0.031 0.09508,0 0.156063,-0.0403 0.06201,-0.0403 0.09922,-0.10645 0.03721,-0.0662 0.05788,-0.14366 v -0.24908 q -0.0124,-0.0568 -0.03617,-0.10956 -0.02274,-0.0537 -0.05994,-0.0951 -0.03617,-0.0424 -0.08992,-0.0672 -0.05271,-0.0248 -0.125057,-0.0248 -0.07855,0 -0.135393,0.0331 -0.05581,0.032 -0.09198,0.0889 -0.03617,0.0558 -0.05374,0.13023 -0.01654,0.0734 -0.01654,0.15709 z m 1.556497,-1.0821 0.04031,0.11782 q -0.12299,0.0382 -0.169499,0.13746 -0.04651,0.0982 -0.04651,0.22531 v 0.21394 q 0,0.10335 -0.04237,0.1881 -0.04134,0.0837 -0.132292,0.13333 -0.08992,0.0496 -0.236679,0.0496 v -0.12609 q 0.116789,0 0.167432,-0.0661 0.05168,-0.0661 0.05168,-0.1788 v -0.21394 q 0,-0.10852 0.03307,-0.20257 0.03411,-0.0951 0.113688,-0.1664 0.08062,-0.0724 0.221176,-0.11162 z m 0.04031,1.90996 -0.04031,0.11886 q -0.14056,-0.0403 -0.221176,-0.11162 -0.07958,-0.0713 -0.113688,-0.1664 -0.03307,-0.0941 -0.03307,-0.20257 v -0.21291 q 0,-0.0755 -0.02274,-0.13023 -0.02274,-0.0548 -0.07131,-0.0847 -0.04754,-0.031 -0.125058,-0.031 v -0.12609 q 0.146762,0 0.236679,0.0496 0.09095,0.0496 0.132292,0.13436 0.04237,0.0837 0.04237,0.1881 v 0.21291 q 0,0.0847 0.01964,0.15709 0.02067,0.0724 0.06718,0.12506 0.04754,0.0537 0.129191,0.0796 z"
|
|
71
|
+
id="path1" />
|
|
72
|
+
<path
|
|
73
|
+
style="font-family:Roboto;-inkscape-font-specification:Roboto"
|
|
74
|
+
d="m 71.54376,135.35097 q 0,-0.0486 0.02997,-0.0816 0.03101,-0.0341 0.08888,-0.0341 0.05788,0 0.08785,0.0341 0.03101,0.0331 0.03101,0.0816 0,0.0475 -0.03101,0.0806 -0.02997,0.0331 -0.08785,0.0331 -0.05788,0 -0.08888,-0.0331 -0.02997,-0.0331 -0.02997,-0.0806 z m 0.451652,0 q 0,-0.0486 0.02997,-0.0816 0.03101,-0.0341 0.08888,-0.0341 0.05788,0 0.08785,0.0341 0.03101,0.0331 0.03101,0.0816 0,0.0475 -0.03101,0.0806 -0.02997,0.0331 -0.08785,0.0331 -0.05788,0 -0.08888,-0.0331 -0.02997,-0.0331 -0.02997,-0.0806 z m 0.428915,0 q 0,-0.0486 0.02997,-0.0816 0.03101,-0.0341 0.08888,-0.0341 0.05788,0 0.08785,0.0341 0.03101,0.0331 0.03101,0.0816 0,0.0475 -0.03101,0.0806 -0.02997,0.0331 -0.08785,0.0331 -0.05788,0 -0.08888,-0.0331 -0.02997,-0.0331 -0.02997,-0.0806 z"
|
|
75
|
+
id="path2" />
|
|
76
|
+
<path class="primary"
|
|
77
|
+
style="font-family:Roboto;-inkscape-font-specification:Roboto;opacity:1"
|
|
78
|
+
d="m 72.827404,133.91953 0.04031,-0.11782 q 0.141594,0.0393 0.221176,0.11162 0.08061,0.0713 0.113688,0.1664 0.03307,0.094 0.03307,0.20257 v 0.21394 q 0,0.0744 0.02274,0.13022 0.02274,0.0548 0.07028,0.0847 0.04858,0.03 0.126091,0.03 v 0.11679 q -0.145728,0 -0.236679,-0.0465 -0.09095,-0.0476 -0.133325,-0.12919 -0.04134,-0.0827 -0.04134,-0.18604 v -0.21394 q 0,-0.0847 -0.01964,-0.1571 -0.01964,-0.0734 -0.06718,-0.12609 -0.04651,-0.0537 -0.129191,-0.0796 z m 0.04031,1.911 -0.04031,-0.11886 q 0.08165,-0.0258 0.128157,-0.0796 0.04754,-0.0527 0.06718,-0.12506 0.02067,-0.0723 0.02067,-0.15709 v -0.21291 q 0,-0.10439 0.04134,-0.18604 0.04237,-0.0816 0.133325,-0.12815 0.09095,-0.0476 0.236679,-0.0476 v 0.11576 q -0.115756,0 -0.167432,0.0672 -0.05168,0.0661 -0.05168,0.1788 v 0.21291 q 0,0.10852 -0.03307,0.20257 -0.03307,0.0951 -0.113688,0.1664 -0.07958,0.0713 -0.221176,0.11162 z m 1.452111,-0.6749 q 0,-0.0413 -0.0186,-0.0765 -0.01757,-0.0362 -0.07338,-0.0651 -0.05478,-0.03 -0.165365,-0.0517 -0.09302,-0.0196 -0.168465,-0.0465 -0.07441,-0.0269 -0.127124,-0.0651 -0.05168,-0.0382 -0.07958,-0.0899 -0.02791,-0.0517 -0.02791,-0.12092 0,-0.0662 0.02894,-0.12506 0.02997,-0.0589 0.08372,-0.10438 0.05478,-0.0455 0.131258,-0.0713 0.07648,-0.0258 0.170532,-0.0258 0.134359,0 0.229444,0.0476 0.09508,0.0475 0.145728,0.12712 0.05064,0.0786 0.05064,0.17467 h -0.191203 q 0,-0.0465 -0.02791,-0.0899 -0.02687,-0.0444 -0.07958,-0.0734 -0.05168,-0.0289 -0.127125,-0.0289 -0.07958,0 -0.129191,0.0248 -0.04858,0.0238 -0.07131,0.061 -0.0217,0.0372 -0.0217,0.0785 0,0.031 0.01034,0.0558 0.01137,0.0238 0.03927,0.0445 0.02791,0.0196 0.07855,0.0372 0.05064,0.0176 0.129191,0.0351 0.13746,0.031 0.226343,0.0744 0.08888,0.0434 0.132292,0.10645 0.04341,0.0631 0.04341,0.15296 0,0.0734 -0.03101,0.13436 -0.02997,0.061 -0.08785,0.10542 -0.05684,0.0434 -0.136426,0.0682 -0.07855,0.0238 -0.176734,0.0238 -0.147795,0 -0.250114,-0.0527 -0.10232,-0.0527 -0.15503,-0.13643 -0.05271,-0.0837 -0.05271,-0.17673 h 0.192237 q 0.0041,0.0785 0.04548,0.12505 0.04134,0.0455 0.101286,0.0651 0.05994,0.0186 0.118856,0.0186 0.07855,0 0.131258,-0.0207 0.05374,-0.0207 0.08165,-0.0568 0.02791,-0.0362 0.02791,-0.0827 z m 0.390675,-0.25011 v -0.0238 q 0,-0.12093 0.03514,-0.22428 0.03514,-0.10439 0.101286,-0.18087 0.06614,-0.0775 0.160197,-0.11989 0.09405,-0.0434 0.21084,-0.0434 0.117822,0 0.211874,0.0434 0.09508,0.0424 0.16123,0.11989 0.06718,0.0765 0.10232,0.18087 0.03514,0.10335 0.03514,0.22428 v 0.0238 q 0,0.12092 -0.03514,0.22427 -0.03514,0.10336 -0.10232,0.18087 -0.06615,0.0765 -0.160197,0.11989 -0.09302,0.0424 -0.21084,0.0424 -0.117823,0 -0.211874,-0.0424 -0.09405,-0.0434 -0.16123,-0.11989 -0.06615,-0.0775 -0.101286,-0.18087 -0.03514,-0.10335 -0.03514,-0.22427 z m 0.191203,-0.0238 v 0.0238 q 0,0.0837 0.01964,0.15813 0.01964,0.0734 0.05891,0.13022 0.04031,0.0568 0.100252,0.0899 0.05994,0.032 0.139527,0.032 0.07855,0 0.137459,-0.032 0.05994,-0.0331 0.09922,-0.0899 0.03928,-0.0568 0.05891,-0.13022 0.02067,-0.0744 0.02067,-0.15813 v -0.0238 q 0,-0.0827 -0.02067,-0.15607 -0.01964,-0.0744 -0.05994,-0.13125 -0.03927,-0.0579 -0.09922,-0.091 -0.05891,-0.0331 -0.138493,-0.0331 -0.07855,0 -0.138493,0.0331 -0.05891,0.0331 -0.09922,0.091 -0.03927,0.0568 -0.05891,0.13125 -0.01964,0.0734 -0.01964,0.15607 z m 1.257805,-0.30903 v 0.87954 h -0.191203 v -1.11828 h 0.180868 z m -0.04547,0.27802 -0.07958,-0.003 q 0.001,-0.11472 0.03411,-0.21187 0.03307,-0.0982 0.09302,-0.17054 0.05994,-0.0723 0.142627,-0.11162 0.08372,-0.0403 0.185002,-0.0403 0.08268,0 0.148828,0.0227 0.06615,0.0217 0.112655,0.0703 0.04754,0.0486 0.07235,0.12609 0.02481,0.0765 0.02481,0.18707 v 0.73278 H 76.6556 v -0.73484 q 0,-0.0879 -0.02584,-0.14056 -0.02584,-0.0538 -0.07545,-0.0775 -0.04961,-0.0248 -0.121957,-0.0248 -0.07131,0 -0.130224,0.03 -0.05788,0.03 -0.100253,0.0827 -0.04134,0.0527 -0.06511,0.12092 -0.02274,0.0672 -0.02274,0.14263 z"
|
|
79
|
+
id="path3" />
|
|
80
|
+
</g>
|
|
81
|
+
</g>
|
|
82
|
+
</g>
|
|
83
|
+
</svg>
|
|
Binary file
|
|
@@ -169,7 +169,7 @@ dependencies = [
|
|
|
169
169
|
|
|
170
170
|
[[package]]
|
|
171
171
|
name = "headson"
|
|
172
|
-
version = "0.
|
|
172
|
+
version = "0.6.1"
|
|
173
173
|
dependencies = [
|
|
174
174
|
"anyhow",
|
|
175
175
|
"clap",
|
|
@@ -182,7 +182,7 @@ dependencies = [
|
|
|
182
182
|
|
|
183
183
|
[[package]]
|
|
184
184
|
name = "headson-python"
|
|
185
|
-
version = "0.
|
|
185
|
+
version = "0.6.1"
|
|
186
186
|
dependencies = [
|
|
187
187
|
"anyhow",
|
|
188
188
|
"headson",
|
|
@@ -2,7 +2,7 @@ use anyhow::{bail, Result};
|
|
|
2
2
|
use pyo3::exceptions::PyRuntimeError;
|
|
3
3
|
use pyo3::prelude::*;
|
|
4
4
|
use pyo3::types::PyModule;
|
|
5
|
-
use headson_core::{ArraySamplerStrategy, OutputTemplate, PriorityConfig, RenderConfig};
|
|
5
|
+
use headson_core::{ArraySamplerStrategy, ColorMode, OutputTemplate, PriorityConfig, RenderConfig};
|
|
6
6
|
|
|
7
7
|
fn to_template(s: &str) -> Result<OutputTemplate> {
|
|
8
8
|
match s.to_ascii_lowercase().as_str() {
|
|
@@ -22,7 +22,7 @@ fn render_config_with_sampler(
|
|
|
22
22
|
let newline = "\n".to_string();
|
|
23
23
|
let indent_unit = " ".to_string();
|
|
24
24
|
let prefer_tail_arrays = matches!(sampler, ArraySamplerStrategy::Tail);
|
|
25
|
-
Ok(RenderConfig { template: t, indent_unit, space, newline, prefer_tail_arrays })
|
|
25
|
+
Ok(RenderConfig { template: t, indent_unit, space, newline, prefer_tail_arrays, color_mode: ColorMode::Auto, color_enabled: false })
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
fn parse_skew(skew: &str) -> Result<ArraySamplerStrategy> {
|
|
@@ -21,7 +21,6 @@ struct SampleAccumulator<'a> {
|
|
|
21
21
|
indices: &'a mut Vec<usize>,
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
#[inline]
|
|
25
24
|
fn mix64(mut x: u64) -> u64 {
|
|
26
25
|
x ^= x >> 30;
|
|
27
26
|
x = x.wrapping_mul(0xbf58_476d_1ce4_e5b9);
|
|
@@ -30,7 +29,6 @@ fn mix64(mut x: u64) -> u64 {
|
|
|
30
29
|
x ^ (x >> 31)
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
#[inline]
|
|
34
32
|
fn accept_index(i: u64) -> bool {
|
|
35
33
|
let h = mix64(i ^ RANDOM_ACCEPT_SEED);
|
|
36
34
|
((h >> 32) as u32) < RANDOM_ACCEPT_THRESHOLD
|
|
@@ -25,7 +25,8 @@ pub use order::{
|
|
|
25
25
|
NodeId, NodeKind, PriorityConfig, PriorityOrder, RankedNode, build_order,
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
pub use serialization::
|
|
28
|
+
pub use serialization::color::resolve_color_enabled;
|
|
29
|
+
pub use serialization::types::{ColorMode, OutputTemplate, RenderConfig};
|
|
29
30
|
|
|
30
31
|
pub fn headson(
|
|
31
32
|
input: Vec<u8>,
|
|
@@ -76,7 +77,11 @@ fn find_largest_render_under_budget(
|
|
|
76
77
|
let mut inclusion_flags: Vec<u32> = vec![0; total];
|
|
77
78
|
// Each render attempt bumps this non-zero identifier to create a fresh inclusion set.
|
|
78
79
|
let mut render_set_id: u32 = 1;
|
|
79
|
-
|
|
80
|
+
// Measure length without color so ANSI escapes do not count toward the
|
|
81
|
+
// character budget. Then render once more with the requested color setting.
|
|
82
|
+
let mut best_k: Option<usize> = None;
|
|
83
|
+
let mut measure_cfg = config.clone();
|
|
84
|
+
measure_cfg.color_enabled = false;
|
|
80
85
|
|
|
81
86
|
let _ = crate::utils::search::binary_search_max(lo, hi, |mid| {
|
|
82
87
|
let s = crate::serialization::render_top_k(
|
|
@@ -84,19 +89,26 @@ fn find_largest_render_under_budget(
|
|
|
84
89
|
mid,
|
|
85
90
|
&mut inclusion_flags,
|
|
86
91
|
render_set_id,
|
|
87
|
-
|
|
92
|
+
&measure_cfg,
|
|
88
93
|
);
|
|
89
94
|
render_set_id = render_set_id.wrapping_add(1).max(1);
|
|
90
95
|
if s.len() <= char_budget {
|
|
91
|
-
|
|
96
|
+
best_k = Some(mid);
|
|
92
97
|
true
|
|
93
98
|
} else {
|
|
94
99
|
false
|
|
95
100
|
}
|
|
96
101
|
});
|
|
97
102
|
|
|
98
|
-
if let Some(
|
|
99
|
-
|
|
103
|
+
if let Some(k) = best_k {
|
|
104
|
+
// Final render with original color settings
|
|
105
|
+
crate::serialization::render_top_k(
|
|
106
|
+
order_build,
|
|
107
|
+
k,
|
|
108
|
+
&mut inclusion_flags,
|
|
109
|
+
render_set_id,
|
|
110
|
+
config,
|
|
111
|
+
)
|
|
100
112
|
} else {
|
|
101
113
|
// Fallback: always render a single node (k=1) to produce the
|
|
102
114
|
// shortest possible preview, even if it exceeds the byte budget.
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
use std::fs::File;
|
|
2
|
+
use std::io::IsTerminal as _;
|
|
2
3
|
use std::io::{self, Read};
|
|
3
4
|
use std::path::{Path, PathBuf};
|
|
4
5
|
|
|
5
6
|
use anyhow::{Context, Result};
|
|
6
|
-
use clap::{Parser, ValueEnum};
|
|
7
|
+
use clap::{ArgAction, Parser, ValueEnum};
|
|
7
8
|
use content_inspector::{ContentType, inspect};
|
|
8
9
|
|
|
9
10
|
type InputEntry = (String, Vec<u8>);
|
|
@@ -65,6 +66,20 @@ struct Cli {
|
|
|
65
66
|
help = "Prefer the beginning of arrays when truncating (keep first N)."
|
|
66
67
|
)]
|
|
67
68
|
head: bool,
|
|
69
|
+
#[arg(
|
|
70
|
+
long = "color",
|
|
71
|
+
action = ArgAction::SetTrue,
|
|
72
|
+
conflicts_with = "no_color",
|
|
73
|
+
help = "Force enable ANSI colors in output"
|
|
74
|
+
)]
|
|
75
|
+
color: bool,
|
|
76
|
+
#[arg(
|
|
77
|
+
long = "no-color",
|
|
78
|
+
action = ArgAction::SetTrue,
|
|
79
|
+
conflicts_with = "color",
|
|
80
|
+
help = "Disable ANSI colors in output"
|
|
81
|
+
)]
|
|
82
|
+
no_color: bool,
|
|
68
83
|
#[arg(
|
|
69
84
|
value_name = "INPUT",
|
|
70
85
|
value_hint = clap::ValueHint::FilePath,
|
|
@@ -85,6 +100,9 @@ fn main() -> Result<()> {
|
|
|
85
100
|
let cli = Cli::parse();
|
|
86
101
|
|
|
87
102
|
let render_cfg = get_render_config_from(&cli);
|
|
103
|
+
// Resolve color auto-detection now (stdout is the surface for user output).
|
|
104
|
+
let _color_enabled =
|
|
105
|
+
render_cfg.color_mode.effective(io::stdout().is_terminal());
|
|
88
106
|
let (output, ignore_notices) = if cli.inputs.is_empty() {
|
|
89
107
|
(run_from_stdin(&cli, &render_cfg)?, Vec::new())
|
|
90
108
|
} else {
|
|
@@ -222,11 +240,24 @@ fn ingest_paths(paths: &[PathBuf]) -> Result<(InputEntries, IgnoreNotices)> {
|
|
|
222
240
|
}
|
|
223
241
|
|
|
224
242
|
fn get_render_config_from(cli: &Cli) -> headson::RenderConfig {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
243
|
+
fn to_output_template(t: Template) -> headson::OutputTemplate {
|
|
244
|
+
match t {
|
|
245
|
+
Template::Json => headson::OutputTemplate::Json,
|
|
246
|
+
Template::Pseudo => headson::OutputTemplate::Pseudo,
|
|
247
|
+
Template::Js => headson::OutputTemplate::Js,
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
fn color_mode_from_flags(cli: &Cli) -> headson::ColorMode {
|
|
251
|
+
if cli.color {
|
|
252
|
+
headson::ColorMode::On
|
|
253
|
+
} else if cli.no_color {
|
|
254
|
+
headson::ColorMode::Off
|
|
255
|
+
} else {
|
|
256
|
+
headson::ColorMode::Auto
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
let template = to_output_template(cli.template);
|
|
230
261
|
let space = if cli.compact || cli.no_space { "" } else { " " }.to_string();
|
|
231
262
|
let newline = if cli.compact || cli.no_newline {
|
|
232
263
|
""
|
|
@@ -239,6 +270,8 @@ fn get_render_config_from(cli: &Cli) -> headson::RenderConfig {
|
|
|
239
270
|
} else {
|
|
240
271
|
cli.indent.clone()
|
|
241
272
|
};
|
|
273
|
+
let color_mode = color_mode_from_flags(cli);
|
|
274
|
+
let color_enabled = headson::resolve_color_enabled(color_mode);
|
|
242
275
|
|
|
243
276
|
headson::RenderConfig {
|
|
244
277
|
template,
|
|
@@ -246,6 +279,8 @@ fn get_render_config_from(cli: &Cli) -> headson::RenderConfig {
|
|
|
246
279
|
space,
|
|
247
280
|
newline,
|
|
248
281
|
prefer_tail_arrays: cli.tail,
|
|
282
|
+
color_mode,
|
|
283
|
+
color_enabled,
|
|
249
284
|
}
|
|
250
285
|
}
|
|
251
286
|
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
use std::io::IsTerminal as _;
|
|
2
|
+
|
|
3
|
+
use crate::serialization::types::ColorMode;
|
|
4
|
+
|
|
5
|
+
// ANSI SGR fragments
|
|
6
|
+
const RESET: &str = "\u{001b}[0m";
|
|
7
|
+
const BOLD_BLUE: &str = "\u{001b}[1;34m";
|
|
8
|
+
const GREEN: &str = "\u{001b}[32m";
|
|
9
|
+
const CYAN: &str = "\u{001b}[36m";
|
|
10
|
+
const BRIGHT_GRAY: &str = "\u{001b}[37m";
|
|
11
|
+
const DARK_GRAY: &str = "\u{001b}[90m";
|
|
12
|
+
|
|
13
|
+
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
|
14
|
+
pub enum ColorRole {
|
|
15
|
+
Key,
|
|
16
|
+
String,
|
|
17
|
+
Number,
|
|
18
|
+
Bool,
|
|
19
|
+
Null,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
pub fn wrap_role<S: Into<String>>(
|
|
23
|
+
s: S,
|
|
24
|
+
role: ColorRole,
|
|
25
|
+
enabled: bool,
|
|
26
|
+
) -> String {
|
|
27
|
+
let s: String = s.into();
|
|
28
|
+
if !enabled {
|
|
29
|
+
return s;
|
|
30
|
+
}
|
|
31
|
+
let prefix = match role {
|
|
32
|
+
ColorRole::Key => BOLD_BLUE,
|
|
33
|
+
ColorRole::String => GREEN,
|
|
34
|
+
ColorRole::Number => CYAN,
|
|
35
|
+
ColorRole::Bool | ColorRole::Null => BRIGHT_GRAY,
|
|
36
|
+
};
|
|
37
|
+
let mut out = String::with_capacity(8 + 8 + s.len());
|
|
38
|
+
out.push_str(prefix);
|
|
39
|
+
out.push_str(&s);
|
|
40
|
+
out.push_str(RESET);
|
|
41
|
+
out
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
pub fn omission_marker(enabled: bool) -> &'static str {
|
|
45
|
+
if enabled {
|
|
46
|
+
"\u{001b}[90m…\u{001b}[0m"
|
|
47
|
+
} else {
|
|
48
|
+
"…"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
pub fn color_comment<S: Into<String>>(body: S, enabled: bool) -> String {
|
|
53
|
+
if !enabled {
|
|
54
|
+
return body.into();
|
|
55
|
+
}
|
|
56
|
+
let b = body.into();
|
|
57
|
+
let mut out = String::with_capacity(b.len() + 8 + 4);
|
|
58
|
+
out.push_str(DARK_GRAY);
|
|
59
|
+
out.push_str(&b);
|
|
60
|
+
out.push_str(RESET);
|
|
61
|
+
out
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
fn env_bool(var: &str) -> Option<bool> {
|
|
65
|
+
std::env::var_os(var).map(|v| {
|
|
66
|
+
let s = v.to_string_lossy();
|
|
67
|
+
!(s == "0" || s.is_empty())
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
struct ColorEnv {
|
|
72
|
+
force: bool, // CLICOLOR_FORCE=1
|
|
73
|
+
force_color: bool, // FORCE_COLOR=1
|
|
74
|
+
no_color: bool, // NO_COLOR present
|
|
75
|
+
dumb: bool, // TERM=dumb
|
|
76
|
+
clicolor: Option<bool>, // CLICOLOR=0/1
|
|
77
|
+
is_tty: bool,
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
fn read_color_env() -> ColorEnv {
|
|
81
|
+
let term_dumb = std::env::var_os("TERM")
|
|
82
|
+
.map(|t| t.to_string_lossy() == "dumb")
|
|
83
|
+
.unwrap_or(false);
|
|
84
|
+
ColorEnv {
|
|
85
|
+
force: matches!(env_bool("CLICOLOR_FORCE"), Some(true)),
|
|
86
|
+
force_color: matches!(env_bool("FORCE_COLOR"), Some(true)),
|
|
87
|
+
no_color: std::env::var_os("NO_COLOR").is_some(),
|
|
88
|
+
dumb: term_dumb,
|
|
89
|
+
clicolor: env_bool("CLICOLOR"),
|
|
90
|
+
is_tty: std::io::stdout().is_terminal(),
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
fn auto_color_enabled(env: &ColorEnv) -> bool {
|
|
95
|
+
if env.force || env.force_color {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
if env.no_color || env.dumb {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
if let Some(b) = env.clicolor {
|
|
102
|
+
return b && env.is_tty;
|
|
103
|
+
}
|
|
104
|
+
env.is_tty
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
pub fn resolve_color_enabled(mode: ColorMode) -> bool {
|
|
108
|
+
match mode {
|
|
109
|
+
ColorMode::On => true,
|
|
110
|
+
ColorMode::Off => false,
|
|
111
|
+
ColorMode::Auto => auto_color_enabled(&read_color_env()),
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -17,7 +17,7 @@ impl<'a> RenderScope<'a> {
|
|
|
17
17
|
out.push_str("// ");
|
|
18
18
|
out.push_str(raw_key);
|
|
19
19
|
out.push_str(nl);
|
|
20
|
-
let rendered = self.
|
|
20
|
+
let rendered = self.render_node_to_string(child_pq_id, depth, false);
|
|
21
21
|
out.push_str(&rendered);
|
|
22
22
|
out.push(';');
|
|
23
23
|
out.push_str(nl);
|
|
@@ -58,7 +58,7 @@ impl<'a> RenderScope<'a> {
|
|
|
58
58
|
out.push_str(raw_key);
|
|
59
59
|
out.push_str(" <==");
|
|
60
60
|
out.push_str(nl);
|
|
61
|
-
let rendered = self.
|
|
61
|
+
let rendered = self.render_node_to_string(child_pq_id, depth, false);
|
|
62
62
|
out.push_str(&rendered);
|
|
63
63
|
}
|
|
64
64
|
|