refactor(webui): unify code and diff highlighting (#6412)
* refactor(webui): unify code and diff highlighting Replace Prism with shared Highlights tokens and Pierre read-only diffs, retaining rare grammars through lazy Shiki and preserving source, copy, preview and diff controls. Restore single-session Composer ownership inside the conversation column while retaining the shared multi-pane footer. Keep the measured large-diff scroll regression explicit during review. * fix(webui): contain highlighting errors and retain diff selections Refs NAN-343 * test(webui): align pane fixtures after main rebase * chore(webui): update highlighting dependencies Keep grammar fallback coverage on a language that still requires Shiki, and align reading-size assertions with main.
This commit is contained in:
1 parent
f5c359476b
commit
3a37269f3f
44 files changed
+2257
-1068
No files matched your search
@@ -239,3 +239,616 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Pierre Diffs and Highlights — code highlighting and read-only diffs (Apache-2.0 and MIT dependencies)
|
||||
|
||||
- **Source**: https://github.com/pierrecomputer/pierre
|
||||
- **Components**: `@pierre/diffs` 1.6.4, `@pierre/highlights` 0.4.0, `@pierre/theme` 2.0.0, and `@pierre/theming` 1.0.2; Shiki 4.6.0 and the dependencies identified below.
|
||||
- **Bundled**: `nanobot/web/dist/assets/*.{js,wasm}`
|
||||
|
||||
The following license texts and upstream notices are retained from the distributed packages.
|
||||
|
||||
### `@pierre/diffs 1.6.4`, `@pierre/highlights 0.4.0`, `@pierre/theme 2.0.0`, `@pierre/theming 1.0.2`
|
||||
|
||||
```text
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and
|
||||
distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the
|
||||
copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other
|
||||
entities that control, are controlled by, or are under common control with
|
||||
that entity. For the purposes of this definition, "control" means (i) the
|
||||
power, direct or indirect, to cause the direction or management of such
|
||||
entity, whether by contract or otherwise, or (ii) ownership of fifty percent
|
||||
(50%) or more of the outstanding shares, or (iii) beneficial ownership of
|
||||
such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
||||
permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation source, and
|
||||
configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation
|
||||
or translation of a Source form, including but not limited to compiled
|
||||
object code, generated documentation, and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form,
|
||||
made available under the License, as indicated by a copyright notice that is
|
||||
included in or attached to the work (an example is provided in the Appendix
|
||||
below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form,
|
||||
that is based on (or derived from) the Work and for which the editorial
|
||||
revisions, annotations, elaborations, or other modifications represent, as a
|
||||
whole, an original work of authorship. For the purposes of this License,
|
||||
Derivative Works shall not include works that remain separable from, or
|
||||
merely link (or bind by name) to the interfaces of, the Work and Derivative
|
||||
Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original
|
||||
version of the Work and any modifications or additions to that Work or
|
||||
Derivative Works thereof, that is intentionally submitted to Licensor for
|
||||
inclusion in the Work by the copyright owner or by an individual or Legal
|
||||
Entity authorized to submit on behalf of the copyright owner. For the
|
||||
purposes of this definition, "submitted" means any form of electronic,
|
||||
verbal, or written communication sent to the Licensor or its
|
||||
representatives, including but not limited to communication on electronic
|
||||
mailing lists, source code control systems, and issue tracking systems that
|
||||
are managed by, or on behalf of, the Licensor for the purpose of discussing
|
||||
and improving the Work, but excluding communication that is conspicuously
|
||||
marked or otherwise designated in writing by the copyright owner as "Not a
|
||||
Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on
|
||||
behalf of whom a Contribution has been received by Licensor and subsequently
|
||||
incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this
|
||||
License, each Contributor hereby grants to You a perpetual, worldwide,
|
||||
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
||||
reproduce, prepare Derivative Works of, publicly display, publicly perform,
|
||||
sublicense, and distribute the Work and such Derivative Works in Source or
|
||||
Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this
|
||||
License, each Contributor hereby grants to You a perpetual, worldwide,
|
||||
non-exclusive, no-charge, royalty-free, irrevocable (except as stated in
|
||||
this section) patent license to make, have made, use, offer to sell, sell,
|
||||
import, and otherwise transfer the Work, where such license applies only to
|
||||
those patent claims licensable by such Contributor that are necessarily
|
||||
infringed by their Contribution(s) alone or by combination of their
|
||||
Contribution(s) with the Work to which such Contribution(s) was submitted.
|
||||
If You institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
||||
Contribution incorporated within the Work constitutes direct or contributory
|
||||
patent infringement, then any patent licenses granted to You under this
|
||||
License for that Work shall terminate as of the date such litigation is
|
||||
filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or
|
||||
Derivative Works thereof in any medium, with or without modifications, and
|
||||
in Source or Object form, provided that You meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or Derivative Works a
|
||||
copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices stating
|
||||
that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works that You
|
||||
distribute, all copyright, patent, trademark, and attribution notices from
|
||||
the Source form of the Work, excluding those notices that do not pertain to
|
||||
any part of the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its distribution,
|
||||
then any Derivative Works that You distribute must include a readable copy
|
||||
of the attribution notices contained within such NOTICE file, excluding
|
||||
those notices that do not pertain to any part of the Derivative Works, in at
|
||||
least one of the following places: within a NOTICE text file distributed as
|
||||
part of the Derivative Works; within the Source form or documentation, if
|
||||
provided along with the Derivative Works; or, within a display generated by
|
||||
the Derivative Works, if and wherever such third-party notices normally
|
||||
appear. The contents of the NOTICE file are for informational purposes only
|
||||
and do not modify the License. You may add Your own attribution notices
|
||||
within Derivative Works that You distribute, alongside or as an addendum to
|
||||
the NOTICE text from the Work, provided that such additional attribution
|
||||
notices cannot be construed as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and may
|
||||
provide additional or different license terms and conditions for use,
|
||||
reproduction, or distribution of Your modifications, or for any such
|
||||
Derivative Works as a whole, provided Your use, reproduction, and
|
||||
distribution of the Work otherwise complies with the conditions stated in
|
||||
this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
||||
Contribution intentionally submitted for inclusion in the Work by You to the
|
||||
Licensor shall be under the terms and conditions of this License, without
|
||||
any additional terms or conditions. Notwithstanding the above, nothing
|
||||
herein shall supersede or modify the terms of any separate license agreement
|
||||
you may have executed with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade names,
|
||||
trademarks, service marks, or product names of the Licensor, except as
|
||||
required for reasonable and customary use in describing the origin of the
|
||||
Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
|
||||
writing, Licensor provides the Work (and each Contributor provides its
|
||||
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied, including, without limitation, any
|
||||
warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining
|
||||
the appropriateness of using or redistributing the Work and assume any risks
|
||||
associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether in
|
||||
tort (including negligence), contract, or otherwise, unless required by
|
||||
applicable law (such as deliberate and grossly negligent acts) or agreed to
|
||||
in writing, shall any Contributor be liable to You for damages, including
|
||||
any direct, indirect, special, incidental, or consequential damages of any
|
||||
character arising as a result of this License or out of the use or inability
|
||||
to use the Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all other
|
||||
commercial damages or losses), even if such Contributor has been advised of
|
||||
the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or
|
||||
Derivative Works thereof, You may choose to offer, and charge a fee for,
|
||||
acceptance of support, warranty, indemnity, or other liability obligations
|
||||
and/or rights consistent with this License. However, in accepting such
|
||||
obligations, You may act only on Your own behalf and on Your sole
|
||||
responsibility, not on behalf of any other Contributor, and only if You
|
||||
agree to indemnify, defend, and hold each Contributor harmless for any
|
||||
liability incurred by, or claims asserted against, such Contributor by
|
||||
reason of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2025 Pierre Computer Company
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software distributed
|
||||
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations under the License.
|
||||
```
|
||||
|
||||
### `@shikijs/core 4.6.0`, `@shikijs/engine-javascript 4.6.0`, `@shikijs/engine-oniguruma 4.6.0`, `@shikijs/langs 4.6.0`, `@shikijs/primitive 4.6.0`, `@shikijs/themes 4.6.0`, `@shikijs/types 4.6.0`, `shiki 4.6.0`
|
||||
|
||||
```text
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Pine Wu
|
||||
Copyright (c) 2023 Anthony Fu <https://github.com/antfu>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
### `@shikijs/vscode-textmate 10.1.0`
|
||||
|
||||
```text
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Microsoft Corporation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
### `hast-util-to-html 9.0.5` and `9.0.6`
|
||||
|
||||
```text
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) Titus Wormer <tituswormer@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
```
|
||||
|
||||
### `lru_map 0.4.1`
|
||||
|
||||
```text
|
||||
MIT license
|
||||
|
||||
Copyright (c) 2010-2016 Rasmus Andersson <https://rsms.me/>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
```
|
||||
|
||||
### `oniguruma-parser 0.12.2`
|
||||
|
||||
```text
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025-2026 Steven Levithan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
### `oniguruma-to-es 4.3.6`
|
||||
|
||||
```text
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024-2026 Steven Levithan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
### `regex 6.1.0`, `regex-recursion 6.0.2`
|
||||
|
||||
```text
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 Steven Levithan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
### `regex-utilities 2.3.0`
|
||||
|
||||
```text
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Steven Levithan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
### Upstream NOTICE: `@pierre/highlights`
|
||||
|
||||
````text
|
||||
# Bundled theme licenses
|
||||
|
||||
Community themes are pruned copies of pinned Zed theme files or conversions of
|
||||
the pinned Shiki TextMate files listed below. Theme names and appearances are
|
||||
normalized to Shiki's catalog.
|
||||
|
||||
## Sources
|
||||
|
||||
Terminal palettes use the same pinned sources as the themes below. Exceptions:
|
||||
|
||||
- Horizon's original repository is unavailable. Its palette comes from the
|
||||
[Zed Horizon 0.0.1 archive](https://api.zed.dev/extensions/horizon/0.0.1/download).
|
||||
- Andromeeda's two null black entries and both Horizon themes' four null black
|
||||
and white entries use their inherited
|
||||
[Zed defaults at `ce48461`](https://github.com/zed-industries/zed/blob/ce48461eaadd16c65c31f835511ab96bd3b6e746/crates/theme/src/default_colors.rs).
|
||||
- LaserWave leaves ten terminal colors undefined; Slack Dark leaves all 16
|
||||
undefined. These entries use the dark palette in
|
||||
[VS Code at `3623f17`](https://github.com/microsoft/vscode/blob/3623f170559712f7ee16f59dfbd87c885b6a2b31/src/vs/workbench/contrib/terminal/common/terminalColorRegistry.ts).
|
||||
- Pierre's palettes come from
|
||||
[its Zed theme](https://github.com/pierrecomputer/pierre/blob/861ce3c61e1cfeaf283d83e95a3767479e75bfee/packages/theme/zed/themes/pierre.json).
|
||||
The vibrant variants preserve the Display P3 values in
|
||||
[Pierre Dark Vibrant](https://github.com/pierrecomputer/pierre/blob/861ce3c61e1cfeaf283d83e95a3767479e75bfee/packages/theme/themes/pierre-dark-vibrant.json)
|
||||
and
|
||||
[Pierre Light Vibrant](https://github.com/pierrecomputer/pierre/blob/861ce3c61e1cfeaf283d83e95a3767479e75bfee/packages/theme/themes/pierre-light-vibrant.json).
|
||||
|
||||
Dracula's `ffffffff` bright white value is normalized to `#ffffffff`.
|
||||
|
||||
The Zed version is the extension version published in the
|
||||
[Zed registry](https://github.com/zed-industries/extensions) at
|
||||
`ab756766c27fca3de3d275149f6937105f464dec`. "Built in" means the theme ships
|
||||
with Zed itself. GitHub-only sources have no marketplace version.
|
||||
|
||||
| Highlights themes | Pinned source | Zed version |
|
||||
| -------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
|
||||
| `andromeeda` | [ChocolateNao/andromeda-zed `23f6768`](https://github.com/ChocolateNao/andromeda-zed/blob/23f67684252059f46b508ae71964ad6085df552a/themes/andromeda.json) | `andromeda` 0.1.2 |
|
||||
| `aurora-x` | [iamrajjoshi/aurora `83477d4`](https://github.com/iamrajjoshi/aurora/blob/83477d4b4abc4aeca9465d9b1b56409e2cd6da97/themes/aurora.json) | `aurora-theme` 0.0.1 |
|
||||
| `ayu-dark`, `ayu-light`, `ayu-mirage` | [Zed Ayu `ce48461`](https://github.com/zed-industries/zed/blob/ce48461eaadd16c65c31f835511ab96bd3b6e746/assets/themes/ayu/ayu.json) | Built in |
|
||||
| `catppuccin-*` | [catppuccin/zed `b54cb81`](https://github.com/catppuccin/zed/blob/b54cb81708d06912d50e6bb9fd2fd2103b9dda25/themes/catppuccin-mauve.json) | `catppuccin` 0.2.25 |
|
||||
| `dark-plus`, `light-plus`, `monokai`, `red`, `solarized-*` | [alanisme/vscode-themes-for-zed `ea65e4d`](https://github.com/alanisme/vscode-themes-for-zed/tree/ea65e4df055035888b6bd0b0c68c6986c3ce4699/themes) | `vscode-classic-themes` 0.4.1 |
|
||||
| `dracula` | [dracula/zed `92f4605`](https://github.com/dracula/zed/blob/92f46057151693648bd3acac1e0c138696f34433/themes/dracula.json) | `dracula` 1.1.2 |
|
||||
| `everforest-dark`, `everforest-light` | [albertsko/zed-everforest `1f1c84e`](https://github.com/albertsko/zed-everforest/blob/1f1c84e081f6dcaaac7105812032086608ca7a44/themes/everforest-regular.json) | `everforest` 0.2.0 |
|
||||
| `github-dark`, `github-light` | [meocoder31099/Github-Classic-Theme-Zed `751146a`](https://github.com/meocoder31099/Github-Classic-Theme-Zed/blob/751146a4387066dd4e2fb7ee4ff91ab089d7c7dd/themes/github-classic.json) | `github-classic` 0.0.3 |
|
||||
| `github-dark-default` | [MordFustang21/zed-github-dark `dbbd661`](https://github.com/MordFustang21/zed-github-dark/blob/dbbd66167753686ff3ff627208e15f7e27a9b1f9/themes/dark-default.json) | `github-dark-default` 1.0.10 |
|
||||
| `github-dark-dimmed`, `github-light-default`, and both `github-*-high-contrast` themes | [PyaeSoneAungRgn/github-zed-theme `89ae5f9`](https://github.com/PyaeSoneAungRgn/github-zed-theme/blob/89ae5f92ca0bc5b96b721b69e41db83aa482cfd6/themes/github_theme.json) | `github-theme` 0.1.8 |
|
||||
| `gruvbox-*` | [Zed Gruvbox `ce48461`](https://github.com/zed-industries/zed/blob/ce48461eaadd16c65c31f835511ab96bd3b6e746/assets/themes/gruvbox/gruvbox.json) | Built in |
|
||||
| `horizon`, `horizon-bright` | [ayn2op/zed-horizon `b3cf502`](https://github.com/ayn2op/zed-horizon/blob/b3cf5022a583455f2e815c4c58996ce6dc3082f5/themes/horizon.json) | `horizon` 0.0.1 |
|
||||
| `houston` | [rudolfjs/houston-zed `2830d5c`](https://github.com/rudolfjs/houston-zed/blob/2830d5c55d80b2c2bce44b184f2370f814509f1f/themes/houston.json) | GitHub only; manifest 0.2.0 |
|
||||
| `kanagawa-*` | [ethangilmore/zed-kanagawa `45b4295`](https://github.com/ethangilmore/zed-kanagawa/blob/45b4295e708a5720d75514013a20a00917d50cc5/themes/Kanagawa.json) | `kanagawa-themes` 0.1.2 |
|
||||
| `material-theme*` | [Codextor/zed-material-theme `e4145b6`](https://github.com/Codextor/zed-material-theme/blob/e4145b69351b773ba8c9c8b0c44e7d89faacbfee/themes/material-theme.json) | `material-theme` 0.0.1 |
|
||||
| `min-dark`, `min-light` | [phibr0/zed-min-theme `0efe9ac`](https://github.com/phibr0/zed-min-theme/blob/0efe9ac439bd27ceb19d6506ed4986d9f348e216/themes/min-theme.json) | `min-theme` 0.2.2 |
|
||||
| `night-owl`, `night-owl-light` | [elGusto/night-owlz `29b5fed`](https://github.com/elGusto/night-owlz/blob/29b5fedfee923b2598d97520962215d26d51d67d/themes/NightOwl.json) | `night-owlz` 0.0.5 |
|
||||
| `nord` | [mikasius/zed-nord-theme `d0b459c`](https://github.com/mikasius/zed-nord-theme/blob/d0b459c49797aec598622bed992537e4a83688da/themes/nord.json) | `nord` 0.1.7 |
|
||||
| `one-dark-pro` | [hadez8877/one-dark-pro-enhanced `0411a00`](https://github.com/hadez8877/one-dark-pro-enhanced/blob/0411a00f702b609746a29c49e2796d6993e9f461/themes/oneDark-Pro.json) | `one-dark-pro-enhanced` 0.0.12 |
|
||||
| `one-light` | [Stelath/zed-atom-one-theme `ed0513f`](https://github.com/Stelath/zed-atom-one-theme/blob/ed0513f0655ec72ffcfd33e87e31fb0a06c28948/themes/one-light.json) | `atom-one-theme` 0.1.0 |
|
||||
| `plastic` | [ibnuh/zed-plastic-theme `98c34dc`](https://github.com/ibnuh/zed-plastic-theme/blob/98c34dc4b59c65d64a9410aa25e4f66be0918cf8/themes/plastic.json) | `plastic-theme` 1.0.0 |
|
||||
| `rose-pine*` | [rose-pine/zed `2c7b4ee`](https://github.com/rose-pine/zed/tree/2c7b4ee61c78334f8f1e9960d1d9e44d447ee9ef/themes) | `rose-pine-theme` 1.5.0 |
|
||||
| `snazzy-light` | [seyhajin/zed-snazzy-light `1d54608`](https://github.com/seyhajin/zed-snazzy-light/blob/1d54608af795053e47d4151612c56b49aff6ed9b/themes/snazzy-light.json) | `snazzy-light` 0.1.0 |
|
||||
| `synthwave-84` | [hydepwns/synthwave84-zed `332a002`](https://github.com/hydepwns/synthwave84-zed/blob/332a002eb64bece661585607fd59d3f9b4250acf/themes/synthwave84.json) | `synthwave84` 0.2.0 |
|
||||
| `tokyo-night` | [ssaunderss/zed-tokyo-night `6d731d0`](https://github.com/ssaunderss/zed-tokyo-night/blob/6d731d0724a6fa487f9031cbb4f8db0b80769568/themes/tokyo-night.json) | `tokyo-night` 0.8.0 |
|
||||
| `vesper` | [bdsqqq/vesper-zed `4ae700c`](https://github.com/bdsqqq/vesper-zed/blob/4ae700c4a2a279c722bdd6c63409a701b4a3236e/themes/vesper-dark.json) | `vesper` 0.0.2 |
|
||||
| `vitesse-black`, `vitesse-dark`, `vitesse-light` | [colinlienard/zed-vitesse-theme-refined `a2b193e`](https://github.com/colinlienard/zed-vitesse-theme-refined/blob/a2b193ec9e5d36a05de4385b127c94597b025b46/themes/vitesse-theme-refined.json) | `vitesse-theme-refined` 0.5.0 |
|
||||
|
||||
No suitable licensed Zed port was available for `dracula-soft`, `laserwave`,
|
||||
`poimandres`, `slack-dark`, or `slack-ochin`. Those files use the corresponding
|
||||
sources from
|
||||
[`tm-themes@1.12.10`](https://github.com/shikijs/textmate-grammars-themes/blob/950dad95387e73a8b2ae36aed2ef19b8a4419f10/packages/tm-themes/index.js),
|
||||
converted with
|
||||
[Zed's scope mapping](https://github.com/zed-industries/zed/blob/ce48461eaadd16c65c31f835511ab96bd3b6e746/crates/theme_importer/src/vscode/syntax.rs).
|
||||
|
||||
Missing syntax captures in the other community ports are supplemented from their
|
||||
corresponding TextMate themes at the same `tm-themes@1.12.10` pin. Existing Zed
|
||||
palette choices are retained. Pierre and the Aurora substitute use colors from
|
||||
their own palettes for missing captures.
|
||||
|
||||
The Zed registry's `aurora-theme` is an MIT-licensed substitute, not an Aurora X
|
||||
port. The original Aurora X source is GPL-3.0-only; bundling it would require
|
||||
GPL-3.0 distribution terms, contrary to this package's Apache-2.0-only policy.
|
||||
|
||||
## MIT themes
|
||||
|
||||
Copyright notices retained from the sources:
|
||||
|
||||
- Andromeda: Copyright (c) 2017 <eliverlara@gmail.com>; Zed port Copyright (c)
|
||||
2025 Andrey L.
|
||||
- Aurora: Copyright (c) 2026 Raj Joshi
|
||||
- Ayu: Copyright (c) 2016 Ike Ku
|
||||
- Catppuccin: Copyright (c) 2021 Catppuccin
|
||||
- Dracula: Copyright (c) 2016 Dracula Theme; Zed port Copyright (c) 2023 Dracula
|
||||
Theme
|
||||
- Everforest: Copyright (c) 2020 sainnhe; Zed port Copyright (c) 2025 Albert
|
||||
Skonieczny
|
||||
- GitHub Classic: Copyright (c) 2020 Primer; Zed port Copyright (c) 2021
|
||||
Catppuccin
|
||||
- GitHub Theme: Copyright (c) 2020 Primer; Zed port Copyright (c) 2025 Pyae Sone
|
||||
Aung
|
||||
- Gruvbox: the original palette is by Pavel Pertsev. Zed's theme-local MIT
|
||||
license contains the unfilled line `Copyright (c) <YEAR> <COPYRIGHT HOLDER>`
|
||||
- Horizon: Copyright (c) 2018 Jonathan Olaleye; Zed port Copyright (c) 2024
|
||||
Ayyan
|
||||
- Houston: Copyright (c) 2022 The Astro Technology Company; Copyright (c) 2026
|
||||
github.com/rudolfjs
|
||||
- Kanagawa: Copyright (c) 2021 Tommaso Laurenzi; Zed port Copyright (c) 2024
|
||||
Ethan Gilmore
|
||||
- LaserWave: Copyright (c) 2019 Jared Jones
|
||||
- Min: Copyright (c) 2018-2021 Miguel Solorio; Zed port Copyright (c) 2024
|
||||
Phillip
|
||||
- Night Owl: Copyright (c) 2018 Sarah Drasner
|
||||
- Nord: Copyright (c) 2016-present Sven Greb <development@svengreb.de>
|
||||
(https://www.svengreb.de); Zed port Copyright (c) 2025 Sergei Metlenkin
|
||||
- One Dark Pro: Copyright (c) 2013-2022 Binaryify; Zed port Copyright (c) 2025
|
||||
/devs/hadez
|
||||
- One Light: Copyright (c) 2015 Mahmoud Ali; Zed port Copyright (c) 2026 Alex
|
||||
- Plastic: Copyright (c) 2017-present, Will Stone; Zed port Copyright (c) 2026
|
||||
Ibnuh
|
||||
- Poimandres: Copyright (c) 2023 drcmda
|
||||
- Rosé Pine: Copyright (c) Rosé Pine
|
||||
- Slack: Copyright (c) 2017 Felipe Mendes
|
||||
- Snazzy Light: Copyright (c) 2020 Florian Reuschel; Zed port Copyright (c) 2026
|
||||
Christophe TES
|
||||
- Synthwave84: Copyright (c) 2019 Robb Owen; Zed port Copyright (c) 2025 DROO
|
||||
- TextMate theme collection: Copyright (c) 2021 Pine Wu; Copyright (c) 2023
|
||||
Anthony Fu
|
||||
- Tokyo Night: Copyright (c) 2018-present Enkia; Zed port Copyright (c) 2024
|
||||
Austin Saunders
|
||||
- Vesper: Copyright (c) 2023 Rauno Freiberg; Zed port Copyright (c) 2024 Igor
|
||||
Bedesqui
|
||||
- Vitesse: Copyright (c) 2020 Primer; Copyright (c) 2021 Anthony Fu; Zed port
|
||||
Copyright (c) 2024 Colin Lienard
|
||||
- VS Code Classics: Copyright (c) 2015 - present Microsoft Corporation; Zed port
|
||||
Copyright (c) 2026 alanisme
|
||||
|
||||
```text
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
```
|
||||
|
||||
## Apache-2.0 themes
|
||||
|
||||
`github-dark-default` and the Material themes are Apache-2.0. The Material
|
||||
themes retain Copyright 2017 Mattia Astorino. `github-dark-default` also derives
|
||||
from the MIT-licensed GitHub/Primer theme credited above. Highlights extracts
|
||||
individual themes and prunes unused Zed style properties. The full Apache-2.0
|
||||
text is included in the package's [`LICENSE.md`](./LICENSE.md).
|
||||
````
|
||||
|
||||
### Upstream NOTICE: `@pierre/theme`
|
||||
|
||||
```text
|
||||
This theme was built on top of
|
||||
[GitHub's Visual Studio Code Theme](https://github.com/primer/github-vscode-theme),
|
||||
reusing its technique and build tooling, which we have since iterated on for
|
||||
more specific language tokens.
|
||||
|
||||
`@pierre/theme` is licensed under Apache-2.0 (see `LICENSE`). The original MIT
|
||||
license for `primer/github-vscode-theme` is included below for attribution.
|
||||
|
||||
Original license for `primer/github-vscode-theme`:
|
||||
|
||||
```
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Primer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
```
|
||||
```
|
||||
@@ -0,0 +1,35 @@
|
||||
import { useState } from "react";
|
||||
|
||||
import { CodeBlock } from "@/components/CodeBlock";
|
||||
import { MarkdownText } from "@/components/MarkdownText";
|
||||
import { ThemeProvider, useTheme } from "@/hooks/useTheme";
|
||||
|
||||
const preview = "<!--\n" + "preserve comment context 中文 😀\n".repeat(79) + "-->\n" + Array.from({ length: 520 }, (_, index) => `<p data-index="${index}">Line ${index} 😀 ${"wide-source ".repeat(12)}</p>`).join("\n");
|
||||
const source = 'export const result = <span className="badge">中文 😀</span>;\n';
|
||||
const markdown = `Before code.\n\n\`\`\`tsx\n${source}\`\`\`\n\nAfter code.`;
|
||||
|
||||
export function CodeHighlightingFixture() {
|
||||
const { theme, toggle } = useTheme();
|
||||
const [streaming, setStreaming] = useState(false);
|
||||
const [changed, setChanged] = useState(false);
|
||||
const [wrap, setWrap] = useState(false);
|
||||
const [showLarge, setShowLarge] = useState(false);
|
||||
return <ThemeProvider theme={theme}><main className="h-full overflow-auto p-4" data-testid="code-fixture-scroll">
|
||||
<button onClick={toggle}>Toggle theme</button>
|
||||
<button onClick={() => setStreaming(true)}>Start streaming</button>
|
||||
<button onClick={() => setStreaming(false)}>Finish streaming</button>
|
||||
<button onClick={() => setChanged(true)}>Change source</button>
|
||||
<button onClick={() => setWrap(value => !value)}>Toggle wrapping</button>
|
||||
<button onClick={() => setShowLarge(true)}>Show large code</button>
|
||||
{showLarge ? <section aria-label="Large code"><CodeBlock language="typescript" code={Array.from({ length: 1200 }, (_, index) => `const value${index} = ${index};`).join("\n")} showLineNumbers /></section> : null}
|
||||
<section aria-label="Markdown"><MarkdownText streaming={streaming}>{streaming ? markdown.slice(0, markdown.indexOf("中文")) : markdown}</MarkdownText></section>
|
||||
<section aria-label="TypeScript"><CodeBlock language="tsx" code={changed ? source.replace("result", "updated") : source} showLineNumbers /></section>
|
||||
<section aria-label="INI"><CodeBlock language="ini" code={"; comment\n[server]\nhost=localhost\n"} /></section>
|
||||
<section aria-label="HJSON"><CodeBlock language="hjson" code={"# comment\n{ host: localhost }\n"} /></section>
|
||||
<section aria-label="Unknown"><CodeBlock language="unknown-file-format" code={'<script>alert("not executable")</script>'} /></section>
|
||||
<section aria-label="ANSI"><CodeBlock language="ansi" code={'\x1b[32mPASS\x1b[0m <img src=x onerror="bad()">'} /></section>
|
||||
<section aria-label="File preview"><div data-file-preview-scroll className="code-content h-80 overflow-auto border">
|
||||
<CodeBlock language="html" code={preview} chrome="none" showLineNumbers wrapLongLines={wrap} viewportHighlight />
|
||||
</div></section>
|
||||
</main></ThemeProvider>;
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
const sourceText = (section: import("@playwright/test").Locator) => section.locator("[data-code-text], [data-highlighted]").allTextContents().then(lines => lines.join(""));
|
||||
|
||||
for (const dark of [false, true]) {
|
||||
for (const narrow of [false, true]) {
|
||||
test(`shared highlighting retains code and preview behavior: ${dark ? "dark" : "light"}, ${narrow ? "narrow" : "desktop"}`, async ({ page }) => {
|
||||
const errors: string[] = [];
|
||||
page.on("pageerror", error => errors.push(error.message));
|
||||
await page.setViewportSize({ width: narrow ? 390 : 1280, height: 900 });
|
||||
await page.addInitScript(theme => {
|
||||
localStorage.setItem("nanobot.locale", "en");
|
||||
localStorage.setItem("nanobot-webui.theme", theme);
|
||||
}, dark ? "dark" : "light");
|
||||
await page.goto("/browser/fixture.html?case=code-highlighting");
|
||||
const code = page.getByRole("region", { name: "TypeScript", exact: true });
|
||||
await expect(code.getByTestId("highlighted-code")).toBeVisible();
|
||||
const expected = 'export const result = <span className="badge">中文 😀</span>;\n';
|
||||
expect(await sourceText(code)).toBe(expected);
|
||||
for (const variable of ["keyword", "string", "property"]) {
|
||||
await expect.poll(async () => code.locator("[data-code-token]").evaluateAll((nodes, category) => {
|
||||
const probe = document.createElement("span");
|
||||
probe.style.color = `var(--code-${category})`;
|
||||
document.body.append(probe);
|
||||
const color = getComputedStyle(probe).color;
|
||||
probe.remove();
|
||||
return nodes.some(node => getComputedStyle(node).color === color);
|
||||
}, variable)).toBe(true);
|
||||
}
|
||||
const ini = page.getByRole("region", { name: "INI", exact: true });
|
||||
await expect(ini.getByTestId("highlighted-code")).toContainText("host=localhost");
|
||||
await expect(ini.locator('[data-code-token][style*="--code-comment"]')).toHaveText("; comment");
|
||||
expect(await sourceText(ini)).toBe("; comment\n[server]\nhost=localhost\n");
|
||||
const hjson = page.getByRole("region", { name: "HJSON", exact: true });
|
||||
await expect(hjson.getByTestId("highlighted-code")).toContainText("host: localhost");
|
||||
expect(await sourceText(hjson)).toBe("# comment\n{ host: localhost }\n");
|
||||
await expect(page.getByRole("region", { name: "Unknown", exact: true }).getByTestId("highlighted-code")).toHaveText('<script>alert("not executable")</script>');
|
||||
await expect(page.getByRole("region", { name: "ANSI", exact: true }).getByTestId("ansi-code")).toHaveText('PASS <img src=x onerror="bad()">');
|
||||
expect(await page.locator("main script, main img").count()).toBe(0);
|
||||
for (const size of ["small", "standard", "large"]) {
|
||||
await page.evaluate(size => { document.documentElement.dataset.readingTextSize = size; }, size);
|
||||
const expectedBody = size === "small" ? 15 : size === "large" ? 18 : 16;
|
||||
await expect(code.getByTestId("highlighted-code")).toHaveCSS("font-size", `${expectedBody * 0.875}px`);
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true);
|
||||
}
|
||||
await page.getByRole("button", { name: "Toggle theme", exact: true }).click();
|
||||
await expect(page.locator("html")).toHaveClass(dark ? "" : "dark");
|
||||
expect(await sourceText(code)).toBe(expected);
|
||||
await page.getByRole("button", { name: "Change source", exact: true }).click();
|
||||
await expect(code.locator("[data-code-text]").first()).toHaveText(expected.replace("result", "updated").trimEnd());
|
||||
const markdown = page.getByRole("region", { name: "Markdown", exact: true });
|
||||
await page.getByRole("button", { name: "Start streaming", exact: true }).click();
|
||||
await expect(markdown.getByTestId("plain-code-fallback")).toContainText("export const result");
|
||||
await page.getByRole("button", { name: "Finish streaming", exact: true }).click();
|
||||
await expect(markdown.getByTestId("highlighted-code")).toContainText("中文 😀");
|
||||
const preview = page.getByRole("region", { name: "File preview", exact: true });
|
||||
await expect(preview.getByTestId("viewport-code-rows")).toBeVisible();
|
||||
const original = await sourceText(preview);
|
||||
expect(original).toContain("Line 519 😀");
|
||||
expect(await page.evaluate(() => "find" in window && typeof window.find === "function" && window.find("Line 519 😀"))).toBe(true);
|
||||
await page.evaluate(() => { document.getSelection()?.removeAllRanges(); document.dispatchEvent(new Event("selectionchange")); });
|
||||
const scroller = preview.locator("[data-file-preview-scroll]");
|
||||
await scroller.scrollIntoViewIfNeeded();
|
||||
await scroller.evaluate(node => { node.scrollTop = node.scrollHeight; node.scrollLeft = 120; });
|
||||
await expect(preview.locator('[data-code-chunk="15"] [data-highlighted]')).toHaveAttribute("data-highlighted", "true");
|
||||
expect(await sourceText(preview)).toBe(original);
|
||||
expect(await scroller.evaluate(node => node.scrollLeft)).toBeGreaterThan(0);
|
||||
const line = preview.locator('[data-highlighted="true"]').last();
|
||||
await line.evaluate(node => {
|
||||
const range = document.createRange(); range.selectNodeContents(node);
|
||||
const selection = document.getSelection()!; selection.removeAllRanges(); selection.addRange(range);
|
||||
});
|
||||
const selected = await page.evaluate(() => document.getSelection()?.toString());
|
||||
await scroller.evaluate(node => { node.scrollTop = 0; });
|
||||
await page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve))));
|
||||
expect(await page.evaluate(() => document.getSelection()?.toString())).toBe(selected);
|
||||
await page.evaluate(() => { document.getSelection()?.removeAllRanges(); document.dispatchEvent(new Event("selectionchange")); });
|
||||
await expect(preview.locator('[data-code-chunk="0"] [data-highlighted]')).toHaveAttribute("data-highlighted", "true");
|
||||
const beforeWidth = await scroller.evaluate(node => node.scrollWidth);
|
||||
await page.getByRole("button", { name: "Toggle wrapping", exact: true }).click();
|
||||
await expect(preview.getByTestId("highlighted-code")).toHaveCSS("white-space", "pre-wrap");
|
||||
expect(await scroller.evaluate(node => node.scrollWidth)).toBeLessThan(beforeWidth);
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
test("large numbered code remains complete and copies original source", async ({ page, context }) => {
|
||||
await context.grantPermissions(["clipboard-read", "clipboard-write"]);
|
||||
await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en"));
|
||||
await page.goto("/browser/fixture.html?case=code-highlighting");
|
||||
await page.getByRole("button", { name: "Show large code", exact: true }).click();
|
||||
const section = page.getByRole("region", { name: "Large code", exact: true });
|
||||
await expect(section.getByTestId("highlighted-code")).toBeAttached();
|
||||
const expected = Array.from({ length: 1200 }, (_, index) => `const value${index} = ${index};`).join("\n");
|
||||
expect(await sourceText(section)).toBe(expected);
|
||||
await expect(section.getByTestId("highlighted-code").locator("span[aria-hidden]").last()).toHaveText("1200");
|
||||
await section.getByRole("button", { name: "Copy code", exact: true }).click();
|
||||
const clipboardText = process.platform === "win32" ? expected.replace(/\n/g, "\r\n") : expected;
|
||||
await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())).toBe(clipboardText);
|
||||
});
|
||||
|
||||
|
||||
test("a real grammar request failure keeps complete source, controls and the application", async ({ page, context }) => {
|
||||
await context.grantPermissions(["clipboard-read", "clipboard-write"]);
|
||||
await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en"));
|
||||
const failed: string[] = [];
|
||||
const warning = page.waitForEvent("console", message => message.type() === "warning" && message.text().startsWith("Code highlighting failed."));
|
||||
await page.route(/\/hjson-[^/]*\.js(?:\?|$)/, async route => {
|
||||
failed.push(route.request().url());
|
||||
await route.abort("failed");
|
||||
});
|
||||
await page.goto("/browser/fixture.html?case=code-highlighting");
|
||||
await warning;
|
||||
expect(failed).toHaveLength(1);
|
||||
const hjson = page.getByRole("region", { name: "HJSON", exact: true });
|
||||
const source = "# comment\n{ host: localhost }\n";
|
||||
await expect(hjson.getByTestId("plain-code-fallback")).toHaveText(source);
|
||||
expect(await hjson.getByTestId("plain-code-fallback").textContent()).toBe(source);
|
||||
await hjson.getByRole("button", { name: "Copy code", exact: true }).click();
|
||||
await expect.poll(() => page.evaluate(() => navigator.clipboard.readText()))
|
||||
.toBe(process.platform === "win32" ? source.replace(/\n/g, "\r\n") : source);
|
||||
await page.getByRole("button", { name: "Change source", exact: true }).click();
|
||||
await expect(page.getByRole("region", { name: "TypeScript", exact: true }).getByTestId("highlighted-code")).toContainText("export const updated");
|
||||
await page.getByRole("button", { name: "Toggle theme", exact: true }).click();
|
||||
expect(await hjson.getByTestId("plain-code-fallback").textContent()).toBe(source);
|
||||
});
|
||||
@@ -10,8 +10,8 @@ test("numbered Markdown code keeps mixed text flowing after stream completion",
|
||||
await expect(block.getByTestId("plain-code-fallback")).toBeVisible();
|
||||
await page.getByRole("button", { name: "Complete message" }).click();
|
||||
const pre = block.locator("pre");
|
||||
await expect(pre.locator(".token").first()).toBeVisible();
|
||||
await expect(pre.locator(".linenumber")).toHaveText(source.split("\n").map((_, index) => String(index + 1)));
|
||||
await expect(pre.locator("[data-code-token]").first()).toBeVisible();
|
||||
await expect(pre.locator("code > span > span[aria-hidden]")).toHaveText(source.split("\n").map((_, index) => String(index + 1)));
|
||||
|
||||
for (const width of [1280, 390]) {
|
||||
await page.setViewportSize({ width, height: 900 });
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import { useMemo, useRef, useState } from "react";
|
||||
import { DiffViewportContext } from "@/components/thread/activity/DiffViewportContext";
|
||||
import { FileEditGroup, type FileEditSummary } from "@/components/thread/activity/FileEditRow";
|
||||
import { ThemeProvider, useTheme } from "@/hooks/useTheme";
|
||||
import { setAppLanguage } from "@/i18n";
|
||||
|
||||
const patch = (name: string, lines: string[], oldCount: number, newCount: number) =>
|
||||
[`--- a/${name}`, `+++ b/${name}`, `@@ -${oldCount ? 1 : 0},${oldCount} +1,${newCount} @@`, ...lines, ""].join("\n");
|
||||
const markdown = ["## 发布安排", "", "| 日期 | 角色 | 方向 |", "| --- | --- | --- |", "| 7/22 | trust / core | data-driven |"];
|
||||
const longLines = Array.from({ length: 600 }, (_, index) => `export const item${index + 1} = "第 ${index + 1} 行 — readable code";`);
|
||||
const samples: Array<[string, string]> = [
|
||||
["Status.tsx", patch("Status.tsx", [
|
||||
' import { useMemo } from "react";', " export function StatusBadge() {",
|
||||
'- return <span className="badge">old</span>;', '+ return <span className="badge">ready</span>;', " }",
|
||||
], 4, 4)],
|
||||
["table.md", patch("table.md", markdown.map(line => `+${line}`), 0, markdown.length)],
|
||||
["callbacks.tsx", patch("callbacks.tsx", ['+<span className={enabled ? "yes" : "no"} onClick={() => save(new Event("ok"))}>ready</span>'], 0, 1)],
|
||||
["page.html", patch("page.html", ['+<script>alert("not executable")</script>'], 0, 1)],
|
||||
["config.ini", patch("config.ini", [" ; comment", " [server]", "-host=old-server", "+host=localhost"], 3, 3)],
|
||||
["bun.lock", patch("bun.lock", ["+unknown-language contents remain readable"], 0, 1)],
|
||||
["separated.ts", ["--- a/separated.ts", "+++ b/separated.ts", "@@ -1,3 +1,3 @@", " function first() {", "- return oldFirst;", "+ return newFirst;", " }", "@@ -25,3 +25,3 @@", " function second() {", "- return oldSecond;", "+ return newSecond;", " }", ""].join("\n")],
|
||||
["long.ts", patch("long.ts", longLines.map(line => `+${line}`), 0, longLines.length)],
|
||||
["worker.ts", patch("worker.ts", longLines.map(line => `+${line} // ${"worker source ".repeat(10)}`), 0, longLines.length)],
|
||||
["long-separated.ts", ["--- a/long-separated.ts", "+++ b/long-separated.ts", ...[0, 1, 2].flatMap(index => [`@@ -${index * 500},0 +${index * 500 + 1},200 @@`, ...longLines.slice(index * 200, (index + 1) * 200).map(line => `+${line}`)]), ""].join("\n")],
|
||||
["truncated.ts", patch("truncated.ts", ["+export const truncated = true;"], 0, 1)],
|
||||
];
|
||||
|
||||
export function FileDiffFixture() {
|
||||
const { theme, toggle } = useTheme();
|
||||
const [opened, setOpened] = useState("");
|
||||
const [changed, setChanged] = useState(false);
|
||||
const scroller = useRef<HTMLDivElement>(null);
|
||||
const content = useRef<HTMLDivElement>(null);
|
||||
const viewport = useMemo(() => ({ scroller, content }), []);
|
||||
return <ThemeProvider theme={theme}><DiffViewportContext.Provider value={viewport}>
|
||||
<div ref={scroller} className="h-full overflow-y-auto" data-testid="diff-fixture-scroller">
|
||||
<main ref={content} className="mx-auto max-w-3xl space-y-6 p-4">
|
||||
<button onClick={toggle}>Toggle theme</button>
|
||||
<button onClick={() => setChanged(true)}>Change source</button>
|
||||
<button onClick={() => void setAppLanguage("zh-CN")}>Chinese</button>
|
||||
{samples.map(([path, text]) => {
|
||||
const edit: FileEditSummary = {
|
||||
key: path, path, absolute_path: `/fixture/${path}`, added: 1, deleted: 1,
|
||||
approximate: false, binary: false, status: "done", pending: false,
|
||||
diff: { format: "unified", text: changed && path === "Status.tsx" ? text.replace(">ready<", ">updated<") : text, truncated: path === "truncated.ts" },
|
||||
};
|
||||
return <section key={path} aria-label={path}>
|
||||
<FileEditGroup edits={[edit]} displayMode="diff" onOpenFilePreview={setOpened} />
|
||||
</section>;
|
||||
})}
|
||||
<output aria-label="Opened file">{opened}</output>
|
||||
</main></div></DiffViewportContext.Provider></ThemeProvider>;
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
import { expect, test, type Locator } from "@playwright/test";
|
||||
|
||||
async function expectKeywordColor(rows: Locator) {
|
||||
await expect.poll(async () => rows.locator("span").evaluateAll(nodes => {
|
||||
const probe = document.createElement("span");
|
||||
probe.style.color = "var(--code-keyword)";
|
||||
document.body.append(probe);
|
||||
const expected = getComputedStyle(probe).color;
|
||||
probe.remove();
|
||||
return nodes.some(node => node.textContent?.trim() === "export" && getComputedStyle(node).color === expected);
|
||||
})).toBe(true);
|
||||
}
|
||||
|
||||
async function expectTokenColor(section: Locator, text: string, variable: string) {
|
||||
await expect.poll(async () => section.locator("[data-line] span").evaluateAll((nodes, target) => {
|
||||
const probe = document.createElement("span");
|
||||
probe.style.color = `var(${target.variable})`;
|
||||
document.body.append(probe);
|
||||
const expected = getComputedStyle(probe).color;
|
||||
probe.remove();
|
||||
return nodes.some(node => node.textContent?.trim() === target.text && getComputedStyle(node).color === expected);
|
||||
}, { text, variable })).toBe(true);
|
||||
}
|
||||
|
||||
for (const dark of [false, true]) {
|
||||
for (const narrow of [false, true]) {
|
||||
test(`read-only diffs preserve source, colors and reading sizes: ${dark ? "dark" : "light"}, ${narrow ? "narrow" : "desktop"}`, async ({ page }) => {
|
||||
const errors: string[] = [];
|
||||
page.on("pageerror", error => errors.push(error.message));
|
||||
await page.setViewportSize({ width: narrow ? 390 : 1280, height: 900 });
|
||||
await page.addInitScript(theme => {
|
||||
localStorage.setItem("nanobot.locale", "en");
|
||||
localStorage.setItem("nanobot-webui.theme", theme);
|
||||
}, dark ? "dark" : "light");
|
||||
await page.goto("/browser/fixture.html?case=file-diff");
|
||||
const tsx = page.getByRole("region", { name: "Status.tsx", exact: true });
|
||||
const rows = tsx.locator("[data-code] [data-line]");
|
||||
await expect(rows).toHaveCount(5);
|
||||
await expect(rows.nth(2)).toHaveText(' return <span className="badge">old</span>;');
|
||||
await expect(rows.nth(3)).toHaveText(' return <span className="badge">ready</span>;');
|
||||
await expect(tsx.locator("[data-line][data-line-type=change-addition] [data-diff-span]")).not.toHaveCount(0);
|
||||
await expectKeywordColor(rows);
|
||||
for (const [size, body] of [["small", 15], ["standard", 16], ["large", 18]] as const) {
|
||||
await page.evaluate(value => { document.documentElement.dataset.readingTextSize = value; }, size);
|
||||
await expect(rows.first()).toHaveCSS("font-size", `${body * 0.75}px`);
|
||||
await expect.poll(async () => rows.first().evaluate(node => parseFloat(getComputedStyle(node).lineHeight)))
|
||||
.toBeCloseTo(body * 0.75 * 1.6);
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true);
|
||||
}
|
||||
const callbacks = page.getByRole("region", { name: "callbacks.tsx", exact: true });
|
||||
for (const [text, variable] of [["\"yes\"", "--code-string"], ["new", "--code-keyword"], ["save", "--code-function"], ["=>", "--code-function"], ["className", "--code-property"], ["span", "--code-property"]]) {
|
||||
await expectTokenColor(callbacks, text, variable);
|
||||
}
|
||||
const config = page.getByRole("region", { name: "config.ini", exact: true });
|
||||
await expect(config.locator("[data-code] [data-line]")).toHaveCount(4);
|
||||
await expectTokenColor(config, "; comment", "--code-comment");
|
||||
await expect(config.locator("[data-code] [data-line]").last()).toHaveText("host=localhost");
|
||||
const markdown = page.getByRole("region", { name: "table.md", exact: true });
|
||||
await expect(markdown.locator("[data-code] [data-line]")).toHaveCount(5);
|
||||
expect((await markdown.locator("[data-code] [data-line]").allTextContents()).map(line => line.replace(/\n$/, ""))).toEqual([
|
||||
"## 发布安排", "", "| 日期 | 角色 | 方向 |", "| --- | --- | --- |", "| 7/22 | trust / core | data-driven |",
|
||||
]);
|
||||
await expect(page.getByRole("region", { name: "page.html", exact: true }).locator("[data-code] [data-line]"))
|
||||
.toHaveText('<script>alert("not executable")</script>');
|
||||
await expect(page.getByRole("region", { name: "bun.lock", exact: true }).locator("[data-code] [data-line]"))
|
||||
.toHaveText("unknown-language contents remain readable");
|
||||
const separated = page.getByRole("region", { name: "separated.ts", exact: true });
|
||||
await expect(separated.getByTestId("file-edit-diff-hunk-gap")).toHaveText(/21 unchanged lines hidden/);
|
||||
expect(await separated.getByTestId("file-edit-diff-hunk-gap").evaluate(node => node.closest("[data-separator]")!.getBoundingClientRect().height)).toBe(26);
|
||||
await expect(separated.locator("[data-code] [data-line]")).toHaveCount(8);
|
||||
await expect(separated.locator("[data-column-number]").last()).toContainText("27");
|
||||
await page.getByRole("button", { name: "Toggle theme" }).click();
|
||||
await expect(page.locator("html")).toHaveClass(dark ? "" : "dark");
|
||||
await expect(rows).toHaveCount(5);
|
||||
await expectKeywordColor(rows);
|
||||
for (const [text, variable] of [["\"yes\"", "--code-string"], ["new", "--code-keyword"], ["save", "--code-function"], ["=>", "--code-function"], ["className", "--code-property"], ["span", "--code-property"]]) {
|
||||
await expectTokenColor(callbacks, text, variable);
|
||||
}
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
test("large diffs retain bounded expansion, release and truncated-file actions", async ({ page }) => {
|
||||
const errors: string[] = [];
|
||||
page.on("pageerror", error => errors.push(error.message));
|
||||
await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en"));
|
||||
await page.goto("/browser/fixture.html?case=file-diff");
|
||||
const long = page.getByRole("region", { name: "long.ts", exact: true });
|
||||
const toggle = long.getByTestId("file-edit-diff-toggle");
|
||||
await expect(toggle).toHaveAttribute("aria-expanded", "false");
|
||||
await expect(long.locator("diffs-container")).toHaveCount(0);
|
||||
await toggle.click();
|
||||
await expect(long.locator("[data-code] [data-line]")).toHaveCount(160);
|
||||
await expect(long.locator("[data-code] [data-line]").last()).toHaveText('export const item160 = "第 160 行 — readable code";');
|
||||
await long.getByTestId("file-edit-diff-expand-lines").click();
|
||||
const scroller = page.getByTestId("diff-fixture-scroller");
|
||||
const seen = new Set<number>();
|
||||
const height = await scroller.evaluate(node => node.scrollHeight);
|
||||
for (let top = 0; top <= height + 700; top += 700) {
|
||||
await scroller.evaluate((node, offset) => { node.scrollTop = offset; }, top);
|
||||
await page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve))));
|
||||
const rows = await long.locator("[data-code] [data-line]").evaluateAll(nodes => nodes.map(node => ({ number: Number(node.getAttribute("data-line")), text: node.textContent?.replace(/\n$/, "") })));
|
||||
expect(rows.length).toBeLessThan(200);
|
||||
for (const row of rows) {
|
||||
expect(row.text).toBe(`export const item${row.number} = "第 ${row.number} 行 — readable code";`);
|
||||
seen.add(row.number);
|
||||
}
|
||||
expect(await scroller.evaluate(node => node.scrollHeight)).toBe(height);
|
||||
}
|
||||
expect([...seen].sort((a, b) => a - b)).toEqual(Array.from({ length: 600 }, (_, i) => i + 1));
|
||||
await expect(long.locator("[data-code] [data-line]").last()).toHaveText('export const item600 = "第 600 行 — readable code";');
|
||||
await long.getByTestId("file-edit-diff-collapse-lines").click();
|
||||
await expect(long.locator("[data-code] [data-line]")).toHaveCount(160);
|
||||
await toggle.click();
|
||||
await expect(long.getByTestId("file-edit-diff")).toHaveCount(0);
|
||||
await toggle.click();
|
||||
await expect(long.locator("[data-code] [data-line]")).toHaveCount(160);
|
||||
const truncated = page.getByRole("region", { name: "truncated.ts", exact: true });
|
||||
await truncated.getByTestId("file-edit-diff-toggle").click();
|
||||
await expect(truncated.getByTestId("file-edit-diff-truncated")).toContainText("Diff truncated");
|
||||
await truncated.getByTestId("file-edit-diff-open-file").click();
|
||||
await expect(page.getByRole("status", { name: "Opened file" })).toHaveText("/fixture/truncated.ts");
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
|
||||
for (const file of ["worker.ts", "long-separated.ts"]) {
|
||||
test(`windowed ${file} retains every source line and coordinate`, async ({ page }) => {
|
||||
const errors: string[] = [];
|
||||
page.on("pageerror", error => errors.push(error.message));
|
||||
await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en"));
|
||||
await page.goto("/browser/fixture.html?case=file-diff");
|
||||
const section = page.getByRole("region", { name: file, exact: true });
|
||||
await section.getByTestId("file-edit-diff-toggle").click();
|
||||
await expect(section.locator("[data-code] [data-line]")).toHaveCount(160);
|
||||
await expectKeywordColor(section.locator("[data-code] [data-line]"));
|
||||
await section.getByTestId("file-edit-diff-expand-lines").click();
|
||||
const scroller = page.getByTestId("diff-fixture-scroller");
|
||||
const seen = new Set<number>();
|
||||
const height = await scroller.evaluate(node => node.scrollHeight);
|
||||
for (let top = 0; top <= height + 700; top += 700) {
|
||||
await scroller.evaluate((node, offset) => { node.scrollTop = offset; }, top);
|
||||
await page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve))));
|
||||
const rows = await section.locator("[data-code] [data-line]").evaluateAll(nodes => nodes.map(node => ({ number: Number(node.getAttribute("data-line")), text: node.textContent?.replace(/\n$/, ""), kind: node.getAttribute("data-line-type") })));
|
||||
expect(rows.length).toBeLessThan(200);
|
||||
for (const row of rows) {
|
||||
const index = file === "long-separated.ts" ? Math.floor((row.number - 1) / 500) * 200 + (row.number - 1) % 500 + 1 : row.number;
|
||||
expect(row.text).toBe(`export const item${index} = "第 ${index} 行 — readable code";${file === "worker.ts" ? ` // ${"worker source ".repeat(10)}` : ""}`);
|
||||
expect(row.kind).toBe("change-addition");
|
||||
seen.add(index);
|
||||
}
|
||||
expect(await scroller.evaluate(node => node.scrollHeight)).toBe(height);
|
||||
}
|
||||
expect([...seen].sort((a, b) => a - b)).toEqual(Array.from({ length: 600 }, (_, i) => i + 1));
|
||||
expect(errors).toEqual([]);
|
||||
});
|
||||
}
|
||||
|
||||
test("a changed source replaces cached syntax without stale text", async ({ page }) => {
|
||||
await page.goto("/browser/fixture.html?case=file-diff");
|
||||
const section = page.getByRole("region", { name: "Status.tsx", exact: true });
|
||||
await expect(section.locator("[data-code] [data-line]").nth(3)).toHaveText(' return <span className="badge">ready</span>;');
|
||||
await page.getByRole("button", { name: "Change source" }).click();
|
||||
await expect(section.locator("[data-code] [data-line]").nth(3)).toHaveText(' return <span className="badge">updated</span>;');
|
||||
await expectKeywordColor(section.locator("[data-code] [data-line]"));
|
||||
const gap = page.getByRole("region", { name: "separated.ts", exact: true }).getByTestId("file-edit-diff-hunk-gap");
|
||||
await page.getByRole("button", { name: "Chinese", exact: true }).click();
|
||||
await expect(gap).toContainText("21");
|
||||
await expect(gap).toHaveText("… 已隐藏 21 行未修改内容");
|
||||
});
|
||||
|
||||
|
||||
for (const [file, renderedIndex, sourceLine, reverse] of [["long.ts", 58, 59, false], ["long-separated.ts", 249, 550, true]] as const) {
|
||||
test(`native selection survives moving diff windows and releases pinned rows: ${file}`, async ({ page, context }) => {
|
||||
await context.grantPermissions(["clipboard-read", "clipboard-write"]);
|
||||
await page.setViewportSize({ width: 1280, height: 700 });
|
||||
await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en"));
|
||||
await page.goto("/browser/fixture.html?case=file-diff");
|
||||
const section = page.getByRole("region", { name: file, exact: true });
|
||||
await section.getByTestId("file-edit-diff-toggle").click();
|
||||
await expectKeywordColor(section.locator("[data-code] [data-line]"));
|
||||
await section.getByTestId("file-edit-diff-expand-lines").click();
|
||||
const scroller = page.getByTestId("diff-fixture-scroller");
|
||||
const height = await scroller.evaluate(node => node.scrollHeight);
|
||||
await section.getByTestId("syntax-highlighted-diff-hunk").evaluate((node, index) => {
|
||||
const scroller = document.querySelector<HTMLElement>('[data-testid="diff-fixture-scroller"]')!;
|
||||
const lineHeight = parseFloat(getComputedStyle(node).lineHeight) + 2;
|
||||
scroller.scrollTop += node.getBoundingClientRect().top - scroller.getBoundingClientRect().top + index * lineHeight - 200;
|
||||
}, renderedIndex);
|
||||
const line = section.locator(`[data-code] [data-line="${sourceLine}"]`);
|
||||
await expect(line).toBeVisible();
|
||||
// Settle the scheduled window update before beginning a physical drag.
|
||||
await page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve))));
|
||||
const box = await line.evaluate(node => {
|
||||
const text = document.createTreeWalker(node, NodeFilter.SHOW_TEXT).nextNode()!;
|
||||
const range = document.createRange();
|
||||
range.setStart(text, 0);
|
||||
range.setEnd(text, 1);
|
||||
const bounds = range.getBoundingClientRect();
|
||||
return { x: bounds.x, y: bounds.y, height: bounds.height };
|
||||
});
|
||||
const left = box.x + 1;
|
||||
const right = left + 200;
|
||||
await page.mouse.move(reverse ? right : left, box.y + box.height / 2);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(reverse ? left : right, box.y + box.height / 2, { steps: 8 });
|
||||
await page.mouse.up();
|
||||
const selected = await page.evaluate(() => document.getSelection()!.toString());
|
||||
expect(selected).toContain("export const");
|
||||
const first = Number(await section.locator("[data-code] [data-line]").first().getAttribute("data-line"));
|
||||
await scroller.evaluate(node => { node.scrollTop += 3200; });
|
||||
await expect.poll(() => section.locator("[data-code] [data-line]").count()).toBeGreaterThan(200);
|
||||
expect(await page.evaluate(() => document.getSelection()!.toString())).toBe(selected);
|
||||
await page.keyboard.press("ControlOrMeta+C");
|
||||
await expect.poll(() => page.evaluate(() => navigator.clipboard.readText())).toBe(selected);
|
||||
await expect(line).toBeAttached();
|
||||
expect(await scroller.evaluate(node => node.scrollHeight)).toBe(height);
|
||||
const last = section.locator("[data-code] [data-line]").last();
|
||||
expect(Number(await last.getAttribute("data-line"))).toBeGreaterThan(sourceLine + 100);
|
||||
await page.evaluate(() => document.getSelection()!.removeAllRanges());
|
||||
await expect.poll(() => section.locator("[data-code] [data-line]").count()).toBeLessThan(200);
|
||||
expect(Number(await section.locator("[data-code] [data-line]").first().getAttribute("data-line"))).toBeGreaterThan(first);
|
||||
await expect(line).toHaveCount(0);
|
||||
});
|
||||
}
|
||||
@@ -36,6 +36,8 @@ import { ActivityLogosFixture } from "./activity-logos-fixture";
|
||||
import { HistoryHydrationFixture } from "./history-hydration-fixture";
|
||||
import { IdleCompactionFixture, installIdleCompactionApi } from "./idle-compaction-fixture";
|
||||
import { FileEditPathFixture } from "./file-edit-path-fixture";
|
||||
import { FileDiffFixture } from "./file-diff-fixture";
|
||||
import { CodeHighlightingFixture } from "./code-highlighting-fixture";
|
||||
import { QueuedGuidanceFixture } from "./queued-guidance-fixture";
|
||||
import { WorkspaceAlignmentFixture } from "./workspace-alignment-fixture";
|
||||
import { ComposerActionFixture } from "./composer-action-fixture";
|
||||
@@ -148,7 +150,7 @@ function RailFixture() {
|
||||
panes={[{ key: "rail", title: "Rail conversation" }]} activePaneKey="rail" layout="columns" showLayoutControl={false}
|
||||
onActivatePane={() => {}} onAddPane={() => {}} onLayoutChange={() => {}} onPaneOrderChange={() => {}}
|
||||
renderPane={(_pane, context) => <>
|
||||
{viewport(true, context.navigationFrame)}
|
||||
{viewport(context.composerPortalTarget !== undefined, context.navigationFrame)}
|
||||
{context.composerPortalTarget && createPortal(composer, context.composerPortalTarget)}
|
||||
</>}
|
||||
/> : viewport(false)}
|
||||
@@ -242,6 +244,10 @@ createRoot(document.getElementById("root")!).render(<TooltipProvider>
|
||||
? <WorkspaceAlignmentFixture parameters={parameters} />
|
||||
: parameters.get("case") === "queued-guidance"
|
||||
? <QueuedGuidanceFixture />
|
||||
: parameters.get("case") === "code-highlighting"
|
||||
? <CodeHighlightingFixture />
|
||||
: parameters.get("case") === "file-diff"
|
||||
? <FileDiffFixture />
|
||||
: parameters.get("case") === "file-edit-path"
|
||||
? <FileEditPathFixture />
|
||||
: parameters.get("case") === "answer-order"
|
||||
|
||||
@@ -46,6 +46,9 @@ const noop = () => {};
|
||||
function ThemeChatFixture({ theme, toggle }: { theme: "light" | "dark"; toggle: () => void }) {
|
||||
const [activeKey, setActiveKey] = useState(sessions[0].key);
|
||||
const composer = <ThreadComposer onSend={noop} />;
|
||||
const header = <ThreadHeader title="Theme chat" hideTitle theme={theme} onToggleTheme={toggle} onToggleSidebar={noop} />;
|
||||
const panes = [{ key: "theme", title: "Theme chat" }];
|
||||
if (new URLSearchParams(location.search).has("split")) panes.push({ key: "theme-secondary", title: "Secondary chat" });
|
||||
return <main data-theme-surface className="flex bg-background" style={{ height: "100vh" }}>
|
||||
<aside className="hidden w-64 shrink-0 sm:block">
|
||||
<Sidebar sessions={sessions} activeKey={activeKey} onSelect={setActiveKey} loading={false} newChatActive={false}
|
||||
@@ -55,14 +58,16 @@ function ThemeChatFixture({ theme, toggle }: { theme: "light" | "dark"; toggle:
|
||||
onOpenChannels={noop} onOpenSearch={noop} onToggleArchived={noop} />
|
||||
</aside>
|
||||
<div className="min-w-0 flex-1">
|
||||
<PaneWorkbench panes={[{ key: "theme", title: "Theme chat" }]} activePaneKey="theme" layout="columns"
|
||||
<PaneWorkbench panes={panes} activePaneKey="theme" layout="columns"
|
||||
showLayoutControl={false} onActivatePane={noop} onAddPane={noop} onLayoutChange={noop} onPaneOrderChange={noop}
|
||||
renderPane={(_pane, context) => <div className="relative flex min-h-0 flex-1 flex-col">
|
||||
<ThreadHeader title="Theme chat" hideTitle theme={theme} onToggleTheme={toggle} onToggleSidebar={noop} />
|
||||
{context.active && (context.headerPortalTarget
|
||||
? createPortal(header, context.headerPortalTarget)
|
||||
: context.headerPortalTarget === undefined ? header : null)}
|
||||
<ThreadViewport messages={messages} isStreaming={false} conversationKey={activeKey}
|
||||
navigationFrame={context.navigationFrame} composer={null} />
|
||||
navigationFrame={context.navigationFrame} composer={context.composerPortalTarget === undefined ? composer : null} />
|
||||
<ThreadHistoryStatus loading={false} error={null} exhausted onRetry={noop} />
|
||||
{context.composerPortalTarget && createPortal(<div data-active-composer>{composer}</div>, context.composerPortalTarget)}
|
||||
{context.active && context.composerPortalTarget && createPortal(<div data-active-composer>{composer}</div>, context.composerPortalTarget)}
|
||||
</div>} />
|
||||
</div>
|
||||
</main>;
|
||||
|
||||
@@ -106,14 +106,14 @@ test("reduced motion keeps the canvas fade but switches the icon directly", asyn
|
||||
|
||||
for (const width of [1440, 390]) {
|
||||
for (const initial of ["light", "dark"] as const) {
|
||||
test(`reduced motion fades existing chat surfaces together from ${initial} at ${width}px`, async ({ page }) => {
|
||||
test(`reduced motion fades shared-composer chat surfaces together from ${initial} at ${width}px`, async ({ page }) => {
|
||||
await page.emulateMedia({ reducedMotion: "reduce" });
|
||||
await page.setViewportSize({ width, height: 844 });
|
||||
await page.addInitScript((theme) => {
|
||||
localStorage.setItem("nanobot.locale", "en");
|
||||
localStorage.setItem("nanobot-webui.theme", theme);
|
||||
}, initial);
|
||||
await page.goto("/browser/fixture.html?case=theme-toggle&chat");
|
||||
await page.goto("/browser/fixture.html?case=theme-toggle&chat&split");
|
||||
const input = page.getByRole("textbox");
|
||||
await input.fill("Keep this draft while changing theme");
|
||||
const inputBox = await input.boundingBox();
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useEffect, useState } from "react";
|
||||
import { MessageBubble } from "@/components/MessageBubble";
|
||||
import { AppearanceSettingsView } from "@/components/settings/overview/AppearanceSettingsView";
|
||||
import { ThreadComposer } from "@/components/thread/ThreadComposer";
|
||||
import { DiffSyntaxHighlight } from "@/components/thread/activity/DiffSyntaxHighlight";
|
||||
import { FileEditGroup } from "@/components/thread/activity/FileEditRow";
|
||||
import { ThemeProvider, useTheme } from "@/hooks/useTheme";
|
||||
import { useReadingTypography } from "@/hooks/useReadingTypography";
|
||||
import { readLocalPreferences, writeLocalPreferences } from "@/lib/local-preferences";
|
||||
@@ -96,10 +96,10 @@ export function TypographyFixture() {
|
||||
</div>
|
||||
<section className="mx-auto max-w-[var(--content-column-width)] space-y-6 px-4 pb-8" aria-label="Reading preview">
|
||||
{[...previewMessages, ...sent].map((message) => <MessageBubble key={message.id} message={message} />)}
|
||||
<div className="overflow-x-auto"><DiffSyntaxHighlight language="typescript" lines={[
|
||||
{ kind: "delete", content: "const size = 16;", old_lineno: 1, new_lineno: null },
|
||||
{ kind: "add", content: "const size = preferences.readingTextSize;", old_lineno: null, new_lineno: 1 },
|
||||
]} /></div>
|
||||
<FileEditGroup displayMode="diff" edits={[{
|
||||
key: "typography", path: "size.ts", added: 1, deleted: 1, approximate: false, binary: false, status: "done", pending: false,
|
||||
diff: { format: "unified", text: "--- a/size.ts\n+++ b/size.ts\n@@ -1 +1 @@\n-const size = 16;\n+const size = preferences.readingTextSize;\n" },
|
||||
}]} />
|
||||
<ThreadComposer compactWhenIdle sessions={[session]} modelLabel="Fixture" persistDraft={false} onSend={(text) => {
|
||||
setSent((current) => [...current, { id: `sent-${current.length}`, role: "user", content: text, createdAt: 3 + current.length }]);
|
||||
}} />
|
||||
|
||||
+62
-69
@@ -5,6 +5,8 @@
|
||||
"": {
|
||||
"name": "nanobot-webui",
|
||||
"dependencies": {
|
||||
"@pierre/diffs": "1.6.4",
|
||||
"@pierre/highlights": "0.4.0",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.4",
|
||||
"@radix-ui/react-dialog": "^1.1.4",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.4",
|
||||
@@ -28,7 +30,6 @@
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-i18next": "^17.0.4",
|
||||
"react-syntax-highlighter": "^15.6.1",
|
||||
"rehype-katex": "^7.0.1",
|
||||
"remark-breaks": "^4.0.0",
|
||||
"remark-cjk-friendly": "2.3.3",
|
||||
@@ -37,6 +38,7 @@
|
||||
"remark-parse": "^11.0.0",
|
||||
"remend": "1.3.0",
|
||||
"saxes": "6.0.0",
|
||||
"shiki": "4.6.0",
|
||||
"streamdown": "2.6.0",
|
||||
"tailwind-merge": "^2.6.0",
|
||||
"unified": "^11.0.5",
|
||||
@@ -55,7 +57,6 @@
|
||||
"@types/qrcode": "^1.5.6",
|
||||
"@types/react": "^18.3.18",
|
||||
"@types/react-dom": "^18.3.5",
|
||||
"@types/react-syntax-highlighter": "^15.5.13",
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"@vitest/coverage-v8": "2.1.9",
|
||||
"autoprefixer": "^10.4.20",
|
||||
@@ -226,6 +227,14 @@
|
||||
|
||||
"@nodelib/fs.walk": ["@nodelib/fs.walk@1.2.8", "", { "dependencies": { "@nodelib/fs.scandir": "2.1.5", "fastq": "^1.6.0" } }, "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg=="],
|
||||
|
||||
"@pierre/diffs": ["@pierre/diffs@1.6.4", "", { "dependencies": { "@pierre/highlights": "0.4.0", "@pierre/theme": "2.0.0", "@pierre/theming": "1.0.2", "diff": "9.0.0", "hast-util-to-html": "9.0.5", "lru_map": "0.4.1", "shiki": "^3.0.0 || ^4.0.0" }, "peerDependencies": { "react": "^18.3.1 || ^19.0.0", "react-dom": "^18.3.1 || ^19.0.0" }, "optionalPeers": ["react", "react-dom"] }, "sha512-RsKoruCOp50qaDM3a7BQan5K77xMkGWT1NF01fiYP1PfT3v4CvIjwytNk5WjZG0BesBkMOP2UbrBIDigB1k0ug=="],
|
||||
|
||||
"@pierre/highlights": ["@pierre/highlights@0.4.0", "", {}, "sha512-2a38H7ep3KweGi1fGQpJk+Krod2OMpDIXagKPlqBd1Y9P460T7zQmc66Wm2JAH1SpIG93wCyyhZVrkc5dnAJVQ=="],
|
||||
|
||||
"@pierre/theme": ["@pierre/theme@2.0.0", "", {}, "sha512-yNDd9GYLQl1mEUJR8AneJ5e4ohLIHQd/wZLWr4fagt78vS2RwwZNW530vVgHqXFAyFVcFlRmGUD5ramXH46OXw=="],
|
||||
|
||||
"@pierre/theming": ["@pierre/theming@1.0.2", "", { "peerDependencies": { "@pierre/theme": "^1.1.0 || ^2.0.0", "@shikijs/themes": "^3.0.0 || ^4.0.0", "react": "^18.3.1 || ^19.0.0", "react-dom": "^18.3.1 || ^19.0.0", "shiki": "^3.0.0 || ^4.0.0" }, "optionalPeers": ["@pierre/theme", "@shikijs/themes", "react", "react-dom", "shiki"] }, "sha512-RmXLLqtx31UGcR8kZyO5hGAQ1EXz6loT1Cu0BFAGsbnBboIxp2BlomkLfWyvdT4WZXnBGyu25onL1gKpFQuSUw=="],
|
||||
|
||||
"@pkgjs/parseargs": ["@pkgjs/parseargs@0.11.0", "", {}, "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg=="],
|
||||
|
||||
"@playwright/test": ["@playwright/test@1.64.1", "", { "dependencies": { "playwright": "1.64.1" }, "bin": { "playwright": "cli.js" } }, "sha512-IaYGml/nSOiZWROfPtuIL7neuu9qDOZ3TNvNljUIrhDMxiGTgPjzj/g9p9RxpS2tSepPDRY+UwAaEeiKtUvIAg=="],
|
||||
@@ -350,6 +359,22 @@
|
||||
|
||||
"@rollup/rollup-win32-x64-msvc": ["@rollup/rollup-win32-x64-msvc@4.60.1", "", { "os": "win32", "cpu": "x64" }, "sha512-lWMnixq/QzxyhTV6NjQJ4SFo1J6PvOX8vUx5Wb4bBPsEb+8xZ89Bz6kOXpfXj9ak9AHTQVQzlgzBEc1SyM27xQ=="],
|
||||
|
||||
"@shikijs/core": ["@shikijs/core@4.6.0", "", { "dependencies": { "@shikijs/primitive": "4.6.0", "@shikijs/types": "4.6.0", "@shikijs/vscode-textmate": "^10.1.0", "@types/hast": "^3.0.5", "hast-util-to-html": "^9.0.6" } }, "sha512-bfd4OKgvoyXYiYmMRuleA656P4V7M/Du9lcTl38Ngm6KszMj7bq4J1IGZwSYR4c95Tv5UQALtYNWUwaI9UT3xw=="],
|
||||
|
||||
"@shikijs/engine-javascript": ["@shikijs/engine-javascript@4.6.0", "", { "dependencies": { "@shikijs/types": "4.6.0", "@shikijs/vscode-textmate": "^10.1.0", "oniguruma-to-es": "^4.3.6" } }, "sha512-K0oqxFoL+kEMdz89mHLFO15Tsbv3kFZ6WR1cXZKMvLSc+oqaM00A6pyga1qSeXB22dP0tTiSApRcGBaKWsEccg=="],
|
||||
|
||||
"@shikijs/engine-oniguruma": ["@shikijs/engine-oniguruma@4.6.0", "", { "dependencies": { "@shikijs/types": "4.6.0", "@shikijs/vscode-textmate": "^10.1.0" } }, "sha512-aggd6Q7SuJOXNnsUbfG2XesxBJKBMAw/PDTUo9PyRjMaaJJ2dNrI+q0C+25ARXAK9yLHAlwxc9oRT2u68YKZ7w=="],
|
||||
|
||||
"@shikijs/langs": ["@shikijs/langs@4.6.0", "", { "dependencies": { "@shikijs/types": "4.6.0" } }, "sha512-1yMEX3oCVV54LUq/ovfpRkDQoYDkcvjSWFFa/YLUDMiSoRzMi2uxLJYbv41ahT8Lu9lFMaa7hecd3Q39trqUyg=="],
|
||||
|
||||
"@shikijs/primitive": ["@shikijs/primitive@4.6.0", "", { "dependencies": { "@shikijs/types": "4.6.0", "@shikijs/vscode-textmate": "^10.1.0", "@types/hast": "^3.0.5" } }, "sha512-c54+TQEo9ToqgfL/AU8FpjnV09+GA9Oa7M5ROkkXteZfp5XzpAJGXjjvZQFQioJOwm/w/6Z3lIzQstAkl8coag=="],
|
||||
|
||||
"@shikijs/themes": ["@shikijs/themes@4.6.0", "", { "dependencies": { "@shikijs/types": "4.6.0" } }, "sha512-qHAVAs80RiGD+IRuH9G+JPDOEc9A/kHsng4EzCUCwB9bLzW6Z0y9WETh2YyCcADJBmfrIaJ1Jp7KBNP6FHkgtQ=="],
|
||||
|
||||
"@shikijs/types": ["@shikijs/types@4.6.0", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.1.0", "@types/hast": "^3.0.5" } }, "sha512-+ENG1adsKt/X7cRYw1Nl7BEpBmPOjmQ7bR/eGmHuMlT8gtOFf3KEi5l31DJYyAWhW6Y6bjP1plU7FmaxWGENFw=="],
|
||||
|
||||
"@shikijs/vscode-textmate": ["@shikijs/vscode-textmate@10.1.0", "", {}, "sha512-cVBuhDQjBZaNMTwBquYfPydrUP+E3hE6oYGasx8h6ZrODIM7/r+gxLDXdd66oszbrggZHEntdE6j+5gYIVyMWQ=="],
|
||||
|
||||
"@tailwindcss/typography": ["@tailwindcss/typography@0.5.19", "", { "dependencies": { "postcss-selector-parser": "6.0.10" }, "peerDependencies": { "tailwindcss": ">=3.0.0 || insiders || >=4.0.0-alpha.20 || >=4.0.0-beta.1" } }, "sha512-w31dd8HOx3k9vPtcQh5QHP9GwKcgbMp87j58qi6xgiBnFFtKEAgCWnDw4qUT8aHwkCp8bKvb/KGKWWHedP0AAg=="],
|
||||
|
||||
"@testing-library/dom": ["@testing-library/dom@10.4.1", "", { "dependencies": { "@babel/code-frame": "^7.10.4", "@babel/runtime": "^7.12.5", "@types/aria-query": "^5.0.1", "aria-query": "5.3.0", "dom-accessibility-api": "^0.5.9", "lz-string": "^1.5.0", "picocolors": "1.1.1", "pretty-format": "^27.0.2" } }, "sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg=="],
|
||||
@@ -402,8 +427,6 @@
|
||||
|
||||
"@types/react-dom": ["@types/react-dom@18.3.7", "", { "peerDependencies": { "@types/react": "^18.0.0" } }, "sha512-MEe3UeoENYVFXzoXEWsvcpg6ZvlrFNlOQ7EOsvhI3CfAXwzPfO8Qwuxd40nepsYKqyyVQnTdEfv68q91yLcKrQ=="],
|
||||
|
||||
"@types/react-syntax-highlighter": ["@types/react-syntax-highlighter@15.5.13", "", { "dependencies": { "@types/react": "*" } }, "sha512-uLGJ87j6Sz8UaBAooU0T6lWJ0dBmjZgN1PZTrj05TNql2/XpC6+4HhMT5syIdFUUt+FASfCeLLv4kBygNU+8qA=="],
|
||||
|
||||
"@types/unist": ["@types/unist@3.0.3", "", {}, "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q=="],
|
||||
|
||||
"@typescript-eslint/eslint-plugin": ["@typescript-eslint/eslint-plugin@8.62.1", "", { "dependencies": { "@eslint-community/regexpp": "^4.12.2", "@typescript-eslint/scope-manager": "8.62.1", "@typescript-eslint/type-utils": "8.62.1", "@typescript-eslint/utils": "8.62.1", "@typescript-eslint/visitor-keys": "8.62.1", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.5.0" }, "peerDependencies": { "@typescript-eslint/parser": "^8.62.1", "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", "typescript": ">=4.8.4 <6.1.0" } }, "sha512-4EQM77WgVNxj7OkL/5b/D/xZsw00G577+UriYTC7JF5opcF3T2AuoeY7ueLaZgSVjSgCS6yOAJB5bRGLPSJUzA=="],
|
||||
@@ -500,9 +523,9 @@
|
||||
|
||||
"character-entities-html4": ["character-entities-html4@2.1.0", "", {}, "sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA=="],
|
||||
|
||||
"character-entities-legacy": ["character-entities-legacy@1.1.4", "", {}, "sha512-3Xnr+7ZFS1uxeiUDvV02wQ+QDbc55o97tIV5zHScSPJpcLm/r0DFPcoY3tYRp+VZukxuMeKgXYmsXQHO05zQeA=="],
|
||||
"character-entities-legacy": ["character-entities-legacy@3.0.0", "", {}, "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ=="],
|
||||
|
||||
"character-reference-invalid": ["character-reference-invalid@1.1.4", "", {}, "sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg=="],
|
||||
"character-reference-invalid": ["character-reference-invalid@2.0.1", "", {}, "sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw=="],
|
||||
|
||||
"check-error": ["check-error@2.1.3", "", {}, "sha512-PAJdDJusoxnwm1VwW07VWwUN1sl7smmC3OKggvndJFadxxDRyFJBX/ggnu/KE4kQAB7a3Dp8f/YXC1FlUprWmA=="],
|
||||
|
||||
@@ -622,8 +645,6 @@
|
||||
|
||||
"fastq": ["fastq@1.20.1", "", { "dependencies": { "reusify": "^1.0.4" } }, "sha512-GGToxJ/w1x32s/D2EKND7kTil4n8OVk/9mycTc4VDza13lOvpUZTGX3mFSCtV9ksdGBVzvsyAVLM6mHFThxXxw=="],
|
||||
|
||||
"fault": ["fault@1.0.4", "", { "dependencies": { "format": "^0.2.0" } }, "sha512-CJ0HCB5tL5fYTEA7ToAq5+kTwd++Borf1/bifxd9iT70QcXr4MRrO3Llf8Ifs70q+SJcGHFtnIE/Nw6giCtECA=="],
|
||||
|
||||
"fdir": ["fdir@6.5.0", "", { "peerDependencies": { "picomatch": "^3 || ^4" }, "optionalPeers": ["picomatch"] }, "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg=="],
|
||||
|
||||
"file-entry-cache": ["file-entry-cache@8.0.0", "", { "dependencies": { "flat-cache": "^4.0.0" } }, "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ=="],
|
||||
@@ -638,8 +659,6 @@
|
||||
|
||||
"foreground-child": ["foreground-child@3.3.1", "", { "dependencies": { "cross-spawn": "^7.0.6", "signal-exit": "^4.0.1" } }, "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw=="],
|
||||
|
||||
"format": ["format@0.2.2", "", {}, "sha512-wzsgA6WOq+09wrU1tsJ09udeR/YZRaeArL9e1wPbFg3GG2yDnC2ldKpxs4xunpFF9DgqCqOIra3bc1HWrJ37Ww=="],
|
||||
|
||||
"fraction.js": ["fraction.js@5.3.4", "", {}, "sha512-1X1NTtiJphryn/uLQz3whtY6jK3fTqoE3ohKs0tT+Ujr1W59oopxmoEh7Lu5p6vBaPbgoM0bzveAW4Qi5RyWDQ=="],
|
||||
|
||||
"framer-motion": ["framer-motion@14.4.0", "https://registry.npmjs.org/framer-motion/-/framer-motion-14.4.0.tgz", { "dependencies": { "motion-dom": "14.4.0", "motion-utils": "14.1.1", "tslib": "^2.4.0" }, "peerDependencies": { "react": "^18.0.0 || ^19.0.0", "react-dom": "^18.0.0 || ^19.0.0" }, "optionalPeers": ["react", "react-dom"] }, "sha512-HtO1fxord2rnXYRyr1laG4uY7+OtgwDc9Szcg1wlMq/LF7BO3/S7a+KEo691U7pSi+i0ueRuRqaD1UaLEmZHuQ=="],
|
||||
@@ -678,12 +697,14 @@
|
||||
|
||||
"hast-util-is-element": ["hast-util-is-element@3.0.0", "", { "dependencies": { "@types/hast": "^3.0.0" } }, "sha512-Val9mnv2IWpLbNPqc/pUem+a7Ipj2aHacCwgNfTiK0vJKl0LF+4Ba4+v1oPHFpf3bLYmreq0/l3Gud9S5OH42g=="],
|
||||
|
||||
"hast-util-parse-selector": ["hast-util-parse-selector@2.2.5", "", {}, "sha512-7j6mrk/qqkSehsM92wQjdIgWM2/BW61u/53G6xmC8i1OmEdKLHbk419QKQUjz6LglWsfqoiHmyMRkP1BGjecNQ=="],
|
||||
"hast-util-parse-selector": ["hast-util-parse-selector@4.0.0", "", { "dependencies": { "@types/hast": "^3.0.0" } }, "sha512-wkQCkSYoOGCRKERFWcxMVMOcYE2K1AaNLU8DXS9arxnLOUEWbOXKXiJUNzEpqZ3JOKpnha3jkFrumEjVliDe7A=="],
|
||||
|
||||
"hast-util-raw": ["hast-util-raw@9.1.0", "", { "dependencies": { "@types/hast": "^3.0.0", "@types/unist": "^3.0.0", "@ungap/structured-clone": "^1.0.0", "hast-util-from-parse5": "^8.0.0", "hast-util-to-parse5": "^8.0.0", "html-void-elements": "^3.0.0", "mdast-util-to-hast": "^13.0.0", "parse5": "^7.0.0", "unist-util-position": "^5.0.0", "unist-util-visit": "^5.0.0", "vfile": "^6.0.0", "web-namespaces": "^2.0.0", "zwitch": "^2.0.0" } }, "sha512-Y8/SBAHkZGoNkpzqqfCldijcuUKh7/su31kEBp67cFY09Wy0mTRgtsLYsiIxMJxlu0f6AA5SUTbDR8K0rxnbUw=="],
|
||||
|
||||
"hast-util-sanitize": ["hast-util-sanitize@5.0.2", "", { "dependencies": { "@types/hast": "^3.0.0", "@ungap/structured-clone": "^1.0.0", "unist-util-position": "^5.0.0" } }, "sha512-3yTWghByc50aGS7JlGhk61SPenfE/p1oaFeNwkOOyrscaOkMGrcW9+Cy/QAIOBpZxP1yqDIzFMR0+Np0i0+usg=="],
|
||||
|
||||
"hast-util-to-html": ["hast-util-to-html@9.0.5", "", { "dependencies": { "@types/hast": "^3.0.0", "@types/unist": "^3.0.0", "ccount": "^2.0.0", "comma-separated-tokens": "^2.0.0", "hast-util-whitespace": "^3.0.0", "html-void-elements": "^3.0.0", "mdast-util-to-hast": "^13.0.0", "property-information": "^7.0.0", "space-separated-tokens": "^2.0.0", "stringify-entities": "^4.0.0", "zwitch": "^2.0.4" } }, "sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw=="],
|
||||
|
||||
"hast-util-to-jsx-runtime": ["hast-util-to-jsx-runtime@2.3.6", "", { "dependencies": { "@types/estree": "^1.0.0", "@types/hast": "^3.0.0", "@types/unist": "^3.0.0", "comma-separated-tokens": "^2.0.0", "devlop": "^1.0.0", "estree-util-is-identifier-name": "^3.0.0", "hast-util-whitespace": "^3.0.0", "mdast-util-mdx-expression": "^2.0.0", "mdast-util-mdx-jsx": "^3.0.0", "mdast-util-mdxjs-esm": "^2.0.0", "property-information": "^7.0.0", "space-separated-tokens": "^2.0.0", "style-to-js": "^1.0.0", "unist-util-position": "^5.0.0", "vfile-message": "^4.0.0" } }, "sha512-zl6s8LwNyo1P9uw+XJGvZtdFF1GdAkOg8ujOw+4Pyb76874fLps4ueHXDhXWdk6YHQ6OgUtinliG7RsYvCbbBg=="],
|
||||
|
||||
"hast-util-to-parse5": ["hast-util-to-parse5@8.0.1", "", { "dependencies": { "@types/hast": "^3.0.0", "comma-separated-tokens": "^2.0.0", "devlop": "^1.0.0", "property-information": "^7.0.0", "space-separated-tokens": "^2.0.0", "web-namespaces": "^2.0.0", "zwitch": "^2.0.0" } }, "sha512-MlWT6Pjt4CG9lFCjiz4BH7l9wmrMkfkJYCxFwKQic8+RTZgWPuWxwAfjJElsXkex7DJjfSJsQIt931ilUgmwdA=="],
|
||||
@@ -692,16 +713,12 @@
|
||||
|
||||
"hast-util-whitespace": ["hast-util-whitespace@3.0.0", "", { "dependencies": { "@types/hast": "^3.0.0" } }, "sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw=="],
|
||||
|
||||
"hastscript": ["hastscript@6.0.0", "", { "dependencies": { "@types/hast": "^2.0.0", "comma-separated-tokens": "^1.0.0", "hast-util-parse-selector": "^2.0.0", "property-information": "^5.0.0", "space-separated-tokens": "^1.0.0" } }, "sha512-nDM6bvd7lIqDUiYEiu5Sl/+6ReP0BMk/2f4U/Rooccxkj0P5nm+acM5PrGJ/t5I8qPGiqZSE6hVAwZEdZIvP4w=="],
|
||||
"hastscript": ["hastscript@9.0.1", "", { "dependencies": { "@types/hast": "^3.0.0", "comma-separated-tokens": "^2.0.0", "hast-util-parse-selector": "^4.0.0", "property-information": "^7.0.0", "space-separated-tokens": "^2.0.0" } }, "sha512-g7df9rMFX/SPi34tyGCyUBREQoKkapwdY/T04Qn9TDWfHhAYt4/I0gMVirzK5wEzeUqIjEB+LXC/ypb7Aqno5w=="],
|
||||
|
||||
"hermes-estree": ["hermes-estree@0.25.1", "", {}, "sha512-0wUoCcLp+5Ev5pDW2OriHC2MJCbwLwuRx+gAqMTOkGKJJiBCLjtrvy4PWUGn6MIVefecRpzoOZ/UV6iGdOr+Cw=="],
|
||||
|
||||
"hermes-parser": ["hermes-parser@0.25.1", "", { "dependencies": { "hermes-estree": "0.25.1" } }, "sha512-6pEjquH3rqaI6cYAXYPcz9MS4rY6R4ngRgrgfDshRptUZIc3lw0MCIJIGDj9++mfySOuPTHB4nrSW99BCvOPIA=="],
|
||||
|
||||
"highlight.js": ["highlight.js@10.7.3", "", {}, "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A=="],
|
||||
|
||||
"highlightjs-vue": ["highlightjs-vue@1.0.0", "", {}, "sha512-PDEfEF102G23vHmPhLyPboFCD+BkMGu+GuJe2d9/eH4FsCwvgBpnc9n0pGE+ffKdph38s6foEZiEjdgHdzp+IA=="],
|
||||
|
||||
"html-escaper": ["html-escaper@2.0.2", "", {}, "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg=="],
|
||||
|
||||
"html-parse-stringify": ["html-parse-stringify@3.0.1", "", { "dependencies": { "void-elements": "3.1.0" } }, "sha512-KknJ50kTInJ7qIScF3jeaFRpMpE8/lfiTdzf/twXyPBLAGrLRTmkz3AdTnKeh40X8k9L2fdYwEp/42WGXIRGcg=="],
|
||||
@@ -720,15 +737,15 @@
|
||||
|
||||
"inline-style-parser": ["inline-style-parser@0.2.7", "", {}, "sha512-Nb2ctOyNR8DqQoR0OwRG95uNWIC0C1lCgf5Naz5H6Ji72KZ8OcFZLz2P5sNgwlyoJ8Yif11oMuYs5pBQa86csA=="],
|
||||
|
||||
"is-alphabetical": ["is-alphabetical@1.0.4", "", {}, "sha512-DwzsA04LQ10FHTZuL0/grVDk4rFoVH1pjAToYwBrHSxcrBIGQuXrQMtD5U1b0U2XVgKZCTLLP8u2Qxqhy3l2Vg=="],
|
||||
"is-alphabetical": ["is-alphabetical@2.0.1", "", {}, "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ=="],
|
||||
|
||||
"is-alphanumerical": ["is-alphanumerical@1.0.4", "", { "dependencies": { "is-alphabetical": "^1.0.0", "is-decimal": "^1.0.0" } }, "sha512-UzoZUr+XfVz3t3v4KyGEniVL9BDRoQtY7tOyrRybkVNjDFWyo1yhXNGrrBTQxp3ib9BLAWs7k2YKBQsFRkZG9A=="],
|
||||
"is-alphanumerical": ["is-alphanumerical@2.0.1", "", { "dependencies": { "is-alphabetical": "^2.0.0", "is-decimal": "^2.0.0" } }, "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw=="],
|
||||
|
||||
"is-binary-path": ["is-binary-path@2.1.0", "", { "dependencies": { "binary-extensions": "^2.0.0" } }, "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw=="],
|
||||
|
||||
"is-core-module": ["is-core-module@2.16.1", "", { "dependencies": { "hasown": "^2.0.2" } }, "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w=="],
|
||||
|
||||
"is-decimal": ["is-decimal@1.0.4", "", {}, "sha512-RGdriMmQQvZ2aqaQq3awNA6dCGtKpiDFcOzrTWrDAT2MiWrKQVPmxLGHl7Y2nNu6led0kEyoX0enY0qXYsv9zw=="],
|
||||
"is-decimal": ["is-decimal@2.0.1", "", {}, "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A=="],
|
||||
|
||||
"is-extglob": ["is-extglob@2.1.1", "", {}, "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ=="],
|
||||
|
||||
@@ -736,7 +753,7 @@
|
||||
|
||||
"is-glob": ["is-glob@4.0.3", "", { "dependencies": { "is-extglob": "^2.1.1" } }, "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg=="],
|
||||
|
||||
"is-hexadecimal": ["is-hexadecimal@1.0.4", "", {}, "sha512-gyPJuv83bHMpocVYoqof5VDiZveEoGoFL8m3BXNb2VW8Xs+rz9kqO8LOQ5DH6EsuvilT1ApazU0pyl+ytbPtlw=="],
|
||||
"is-hexadecimal": ["is-hexadecimal@2.0.1", "", {}, "sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg=="],
|
||||
|
||||
"is-number": ["is-number@7.0.0", "", {}, "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="],
|
||||
|
||||
@@ -786,10 +803,10 @@
|
||||
|
||||
"loupe": ["loupe@3.2.1", "", {}, "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ=="],
|
||||
|
||||
"lowlight": ["lowlight@1.20.0", "", { "dependencies": { "fault": "^1.0.0", "highlight.js": "~10.7.0" } }, "sha512-8Ktj+prEb1RoCPkEOrPMYUN/nCggB7qAWe3a7OpMjWQkh3l2RD5wKRQ+o8Q8YuI9RG/xs95waaI/E6ym/7NsTw=="],
|
||||
|
||||
"lru-cache": ["lru-cache@5.1.1", "", { "dependencies": { "yallist": "^3.0.2" } }, "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w=="],
|
||||
|
||||
"lru_map": ["lru_map@0.4.1", "", {}, "sha512-I+lBvqMMFfqaV8CJCISjI3wbjmwVu/VyOoU7+qtu9d7ioW5klMgsTTiUOUp+DJvfTTzKXoPbyC6YfgkNcyPSOg=="],
|
||||
|
||||
"lucide-react": ["lucide-react@0.469.0", "", { "peerDependencies": { "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-28vvUnnKQ/dBwiCQtwJw7QauYnE7yd2Cyp4tTTJpvglX4EMpbflcdBgrgToX2j71B3YvugK/NH3BGUk+E/p/Fw=="],
|
||||
|
||||
"lz-string": ["lz-string@1.5.0", "", { "bin": { "lz-string": "bin/bin.js" } }, "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ=="],
|
||||
@@ -936,6 +953,10 @@
|
||||
|
||||
"object-hash": ["object-hash@3.0.0", "", {}, "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw=="],
|
||||
|
||||
"oniguruma-parser": ["oniguruma-parser@0.12.2", "", {}, "sha512-6HVa5oIrgMC6aA6WF6XyyqbhRPJrKR02L20+2+zpDtO5QAzGHAUGw5TKQvwi5vctNnRHkJYmjAhRVQF2EKdTQw=="],
|
||||
|
||||
"oniguruma-to-es": ["oniguruma-to-es@4.3.6", "", { "dependencies": { "oniguruma-parser": "^0.12.2", "regex": "^6.1.0", "regex-recursion": "^6.0.2" } }, "sha512-csuQ9x3Yr0cEIs/Zgx/OEt9iBw9vqIunAPQkx19R/fiMq2oGVTgcMqO/V3Ybqefr1TBvosI6jU539ksaBULJyA=="],
|
||||
|
||||
"optionator": ["optionator@0.9.4", "", { "dependencies": { "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", "levn": "^0.4.1", "prelude-ls": "^1.2.1", "type-check": "^0.4.0", "word-wrap": "^1.2.5" } }, "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g=="],
|
||||
|
||||
"p-limit": ["p-limit@3.1.0", "", { "dependencies": { "yocto-queue": "^0.1.0" } }, "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ=="],
|
||||
@@ -946,7 +967,7 @@
|
||||
|
||||
"package-json-from-dist": ["package-json-from-dist@1.0.1", "", {}, "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw=="],
|
||||
|
||||
"parse-entities": ["parse-entities@2.0.0", "", { "dependencies": { "character-entities": "^1.0.0", "character-entities-legacy": "^1.0.0", "character-reference-invalid": "^1.0.0", "is-alphanumerical": "^1.0.0", "is-decimal": "^1.0.0", "is-hexadecimal": "^1.0.0" } }, "sha512-kkywGpCcRYhqQIchaWqZ875wzpS/bMKhz5HnN3p7wveJTkTtyAB/AlnS0f8DFSqYW1T82t6yEAkEcB+A1I3MbQ=="],
|
||||
"parse-entities": ["parse-entities@4.0.2", "", { "dependencies": { "@types/unist": "^2.0.0", "character-entities-legacy": "^3.0.0", "character-reference-invalid": "^2.0.0", "decode-named-character-reference": "^1.0.0", "is-alphanumerical": "^2.0.0", "is-decimal": "^2.0.0", "is-hexadecimal": "^2.0.0" } }, "sha512-GG2AQYWoLgL877gQIKeRPGO1xF9+eG1ujIb5soS5gPvLQ1y2o8FL90w2QWNdf9I361Mpp7726c+lj3U0qK1uGw=="],
|
||||
|
||||
"parse5": ["parse5@7.3.0", "", { "dependencies": { "entities": "^6.0.0" } }, "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw=="],
|
||||
|
||||
@@ -996,8 +1017,6 @@
|
||||
|
||||
"pretty-format": ["pretty-format@27.5.1", "", { "dependencies": { "ansi-regex": "^5.0.1", "ansi-styles": "^5.0.0", "react-is": "^17.0.1" } }, "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ=="],
|
||||
|
||||
"prismjs": ["prismjs@1.30.0", "", {}, "sha512-DEvV2ZF2r2/63V+tK8hQvrR2ZGn10srHbXviTlcv7Kpzw8jWiNTqbVgjO3IY8RxrrOUF8VPMQQFysYYYv0YZxw=="],
|
||||
|
||||
"property-information": ["property-information@7.1.0", "", {}, "sha512-TwEZ+X+yCJmYfL7TPUOcvBZ4QfoT5YenQiJuX//0th53DE6w0xxLEtfK3iyryQFddXuvkIk51EEgrJQ0WJkOmQ=="],
|
||||
|
||||
"punycode": ["punycode@2.3.1", "", {}, "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg=="],
|
||||
@@ -1022,15 +1041,17 @@
|
||||
|
||||
"react-style-singleton": ["react-style-singleton@2.2.3", "", { "dependencies": { "get-nonce": "^1.0.0", "tslib": "^2.0.0" }, "peerDependencies": { "@types/react": "*", "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-b6jSvxvVnyptAiLjbkWLE/lOnR4lfTtDAl+eUC7RZy+QQWc6wRzIV2CE6xBuMmDxc2qIihtDCZD5NPOFl7fRBQ=="],
|
||||
|
||||
"react-syntax-highlighter": ["react-syntax-highlighter@15.6.6", "", { "dependencies": { "@babel/runtime": "^7.3.1", "highlight.js": "^10.4.1", "highlightjs-vue": "^1.0.0", "lowlight": "^1.17.0", "prismjs": "^1.30.0", "refractor": "^3.6.0" }, "peerDependencies": { "react": ">= 0.14.0" } }, "sha512-DgXrc+AZF47+HvAPEmn7Ua/1p10jNoVZVI/LoPiYdtY+OM+/nG5yefLHKJwdKqY1adMuHFbeyBaG9j64ML7vTw=="],
|
||||
|
||||
"read-cache": ["read-cache@1.0.0", "", { "dependencies": { "pify": "^2.3.0" } }, "sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA=="],
|
||||
|
||||
"readdirp": ["readdirp@3.6.0", "", { "dependencies": { "picomatch": "^2.2.1" } }, "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA=="],
|
||||
|
||||
"redent": ["redent@3.0.0", "", { "dependencies": { "indent-string": "^4.0.0", "strip-indent": "^3.0.0" } }, "sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg=="],
|
||||
|
||||
"refractor": ["refractor@3.6.0", "", { "dependencies": { "hastscript": "^6.0.0", "parse-entities": "^2.0.0", "prismjs": "~1.27.0" } }, "sha512-MY9W41IOWxxk31o+YvFCNyNzdkc9M20NoZK5vq6jkv4I/uh2zkWcfudj0Q1fovjUQJrNewS9NMzeTtqPf+n5EA=="],
|
||||
"regex": ["regex@6.1.0", "", { "dependencies": { "regex-utilities": "^2.3.0" } }, "sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg=="],
|
||||
|
||||
"regex-recursion": ["regex-recursion@6.0.2", "", { "dependencies": { "regex-utilities": "^2.3.0" } }, "sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg=="],
|
||||
|
||||
"regex-utilities": ["regex-utilities@2.3.0", "", {}, "sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng=="],
|
||||
|
||||
"rehype-harden": ["rehype-harden@1.1.8", "", { "dependencies": { "unist-util-visit": "^5.0.0" } }, "sha512-Qn7vR1xrf6fZCrkm9TDWi/AB4ylrHy+jqsNm1EHOAmbARYA6gsnVJBq/sdBh6kmT4NEZxH5vgIjrscefJAOXcw=="],
|
||||
|
||||
@@ -1080,6 +1101,8 @@
|
||||
|
||||
"shebang-regex": ["shebang-regex@3.0.0", "", {}, "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A=="],
|
||||
|
||||
"shiki": ["shiki@4.6.0", "", { "dependencies": { "@shikijs/core": "4.6.0", "@shikijs/engine-javascript": "4.6.0", "@shikijs/engine-oniguruma": "4.6.0", "@shikijs/langs": "4.6.0", "@shikijs/themes": "4.6.0", "@shikijs/types": "4.6.0", "@shikijs/vscode-textmate": "^10.1.0", "@types/hast": "^3.0.5" } }, "sha512-imjLsVHgPuWhvpU3P+zOekvMYqnel7QmKsFC4Sn0fCuAvaaalBsxwKEsrU8Ko5BdFnZA6Go/8a0RzahS634UgA=="],
|
||||
|
||||
"siginfo": ["siginfo@2.0.0", "", {}, "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g=="],
|
||||
|
||||
"signal-exit": ["signal-exit@4.1.0", "", {}, "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw=="],
|
||||
@@ -1222,8 +1245,6 @@
|
||||
|
||||
"xmlchars": ["xmlchars@2.2.0", "", {}, "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw=="],
|
||||
|
||||
"xtend": ["xtend@4.0.2", "", {}, "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ=="],
|
||||
|
||||
"y18n": ["y18n@4.0.3", "", {}, "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ=="],
|
||||
|
||||
"yallist": ["yallist@3.1.1", "", {}, "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g=="],
|
||||
@@ -1264,6 +1285,14 @@
|
||||
|
||||
"@radix-ui/react-tooltip/@radix-ui/react-slot": ["@radix-ui/react-slot@1.2.3", "", { "dependencies": { "@radix-ui/react-compose-refs": "1.1.2" }, "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A=="],
|
||||
|
||||
"@shikijs/core/@types/hast": ["@types/hast@3.0.5", "", { "dependencies": { "@types/unist": "*" } }, "sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g=="],
|
||||
|
||||
"@shikijs/core/hast-util-to-html": ["hast-util-to-html@9.0.6", "", { "dependencies": { "@types/hast": "^3.0.0", "@types/unist": "^3.0.0", "ccount": "^2.0.0", "comma-separated-tokens": "^2.0.0", "hast-util-whitespace": "^3.0.0", "html-void-elements": "^3.0.0", "mdast-util-to-hast": "^13.0.0", "property-information": "^7.0.0", "space-separated-tokens": "^2.0.0", "stringify-entities": "^4.0.0", "zwitch": "^2.0.4" } }, "sha512-1SZUxCN3TtJAE7e2BQN2MBHsoZ1gnmi9GoCP5Di59CSWptIezSAW09yDZyVbanb78V9eCwrKqdQsjtfVTxYHWA=="],
|
||||
|
||||
"@shikijs/primitive/@types/hast": ["@types/hast@3.0.5", "", { "dependencies": { "@types/unist": "*" } }, "sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g=="],
|
||||
|
||||
"@shikijs/types/@types/hast": ["@types/hast@3.0.5", "", { "dependencies": { "@types/unist": "*" } }, "sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g=="],
|
||||
|
||||
"@testing-library/dom/aria-query": ["aria-query@5.3.0", "", { "dependencies": { "dequal": "^2.0.3" } }, "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A=="],
|
||||
|
||||
"@testing-library/dom/dom-accessibility-api": ["dom-accessibility-api@0.5.16", "", {}, "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg=="],
|
||||
@@ -1278,18 +1307,6 @@
|
||||
|
||||
"glob/minimatch": ["minimatch@9.0.9", "", { "dependencies": { "brace-expansion": "^2.0.2" } }, "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg=="],
|
||||
|
||||
"hast-util-from-dom/hastscript": ["hastscript@9.0.1", "", { "dependencies": { "@types/hast": "^3.0.0", "comma-separated-tokens": "^2.0.0", "hast-util-parse-selector": "^4.0.0", "property-information": "^7.0.0", "space-separated-tokens": "^2.0.0" } }, "sha512-g7df9rMFX/SPi34tyGCyUBREQoKkapwdY/T04Qn9TDWfHhAYt4/I0gMVirzK5wEzeUqIjEB+LXC/ypb7Aqno5w=="],
|
||||
|
||||
"hast-util-from-parse5/hastscript": ["hastscript@9.0.1", "", { "dependencies": { "@types/hast": "^3.0.0", "comma-separated-tokens": "^2.0.0", "hast-util-parse-selector": "^4.0.0", "property-information": "^7.0.0", "space-separated-tokens": "^2.0.0" } }, "sha512-g7df9rMFX/SPi34tyGCyUBREQoKkapwdY/T04Qn9TDWfHhAYt4/I0gMVirzK5wEzeUqIjEB+LXC/ypb7Aqno5w=="],
|
||||
|
||||
"hastscript/@types/hast": ["@types/hast@2.3.10", "", { "dependencies": { "@types/unist": "^2" } }, "sha512-McWspRw8xx8J9HurkVBfYj0xKoE25tOFlHGdx4MJ5xORQrMGZNqJhVQWaIbm6Oyla5kYOXtDiopzKRJzEOkwJw=="],
|
||||
|
||||
"hastscript/comma-separated-tokens": ["comma-separated-tokens@1.0.8", "", {}, "sha512-GHuDRO12Sypu2cV70d1dkA2EUmXHgntrzbpvOB+Qy+49ypNfGgFQIC2fhhXbnyrJRynDCAARsT7Ou0M6hirpfw=="],
|
||||
|
||||
"hastscript/property-information": ["property-information@5.6.0", "", { "dependencies": { "xtend": "^4.0.0" } }, "sha512-YUHSPk+A30YPv+0Qf8i9Mbfe/C0hdPXk1s1jPVToV8pk8BQtpw10ct89Eo7OWkutrwqvT0eicAxlOg3dOAu8JA=="],
|
||||
|
||||
"hastscript/space-separated-tokens": ["space-separated-tokens@1.1.5", "", {}, "sha512-q/JSVd1Lptzhf5bkYm4ob4iWPjx0KiRe3sRFBNrVqbJkFaBm5vbbowy1mymoPNLRa52+oadOhJ+K49wsSeSjTA=="],
|
||||
|
||||
"make-dir/semver": ["semver@7.8.5", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA=="],
|
||||
|
||||
"mdast-util-find-and-replace/escape-string-regexp": ["escape-string-regexp@5.0.0", "", {}, "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw=="],
|
||||
@@ -1310,26 +1327,22 @@
|
||||
|
||||
"mdast-util-mdx-jsx/mdast-util-to-markdown": ["mdast-util-to-markdown@2.1.2", "", { "dependencies": { "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", "longest-streak": "^3.0.0", "mdast-util-phrasing": "^4.0.0", "mdast-util-to-string": "^4.0.0", "micromark-util-classify-character": "^2.0.0", "micromark-util-decode-string": "^2.0.0", "unist-util-visit": "^5.0.0", "zwitch": "^2.0.0" } }, "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA=="],
|
||||
|
||||
"mdast-util-mdx-jsx/parse-entities": ["parse-entities@4.0.2", "", { "dependencies": { "@types/unist": "^2.0.0", "character-entities-legacy": "^3.0.0", "character-reference-invalid": "^2.0.0", "decode-named-character-reference": "^1.0.0", "is-alphanumerical": "^2.0.0", "is-decimal": "^2.0.0", "is-hexadecimal": "^2.0.0" } }, "sha512-GG2AQYWoLgL877gQIKeRPGO1xF9+eG1ujIb5soS5gPvLQ1y2o8FL90w2QWNdf9I361Mpp7726c+lj3U0qK1uGw=="],
|
||||
|
||||
"mdast-util-mdxjs-esm/mdast-util-to-markdown": ["mdast-util-to-markdown@2.1.2", "", { "dependencies": { "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", "longest-streak": "^3.0.0", "mdast-util-phrasing": "^4.0.0", "mdast-util-to-string": "^4.0.0", "micromark-util-classify-character": "^2.0.0", "micromark-util-decode-string": "^2.0.0", "unist-util-visit": "^5.0.0", "zwitch": "^2.0.0" } }, "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA=="],
|
||||
|
||||
"parse-entities/character-entities": ["character-entities@1.2.4", "", {}, "sha512-iBMyeEHxfVnIakwOuDXpVkc54HijNgCyQB2w0VfGQThle6NXn50zU6V/u+LDhxHcDUPojn6Kpga3PTAD8W1bQw=="],
|
||||
"parse-entities/@types/unist": ["@types/unist@2.0.11", "", {}, "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA=="],
|
||||
|
||||
"path-scurry/lru-cache": ["lru-cache@10.4.3", "", {}, "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ=="],
|
||||
|
||||
"postcss-nested/postcss-selector-parser": ["postcss-selector-parser@6.1.2", "", { "dependencies": { "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" } }, "sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg=="],
|
||||
|
||||
"refractor/prismjs": ["prismjs@1.27.0", "", {}, "sha512-t13BGPUlFDR7wRB5kQDG4jjl7XeuH6jbJGt11JHPL96qwsEHNX2+68tFXqc1/k+/jALsbSWJKUOT/hcYAZ5LkA=="],
|
||||
|
||||
"remark-stringify/mdast-util-to-markdown": ["mdast-util-to-markdown@2.1.2", "", { "dependencies": { "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", "longest-streak": "^3.0.0", "mdast-util-phrasing": "^4.0.0", "mdast-util-to-string": "^4.0.0", "micromark-util-classify-character": "^2.0.0", "micromark-util-decode-string": "^2.0.0", "unist-util-visit": "^5.0.0", "zwitch": "^2.0.0" } }, "sha512-xj68wMTvGXVOKonmog6LwyJKrYXZPvlwabaryTjLh9LuvovB/KAH+kvi8Gjj+7rJjsFi23nkUxRQv1KqSroMqA=="],
|
||||
|
||||
"shiki/@types/hast": ["@types/hast@3.0.5", "", { "dependencies": { "@types/unist": "*" } }, "sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g=="],
|
||||
|
||||
"streamdown/remend": ["remend@1.3.1", "", {}, "sha512-N3DiY5qbRPoa5vkxn1oDLMyXOVTeo6Hp+XOj6SIqJAYUgLS0Q587gILPMom/qm86AQ/ZrcOdwEIzCz8V3J0nxQ=="],
|
||||
|
||||
"streamdown/tailwind-merge": ["tailwind-merge@3.6.0", "", {}, "sha512-uxL7qAVQriqRQPAyK3pj66VqskWqoZ37PW94jwOTwNfq/z9oyu1V+eqrZqtR2+fCiXdYOZe/Modt8GtvqNzu+w=="],
|
||||
|
||||
"stringify-entities/character-entities-legacy": ["character-entities-legacy@3.0.0", "", {}, "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ=="],
|
||||
|
||||
"sucrase/commander": ["commander@4.1.1", "", {}, "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA=="],
|
||||
|
||||
"tailwindcss/postcss-selector-parser": ["postcss-selector-parser@6.1.2", "", { "dependencies": { "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" } }, "sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg=="],
|
||||
@@ -1350,30 +1363,10 @@
|
||||
|
||||
"glob/minimatch/brace-expansion": ["brace-expansion@2.1.4", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg=="],
|
||||
|
||||
"hast-util-from-dom/hastscript/hast-util-parse-selector": ["hast-util-parse-selector@4.0.0", "", { "dependencies": { "@types/hast": "^3.0.0" } }, "sha512-wkQCkSYoOGCRKERFWcxMVMOcYE2K1AaNLU8DXS9arxnLOUEWbOXKXiJUNzEpqZ3JOKpnha3jkFrumEjVliDe7A=="],
|
||||
|
||||
"hast-util-from-parse5/hastscript/hast-util-parse-selector": ["hast-util-parse-selector@4.0.0", "", { "dependencies": { "@types/hast": "^3.0.0" } }, "sha512-wkQCkSYoOGCRKERFWcxMVMOcYE2K1AaNLU8DXS9arxnLOUEWbOXKXiJUNzEpqZ3JOKpnha3jkFrumEjVliDe7A=="],
|
||||
|
||||
"hastscript/@types/hast/@types/unist": ["@types/unist@2.0.11", "", {}, "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA=="],
|
||||
|
||||
"mdast-util-mdx-jsx/parse-entities/@types/unist": ["@types/unist@2.0.11", "", {}, "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA=="],
|
||||
|
||||
"mdast-util-mdx-jsx/parse-entities/character-entities-legacy": ["character-entities-legacy@3.0.0", "", {}, "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ=="],
|
||||
|
||||
"mdast-util-mdx-jsx/parse-entities/character-reference-invalid": ["character-reference-invalid@2.0.1", "", {}, "sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw=="],
|
||||
|
||||
"mdast-util-mdx-jsx/parse-entities/is-alphanumerical": ["is-alphanumerical@2.0.1", "", { "dependencies": { "is-alphabetical": "^2.0.0", "is-decimal": "^2.0.0" } }, "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw=="],
|
||||
|
||||
"mdast-util-mdx-jsx/parse-entities/is-decimal": ["is-decimal@2.0.1", "", {}, "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A=="],
|
||||
|
||||
"mdast-util-mdx-jsx/parse-entities/is-hexadecimal": ["is-hexadecimal@2.0.1", "", {}, "sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg=="],
|
||||
|
||||
"yargs/find-up/locate-path": ["locate-path@5.0.0", "", { "dependencies": { "p-locate": "^4.1.0" } }, "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g=="],
|
||||
|
||||
"glob/minimatch/brace-expansion/balanced-match": ["balanced-match@1.0.2", "", {}, "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="],
|
||||
|
||||
"mdast-util-mdx-jsx/parse-entities/is-alphanumerical/is-alphabetical": ["is-alphabetical@2.0.1", "", {}, "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ=="],
|
||||
|
||||
"yargs/find-up/locate-path/p-locate": ["p-locate@4.1.0", "", { "dependencies": { "p-limit": "^2.2.0" } }, "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A=="],
|
||||
|
||||
"yargs/find-up/locate-path/p-locate/p-limit": ["p-limit@2.3.0", "", { "dependencies": { "p-try": "^2.0.0" } }, "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w=="],
|
||||
|
||||
Generated
+282
-229
@@ -8,6 +8,8 @@
|
||||
"name": "nanobot-webui",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"@pierre/diffs": "1.6.4",
|
||||
"@pierre/highlights": "0.4.0",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.4",
|
||||
"@radix-ui/react-dialog": "^1.1.4",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.4",
|
||||
@@ -31,7 +33,6 @@
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-i18next": "^17.0.4",
|
||||
"react-syntax-highlighter": "^15.6.1",
|
||||
"rehype-katex": "^7.0.1",
|
||||
"remark-breaks": "^4.0.0",
|
||||
"remark-cjk-friendly": "2.3.3",
|
||||
@@ -40,6 +41,7 @@
|
||||
"remark-parse": "^11.0.0",
|
||||
"remend": "1.3.0",
|
||||
"saxes": "6.0.0",
|
||||
"shiki": "4.6.0",
|
||||
"streamdown": "2.6.0",
|
||||
"tailwind-merge": "^2.6.0",
|
||||
"unified": "^11.0.5"
|
||||
@@ -58,7 +60,6 @@
|
||||
"@types/qrcode": "^1.5.6",
|
||||
"@types/react": "^18.3.18",
|
||||
"@types/react-dom": "^18.3.5",
|
||||
"@types/react-syntax-highlighter": "^15.5.13",
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"@vitest/coverage-v8": "2.1.9",
|
||||
"autoprefixer": "^10.4.20",
|
||||
@@ -1165,6 +1166,78 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/@pierre/diffs": {
|
||||
"version": "1.6.4",
|
||||
"resolved": "https://registry.npmjs.org/@pierre/diffs/-/diffs-1.6.4.tgz",
|
||||
"integrity": "sha512-RsKoruCOp50qaDM3a7BQan5K77xMkGWT1NF01fiYP1PfT3v4CvIjwytNk5WjZG0BesBkMOP2UbrBIDigB1k0ug==",
|
||||
"license": "apache-2.0",
|
||||
"dependencies": {
|
||||
"@pierre/highlights": "0.4.0",
|
||||
"@pierre/theme": "2.0.0",
|
||||
"@pierre/theming": "1.0.2",
|
||||
"diff": "9.0.0",
|
||||
"hast-util-to-html": "9.0.5",
|
||||
"lru_map": "0.4.1",
|
||||
"shiki": "^3.0.0 || ^4.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^18.3.1 || ^19.0.0",
|
||||
"react-dom": "^18.3.1 || ^19.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"react": {
|
||||
"optional": true
|
||||
},
|
||||
"react-dom": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@pierre/highlights": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@pierre/highlights/-/highlights-0.4.0.tgz",
|
||||
"integrity": "sha512-2a38H7ep3KweGi1fGQpJk+Krod2OMpDIXagKPlqBd1Y9P460T7zQmc66Wm2JAH1SpIG93wCyyhZVrkc5dnAJVQ==",
|
||||
"license": "apache-2.0"
|
||||
},
|
||||
"node_modules/@pierre/theme": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@pierre/theme/-/theme-2.0.0.tgz",
|
||||
"integrity": "sha512-yNDd9GYLQl1mEUJR8AneJ5e4ohLIHQd/wZLWr4fagt78vS2RwwZNW530vVgHqXFAyFVcFlRmGUD5ramXH46OXw==",
|
||||
"license": "apache-2.0",
|
||||
"engines": {
|
||||
"vscode": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@pierre/theming": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@pierre/theming/-/theming-1.0.2.tgz",
|
||||
"integrity": "sha512-RmXLLqtx31UGcR8kZyO5hGAQ1EXz6loT1Cu0BFAGsbnBboIxp2BlomkLfWyvdT4WZXnBGyu25onL1gKpFQuSUw==",
|
||||
"license": "apache-2.0",
|
||||
"peerDependencies": {
|
||||
"@pierre/theme": "^1.1.0 || ^2.0.0",
|
||||
"@shikijs/themes": "^3.0.0 || ^4.0.0",
|
||||
"react": "^18.3.1 || ^19.0.0",
|
||||
"react-dom": "^18.3.1 || ^19.0.0",
|
||||
"shiki": "^3.0.0 || ^4.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@pierre/theme": {
|
||||
"optional": true
|
||||
},
|
||||
"@shikijs/themes": {
|
||||
"optional": true
|
||||
},
|
||||
"react": {
|
||||
"optional": true
|
||||
},
|
||||
"react-dom": {
|
||||
"optional": true
|
||||
},
|
||||
"shiki": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@pkgjs/parseargs": {
|
||||
"version": "0.11.0",
|
||||
"resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
|
||||
@@ -2370,6 +2443,129 @@
|
||||
"win32"
|
||||
]
|
||||
},
|
||||
"node_modules/@shikijs/core": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@shikijs/core/-/core-4.6.0.tgz",
|
||||
"integrity": "sha512-bfd4OKgvoyXYiYmMRuleA656P4V7M/Du9lcTl38Ngm6KszMj7bq4J1IGZwSYR4c95Tv5UQALtYNWUwaI9UT3xw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@shikijs/primitive": "4.6.0",
|
||||
"@shikijs/types": "4.6.0",
|
||||
"@shikijs/vscode-textmate": "^10.1.0",
|
||||
"@types/hast": "^3.0.5",
|
||||
"hast-util-to-html": "^9.0.6"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/@shikijs/core/node_modules/hast-util-to-html": {
|
||||
"version": "9.0.6",
|
||||
"resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.6.tgz",
|
||||
"integrity": "sha512-1SZUxCN3TtJAE7e2BQN2MBHsoZ1gnmi9GoCP5Di59CSWptIezSAW09yDZyVbanb78V9eCwrKqdQsjtfVTxYHWA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/hast": "^3.0.0",
|
||||
"@types/unist": "^3.0.0",
|
||||
"ccount": "^2.0.0",
|
||||
"comma-separated-tokens": "^2.0.0",
|
||||
"hast-util-whitespace": "^3.0.0",
|
||||
"html-void-elements": "^3.0.0",
|
||||
"mdast-util-to-hast": "^13.0.0",
|
||||
"property-information": "^7.0.0",
|
||||
"space-separated-tokens": "^2.0.0",
|
||||
"stringify-entities": "^4.0.0",
|
||||
"zwitch": "^2.0.4"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
}
|
||||
},
|
||||
"node_modules/@shikijs/engine-javascript": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-4.6.0.tgz",
|
||||
"integrity": "sha512-K0oqxFoL+kEMdz89mHLFO15Tsbv3kFZ6WR1cXZKMvLSc+oqaM00A6pyga1qSeXB22dP0tTiSApRcGBaKWsEccg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@shikijs/types": "4.6.0",
|
||||
"@shikijs/vscode-textmate": "^10.1.0",
|
||||
"oniguruma-to-es": "^4.3.6"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/@shikijs/engine-oniguruma": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-4.6.0.tgz",
|
||||
"integrity": "sha512-aggd6Q7SuJOXNnsUbfG2XesxBJKBMAw/PDTUo9PyRjMaaJJ2dNrI+q0C+25ARXAK9yLHAlwxc9oRT2u68YKZ7w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@shikijs/types": "4.6.0",
|
||||
"@shikijs/vscode-textmate": "^10.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/@shikijs/langs": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-4.6.0.tgz",
|
||||
"integrity": "sha512-1yMEX3oCVV54LUq/ovfpRkDQoYDkcvjSWFFa/YLUDMiSoRzMi2uxLJYbv41ahT8Lu9lFMaa7hecd3Q39trqUyg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@shikijs/types": "4.6.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/@shikijs/primitive": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@shikijs/primitive/-/primitive-4.6.0.tgz",
|
||||
"integrity": "sha512-c54+TQEo9ToqgfL/AU8FpjnV09+GA9Oa7M5ROkkXteZfp5XzpAJGXjjvZQFQioJOwm/w/6Z3lIzQstAkl8coag==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@shikijs/types": "4.6.0",
|
||||
"@shikijs/vscode-textmate": "^10.1.0",
|
||||
"@types/hast": "^3.0.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/@shikijs/themes": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-4.6.0.tgz",
|
||||
"integrity": "sha512-qHAVAs80RiGD+IRuH9G+JPDOEc9A/kHsng4EzCUCwB9bLzW6Z0y9WETh2YyCcADJBmfrIaJ1Jp7KBNP6FHkgtQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@shikijs/types": "4.6.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/@shikijs/types": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@shikijs/types/-/types-4.6.0.tgz",
|
||||
"integrity": "sha512-+ENG1adsKt/X7cRYw1Nl7BEpBmPOjmQ7bR/eGmHuMlT8gtOFf3KEi5l31DJYyAWhW6Y6bjP1plU7FmaxWGENFw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@shikijs/vscode-textmate": "^10.1.0",
|
||||
"@types/hast": "^3.0.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/@shikijs/vscode-textmate": {
|
||||
"version": "10.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-10.1.0.tgz",
|
||||
"integrity": "sha512-cVBuhDQjBZaNMTwBquYfPydrUP+E3hE6oYGasx8h6ZrODIM7/r+gxLDXdd66oszbrggZHEntdE6j+5gYIVyMWQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@tailwindcss/typography": {
|
||||
"version": "0.5.19",
|
||||
"dev": true,
|
||||
@@ -2554,7 +2750,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/hast": {
|
||||
"version": "3.0.4",
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.5.tgz",
|
||||
"integrity": "sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/unist": "*"
|
||||
@@ -2624,14 +2822,6 @@
|
||||
"@types/react": "^18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/react-syntax-highlighter": {
|
||||
"version": "15.5.13",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/react": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/unist": {
|
||||
"version": "3.0.3",
|
||||
"license": "MIT"
|
||||
@@ -3352,14 +3542,6 @@
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/character-entities": {
|
||||
"version": "1.2.4",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/character-entities-html4": {
|
||||
"version": "2.1.0",
|
||||
"license": "MIT",
|
||||
@@ -3368,22 +3550,6 @@
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/character-entities-legacy": {
|
||||
"version": "1.1.4",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/character-reference-invalid": {
|
||||
"version": "1.1.4",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/check-error": {
|
||||
"version": "2.1.3",
|
||||
"dev": true,
|
||||
@@ -4056,17 +4222,6 @@
|
||||
"reusify": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/fault": {
|
||||
"version": "1.0.4",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"format": "^0.2.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/fdir": {
|
||||
"version": "6.5.0",
|
||||
"dev": true,
|
||||
@@ -4162,12 +4317,6 @@
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/format": {
|
||||
"version": "0.2.2",
|
||||
"engines": {
|
||||
"node": ">=0.4.x"
|
||||
}
|
||||
},
|
||||
"node_modules/fraction.js": {
|
||||
"version": "5.3.4",
|
||||
"dev": true,
|
||||
@@ -4497,14 +4646,6 @@
|
||||
"url": "https://opencollective.com/unified"
|
||||
}
|
||||
},
|
||||
"node_modules/hast-util-parse-selector": {
|
||||
"version": "2.2.5",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
}
|
||||
},
|
||||
"node_modules/hast-util-raw": {
|
||||
"version": "9.1.0",
|
||||
"resolved": "https://registry.npmjs.org/hast-util-raw/-/hast-util-raw-9.1.0.tgz",
|
||||
@@ -4545,6 +4686,29 @@
|
||||
"url": "https://opencollective.com/unified"
|
||||
}
|
||||
},
|
||||
"node_modules/hast-util-to-html": {
|
||||
"version": "9.0.5",
|
||||
"resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.5.tgz",
|
||||
"integrity": "sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/hast": "^3.0.0",
|
||||
"@types/unist": "^3.0.0",
|
||||
"ccount": "^2.0.0",
|
||||
"comma-separated-tokens": "^2.0.0",
|
||||
"hast-util-whitespace": "^3.0.0",
|
||||
"html-void-elements": "^3.0.0",
|
||||
"mdast-util-to-hast": "^13.0.0",
|
||||
"property-information": "^7.0.0",
|
||||
"space-separated-tokens": "^2.0.0",
|
||||
"stringify-entities": "^4.0.0",
|
||||
"zwitch": "^2.0.4"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
}
|
||||
},
|
||||
"node_modules/hast-util-to-jsx-runtime": {
|
||||
"version": "2.3.6",
|
||||
"license": "MIT",
|
||||
@@ -4614,59 +4778,6 @@
|
||||
"url": "https://opencollective.com/unified"
|
||||
}
|
||||
},
|
||||
"node_modules/hastscript": {
|
||||
"version": "6.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/hast": "^2.0.0",
|
||||
"comma-separated-tokens": "^1.0.0",
|
||||
"hast-util-parse-selector": "^2.0.0",
|
||||
"property-information": "^5.0.0",
|
||||
"space-separated-tokens": "^1.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
}
|
||||
},
|
||||
"node_modules/hastscript/node_modules/@types/hast": {
|
||||
"version": "2.3.10",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/unist": "^2"
|
||||
}
|
||||
},
|
||||
"node_modules/hastscript/node_modules/@types/hast/node_modules/@types/unist": {
|
||||
"version": "2.0.11",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/hastscript/node_modules/comma-separated-tokens": {
|
||||
"version": "1.0.8",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/hastscript/node_modules/property-information": {
|
||||
"version": "5.6.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"xtend": "^4.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/hastscript/node_modules/space-separated-tokens": {
|
||||
"version": "1.1.5",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/hermes-estree": {
|
||||
"version": "0.25.1",
|
||||
"resolved": "https://registry.npmjs.org/hermes-estree/-/hermes-estree-0.25.1.tgz",
|
||||
@@ -4684,17 +4795,6 @@
|
||||
"hermes-estree": "0.25.1"
|
||||
}
|
||||
},
|
||||
"node_modules/highlight.js": {
|
||||
"version": "10.7.3",
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/highlightjs-vue": {
|
||||
"version": "1.0.0",
|
||||
"license": "CC0-1.0"
|
||||
},
|
||||
"node_modules/html-escaper": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz",
|
||||
@@ -4792,26 +4892,6 @@
|
||||
"version": "0.2.7",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/is-alphabetical": {
|
||||
"version": "1.0.4",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/is-alphanumerical": {
|
||||
"version": "1.0.4",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"is-alphabetical": "^1.0.0",
|
||||
"is-decimal": "^1.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/is-binary-path": {
|
||||
"version": "2.1.0",
|
||||
"dev": true,
|
||||
@@ -4837,14 +4917,6 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-decimal": {
|
||||
"version": "1.0.4",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/is-extglob": {
|
||||
"version": "2.1.1",
|
||||
"dev": true,
|
||||
@@ -4873,14 +4945,6 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/is-hexadecimal": {
|
||||
"version": "1.0.4",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/is-number": {
|
||||
"version": "7.0.0",
|
||||
"dev": true,
|
||||
@@ -5124,17 +5188,11 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/lowlight": {
|
||||
"version": "1.20.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"fault": "^1.0.0",
|
||||
"highlight.js": "~10.7.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
"node_modules/lru_map": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/lru_map/-/lru_map-0.4.1.tgz",
|
||||
"integrity": "sha512-I+lBvqMMFfqaV8CJCISjI3wbjmwVu/VyOoU7+qtu9d7ioW5klMgsTTiUOUp+DJvfTTzKXoPbyC6YfgkNcyPSOg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/lru-cache": {
|
||||
"version": "5.1.1",
|
||||
@@ -6346,6 +6404,23 @@
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/oniguruma-parser": {
|
||||
"version": "0.12.2",
|
||||
"resolved": "https://registry.npmjs.org/oniguruma-parser/-/oniguruma-parser-0.12.2.tgz",
|
||||
"integrity": "sha512-6HVa5oIrgMC6aA6WF6XyyqbhRPJrKR02L20+2+zpDtO5QAzGHAUGw5TKQvwi5vctNnRHkJYmjAhRVQF2EKdTQw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/oniguruma-to-es": {
|
||||
"version": "4.3.6",
|
||||
"resolved": "https://registry.npmjs.org/oniguruma-to-es/-/oniguruma-to-es-4.3.6.tgz",
|
||||
"integrity": "sha512-csuQ9x3Yr0cEIs/Zgx/OEt9iBw9vqIunAPQkx19R/fiMq2oGVTgcMqO/V3Ybqefr1TBvosI6jU539ksaBULJyA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"oniguruma-parser": "^0.12.2",
|
||||
"regex": "^6.1.0",
|
||||
"regex-recursion": "^6.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/optionator": {
|
||||
"version": "0.9.4",
|
||||
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz",
|
||||
@@ -6412,22 +6487,6 @@
|
||||
"dev": true,
|
||||
"license": "BlueOak-1.0.0"
|
||||
},
|
||||
"node_modules/parse-entities": {
|
||||
"version": "2.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"character-entities": "^1.0.0",
|
||||
"character-entities-legacy": "^1.0.0",
|
||||
"character-reference-invalid": "^1.0.0",
|
||||
"is-alphanumerical": "^1.0.0",
|
||||
"is-decimal": "^1.0.0",
|
||||
"is-hexadecimal": "^1.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/parse5": {
|
||||
"version": "7.3.0",
|
||||
"license": "MIT",
|
||||
@@ -6765,13 +6824,6 @@
|
||||
"node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/prismjs": {
|
||||
"version": "1.30.0",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/property-information": {
|
||||
"version": "7.1.0",
|
||||
"license": "MIT",
|
||||
@@ -6951,21 +7003,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/react-syntax-highlighter": {
|
||||
"version": "15.6.6",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.3.1",
|
||||
"highlight.js": "^10.4.1",
|
||||
"highlightjs-vue": "^1.0.0",
|
||||
"lowlight": "^1.17.0",
|
||||
"prismjs": "^1.30.0",
|
||||
"refractor": "^3.6.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">= 0.14.0"
|
||||
}
|
||||
},
|
||||
"node_modules/read-cache": {
|
||||
"version": "1.0.0",
|
||||
"dev": true,
|
||||
@@ -7010,26 +7047,30 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/refractor": {
|
||||
"version": "3.6.0",
|
||||
"node_modules/regex": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/regex/-/regex-6.1.0.tgz",
|
||||
"integrity": "sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"hastscript": "^6.0.0",
|
||||
"parse-entities": "^2.0.0",
|
||||
"prismjs": "~1.27.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
"regex-utilities": "^2.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/refractor/node_modules/prismjs": {
|
||||
"version": "1.27.0",
|
||||
"node_modules/regex-recursion": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/regex-recursion/-/regex-recursion-6.0.2.tgz",
|
||||
"integrity": "sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
"dependencies": {
|
||||
"regex-utilities": "^2.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/regex-utilities": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/regex-utilities/-/regex-utilities-2.3.0.tgz",
|
||||
"integrity": "sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/rehype-harden": {
|
||||
"version": "1.1.8",
|
||||
"resolved": "https://registry.npmjs.org/rehype-harden/-/rehype-harden-1.1.8.tgz",
|
||||
@@ -7365,6 +7406,25 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/shiki": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/shiki/-/shiki-4.6.0.tgz",
|
||||
"integrity": "sha512-imjLsVHgPuWhvpU3P+zOekvMYqnel7QmKsFC4Sn0fCuAvaaalBsxwKEsrU8Ko5BdFnZA6Go/8a0RzahS634UgA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@shikijs/core": "4.6.0",
|
||||
"@shikijs/engine-javascript": "4.6.0",
|
||||
"@shikijs/engine-oniguruma": "4.6.0",
|
||||
"@shikijs/langs": "4.6.0",
|
||||
"@shikijs/themes": "4.6.0",
|
||||
"@shikijs/types": "4.6.0",
|
||||
"@shikijs/vscode-textmate": "^10.1.0",
|
||||
"@types/hast": "^3.0.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
}
|
||||
},
|
||||
"node_modules/siginfo": {
|
||||
"version": "2.0.0",
|
||||
"dev": true,
|
||||
@@ -8375,13 +8435,6 @@
|
||||
"integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/xtend": {
|
||||
"version": "4.0.2",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/y18n": {
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
|
||||
|
||||
+3
-2
@@ -18,6 +18,8 @@
|
||||
"lint": "cd .. && eslint --config webui/eslint.config.js webui/src webui/browser \"nanobot/channels/*/webui/**/*.{ts,tsx}\" \"nanobot/channels/*/tests/webui/**/*.{ts,tsx}\" \"scripts/check_client_import_boundaries*.mjs\" --max-warnings 0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pierre/diffs": "1.6.4",
|
||||
"@pierre/highlights": "0.4.0",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.4",
|
||||
"@radix-ui/react-dialog": "^1.1.4",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.4",
|
||||
@@ -41,7 +43,6 @@
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-i18next": "^17.0.4",
|
||||
"react-syntax-highlighter": "^15.6.1",
|
||||
"rehype-katex": "^7.0.1",
|
||||
"remark-breaks": "^4.0.0",
|
||||
"remark-cjk-friendly": "2.3.3",
|
||||
@@ -50,6 +51,7 @@
|
||||
"remark-parse": "^11.0.0",
|
||||
"remend": "1.3.0",
|
||||
"saxes": "6.0.0",
|
||||
"shiki": "4.6.0",
|
||||
"streamdown": "2.6.0",
|
||||
"tailwind-merge": "^2.6.0",
|
||||
"unified": "^11.0.5"
|
||||
@@ -68,7 +70,6 @@
|
||||
"@types/qrcode": "^1.5.6",
|
||||
"@types/react": "^18.3.18",
|
||||
"@types/react-dom": "^18.3.5",
|
||||
"@types/react-syntax-highlighter": "^15.5.13",
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"@vitest/coverage-v8": "2.1.9",
|
||||
"autoprefixer": "^10.4.20",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Suspense, lazy, memo, startTransition, useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
|
||||
import { Component, Suspense, lazy, memo, startTransition, useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
|
||||
import { Check, Copy } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
@@ -6,6 +6,7 @@ import { useThemeValue } from "@/hooks/useTheme";
|
||||
import { hasAnsi, parseAnsiSegments, stripAnsi } from "@/lib/ansi";
|
||||
import { copyTextToClipboard } from "@/lib/clipboard";
|
||||
import { normalizeCodeLanguage } from "@/lib/code-language";
|
||||
import { discardCodeHighlight } from "@/lib/code-highlight-cache";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
interface CodeBlockProps {
|
||||
@@ -20,82 +21,41 @@ interface CodeBlockProps {
|
||||
viewportHighlight?: boolean;
|
||||
}
|
||||
|
||||
interface HighlightedCodeProps {
|
||||
language?: string;
|
||||
code: string;
|
||||
chrome: "default" | "none";
|
||||
showLineNumbers: boolean;
|
||||
wrapLongLines: boolean;
|
||||
viewportHighlight: boolean;
|
||||
}
|
||||
|
||||
const ANSI_LANGUAGES = new Set(["ansi", "ansi-output"]);
|
||||
|
||||
const LazyHighlightedCode = lazy(async () => {
|
||||
const [
|
||||
{ default: SyntaxHighlighter },
|
||||
{ ViewportCodeRows },
|
||||
{ WrappedCodeRows },
|
||||
] = await Promise.all([
|
||||
import("react-syntax-highlighter/dist/esm/prism-async-light"),
|
||||
import("@/components/ViewportCodeRows"),
|
||||
import("@/components/WrappedCodeRows"),
|
||||
]);
|
||||
|
||||
return {
|
||||
default({
|
||||
language,
|
||||
code,
|
||||
chrome,
|
||||
showLineNumbers,
|
||||
wrapLongLines,
|
||||
viewportHighlight,
|
||||
}: HighlightedCodeProps) {
|
||||
return (
|
||||
<SyntaxHighlighter
|
||||
language={language || "text"}
|
||||
useInlineStyles={false}
|
||||
style={{}}
|
||||
customStyle={{
|
||||
background: "transparent",
|
||||
margin: 0,
|
||||
padding: viewportHighlight ? "0.75rem 1rem 0.75rem 0.5rem" : chrome === "none" ? "0.75rem 1rem" : "1rem 3.5rem 1rem 1.25rem",
|
||||
fontFamily: "inherit",
|
||||
fontSize: "inherit",
|
||||
lineHeight: "inherit",
|
||||
tabSize: 2,
|
||||
// FilePreviewPanel owns both scroll axes. Replacing this <pre>
|
||||
// during progressive highlighting must not reset horizontal scroll.
|
||||
...(viewportHighlight ? { overflow: "visible" } : {}),
|
||||
}}
|
||||
codeTagProps={{
|
||||
style: {
|
||||
background: "transparent",
|
||||
fontFamily: "inherit",
|
||||
fontSize: "inherit",
|
||||
...(viewportHighlight ? { lineHeight: "inherit" } : {}),
|
||||
},
|
||||
}}
|
||||
lineNumberStyle={{
|
||||
minWidth: "2.6em",
|
||||
paddingRight: "1.15rem",
|
||||
color: "var(--code-comment)",
|
||||
fontFamily: "inherit",
|
||||
userSelect: "none",
|
||||
}}
|
||||
PreTag="pre"
|
||||
showLineNumbers={showLineNumbers && !viewportHighlight}
|
||||
wrapLongLines={wrapLongLines}
|
||||
renderer={viewportHighlight ? props => <ViewportCodeRows {...props} />
|
||||
: showLineNumbers && wrapLongLines ? props => <WrappedCodeRows {...props} /> : undefined}
|
||||
>
|
||||
{code}
|
||||
</SyntaxHighlighter>
|
||||
);
|
||||
},
|
||||
};
|
||||
const { HighlightedCode } = await import("./HighlightedCode");
|
||||
return { default: HighlightedCode };
|
||||
});
|
||||
|
||||
class CodeHighlightBoundary extends Component<{
|
||||
code: string;
|
||||
language: string;
|
||||
fallback: ReactNode;
|
||||
children: ReactNode;
|
||||
}, { failed: boolean }> {
|
||||
state = { failed: false };
|
||||
|
||||
static getDerivedStateFromError() {
|
||||
return { failed: true };
|
||||
}
|
||||
|
||||
componentDidCatch(error: Error) {
|
||||
discardCodeHighlight(this.props.code, this.props.language);
|
||||
console.warn("Code highlighting failed.", error);
|
||||
}
|
||||
|
||||
componentDidUpdate(previous: Readonly<{ code: string; language: string }>) {
|
||||
if (this.state.failed && (previous.code !== this.props.code || previous.language !== this.props.language)) {
|
||||
this.setState({ failed: false });
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return this.state.failed ? this.props.fallback : this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
function renderPlainText(value: string): ReactNode {
|
||||
return value;
|
||||
}
|
||||
@@ -188,7 +148,7 @@ export const CodeBlock = memo(function CodeBlock({
|
||||
const hasChrome = chrome === "default";
|
||||
const syntaxLanguage = normalizeCodeLanguage(language);
|
||||
const useViewportHighlight = viewportHighlight && showLineNumbers && !wrapLongLines;
|
||||
// Minified/very large previews must not monopolize the main thread in Prism.
|
||||
// Minified/very large previews must not monopolize the main thread during highlighting.
|
||||
// Plain text still contains the entire preview, with normal selection and find.
|
||||
const withinHighlightBudget = useMemo(() => {
|
||||
if (!useViewportHighlight) return true;
|
||||
@@ -226,6 +186,8 @@ export const CodeBlock = memo(function CodeBlock({
|
||||
};
|
||||
}, [code, deferHighlight]);
|
||||
const copyLabel = copied ? t("code.copied") : t("code.copyAria");
|
||||
const plainBlock = <CodeTextBlock code={code} chrome={chrome} showLineNumbers={showLineNumbers}
|
||||
testId="plain-code-fallback" compact={useViewportHighlight} />;
|
||||
|
||||
const onCopy = useCallback(() => {
|
||||
void copyTextToClipboard(plainCode).then((ok) => {
|
||||
@@ -256,17 +218,8 @@ export const CodeBlock = memo(function CodeBlock({
|
||||
compact={useViewportHighlight}
|
||||
/>
|
||||
) : highlight && withinHighlightBudget && (!deferHighlight || highlightedSource === code) ? (
|
||||
<Suspense
|
||||
fallback={
|
||||
<CodeTextBlock
|
||||
code={code}
|
||||
chrome={chrome}
|
||||
showLineNumbers={showLineNumbers}
|
||||
testId="plain-code-fallback"
|
||||
compact={useViewportHighlight}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<CodeHighlightBoundary code={code} language={syntaxLanguage} fallback={plainBlock}>
|
||||
<Suspense fallback={plainBlock}>
|
||||
<LazyHighlightedCode
|
||||
language={syntaxLanguage}
|
||||
code={code}
|
||||
@@ -276,15 +229,8 @@ export const CodeBlock = memo(function CodeBlock({
|
||||
viewportHighlight={useViewportHighlight}
|
||||
/>
|
||||
</Suspense>
|
||||
) : (
|
||||
<CodeTextBlock
|
||||
code={code}
|
||||
chrome={chrome}
|
||||
showLineNumbers={showLineNumbers}
|
||||
testId="plain-code-fallback"
|
||||
compact={useViewportHighlight}
|
||||
/>
|
||||
)}
|
||||
</CodeHighlightBoundary>
|
||||
) : plainBlock}
|
||||
{hasChrome ? (
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Fragment } from "react";
|
||||
|
||||
import type { CodeLine } from "@/lib/code-tokens";
|
||||
|
||||
export function CodeTokens({ lines }: { lines: CodeLine[] }) {
|
||||
return <>{lines.map((line, lineIndex) => <Fragment key={lineIndex}>
|
||||
{line.tokens.map((token, index) => token.color || token.fontStyle ? <span key={index} data-code-token="" style={{
|
||||
color: token.color,
|
||||
fontStyle: token.fontStyle && token.fontStyle & 1 ? "italic" : undefined,
|
||||
fontWeight: token.fontStyle && token.fontStyle & 2 ? 700 : undefined,
|
||||
textDecoration: token.fontStyle && token.fontStyle & 4 ? "underline" : undefined,
|
||||
}}>{token.content}</span> : token.content)}
|
||||
</Fragment>)}</>;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { useMemo } from "react";
|
||||
|
||||
import { codeHighlight } from "@/lib/code-highlighter";
|
||||
import { CodeTokens } from "./CodeTokens";
|
||||
import { ViewportCodeRows } from "./ViewportCodeRows";
|
||||
|
||||
export interface HighlightedCodeProps {
|
||||
language?: string;
|
||||
code: string;
|
||||
chrome: "default" | "none";
|
||||
showLineNumbers: boolean;
|
||||
wrapLongLines: boolean;
|
||||
viewportHighlight: boolean;
|
||||
}
|
||||
|
||||
export function HighlightedCode({ language = "text", code, chrome, showLineNumbers, wrapLongLines, viewportHighlight }: HighlightedCodeProps) {
|
||||
const resource = useMemo(() => codeHighlight(code, language), [code, language]);
|
||||
const lines = resource.read();
|
||||
return <pre data-testid="highlighted-code" data-language={language} style={{
|
||||
background: "transparent", margin: 0,
|
||||
padding: viewportHighlight ? "0.75rem 1rem 0.75rem 0.5rem" : chrome === "none" ? "0.75rem 1rem" : "1rem 3.5rem 1rem 1.25rem",
|
||||
fontFamily: "inherit", fontSize: "inherit", lineHeight: "inherit", tabSize: 2,
|
||||
whiteSpace: wrapLongLines ? "pre-wrap" : "pre", overflow: viewportHighlight ? "visible" : "auto",
|
||||
overflowWrap: wrapLongLines ? "anywhere" : undefined,
|
||||
}}><code className="text-inherit">
|
||||
{viewportHighlight ? <ViewportCodeRows lines={lines} /> : showLineNumbers ? lines.map((line, index) => (
|
||||
<span key={index} className="flex">
|
||||
<span aria-hidden className="shrink-0 select-none pr-[1.15rem] text-right text-muted-foreground" style={{ minWidth: "2.6em" }}>{index + 1}</span>
|
||||
<span data-code-text="" className="min-w-0"><CodeTokens lines={[line]} /></span>
|
||||
</span>
|
||||
)) : <span data-code-text=""><CodeTokens lines={lines} /></span>}
|
||||
</code></pre>;
|
||||
}
|
||||
@@ -1,16 +1,10 @@
|
||||
import { memo, useEffect, useMemo, useRef, useState } from "react";
|
||||
import type { SyntaxHighlighterProps } from "react-syntax-highlighter";
|
||||
import createElement from "react-syntax-highlighter/dist/esm/create-element";
|
||||
|
||||
type RowsProps = Parameters<NonNullable<SyntaxHighlighterProps["renderer"]>>[0];
|
||||
type Row = RowsProps["rows"][number];
|
||||
import type { CodeLine } from "@/lib/code-tokens";
|
||||
import { CodeTokens } from "./CodeTokens";
|
||||
const CHUNK_LINES = 40;
|
||||
|
||||
function textOf(node: Row): string {
|
||||
return node.type === "text" ? String(node.value ?? "") : (node.children ?? []).map(textOf).join("");
|
||||
}
|
||||
|
||||
const CodeChunk = memo(function CodeChunk({ rows, text, start, stylesheet, useInlineStyles, highlighted, lineNumberWidth }: RowsProps & {
|
||||
const CodeChunk = memo(function CodeChunk({ lines, text, start, highlighted, lineNumberWidth }: {
|
||||
lines: CodeLine[];
|
||||
text: string;
|
||||
start: number;
|
||||
highlighted: boolean;
|
||||
@@ -20,33 +14,27 @@ const CodeChunk = memo(function CodeChunk({ rows, text, start, stylesheet, useIn
|
||||
<span data-code-chunk={start / CHUNK_LINES} className="flex min-w-max">
|
||||
<span aria-hidden className="shrink-0 select-none pr-[1.15rem] text-right text-muted-foreground"
|
||||
style={{ minWidth: lineNumberWidth }}>
|
||||
{rows.map((_, index) => start + index + 1).join("\n")}
|
||||
{lines.map((_, index) => start + index + 1).join("\n")}
|
||||
</span>
|
||||
<span data-highlighted={highlighted}>
|
||||
{highlighted ? rows.map((node, index) => createElement({
|
||||
node, stylesheet, useInlineStyles, key: start + index,
|
||||
})) : text}
|
||||
{highlighted ? <CodeTokens lines={lines} /> : text}
|
||||
</span>
|
||||
</span>
|
||||
);
|
||||
});
|
||||
|
||||
/** Keep the complete source searchable/selectable; only offscreen token spans are omitted. */
|
||||
export function ViewportCodeRows({ rows, stylesheet, useInlineStyles }: RowsProps) {
|
||||
export function ViewportCodeRows({ lines }: { lines: CodeLine[] }) {
|
||||
const rootRef = useRef<HTMLSpanElement>(null);
|
||||
const [visible, setVisible] = useState(() => new Set([0]));
|
||||
// The inline renderer only matches token class combinations. Passing Prism's
|
||||
// unrelated toolbar/pseudo selectors makes it scan those again for every token.
|
||||
const tokenStyles = useMemo(() => Object.fromEntries(Object.entries(stylesheet)
|
||||
.filter(([selector]) => /^[\w-]+(?:\.[\w-]+)*$/.test(selector))), [stylesheet]);
|
||||
const chunks = useMemo(() => {
|
||||
const result = [];
|
||||
for (let start = 0; start < rows.length; start += CHUNK_LINES) {
|
||||
const chunk = rows.slice(start, start + CHUNK_LINES);
|
||||
result.push({ start, rows: chunk, text: chunk.map(textOf).join("") });
|
||||
for (let start = 0; start < lines.length; start += CHUNK_LINES) {
|
||||
const chunk = lines.slice(start, start + CHUNK_LINES);
|
||||
result.push({ start, lines: chunk, text: chunk.map(line => line.text).join("") });
|
||||
}
|
||||
return result;
|
||||
}, [rows]);
|
||||
}, [lines]);
|
||||
|
||||
useEffect(() => {
|
||||
const root = rootRef.current;
|
||||
@@ -78,9 +66,8 @@ export function ViewportCodeRows({ rows, stylesheet, useInlineStyles }: RowsProp
|
||||
|
||||
return (
|
||||
<span ref={rootRef} className="block min-w-max" data-testid="viewport-code-rows">
|
||||
{chunks.map((chunk, index) => <CodeChunk key={chunk.start} {...chunk}
|
||||
stylesheet={tokenStyles} useInlineStyles={useInlineStyles} highlighted={visible.has(index)}
|
||||
lineNumberWidth={`calc(${String(rows.length).length}ch + 1.15rem)`} />)}
|
||||
{chunks.map((chunk, index) => <CodeChunk key={chunk.start} {...chunk} highlighted={visible.has(index)}
|
||||
lineNumberWidth={`calc(${String(lines.length).length}ch + 1.15rem)`} />)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import type { SyntaxHighlighterProps } from "react-syntax-highlighter";
|
||||
import createElement from "react-syntax-highlighter/dist/esm/create-element";
|
||||
|
||||
type RowsProps = Parameters<NonNullable<SyntaxHighlighterProps["renderer"]>>[0];
|
||||
|
||||
export function WrappedCodeRows({ rows, ...props }: RowsProps) {
|
||||
return rows.map((row, index) => {
|
||||
const [lineNumber, ...content] = row.children!;
|
||||
return createElement({
|
||||
...props,
|
||||
key: index,
|
||||
node: {
|
||||
...row,
|
||||
children: [lineNumber, {
|
||||
type: "element",
|
||||
tagName: "span",
|
||||
properties: { className: ["min-w-0", "flex-1"] },
|
||||
children: content,
|
||||
}],
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { PromptRail } from "@/components/thread/PromptRail";
|
||||
import { SubagentThreadMessages, useHasSubagentResults } from "@/components/thread/SubagentTaskResults";
|
||||
import { DiagramScope } from "@/components/markdown-diagrams/context";
|
||||
import { DiffViewportContext } from "./activity/DiffViewportContext";
|
||||
import { ThreadHistoryStatus } from "@/components/thread/ThreadHistoryStatus";
|
||||
import { isAgentActivityMember } from "@/components/thread/AgentActivityCluster";
|
||||
import { ThreadCameraController } from "@/components/thread/thread-camera";
|
||||
@@ -306,6 +307,7 @@ export const ThreadViewport = forwardRef<ThreadViewportHandle, ThreadViewportPro
|
||||
const contentRef = useRef<HTMLDivElement>(null);
|
||||
const messageRegionRef = useRef<HTMLDivElement | null>(null);
|
||||
const messageContentRef = useRef<HTMLDivElement>(null);
|
||||
const diffViewport = useMemo(() => ({ scroller: messageRegionRef, content: messageContentRef }), []);
|
||||
const emptyStateRef = useRef<HTMLDivElement>(null);
|
||||
const composerDockRef = useRef<HTMLDivElement>(null);
|
||||
const composerLayoutChangeRef = useRef(onComposerLayoutChange);
|
||||
@@ -1211,6 +1213,7 @@ export const ThreadViewport = forwardRef<ThreadViewportHandle, ThreadViewportPro
|
||||
)}
|
||||
>
|
||||
<div ref={messageContentRef} className="w-full">
|
||||
<DiffViewportContext.Provider value={diffViewport}>
|
||||
<DiagramScope identity={conversationKey}>
|
||||
<SubagentThreadMessages
|
||||
key={messagesKey}
|
||||
@@ -1239,6 +1242,7 @@ export const ThreadViewport = forwardRef<ThreadViewportHandle, ThreadViewportPro
|
||||
onActivityToggle={yieldCameraToUser}
|
||||
/>
|
||||
</DiagramScope>
|
||||
</DiffViewportContext.Provider>
|
||||
</div>
|
||||
<div aria-hidden className="thread-message-end-gap shrink-0" />
|
||||
<div ref={bottomRef} aria-hidden className="h-px shrink-0" />
|
||||
|
||||
@@ -1,187 +1,66 @@
|
||||
import { Suspense, lazy, type ReactNode } from "react";
|
||||
import type { SyntaxHighlighterProps } from "react-syntax-highlighter";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import type { RenderableFileDiffLine } from "@/lib/file-diff";
|
||||
import type { RenderableFileDiff, RenderableFileDiffLine } from "@/lib/file-diff";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
interface DiffSyntaxHighlightProps {
|
||||
export interface DiffSyntaxHighlightProps {
|
||||
language: string;
|
||||
lines: RenderableFileDiffLine[];
|
||||
text: string;
|
||||
diff: RenderableFileDiff;
|
||||
lineLimit: number;
|
||||
}
|
||||
|
||||
type RendererArgs = Parameters<NonNullable<SyntaxHighlighterProps["renderer"]>>[0];
|
||||
type SyntaxNode = RendererArgs["rows"][number];
|
||||
|
||||
const LazyDiffSyntaxHighlight = lazy(async () => {
|
||||
const [
|
||||
{ default: SyntaxHighlighter },
|
||||
{ default: createSyntaxElement },
|
||||
] = await Promise.all([
|
||||
import("react-syntax-highlighter/dist/esm/prism-async-light"),
|
||||
import("react-syntax-highlighter/dist/esm/create-element"),
|
||||
]);
|
||||
return {
|
||||
default: function LoadedDiffSyntaxHighlight({
|
||||
language,
|
||||
lines,
|
||||
}: DiffSyntaxHighlightProps) {
|
||||
const code = lines.map((line) => line.content || " ").join("\n");
|
||||
return (
|
||||
<SyntaxHighlighter
|
||||
language={language}
|
||||
useInlineStyles={false}
|
||||
style={{}}
|
||||
PreTag="div"
|
||||
CodeTag="div"
|
||||
customStyle={{
|
||||
background: "transparent",
|
||||
margin: 0,
|
||||
padding: 0,
|
||||
overflow: "visible",
|
||||
fontFamily: "inherit",
|
||||
fontSize: "inherit",
|
||||
lineHeight: "inherit",
|
||||
}}
|
||||
codeTagProps={{
|
||||
style: {
|
||||
background: "transparent",
|
||||
fontFamily: "inherit",
|
||||
},
|
||||
}}
|
||||
data-language={language}
|
||||
className="code-content font-mono text-code-dense"
|
||||
data-testid="syntax-highlighted-diff-hunk"
|
||||
renderer={({ rows, stylesheet, useInlineStyles }) => (
|
||||
<DiffLineTable
|
||||
lines={lines}
|
||||
renderCode={(line, index) => {
|
||||
const node = rows[index];
|
||||
if (!node) return line.content || " ";
|
||||
return createSyntaxElement({
|
||||
node: stripConflictingTableClass(trimTrailingLineBreak(node)),
|
||||
stylesheet,
|
||||
useInlineStyles,
|
||||
key: `diff-code-${index}`,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
>
|
||||
{code}
|
||||
</SyntaxHighlighter>
|
||||
);
|
||||
},
|
||||
};
|
||||
const renderer = await import("./PierreFileDiff");
|
||||
await renderer.prepareDiffRenderer();
|
||||
return { default: renderer.PierreFileDiff };
|
||||
});
|
||||
|
||||
export function DiffSyntaxHighlight({ language, lines }: DiffSyntaxHighlightProps) {
|
||||
export function DiffSyntaxHighlight(props: DiffSyntaxHighlightProps) {
|
||||
return (
|
||||
<Suspense fallback={<PlainDiffLines lines={lines} />}>
|
||||
<LazyDiffSyntaxHighlight language={language} lines={lines} />
|
||||
<Suspense fallback={<PlainDiffLines diff={props.diff} lineLimit={props.lineLimit} />}>
|
||||
<LazyDiffSyntaxHighlight {...props} />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
|
||||
function PlainDiffLines({ lines }: { lines: RenderableFileDiffLine[] }) {
|
||||
export function DiffHunkGap({ lineCount }: { lineCount: number }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div data-testid="plain-diff-hunk">
|
||||
<DiffLineTable lines={lines} renderCode={(line) => line.content || " "} />
|
||||
<div className="nanobot-diff-gap flex items-center gap-2 bg-muted/35 px-2 text-[11px] text-muted-foreground" data-testid="file-edit-diff-hunk-gap">
|
||||
<span className="select-none rounded border border-border/45 bg-background/70 px-1 font-mono text-muted-foreground/70" aria-hidden>...</span>
|
||||
<span>{t("message.fileEditUnchangedLinesHidden", { count: lineCount, defaultValue: "{{count}} unchanged lines hidden" })}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function DiffLineTable({
|
||||
lines,
|
||||
renderCode,
|
||||
}: {
|
||||
lines: RenderableFileDiffLine[];
|
||||
renderCode: (line: RenderableFileDiffLine, index: number) => ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<table className="w-full border-collapse font-mono text-code-dense">
|
||||
<tbody>
|
||||
{lines.map((line, index) => (
|
||||
<DiffLineRow
|
||||
key={`${line.old_lineno ?? ""}:${line.new_lineno ?? ""}:${index}`}
|
||||
line={line}
|
||||
>
|
||||
{renderCode(line, index)}
|
||||
</DiffLineRow>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
);
|
||||
export function PlainDiffLines({ diff, lineLimit }: { diff: RenderableFileDiff; lineLimit: number }) {
|
||||
let remaining = lineLimit;
|
||||
return <div data-testid="plain-diff-hunk">{diff.hunks.map((hunk, index) => {
|
||||
const lines = hunk.lines.slice(0, Math.max(0, remaining));
|
||||
remaining -= lines.length;
|
||||
if (lines.length === 0) return null;
|
||||
const previous = diff.hunks[index - 1];
|
||||
const skipped = previous ? Math.max(0, hunk.old_start - previous.old_start - previous.old_lines, hunk.new_start - previous.new_start - previous.new_lines) : 0;
|
||||
return <div key={index}>
|
||||
{skipped > 0 ? <DiffHunkGap lineCount={skipped} /> : null}
|
||||
<table className="w-full border-collapse font-mono text-code-dense"><tbody>
|
||||
{lines.map((line, lineIndex) => <DiffLineRow key={lineIndex} line={line}>{line.content || " "}</DiffLineRow>)}
|
||||
</tbody></table>
|
||||
</div>;
|
||||
})}</div>;
|
||||
}
|
||||
|
||||
function DiffLineRow({
|
||||
line,
|
||||
children,
|
||||
}: {
|
||||
line: RenderableFileDiffLine;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
function DiffLineRow({ line, children }: { line: RenderableFileDiffLine; children: ReactNode }) {
|
||||
const kind = line.kind === "add" || line.kind === "delete" ? line.kind : "context";
|
||||
const marker = kind === "add" ? "+" : kind === "delete" ? "-" : " ";
|
||||
return (
|
||||
<tr
|
||||
className={cn(
|
||||
"border-0",
|
||||
kind === "add" && "bg-diff-added",
|
||||
kind === "delete" && "bg-diff-deleted",
|
||||
)}
|
||||
>
|
||||
<td className="w-10 select-none border-r border-border/35 px-1.5 text-right text-muted-foreground">
|
||||
{line.old_lineno ?? ""}
|
||||
</td>
|
||||
<td className="w-10 select-none border-r border-border/35 px-1.5 text-right text-muted-foreground">
|
||||
{line.new_lineno ?? ""}
|
||||
</td>
|
||||
<td
|
||||
className={cn(
|
||||
"w-5 select-none px-1 text-center",
|
||||
kind === "add" && "text-diff-added-foreground",
|
||||
kind === "delete" && "text-diff-deleted-foreground",
|
||||
kind === "context" && "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
{marker}
|
||||
</td>
|
||||
<td className="min-w-[16rem] px-1.5 text-foreground/86">
|
||||
<span className="whitespace-pre">{children}</span>
|
||||
</td>
|
||||
<tr className={cn("border-0", kind === "add" && "bg-diff-added", kind === "delete" && "bg-diff-deleted")}>
|
||||
<td className="w-10 select-none border-r border-border/35 px-1.5 text-right text-muted-foreground">{line.old_lineno ?? ""}</td>
|
||||
<td className="w-10 select-none border-r border-border/35 px-1.5 text-right text-muted-foreground">{line.new_lineno ?? ""}</td>
|
||||
<td className={cn("w-5 select-none px-1 text-center", kind === "add" && "text-diff-added-foreground", kind === "delete" && "text-diff-deleted-foreground", kind === "context" && "text-muted-foreground")}>{marker}</td>
|
||||
<td className="min-w-[16rem] px-1.5 text-foreground/86"><span className="whitespace-pre">{children}</span></td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
function trimTrailingLineBreak(node: SyntaxNode): SyntaxNode {
|
||||
if (node.type === "text" && typeof node.value === "string") {
|
||||
return { ...node, value: node.value.replace(/\n$/, "") };
|
||||
}
|
||||
if (!node.children?.length) return node;
|
||||
const children = [...node.children];
|
||||
children[children.length - 1] = trimTrailingLineBreak(children[children.length - 1]!);
|
||||
return { ...node, children };
|
||||
}
|
||||
|
||||
function stripConflictingTableClass(node: SyntaxNode): SyntaxNode {
|
||||
const className = node.properties?.className;
|
||||
const children = node.children?.map(stripConflictingTableClass);
|
||||
const hasTableClass = Array.isArray(className) && className.includes("table");
|
||||
|
||||
if (!hasTableClass && !children) return node;
|
||||
|
||||
return {
|
||||
...node,
|
||||
...(hasTableClass
|
||||
? {
|
||||
properties: {
|
||||
...node.properties,
|
||||
// Tailwind's global `.table` utility changes Prism's inline Markdown
|
||||
// table tokens into CSS tables, splitting a single diff line vertically.
|
||||
className: className.filter((name) => name !== "table"),
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
...(children ? { children } : {}),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createContext, type RefObject } from "react";
|
||||
|
||||
export const DiffViewportContext = createContext<{
|
||||
scroller: RefObject<HTMLElement>;
|
||||
content: RefObject<HTMLElement>;
|
||||
} | null>(null);
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
hasRenderableFileDiff,
|
||||
parseRenderableFileDiff,
|
||||
type RenderableFileDiff,
|
||||
type RenderableFileDiffHunk,
|
||||
} from "@/lib/file-diff";
|
||||
import type { FileEditDisplayMode } from "@/lib/local-preferences";
|
||||
import type { UIFileDiff, UIFileEdit } from "@/lib/types";
|
||||
@@ -28,18 +27,6 @@ import { DiffSyntaxHighlight } from "./DiffSyntaxHighlight";
|
||||
const INITIAL_VISIBLE_DIFF_LINES = 160;
|
||||
const AUTO_COLLAPSE_DIFF_LINES = INITIAL_VISIBLE_DIFF_LINES;
|
||||
|
||||
interface VisibleDiffHunk {
|
||||
hunk: RenderableFileDiffHunk;
|
||||
skippedBefore: number;
|
||||
}
|
||||
|
||||
interface VisibleDiff {
|
||||
hunks: VisibleDiffHunk[];
|
||||
hiddenLineCount: number;
|
||||
}
|
||||
|
||||
const EMPTY_VISIBLE_DIFF: VisibleDiff = { hunks: [], hiddenLineCount: 0 };
|
||||
|
||||
export interface FileEditSummary {
|
||||
key: string;
|
||||
path: string;
|
||||
@@ -192,12 +179,7 @@ function FileUnifiedDiff({
|
||||
const lineLimit = expandedLines || !shouldLimitLines
|
||||
? totalLineCount
|
||||
: INITIAL_VISIBLE_DIFF_LINES;
|
||||
const visibleDiff = useMemo(
|
||||
() => shouldRenderBody
|
||||
? selectVisibleDiffLines(renderableDiff, lineLimit, totalLineCount)
|
||||
: EMPTY_VISIBLE_DIFF,
|
||||
[lineLimit, renderableDiff, shouldRenderBody, totalLineCount],
|
||||
);
|
||||
const hiddenLineCount = totalLineCount - lineLimit;
|
||||
const viewDiffLabel = shouldAutoCollapse
|
||||
? tx("message.fileEditViewLargeDiff", "View large diff")
|
||||
: tx("message.fileEditViewDiff", "View diff");
|
||||
@@ -227,18 +209,8 @@ function FileUnifiedDiff({
|
||||
className="mt-1 overflow-hidden rounded-md border border-border/55 bg-background/80 shadow-[0_1px_0_rgba(15,23,42,0.03)]"
|
||||
data-testid="file-edit-diff"
|
||||
>
|
||||
{visibleDiff.hunks.map(({ hunk, skippedBefore }, index) => (
|
||||
<div
|
||||
key={`${hunk.old_start}-${hunk.new_start}-${index}`}
|
||||
className={cn("min-w-0", index > 0 && "border-t border-border/45")}
|
||||
>
|
||||
{skippedBefore > 0 ? <DiffHunkGap lineCount={skippedBefore} /> : null}
|
||||
<div className="overflow-x-auto">
|
||||
<DiffSyntaxHighlight language={language} lines={hunk.lines} />
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
{visibleDiff.hiddenLineCount > 0 ? (
|
||||
<DiffSyntaxHighlight language={language} text={diff.text!} diff={renderableDiff} lineLimit={lineLimit} />
|
||||
{hiddenLineCount > 0 ? (
|
||||
<div className="border-t border-border/45 bg-muted/30 px-2 py-1">
|
||||
<button
|
||||
type="button"
|
||||
@@ -251,7 +223,7 @@ function FileUnifiedDiff({
|
||||
>
|
||||
<ChevronDown className="h-3 w-3" aria-hidden />
|
||||
{t("message.fileEditShowMoreLines", {
|
||||
count: visibleDiff.hiddenLineCount,
|
||||
count: hiddenLineCount,
|
||||
defaultValue: "Show {{count}} more lines",
|
||||
})}
|
||||
</button>
|
||||
@@ -330,72 +302,3 @@ function FileUnifiedDiff({
|
||||
function countDiffLines(diff: RenderableFileDiff): number {
|
||||
return diff.hunks.reduce((total, hunk) => total + hunk.lines.length, 0);
|
||||
}
|
||||
|
||||
function selectVisibleDiffLines(
|
||||
diff: RenderableFileDiff,
|
||||
lineLimit: number,
|
||||
totalLineCount: number,
|
||||
): VisibleDiff {
|
||||
if (lineLimit >= totalLineCount) {
|
||||
return {
|
||||
hunks: diff.hunks.map((hunk, index) => ({
|
||||
hunk,
|
||||
skippedBefore: index > 0 ? countSkippedUnchangedLines(diff.hunks[index - 1], hunk) : 0,
|
||||
})),
|
||||
hiddenLineCount: 0,
|
||||
};
|
||||
}
|
||||
|
||||
let remaining = Math.max(0, lineLimit);
|
||||
const hunks: VisibleDiffHunk[] = [];
|
||||
let previousHunk: RenderableFileDiffHunk | null = null;
|
||||
for (const hunk of diff.hunks) {
|
||||
if (remaining <= 0) break;
|
||||
const skippedBefore = previousHunk ? countSkippedUnchangedLines(previousHunk, hunk) : 0;
|
||||
if (hunk.lines.length <= remaining) {
|
||||
hunks.push({ hunk, skippedBefore });
|
||||
remaining -= hunk.lines.length;
|
||||
previousHunk = hunk;
|
||||
continue;
|
||||
}
|
||||
hunks.push({ hunk: { ...hunk, lines: hunk.lines.slice(0, remaining) }, skippedBefore });
|
||||
remaining = 0;
|
||||
previousHunk = hunk;
|
||||
}
|
||||
return {
|
||||
hunks,
|
||||
hiddenLineCount: Math.max(0, totalLineCount - lineLimit),
|
||||
};
|
||||
}
|
||||
|
||||
function countSkippedUnchangedLines(
|
||||
previous: RenderableFileDiffHunk,
|
||||
current: RenderableFileDiffHunk,
|
||||
): number {
|
||||
const oldGap = current.old_start - (previous.old_start + previous.old_lines);
|
||||
const newGap = current.new_start - (previous.new_start + previous.new_lines);
|
||||
return Math.max(0, oldGap, newGap);
|
||||
}
|
||||
|
||||
function DiffHunkGap({ lineCount }: { lineCount: number }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div
|
||||
className="flex items-center gap-2 bg-muted/35 px-2 py-1 text-[11px] text-muted-foreground"
|
||||
data-testid="file-edit-diff-hunk-gap"
|
||||
>
|
||||
<span
|
||||
className="select-none rounded border border-border/45 bg-background/70 px-1 font-mono text-muted-foreground/70"
|
||||
aria-hidden
|
||||
>
|
||||
...
|
||||
</span>
|
||||
<span>
|
||||
{t("message.fileEditUnchangedLinesHidden", {
|
||||
count: lineCount,
|
||||
defaultValue: "{{count}} unchanged lines hidden",
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
import { FileDiff, getSharedHighlighter, getSingularPatch, registerCustomTheme, type FileDiffMetadata, type FileDiffOptions, type RenderRange } from "@pierre/diffs";
|
||||
import { WorkerPoolManager } from "@pierre/diffs/worker";
|
||||
import { isSupportedLanguage } from "@pierre/highlights";
|
||||
import { bundledLanguages } from "shiki/langs";
|
||||
import { useCallback, useContext, useLayoutEffect, useMemo, useRef } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { useThemeValue } from "@/hooks/useTheme";
|
||||
import { CODE_TEXTMATE_THEME, CODE_THEME, CODE_THEME_NAME, codeHighlighterLanguage } from "@/lib/code-theme";
|
||||
import { DiffViewportContext } from "./DiffViewportContext";
|
||||
import type { DiffSyntaxHighlightProps } from "./DiffSyntaxHighlight";
|
||||
import { DIFF_GAP_HEIGHT, diffRenderWindow, diffRowOffsets } from "./diff-render-window";
|
||||
import { selectedDiffRows } from "./diff-selection";
|
||||
|
||||
const THEME = CODE_THEME_NAME;
|
||||
const CACHE_ENTRIES = 16;
|
||||
const CACHE_SOURCE_BYTES = 2 * 1024 * 1024;
|
||||
const metadataCache = new Map<string, FileDiffMetadata>();
|
||||
let sourceBytes = 0;
|
||||
let revision = 0;
|
||||
let pool: WorkerPoolManager | undefined;
|
||||
let grammarPool: WorkerPoolManager | undefined;
|
||||
let preparation: Promise<void> | undefined;
|
||||
|
||||
registerCustomTheme(THEME, async () => CODE_THEME, "zed");
|
||||
registerCustomTheme(THEME, async () => CODE_TEXTMATE_THEME, "textmate");
|
||||
|
||||
export function prepareDiffRenderer(): Promise<void> {
|
||||
return preparation ??= (async () => {
|
||||
await getSharedHighlighter({ themes: [THEME], langs: ["text"], preferredHighlighter: "highlights" });
|
||||
pool = new WorkerPoolManager({
|
||||
// The zero-worker pool owns the bounded AST cache; Highlights shares its main-thread engine with code blocks.
|
||||
workerFactory: () => { throw new Error("The Highlights cache does not create workers"); },
|
||||
poolSize: 0,
|
||||
totalASTLRUCacheSize: CACHE_ENTRIES,
|
||||
mainThreadMaxCharacters: Number.MAX_SAFE_INTEGER,
|
||||
}, { theme: THEME, preferredHighlighter: "highlights", lineDiffType: "word" });
|
||||
})();
|
||||
}
|
||||
|
||||
function getGrammarPool(): WorkerPoolManager {
|
||||
return grammarPool ??= new WorkerPoolManager({
|
||||
workerFactory: () => new Worker(new URL("@pierre/diffs/worker/worker.js", import.meta.url), { type: "module" }),
|
||||
poolSize: 1, totalASTLRUCacheSize: CACHE_ENTRIES,
|
||||
}, { theme: THEME, preferredHighlighter: "shiki-js", lineDiffType: "word" });
|
||||
}
|
||||
|
||||
export function getDiffMetadata(text: string, language: string): FileDiffMetadata {
|
||||
const alias = codeHighlighterLanguage(language);
|
||||
const lang = isSupportedLanguage(alias) || Object.hasOwn(bundledLanguages, alias)
|
||||
? alias as NonNullable<FileDiffMetadata["lang"]> : "text";
|
||||
const key = `${lang}\0${text}`;
|
||||
const cached = metadataCache.get(key);
|
||||
if (cached) {
|
||||
metadataCache.delete(key);
|
||||
metadataCache.set(key, cached);
|
||||
return cached;
|
||||
}
|
||||
const metadata = getSingularPatch(text);
|
||||
metadata.lang = lang;
|
||||
const bytes = key.length * 2;
|
||||
if (bytes <= CACHE_SOURCE_BYTES) {
|
||||
while (metadataCache.size >= CACHE_ENTRIES || sourceBytes + bytes > CACHE_SOURCE_BYTES) {
|
||||
const [oldKey, oldMetadata] = metadataCache.entries().next().value!;
|
||||
metadataCache.delete(oldKey);
|
||||
sourceBytes -= oldKey.length * 2;
|
||||
pool?.evictDiffFromCache(oldMetadata.cacheKey!);
|
||||
grammarPool?.evictDiffFromCache(oldMetadata.cacheKey!);
|
||||
}
|
||||
metadata.cacheKey = `nanobot-diff-${++revision}`;
|
||||
metadataCache.set(key, metadata);
|
||||
sourceBytes += bytes;
|
||||
}
|
||||
return metadata;
|
||||
}
|
||||
|
||||
export function PierreFileDiff({ text, language, diff, lineLimit }: DiffSyntaxHighlightProps) {
|
||||
const theme = useThemeValue();
|
||||
const { t } = useTranslation();
|
||||
const viewport = useContext(DiffViewportContext);
|
||||
const wrapperRef = useRef<HTMLDivElement>(null);
|
||||
const instanceRef = useRef<FileDiff>();
|
||||
const metadata = useMemo(() => getDiffMetadata(text, language), [text, language]);
|
||||
const needsGrammar = !isSupportedLanguage(metadata.lang!);
|
||||
const gapLabel = useCallback((count: number) => `… ${t("message.fileEditUnchangedLinesHidden", { count, defaultValue: "{{count}} unchanged lines hidden" })}`, [t]);
|
||||
const options = useMemo<FileDiffOptions<undefined, undefined>>(() => ({
|
||||
theme: THEME, themeType: theme, preferredHighlighter: "highlights", diffStyle: "unified", diffIndicators: "classic",
|
||||
disableFileHeader: true, lineDiffType: "word",
|
||||
// Function separators disable Pierre's incremental row updates and destroy native selections.
|
||||
hunkSeparators: "line-info",
|
||||
onPostRender: (node, _instance, phase) => {
|
||||
if (phase === "unmount") return;
|
||||
for (const gap of node.shadowRoot!.querySelectorAll<HTMLElement>("[data-separator]")) {
|
||||
const nextIndex = Number(gap.nextElementSibling?.getAttribute("data-line-index")?.split(",")[0]);
|
||||
const hunk = metadata.hunks.find(item => item.unifiedLineStart === nextIndex);
|
||||
const label = gap.querySelector<HTMLElement>("[data-unmodified-lines]");
|
||||
if (!hunk || !label) continue;
|
||||
const text = gapLabel(hunk.collapsedBefore);
|
||||
if (label.textContent !== text) label.textContent = text;
|
||||
if (gap.closest("[data-gutter]")) label.dataset.testid = "file-edit-diff-hunk-gap";
|
||||
}
|
||||
},
|
||||
unsafeCSS: `:host, pre, code { font: inherit; } pre { padding-block: 0; } [data-line], [data-column-number] { padding-block: 1px; } [data-separator] { height: ${DIFF_GAP_HEIGHT}px; margin: 0; padding: 0; } [data-separator-wrapper], [data-separator-content] { background: transparent; color: hsl(var(--muted-foreground)); } [data-separator-wrapper] { padding-inline: 8px; background: hsl(var(--muted) / .35); font-size: 11px; } [data-separator-first], [data-separator-last] { display: none; }`,
|
||||
}), [theme, gapLabel, metadata]);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const wrapper = wrapperRef.current!;
|
||||
const instance = new FileDiff({ theme: THEME, preferredHighlighter: "highlights" }, needsGrammar ? getGrammarPool() : pool);
|
||||
instanceRef.current = instance;
|
||||
return () => { instance.cleanUp(); instanceRef.current = undefined; wrapper.replaceChildren(); };
|
||||
}, [needsGrammar]);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const wrapper = wrapperRef.current!;
|
||||
const instance = instanceRef.current!;
|
||||
instance.setOptions(options);
|
||||
const scroller = viewport?.scroller.current;
|
||||
const eventTarget = scroller ?? window;
|
||||
let frame = 0;
|
||||
let previous: RenderRange | undefined;
|
||||
let forceRender = true;
|
||||
const render = () => {
|
||||
frame = 0;
|
||||
const lineHeight = Math.floor((parseFloat(getComputedStyle(wrapper).lineHeight) + 2) * 64) / 64;
|
||||
const offsets = diffRowOffsets(diff, lineLimit, lineHeight);
|
||||
const rootRect = scroller?.getBoundingClientRect();
|
||||
const wrapperTop = wrapper.getBoundingClientRect().top;
|
||||
const top = (rootRect?.top ?? 0) - wrapperTop;
|
||||
const height = rootRect?.height ?? window.innerHeight;
|
||||
const range = diffRenderWindow(diff, offsets, top - height, top + height * 2, lineHeight, selectedDiffRows(wrapper, metadata));
|
||||
if (!forceRender && previous && Object.keys(range).every(key => range[key as keyof RenderRange] === previous![key as keyof RenderRange])) return;
|
||||
previous = range;
|
||||
instance.render({ fileDiff: metadata, containerWrapper: wrapper, renderRange: range, forceRender });
|
||||
forceRender = false;
|
||||
};
|
||||
const schedule = () => { if (!frame) frame = requestAnimationFrame(render); };
|
||||
// This observer projects a read-only window; ThreadCameraController remains the sole scroll writer.
|
||||
const resize = new ResizeObserver(schedule);
|
||||
resize.observe(wrapper);
|
||||
if (scroller) resize.observe(scroller);
|
||||
if (viewport?.content.current) resize.observe(viewport.content.current);
|
||||
const typography = new MutationObserver(schedule);
|
||||
typography.observe(document.documentElement, { attributes: true, attributeFilter: ["data-reading-text-size"] });
|
||||
eventTarget.addEventListener("scroll", schedule, { passive: true });
|
||||
document.addEventListener("selectionchange", schedule);
|
||||
window.addEventListener("resize", schedule);
|
||||
render();
|
||||
return () => {
|
||||
cancelAnimationFrame(frame);
|
||||
resize.disconnect();
|
||||
typography.disconnect();
|
||||
eventTarget.removeEventListener("scroll", schedule);
|
||||
document.removeEventListener("selectionchange", schedule);
|
||||
window.removeEventListener("resize", schedule);
|
||||
};
|
||||
}, [diff, lineLimit, metadata, options, viewport]);
|
||||
|
||||
return <div ref={wrapperRef} className="nanobot-file-diff font-mono text-code-dense" data-testid="syntax-highlighted-diff-hunk" data-language={language} />;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import type { RenderableFileDiff } from "@/lib/file-diff";
|
||||
|
||||
export const DIFF_GAP_HEIGHT = 26;
|
||||
const ROW_BATCH = 40;
|
||||
|
||||
export function diffRowOffsets(diff: RenderableFileDiff, lineLimit: number, lineHeight: number): number[] {
|
||||
const offsets: number[] = [];
|
||||
let top = 0;
|
||||
for (const [index, hunk] of diff.hunks.entries()) {
|
||||
if (offsets.length >= lineLimit) break;
|
||||
const previous = diff.hunks[index - 1];
|
||||
if (previous && (hunk.old_start > previous.old_start + previous.old_lines || hunk.new_start > previous.new_start + previous.new_lines)) top += DIFF_GAP_HEIGHT;
|
||||
for (let line = 0; line < hunk.lines.length; line++) {
|
||||
if (offsets.length >= lineLimit) break;
|
||||
offsets.push(top);
|
||||
top += lineHeight;
|
||||
}
|
||||
}
|
||||
offsets.push(top);
|
||||
return offsets;
|
||||
}
|
||||
|
||||
export function diffRenderWindow(diff: RenderableFileDiff, offsets: number[], top: number, bottom: number, lineHeight: number, selected?: readonly [number, number]) {
|
||||
const count = offsets.length - 1;
|
||||
if (count <= 160) return { startingLine: 0, totalLines: count, bufferBefore: 0, bufferAfter: 0 };
|
||||
let start = offsets.findIndex((offset) => offset >= top);
|
||||
if (start < 0) start = count - 1;
|
||||
// Keep both edges together, with one extra batch for the rounded-down start.
|
||||
const capacity = Math.min(count, (Math.ceil((bottom - top) / lineHeight / ROW_BATCH) + 1) * ROW_BATCH);
|
||||
start = Math.min(count - capacity, Math.max(0, Math.floor((start - 1) / ROW_BATCH) * ROW_BATCH));
|
||||
let end = start + capacity;
|
||||
// Retain only the active selection's rows as the viewport keeps moving. Clearing it
|
||||
// returns to the ordinary bounded window; do not freeze rendering or accumulate old windows.
|
||||
if (selected) {
|
||||
start = Math.min(start, selected[0]);
|
||||
end = Math.min(count, Math.max(end, selected[1]));
|
||||
}
|
||||
let before = offsets[start];
|
||||
let after = offsets[count] - offsets[end];
|
||||
// A separator is rendered with its first row, not with the preceding window.
|
||||
let row = 0;
|
||||
for (const [index, hunk] of diff.hunks.entries()) {
|
||||
const previous = diff.hunks[index - 1];
|
||||
const gap = previous && (hunk.old_start > previous.old_start + previous.old_lines || hunk.new_start > previous.new_start + previous.new_lines);
|
||||
if (gap && row === start) before -= DIFF_GAP_HEIGHT;
|
||||
if (gap && row === end) after += DIFF_GAP_HEIGHT;
|
||||
row += hunk.lines.length;
|
||||
}
|
||||
return { startingLine: start, totalLines: end - start, bufferBefore: before, bufferAfter: after };
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import type { FileDiffMetadata } from "@pierre/diffs";
|
||||
|
||||
// Native ranges must be read inside Pierre's shadow tree, not from retargeted host endpoints.
|
||||
export function selectedDiffRows(wrapper: HTMLElement, metadata: FileDiffMetadata): readonly [number, number] | undefined {
|
||||
const host = wrapper.querySelector("diffs-container");
|
||||
const root = host?.shadowRoot;
|
||||
const selection = document.getSelection();
|
||||
if (!root || !selection) return;
|
||||
const shadowSelection = (root as ShadowRoot & { getSelection?(): Selection | null }).getSelection?.();
|
||||
const ranges = typeof selection.getComposedRanges === "function"
|
||||
? selection.getComposedRanges({ shadowRoots: [root] })
|
||||
: shadowSelection?.rangeCount ? [shadowSelection.getRangeAt(0)] : selection.rangeCount ? [selection.getRangeAt(0)] : [];
|
||||
const selected = ranges[0];
|
||||
// Chromium can report document Selection.isCollapsed=true for a nonempty shadow selection.
|
||||
if (!selected || (selected.startContainer === selected.endContainer && selected.startOffset === selected.endOffset)) return;
|
||||
const startsInside = selected.startContainer.getRootNode() === root;
|
||||
const endsInside = selected.endContainer.getRootNode() === root;
|
||||
if (!startsInside && !endsInside && (!selection.rangeCount || !selection.getRangeAt(0).intersectsNode(host))) return;
|
||||
const localRange = document.createRange();
|
||||
localRange.selectNodeContents(root);
|
||||
if (startsInside) localRange.setStart(selected.startContainer, selected.startOffset);
|
||||
if (endsInside) localRange.setEnd(selected.endContainer, selected.endOffset);
|
||||
let first: number | undefined;
|
||||
let last: number | undefined;
|
||||
for (const row of root.querySelectorAll<HTMLElement>("[data-code] [data-line][data-line-index]")) {
|
||||
if (!localRange.intersectsNode(row)) continue;
|
||||
const index = Number(row.dataset.lineIndex!.split(",")[0]);
|
||||
let renderedStart = 0;
|
||||
for (const hunk of metadata.hunks) {
|
||||
if (index >= hunk.unifiedLineStart && index < hunk.unifiedLineStart + hunk.unifiedLineCount) {
|
||||
const renderedIndex = renderedStart + index - hunk.unifiedLineStart;
|
||||
first = first === undefined ? renderedIndex : Math.min(first, renderedIndex);
|
||||
last = last === undefined ? renderedIndex + 1 : Math.max(last, renderedIndex + 1);
|
||||
break;
|
||||
}
|
||||
renderedStart += hunk.unifiedLineCount;
|
||||
}
|
||||
}
|
||||
return first === undefined || last === undefined ? undefined : [first, last];
|
||||
}
|
||||
@@ -205,6 +205,7 @@ export function PaneWorkbench({
|
||||
}: PaneWorkbenchProps) {
|
||||
const { t } = useTranslation();
|
||||
const compact = useMediaQuery("(max-width: 767px)");
|
||||
const sharedComposer = chrome && panes.length > 1;
|
||||
const effectiveLayout = layout;
|
||||
const [headerPortalTarget, setHeaderPortalTarget] = useState<HTMLElement | null>(null);
|
||||
const [composerPortalTarget, setComposerPortalTarget] = useState<HTMLElement | null>(null);
|
||||
@@ -728,7 +729,7 @@ export function PaneWorkbench({
|
||||
active,
|
||||
multiplePanes: displayedPanes.length > 1,
|
||||
headerPortalTarget: chrome && displayedPanes.length > 1 ? headerPortalTarget : undefined,
|
||||
composerPortalTarget: chrome ? composerPortalTarget : undefined,
|
||||
composerPortalTarget: sharedComposer ? composerPortalTarget : undefined,
|
||||
navigationFrame: displayedPanes.length === 1 ? navigationFrame : undefined,
|
||||
headerActions,
|
||||
})}
|
||||
@@ -827,7 +828,7 @@ export function PaneWorkbench({
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{chrome ? (
|
||||
{sharedComposer ? (
|
||||
<footer className="workbench-composer-footer shrink-0 px-3 pb-[calc(0.5rem+env(safe-area-inset-bottom))] sm:px-4 sm:pb-[calc(0.75rem+env(safe-area-inset-bottom))]">
|
||||
<div
|
||||
ref={setComposerPortalTarget}
|
||||
|
||||
+27
-32
@@ -987,11 +987,6 @@
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
/* Prism's Markdown table tokens must not pick up Tailwind's table layout. */
|
||||
.not-prose pre .token.table {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
/* Markdown table cells retain whole-word minimum widths. The renderer's
|
||||
overflow-x:auto wrapper contains tables wider than the preview or chat. */
|
||||
|
||||
@@ -1877,35 +1872,35 @@
|
||||
to { transform: translateX(100%); }
|
||||
}
|
||||
|
||||
/* Prism classes are generated at runtime, outside Tailwind's source inventory. */
|
||||
.code-content {
|
||||
--code-foreground: hsl(var(--foreground));
|
||||
--code-background: hsl(var(--background));
|
||||
color: hsl(var(--foreground));
|
||||
}
|
||||
/* Flattened JSX tokens retain the ancestor tag class; let inner token types win. */
|
||||
.code-content .token.tag {
|
||||
color: var(--code-property);
|
||||
|
||||
.nanobot-file-diff {
|
||||
--code-foreground: hsl(var(--foreground));
|
||||
--code-background: hsl(var(--background));
|
||||
display: block;
|
||||
min-width: 0;
|
||||
--diffs-font-size: var(--text-code-dense-size);
|
||||
--diffs-line-height: calc(var(--text-code-dense-size) * 1.6);
|
||||
--diffs-gap-block: 0px;
|
||||
--diffs-bg-context-override: transparent;
|
||||
--diffs-bg-context-gutter-override: transparent;
|
||||
--diffs-bg-addition-override: var(--diff-added);
|
||||
--diffs-bg-addition-number-override: var(--diff-added);
|
||||
--diffs-bg-deletion-override: var(--diff-deleted);
|
||||
--diffs-bg-deletion-number-override: var(--diff-deleted);
|
||||
--diffs-addition-color-override: var(--diff-added-foreground);
|
||||
--diffs-deletion-color-override: var(--diff-deleted-foreground);
|
||||
--diffs-fg-number-override: hsl(var(--muted-foreground));
|
||||
--diffs-bg-addition-emphasis-override: color-mix(in srgb, var(--diff-added-foreground) 15%, transparent);
|
||||
--diffs-bg-deletion-emphasis-override: color-mix(in srgb, var(--diff-deleted-foreground) 15%, transparent);
|
||||
}
|
||||
.code-content :is(.token.comment, .token.prolog, .token.doctype, .token.cdata, .linenumber) {
|
||||
color: var(--code-comment);
|
||||
}
|
||||
.code-content .token.comment {
|
||||
font-style: italic;
|
||||
}
|
||||
.code-content :is(.token.string, .token.char, .token.attr-value, .token.regex, .token.inserted) {
|
||||
color: var(--code-string);
|
||||
}
|
||||
.code-content :is(.token.keyword, .token.selector, .token.important, .token.atrule) {
|
||||
color: var(--code-keyword);
|
||||
}
|
||||
.code-content :is(.token.function, .token.operator, .token.entity, .token.url) {
|
||||
color: var(--code-function);
|
||||
}
|
||||
.code-content :is(.token.number, .token.boolean, .token.constant, .token.symbol, .token.attr-name, .token.class-name, .token.builtin, .token.property, .token.deleted) {
|
||||
color: var(--code-property);
|
||||
}
|
||||
.code-content :is(.token.bold, .token.important) {
|
||||
font-weight: 600;
|
||||
}
|
||||
.code-content .token.italic {
|
||||
font-style: italic;
|
||||
|
||||
.nanobot-diff-gap {
|
||||
height: 26px;
|
||||
box-sizing: border-box;
|
||||
white-space: nowrap;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { normalizeCodeLanguage } from "./code-language";
|
||||
import type { CodeLine } from "./code-tokens";
|
||||
|
||||
export interface CodeHighlight {
|
||||
read(): CodeLine[];
|
||||
}
|
||||
|
||||
const MAX_CACHED_SOURCE_BYTES = 2 * 1024 * 1024;
|
||||
const MAX_CACHE_ENTRIES = 16;
|
||||
const cache = new Map<string, CodeHighlight>();
|
||||
let sourceBytes = 0;
|
||||
|
||||
function cacheKey(source: string, language: string): string {
|
||||
return `${normalizeCodeLanguage(language)}\0${source}`;
|
||||
}
|
||||
|
||||
export function cachedCodeHighlight(source: string, language: string): CodeHighlight | undefined {
|
||||
const key = cacheKey(source, language);
|
||||
const resource = cache.get(key);
|
||||
if (resource) {
|
||||
cache.delete(key);
|
||||
cache.set(key, resource);
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
|
||||
export function discardCodeHighlight(source: string, language: string): void {
|
||||
const key = cacheKey(source, language);
|
||||
if (cache.delete(key)) sourceBytes -= key.length * 2;
|
||||
}
|
||||
|
||||
export function cacheCodeHighlight(source: string, language: string, resource: CodeHighlight): void {
|
||||
const key = cacheKey(source, language);
|
||||
const bytes = key.length * 2;
|
||||
if (bytes > MAX_CACHED_SOURCE_BYTES) return;
|
||||
discardCodeHighlight(source, language);
|
||||
while (cache.size >= MAX_CACHE_ENTRIES || sourceBytes + bytes > MAX_CACHED_SOURCE_BYTES) {
|
||||
const oldest = cache.keys().next().value!;
|
||||
cache.delete(oldest);
|
||||
sourceBytes -= oldest.length * 2;
|
||||
}
|
||||
cache.set(key, resource);
|
||||
sourceBytes += bytes;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { createHighlighterCore } from "shiki/core";
|
||||
import { createJavaScriptRegexEngine } from "shiki/engine/javascript";
|
||||
import { bundledLanguages } from "shiki/langs";
|
||||
|
||||
import { CODE_TEXTMATE_THEME, CODE_THEME_NAME } from "./code-theme";
|
||||
import type { CodeToken } from "./code-tokens";
|
||||
|
||||
let loaded: Awaited<ReturnType<typeof createHighlighterCore>> | undefined;
|
||||
const highlighter = createHighlighterCore({
|
||||
engine: createJavaScriptRegexEngine(), langs: [],
|
||||
themes: [CODE_TEXTMATE_THEME],
|
||||
}).then(engine => { loaded = engine; return engine; });
|
||||
|
||||
export function highlightGrammar(source: string, language: string): CodeToken[][] | Promise<CodeToken[][]> {
|
||||
const loader = Object.hasOwn(bundledLanguages, language) ? bundledLanguages[language as keyof typeof bundledLanguages] : undefined;
|
||||
if (!loader) return source.split("\n").map(content => [{ content }]);
|
||||
if (loaded?.getLoadedLanguages().includes(language)) return loaded.codeToTokens(source, { lang: language, theme: CODE_THEME_NAME }).tokens;
|
||||
return highlighter.then(async engine => {
|
||||
await engine.loadLanguage(loader);
|
||||
return engine.codeToTokens(source, { lang: language, theme: CODE_THEME_NAME }).tokens;
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { codeToTokens, isSupportedLanguage } from "@pierre/highlights";
|
||||
|
||||
import { cacheCodeHighlight, cachedCodeHighlight, type CodeHighlight } from "./code-highlight-cache";
|
||||
import { CODE_THEME, codeHighlighterLanguage } from "./code-theme";
|
||||
import { codeTokenLines, type CodeLine } from "./code-tokens";
|
||||
|
||||
type HighlightResult =
|
||||
| { state: "ready"; lines: CodeLine[] }
|
||||
| { state: "pending"; promise: Promise<void> }
|
||||
| { state: "failed"; error: unknown };
|
||||
let grammars: typeof import("./code-highlighter-grammars") | undefined;
|
||||
|
||||
function highlight(source: string, language: string): CodeHighlight {
|
||||
const code = source.replace(/\r\n/g, "\n").replace(/\r$/, "");
|
||||
let result: HighlightResult;
|
||||
if (isSupportedLanguage(language)) {
|
||||
result = { state: "ready", lines: codeTokenLines(source, codeToTokens(code, { lang: language, theme: CODE_THEME }).tokens) };
|
||||
} else {
|
||||
const tokens = grammars ? grammars.highlightGrammar(code, language) : import("./code-highlighter-grammars").then(module => {
|
||||
grammars = module;
|
||||
return module.highlightGrammar(code, language);
|
||||
});
|
||||
if (tokens instanceof Promise) {
|
||||
const promise = tokens.then(tokens => {
|
||||
result = { state: "ready", lines: codeTokenLines(source, tokens) };
|
||||
}, error => { result = { state: "failed", error }; });
|
||||
result = { state: "pending", promise };
|
||||
} else {
|
||||
result = { state: "ready", lines: codeTokenLines(source, tokens) };
|
||||
}
|
||||
}
|
||||
return { read() {
|
||||
if (result.state === "pending") throw result.promise;
|
||||
if (result.state === "failed") throw result.error;
|
||||
return result.lines;
|
||||
} };
|
||||
}
|
||||
|
||||
export function codeHighlight(source: string, language: string): CodeHighlight {
|
||||
const cached = cachedCodeHighlight(source, language);
|
||||
if (cached) return cached;
|
||||
const resource = highlight(source, codeHighlighterLanguage(language));
|
||||
cacheCodeHighlight(source, language, resource);
|
||||
return resource;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import type { Theme } from "@pierre/highlights";
|
||||
import type { ThemeRegistration } from "shiki";
|
||||
|
||||
export const CODE_THEME_NAME = "nanobot-code";
|
||||
export const CODE_THEME: Theme = {
|
||||
name: CODE_THEME_NAME, appearance: "dark", cssVariables: { prefix: "--code-" },
|
||||
style: {
|
||||
"editor.foreground": "foreground", "editor.background": "background",
|
||||
syntax: {
|
||||
comment: { color: "comment", font_style: "italic" },
|
||||
string: "string", "text.literal": "string",
|
||||
keyword: "keyword", preproc: "keyword",
|
||||
operator: "function", function: "function", constructor: "function",
|
||||
type: "property", attribute: "property", tag: "property",
|
||||
property: "property", number: "property", boolean: "property", constant: "property",
|
||||
title: { color: "keyword", font_weight: 700 }, emphasis: { font_style: "italic" }, "emphasis.strong": { font_weight: 700 },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const CODE_TEXTMATE_THEME: ThemeRegistration = {
|
||||
name: CODE_THEME_NAME, type: "dark", fg: "var(--code-foreground)", bg: "var(--code-background)",
|
||||
tokenColors: [
|
||||
{ scope: "comment", settings: { foreground: "var(--code-comment)", fontStyle: "italic" } },
|
||||
{ scope: ["string", "markup.raw"], settings: { foreground: "var(--code-string)" } },
|
||||
{ scope: ["keyword", "storage"], settings: { foreground: "var(--code-keyword)" } },
|
||||
{ scope: ["entity.name.function", "support.function", "variable.function", "keyword.operator"], settings: { foreground: "var(--code-function)" } },
|
||||
{ scope: ["constant", "support.type", "entity.name.type", "entity.name.tag", "entity.other.attribute-name", "entity.name.section"], settings: { foreground: "var(--code-property)" } },
|
||||
{ scope: ["keyword.operator.new", "keyword.operator.expression"], settings: { foreground: "var(--code-keyword)" } },
|
||||
{ scope: "markup.heading", settings: { foreground: "var(--code-keyword)", fontStyle: "bold" } },
|
||||
{ scope: "markup.italic", settings: { fontStyle: "italic" } },
|
||||
{ scope: "markup.bold", settings: { fontStyle: "bold" } },
|
||||
],
|
||||
};
|
||||
|
||||
export function codeHighlighterLanguage(language: string): string {
|
||||
return language === "markup" ? "html" : language === "docker" ? "dockerfile" : language;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
export interface CodeToken {
|
||||
content: string;
|
||||
color?: string;
|
||||
fontStyle?: number;
|
||||
}
|
||||
|
||||
export interface CodeLine {
|
||||
text: string;
|
||||
tokens: CodeToken[];
|
||||
}
|
||||
|
||||
export function codeTokenLines(source: string, tokens: CodeToken[][]): CodeLine[] {
|
||||
const lines = source.split("\n");
|
||||
return lines.map((text, index) => {
|
||||
const ending = index < lines.length - 1 ? "\n" : "";
|
||||
const cr = text.endsWith("\r") ? "\r" : "";
|
||||
return { text: text + ending, tokens: [...tokens[index] ?? [], ...(cr || ending ? [{ content: cr + ending }] : [])] };
|
||||
});
|
||||
}
|
||||
@@ -7,6 +7,12 @@ import { setAppLanguage } from "@/i18n";
|
||||
import { DEFAULT_LOCAL_PREFS, LOCAL_PREFS_STORAGE_KEY, writeLocalPreferences } from "@/lib/local-preferences";
|
||||
import type { CliAppInfo, McpPresetInfo, UIMessage } from "@/lib/types";
|
||||
|
||||
// These DOM tests exercise disclosure/source contracts; the real shadow renderer runs in browser tests.
|
||||
vi.mock("@/components/thread/activity/DiffSyntaxHighlight", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("@/components/thread/activity/DiffSyntaxHighlight")>();
|
||||
return { ...actual, DiffSyntaxHighlight: actual.PlainDiffLines };
|
||||
});
|
||||
|
||||
const BLENDER_CLI_APP: CliAppInfo = {
|
||||
name: "blender",
|
||||
display_name: "Blender",
|
||||
|
||||
@@ -4088,6 +4088,13 @@ describe("App layout", () => {
|
||||
.toEqual(["Alpha"]);
|
||||
expect(screen.queryByRole("button", { name: "Layout" }))
|
||||
.not.toBeInTheDocument();
|
||||
const alphaInput = screen.getByRole("textbox", { name: "Message Alpha" });
|
||||
expect(screen.getByTestId("workbench-pane-websocket:chat-alpha")).toContainElement(alphaInput);
|
||||
fireEvent.change(alphaInput, { target: { value: "keep this Alpha draft" } });
|
||||
fireEvent.change(alphaInput.closest(".thread-composer-surface")!.querySelector('input[type="file"]')!, {
|
||||
target: { files: [new File(["notes"], "alpha-notes.txt", { type: "text/plain" })] },
|
||||
});
|
||||
expect(within(await screen.findByTestId("composer-chip")).getByRole("button", { name: "alpha-notes.txt" })).toBeVisible();
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "Add pane" }));
|
||||
expect(screen.queryByRole("dialog", { name: "Search" })).not.toBeInTheDocument();
|
||||
@@ -4163,6 +4170,11 @@ describe("App layout", () => {
|
||||
name: "Remove",
|
||||
}));
|
||||
await waitFor(() => expect(screen.getByTestId("pane-grid").children).toHaveLength(1));
|
||||
fireEvent.click(within(sidebar).getByRole("button", { name: "Alpha" }));
|
||||
const restoredInput = await screen.findByRole("textbox", { name: "Message Alpha" });
|
||||
expect(screen.getByTestId("workbench-pane-websocket:chat-alpha")).toContainElement(restoredInput);
|
||||
expect(restoredInput).toHaveValue("keep this Alpha draft");
|
||||
expect(within(await screen.findByTestId("composer-chip")).getByRole("button", { name: "alpha-notes.txt" })).toBeVisible();
|
||||
const researchGroup = within(sidebar).getByRole("button", {
|
||||
name: "Group: Research",
|
||||
}).closest("[data-sidebar-tab-group]") as HTMLElement;
|
||||
|
||||
@@ -1,31 +1,49 @@
|
||||
import { act, render, screen, waitFor } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import type { HighlightedCodeProps } from "@/components/HighlightedCode";
|
||||
|
||||
import { CodeBlock } from "@/components/CodeBlock";
|
||||
import { ThemeProvider } from "@/hooks/useTheme";
|
||||
|
||||
vi.mock("react-syntax-highlighter/dist/esm/prism-async-light", () => ({
|
||||
default: ({
|
||||
children,
|
||||
language,
|
||||
customStyle,
|
||||
}: {
|
||||
children: string;
|
||||
language?: string;
|
||||
customStyle?: React.CSSProperties;
|
||||
}) => (
|
||||
<pre
|
||||
data-testid="highlighted-code"
|
||||
data-language={language}
|
||||
style={customStyle}
|
||||
>
|
||||
<code>{children}</code>
|
||||
</pre>
|
||||
),
|
||||
const failures = vi.hoisted(() => new Set<string>());
|
||||
|
||||
// Test CodeBlock's controls and enhancement boundary here; token/DOM rendering has dedicated real-engine and browser coverage.
|
||||
vi.mock("@/components/HighlightedCode", () => ({
|
||||
HighlightedCode: ({ code, language, viewportHighlight }: HighlightedCodeProps) => {
|
||||
if (failures.has(code)) throw new Error("Grammar download failed");
|
||||
return <pre data-testid="highlighted-code" data-language={language || "text"}
|
||||
style={{ overflow: viewportHighlight ? "visible" : "auto" }}><code data-code-text="">{code}</code></pre>;
|
||||
},
|
||||
}));
|
||||
|
||||
describe("CodeBlock", () => {
|
||||
it("contains a failed grammar, preserves source and copy, and enhances changed source", async () => {
|
||||
const source = "; 中文 😀\r\n[server]\r\nhost=localhost\r\n";
|
||||
failures.add(source);
|
||||
const user = userEvent.setup();
|
||||
const writeText = vi.fn().mockResolvedValue(undefined);
|
||||
Object.defineProperty(navigator, "clipboard", { configurable: true, value: { writeText } });
|
||||
const errors = vi.spyOn(console, "error").mockImplementation(() => {});
|
||||
const warnings = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
try {
|
||||
const { rerender } = render(<><textarea defaultValue="keep draft" /><CodeBlock code={source} language="ini" /></>);
|
||||
await waitFor(() => expect(warnings).toHaveBeenCalledWith("Code highlighting failed.", expect.any(Error)));
|
||||
expect(screen.getByTestId("plain-code-fallback").textContent).toBe(source);
|
||||
expect(screen.getByRole("textbox")).toHaveValue("keep draft");
|
||||
await user.click(screen.getByRole("button", { name: "Copy code" }));
|
||||
expect(writeText).toHaveBeenCalledWith(source);
|
||||
rerender(<><textarea defaultValue="keep draft" /><CodeBlock code={source + "; updated"} language="ini" /></>);
|
||||
expect((await screen.findByTestId("highlighted-code")).textContent).toBe(source + "; updated");
|
||||
expect(screen.getByRole("textbox")).toHaveValue("keep draft");
|
||||
} finally {
|
||||
failures.clear();
|
||||
errors.mockRestore();
|
||||
warnings.mockRestore();
|
||||
Reflect.deleteProperty(navigator, "clipboard");
|
||||
}
|
||||
});
|
||||
|
||||
it("renders and copies a large code block in full without pagination", async () => {
|
||||
const user = userEvent.setup();
|
||||
const writeText = vi.fn().mockResolvedValue(undefined);
|
||||
@@ -37,7 +55,8 @@ describe("CodeBlock", () => {
|
||||
|
||||
try {
|
||||
render(<CodeBlock code={source} language="typescript" showLineNumbers />);
|
||||
expect((await screen.findByTestId("highlighted-code")).textContent).toBe(source);
|
||||
const code = await screen.findByTestId("highlighted-code");
|
||||
expect([...code.querySelectorAll("[data-code-text]")].map(node => node.textContent).join("")).toBe(source);
|
||||
expect(screen.getAllByRole("button")).toHaveLength(1);
|
||||
await user.click(screen.getByRole("button", { name: "Copy code" }));
|
||||
expect(writeText).toHaveBeenCalledWith(source);
|
||||
@@ -179,7 +198,7 @@ describe("CodeBlock", () => {
|
||||
expect(screen.getByText("const value = 1;")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("normalizes file language aliases before loading Prism", async () => {
|
||||
it("normalizes file language aliases before highlighting", async () => {
|
||||
render(
|
||||
<ThemeProvider theme="light">
|
||||
<CodeBlock language="html" code="<main />" />
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { CodeTokens } from "@/components/CodeTokens";
|
||||
import { codeHighlight } from "@/lib/code-highlighter";
|
||||
|
||||
async function lines(source: string, language: string) {
|
||||
const resource = codeHighlight(source, language);
|
||||
try { return resource.read(); } catch (pending) {
|
||||
if (!(pending instanceof Promise)) throw pending;
|
||||
await pending;
|
||||
return resource.read();
|
||||
}
|
||||
}
|
||||
|
||||
describe("shared code highlighting", () => {
|
||||
it.each(["", "中文 😀\tconst x = 1;\n", "const a = 1;\r\n\tconst b = '中文';\r\n", "unterminated\r"])("preserves the complete source %j", async (source) => {
|
||||
const value = await lines(source, "typescript");
|
||||
expect(value.map(line => line.text).join("")).toBe(source);
|
||||
expect(value.flatMap(line => line.tokens).map(token => token.content).join("")).toBe(source);
|
||||
});
|
||||
|
||||
it("tokenizes the complete large code block without pagination or dropping rows", async () => {
|
||||
const source = Array.from({ length: 1200 }, (_, index) => `const value${index} = ${index};`).join("\n");
|
||||
const value = await lines(source, "typescript");
|
||||
expect(value).toHaveLength(1200);
|
||||
expect(value.flatMap(line => line.tokens).map(token => token.content).join("")).toBe(source);
|
||||
});
|
||||
|
||||
it("keeps multiline lexical context and produces the existing keyword/string palette", async () => {
|
||||
const value = await lines("/* start\ncomment\n*/\nexport const value = 'yes';", "typescript");
|
||||
expect(value[1].tokens.some(token => token.color === "var(--code-comment)" && token.fontStyle === 1)).toBe(true);
|
||||
expect(value[3].tokens.some(token => token.color === "var(--code-keyword)" && token.content.trim() === "export")).toBe(true);
|
||||
expect(value[3].tokens.some(token => token.color === "var(--code-string)" && token.content === "'yes'")).toBe(true);
|
||||
});
|
||||
|
||||
it("retains INI configuration-file colors", async () => {
|
||||
const source = "; comment\n[server]\nhost=localhost\n";
|
||||
const value = await lines(source, "ini");
|
||||
expect(value.flatMap(line => line.tokens).map(token => token.content).join("")).toBe(source);
|
||||
expect(value[0].tokens.some(token => token.color === "var(--code-comment)")).toBe(true);
|
||||
expect(value[1].tokens.some(token => token.color === "var(--code-property)")).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps an unknown language readable and never turns source into active HTML", async () => {
|
||||
const source = "<script>alert('x')</script><img onerror='bad()'>";
|
||||
render(<pre data-testid="source"><CodeTokens lines={await lines(source, "unknown-file-format")} /></pre>);
|
||||
expect(screen.getByTestId("source").textContent).toBe(source);
|
||||
expect(document.querySelector("script, img")).toBeNull();
|
||||
});
|
||||
|
||||
it("reuses source revisions but does not return stale text after an edit", async () => {
|
||||
const source = "export const value = 1;";
|
||||
expect(codeHighlight(source, "typescript")).toBe(codeHighlight(source, "typescript"));
|
||||
const changed = await lines(source.replace("1", "2"), "typescript");
|
||||
expect(changed.flatMap(line => line.tokens).map(token => token.content).join("")).toBe("export const value = 2;");
|
||||
});
|
||||
});
|
||||
@@ -1,161 +0,0 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { render, screen, waitFor } from "@testing-library/react";
|
||||
import { parse } from "postcss";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { DiffSyntaxHighlight } from "@/components/thread/activity/DiffSyntaxHighlight";
|
||||
import { ThemeProvider } from "@/hooks/useTheme";
|
||||
|
||||
const globalStyles = parse(readFileSync(resolve(process.cwd(), "src/globals.css"), "utf8"));
|
||||
// happy-dom does not apply cascade layers; retain the real rules and their order.
|
||||
globalStyles.walkAtRules("layer", (layer) => {
|
||||
layer.replaceWith(...(layer.nodes ?? []));
|
||||
});
|
||||
|
||||
describe("DiffSyntaxHighlight with Prism", () => {
|
||||
it("loads the TSX grammar and renders styled syntax tokens", async () => {
|
||||
render(
|
||||
<ThemeProvider theme="light">
|
||||
<DiffSyntaxHighlight
|
||||
language="tsx"
|
||||
lines={[
|
||||
{
|
||||
kind: "context",
|
||||
old_lineno: 1,
|
||||
new_lineno: 1,
|
||||
content: 'import { useMemo } from "react";',
|
||||
},
|
||||
{
|
||||
kind: "delete",
|
||||
old_lineno: 2,
|
||||
new_lineno: null,
|
||||
content: "export function StatusBadge() {",
|
||||
},
|
||||
{
|
||||
kind: "add",
|
||||
old_lineno: null,
|
||||
new_lineno: 2,
|
||||
content: "export function StatusBadge(): JSX.Element {",
|
||||
},
|
||||
{
|
||||
kind: "context",
|
||||
old_lineno: 3,
|
||||
new_lineno: 3,
|
||||
content: ' return <span className="badge">ready</span>;',
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</ThemeProvider>,
|
||||
);
|
||||
|
||||
// Full-suite workers can keep the first Prism grammar import busy for more
|
||||
// than Testing Library's one-second default, especially on Windows.
|
||||
const highlighted = await screen.findByTestId(
|
||||
"syntax-highlighted-diff-hunk",
|
||||
{},
|
||||
{ timeout: 10_000 },
|
||||
);
|
||||
await waitFor(
|
||||
() => {
|
||||
const tokens = highlighted.querySelectorAll<HTMLElement>(
|
||||
"td:last-child .token",
|
||||
);
|
||||
expect(tokens).not.toHaveLength(0);
|
||||
expect(highlighted.querySelector(".token.keyword")).not.toBeNull();
|
||||
expect(highlighted.querySelector(".token.string")).not.toBeNull();
|
||||
},
|
||||
{ timeout: 10_000 },
|
||||
);
|
||||
|
||||
expect(highlighted).toHaveAttribute("data-language", "tsx");
|
||||
expect(highlighted.querySelectorAll("tbody tr")).toHaveLength(4);
|
||||
});
|
||||
|
||||
it.each(["light", "dark"] as const)(
|
||||
"preserves nested JSX token colors in the %s appearance",
|
||||
async (appearance) => {
|
||||
const { container } = render(
|
||||
<div className={appearance === "dark" ? "dark" : ""}>
|
||||
<style>{globalStyles.toString()}</style>
|
||||
<DiffSyntaxHighlight
|
||||
language="tsx"
|
||||
lines={[{
|
||||
kind: "add",
|
||||
old_lineno: null,
|
||||
new_lineno: 1,
|
||||
content: '<span className={enabled ? "yes" : "no"} onClick={() => save(new Event("ok"))}>ready</span>',
|
||||
}]}
|
||||
/>
|
||||
</div>,
|
||||
);
|
||||
|
||||
const highlighted = await screen.findByTestId(
|
||||
"syntax-highlighted-diff-hunk",
|
||||
{},
|
||||
{ timeout: 10_000 },
|
||||
);
|
||||
await waitFor(() => {
|
||||
expect(highlighted.querySelector(".token.function")).not.toBeNull();
|
||||
}, { timeout: 10_000 });
|
||||
|
||||
const colors = getComputedStyle(
|
||||
appearance === "dark" ? container.firstElementChild! : document.documentElement,
|
||||
);
|
||||
const tokens = [...highlighted.querySelectorAll<HTMLElement>(".token")];
|
||||
for (const [text, category, variable] of [
|
||||
['"yes"', "string", "--code-string"],
|
||||
["new", "keyword", "--code-keyword"],
|
||||
["save", "function", "--code-function"],
|
||||
["=>", "operator", "--code-function"],
|
||||
["className", "attr-name", "--code-property"],
|
||||
["span", "tag", "--code-property"],
|
||||
]) {
|
||||
const token = tokens.find(
|
||||
(node) => node.textContent === text && node.classList.contains(category),
|
||||
);
|
||||
const expectedColor = colors.getPropertyValue(variable).trim();
|
||||
expect(token, `${category}: ${text}`).toBeDefined();
|
||||
expect(expectedColor).not.toBe("");
|
||||
expect.soft(getComputedStyle(token!).color, `${category}: ${text}`).toBe(expectedColor);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
it("preserves markdown table line boundaries", async () => {
|
||||
const lines = [
|
||||
"## 发布安排",
|
||||
"",
|
||||
"| 日期 | 角色 | 方向 | 是否进实验 |",
|
||||
"| --- | --- | --- | --- |",
|
||||
"| 7/22 | trust / core | data-driven | yes |",
|
||||
];
|
||||
|
||||
render(
|
||||
<ThemeProvider theme="light">
|
||||
<DiffSyntaxHighlight
|
||||
language="markdown"
|
||||
lines={lines.map((content, index) => ({
|
||||
kind: "add" as const,
|
||||
old_lineno: null,
|
||||
new_lineno: 20 + index,
|
||||
content,
|
||||
}))}
|
||||
/>
|
||||
</ThemeProvider>,
|
||||
);
|
||||
|
||||
const highlighted = await screen.findByTestId(
|
||||
"syntax-highlighted-diff-hunk",
|
||||
{},
|
||||
{ timeout: 10_000 },
|
||||
);
|
||||
const rows = [...highlighted.querySelectorAll("tbody tr")];
|
||||
|
||||
expect(rows).toHaveLength(lines.length);
|
||||
expect(rows.map((row) => row.querySelector("td:last-child")?.textContent)).toEqual(
|
||||
lines.map((line) => line || " "),
|
||||
);
|
||||
expect(highlighted.querySelector(".token.table")).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -1,84 +1,85 @@
|
||||
import { act, render, screen } from "@testing-library/react";
|
||||
import type { ReactNode } from "react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { DiffSyntaxHighlight } from "@/components/thread/activity/DiffSyntaxHighlight";
|
||||
import { ThemeProvider } from "@/hooks/useTheme";
|
||||
import { getDiffMetadata } from "@/components/thread/activity/PierreFileDiff";
|
||||
import { DIFF_GAP_HEIGHT, diffRenderWindow, diffRowOffsets } from "@/components/thread/activity/diff-render-window";
|
||||
import { parseRenderableFileDiff } from "@/lib/file-diff";
|
||||
|
||||
vi.mock("react-syntax-highlighter/dist/esm/prism-async-light", () => {
|
||||
const MockSyntaxHighlighter = ({
|
||||
children,
|
||||
language,
|
||||
renderer,
|
||||
...props
|
||||
}: {
|
||||
children: string;
|
||||
language: string;
|
||||
renderer: (args: {
|
||||
rows: Array<{
|
||||
type: "element";
|
||||
tagName: "span";
|
||||
properties: { className: string[] };
|
||||
children: Array<{ type: "text"; value: string }>;
|
||||
}>;
|
||||
stylesheet: Record<string, React.CSSProperties>;
|
||||
useInlineStyles: boolean;
|
||||
}) => ReactNode;
|
||||
[key: string]: unknown;
|
||||
}) => (
|
||||
<div data-testid={String(props["data-testid"])} data-language={language}>
|
||||
{renderer({
|
||||
rows: children.split("\n").map((line) => ({
|
||||
type: "element" as const,
|
||||
tagName: "span" as const,
|
||||
properties: { className: ["token", "keyword"] },
|
||||
children: [{ type: "text" as const, value: `${line}\n` }],
|
||||
})),
|
||||
stylesheet: {},
|
||||
useInlineStyles: true,
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
return { default: MockSyntaxHighlighter };
|
||||
});
|
||||
const patch = (name: string, content: string, start = 20) => `--- a/${name}\n+++ b/${name}\n@@ -0,0 +${start},1 @@\n+${content}\n`;
|
||||
|
||||
vi.mock("react-syntax-highlighter/dist/esm/create-element", () => ({
|
||||
default: ({ node }: { node: { children?: Array<{ value?: string }> } }) => (
|
||||
<span data-testid="syntax-token">{node.children?.[0]?.value}</span>
|
||||
),
|
||||
}));
|
||||
|
||||
describe("DiffSyntaxHighlight", () => {
|
||||
it("highlights a complete hunk while preserving diff rows and line numbers", async () => {
|
||||
render(
|
||||
<ThemeProvider theme="light">
|
||||
<DiffSyntaxHighlight
|
||||
language="typescript"
|
||||
lines={[
|
||||
{ kind: "context", old_lineno: 4, new_lineno: 4, content: "export function run() {" },
|
||||
{ kind: "delete", old_lineno: 5, new_lineno: null, content: " return oldValue;" },
|
||||
{ kind: "add", old_lineno: null, new_lineno: 5, content: " return newValue;" },
|
||||
]}
|
||||
/>
|
||||
</ThemeProvider>,
|
||||
);
|
||||
|
||||
await act(async () => {
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
describe("file diff render metadata", () => {
|
||||
it("preserves complete source and coordinates and reuses a revision across remounts", () => {
|
||||
const text = "--- a/fixture.ts\n+++ b/fixture.ts\n@@ -4,3 +4,3 @@\n export function run() {\n- return oldValue;\n+ return newValue;\n \n";
|
||||
const file = getDiffMetadata(text, "typescript");
|
||||
expect(file.hunks).toHaveLength(1);
|
||||
expect(file.hunks[0]).toMatchObject({ deletionStart: 4, additionStart: 4, deletionCount: 3, additionCount: 3, unifiedLineCount: 4 });
|
||||
expect(file.deletionLines).toEqual(["export function run() {\n", " return oldValue;\n", "\n"]);
|
||||
expect(file.additionLines).toEqual(["export function run() {\n", " return newValue;\n", "\n"]);
|
||||
expect(getDiffMetadata(text, "typescript")).toBe(file);
|
||||
expect(getDiffMetadata(text.replace("newValue", "changedValue"), "typescript").cacheKey).not.toBe(file.cacheKey);
|
||||
expect(getDiffMetadata(text, "javascript").cacheKey).not.toBe(file.cacheKey);
|
||||
});
|
||||
|
||||
const highlighted = await screen.findByTestId("syntax-highlighted-diff-hunk");
|
||||
expect(highlighted).toHaveAttribute("data-language", "typescript");
|
||||
expect(screen.getAllByTestId("syntax-token")).toHaveLength(3);
|
||||
expect(screen.getByText("return oldValue;", { exact: false }).closest("tr")).toHaveClass(
|
||||
"bg-diff-deleted",
|
||||
);
|
||||
expect(screen.getByText("return newValue;", { exact: false }).closest("tr")).toHaveClass(
|
||||
"bg-diff-added",
|
||||
);
|
||||
expect(screen.getAllByText("5")).toHaveLength(2);
|
||||
expect(screen.getAllByTestId("syntax-token").some((node) => node.textContent?.endsWith("\n"))).toBe(false);
|
||||
it.each([["markup", "html"], ["docker", "dockerfile"], ["ini", "ini"], ["lock", "text"]])("maps %s to %s without losing source", (language, expected) => {
|
||||
const file = getDiffMetadata(patch("fixture", "<span>中文 & text</span>"), language);
|
||||
expect(file.lang).toBe(expected);
|
||||
expect(file.additionLines).toEqual(["<span>中文 & text</span>\n"]);
|
||||
expect(file.hunks[0]).toMatchObject({ deletionCount: 0, additionStart: 20, additionCount: 1 });
|
||||
});
|
||||
|
||||
it("evicts older revisions under the entry budget without reusing their identity", () => {
|
||||
const text = patch("old.ts", "old revision");
|
||||
const old = getDiffMetadata(text, "typescript");
|
||||
for (let i = 0; i < 16; i++) getDiffMetadata(patch(`revision-${i}.ts`, `const item = ${i};`), "typescript");
|
||||
const reloaded = getDiffMetadata(text, "typescript");
|
||||
expect(reloaded.cacheKey).not.toBe(old.cacheKey);
|
||||
expect(reloaded.additionLines).toEqual(old.additionLines);
|
||||
});
|
||||
});
|
||||
|
||||
describe("file diff render windows", () => {
|
||||
const lines = Array.from({ length: 200 }, (_, i) => `+export const item${i} = ${i};`);
|
||||
const text = `--- a/fixture.ts\n+++ b/fixture.ts\n@@ -0,0 +1,200 @@\n${lines.join("\n")}\n@@ -500,0 +501,200 @@\n${lines.join("\n")}\n`;
|
||||
const diff = parseRenderableFileDiff({ format: "unified", text });
|
||||
|
||||
it("keeps the initial 160-line disclosure bounded and reserves no space for hidden content", () => {
|
||||
const offsets = diffRowOffsets(diff, 160, 24);
|
||||
expect(offsets).toHaveLength(161);
|
||||
expect(offsets.at(-1)).toBe(160 * 24);
|
||||
expect(diffRenderWindow(diff, offsets, 0, 900, 24)).toEqual({ startingLine: 0, totalLines: 160, bufferBefore: 0, bufferAfter: 0 });
|
||||
});
|
||||
|
||||
it("retains a fixed row budget while an overlapping viewport remains in the same start chunk", () => {
|
||||
const offsets = diffRowOffsets(diff, 400, 24);
|
||||
expect(diffRenderWindow(diff, offsets, -900, 1800, 24)).toEqual(diffRenderWindow(diff, offsets, -300, 2400, 24));
|
||||
});
|
||||
|
||||
it("covers the requested overscan in short and tall reading viewports", () => {
|
||||
for (const lineHeight of [21.1875, 23.59375, 26]) {
|
||||
const offsets = diffRowOffsets(diff, 400, lineHeight);
|
||||
const height = offsets.at(-1)!;
|
||||
for (const viewportHeight of [240, 390, 844, 1050]) {
|
||||
for (let y = 0; y < height; y += lineHeight * 10) {
|
||||
const top = y - viewportHeight;
|
||||
const bottom = y + viewportHeight * 2;
|
||||
const window = diffRenderWindow(diff, offsets, top, bottom, lineHeight);
|
||||
expect(window.bufferBefore).toBeLessThanOrEqual(Math.max(0, top));
|
||||
expect(height - window.bufferAfter).toBeGreaterThanOrEqual(Math.min(height, bottom));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("preserves total geometry and gap ownership across adjacent virtual windows", () => {
|
||||
const offsets = diffRowOffsets(diff, 400, 24);
|
||||
expect(offsets.at(-1)).toBe(400 * 24 + DIFF_GAP_HEIGHT);
|
||||
const first = diffRenderWindow(diff, offsets, 0, 3840, 24);
|
||||
expect(first).toEqual({ startingLine: 0, totalLines: 200, bufferBefore: 0, bufferAfter: 200 * 24 + DIFF_GAP_HEIGHT });
|
||||
const second = diffRenderWindow(diff, offsets, 4827, 6000, 24);
|
||||
expect(second.startingLine).toBe(200);
|
||||
expect(second.bufferBefore).toBe(200 * 24);
|
||||
expect(second.totalLines * 24 + DIFF_GAP_HEIGHT + second.bufferBefore + second.bufferAfter).toBe(offsets.at(-1));
|
||||
const tail = diffRenderWindow(diff, offsets, 30000, 32000, 24);
|
||||
expect(tail.startingLine + tail.totalLines).toBe(400);
|
||||
expect(tail.bufferAfter).toBe(0);
|
||||
});
|
||||
});
|
||||
@@ -108,17 +108,24 @@ function BspWorkbenchHarness() {
|
||||
}
|
||||
|
||||
describe("PaneWorkbench", () => {
|
||||
it("keeps a single conversation's header inside that pane instead of above its previews", () => {
|
||||
it("keeps a single conversation's header and composer inside its preview layout", () => {
|
||||
const composer = <textarea aria-label="Composer Alpha" />;
|
||||
render(<PaneWorkbench panes={[{ key: "alpha", title: "Alpha" }]} activePaneKey="alpha"
|
||||
layout="columns" chrome showLayoutControl={false} onActivatePane={vi.fn()} onAddPane={vi.fn()}
|
||||
onLayoutChange={vi.fn()} onPaneOrderChange={vi.fn()}
|
||||
renderPane={(_pane, context) => {
|
||||
expect(context.headerPortalTarget).toBeUndefined();
|
||||
expect(context.multiplePanes).toBe(false);
|
||||
return <div data-testid="local-toolbar">{context.headerActions}</div>;
|
||||
return <div data-testid="local-toolbar">
|
||||
{context.headerActions}
|
||||
{context.composerPortalTarget === undefined ? composer : context.composerPortalTarget
|
||||
? createPortal(composer, context.composerPortalTarget) : null}
|
||||
</div>;
|
||||
}} />);
|
||||
expect(screen.getByTestId("workbench-header-host")).toBeEmptyDOMElement();
|
||||
expect(within(screen.getByTestId("local-toolbar")).getByRole("button", { name: "Add pane" })).toBeVisible();
|
||||
const conversation = screen.getByTestId("local-toolbar");
|
||||
expect(within(conversation).getByRole("button", { name: "Add pane" })).toBeVisible();
|
||||
expect(within(conversation).getByRole("textbox", { name: "Composer Alpha" })).toBeVisible();
|
||||
});
|
||||
|
||||
const originalGetBoundingClientRect = HTMLElement.prototype.getBoundingClientRect;
|
||||
@@ -168,7 +175,7 @@ describe("PaneWorkbench", () => {
|
||||
.toEqual(["Alpha", "Beta"]);
|
||||
expect(screen.getByRole("button", { name: "Focus Alpha" })).toHaveAttribute("data-multiple-panes", "true");
|
||||
expect(screen.getByRole("button", { name: "Focus Beta" })).toHaveAttribute("data-multiple-panes", "true");
|
||||
expect(screen.getByLabelText("Composer Beta")).toBeVisible();
|
||||
expect(within(screen.getByTestId("workbench-composer-host")).getByLabelText("Composer Beta")).toBeVisible();
|
||||
expect(screen.getByLabelText("Composer Alpha")).not.toBeVisible();
|
||||
|
||||
fireEvent.pointerDown(
|
||||
@@ -400,7 +407,12 @@ describe("PaneWorkbench", () => {
|
||||
renderPane: (pane: { key: string; title: string }, context: {
|
||||
headerActions: ReactNode;
|
||||
multiplePanes: boolean;
|
||||
}) => <>{context.headerActions}<span data-multiple-panes={context.multiplePanes}>{pane.title}</span></>,
|
||||
composerPortalTarget: HTMLElement | null | undefined;
|
||||
}) => <>{context.headerActions}<span data-multiple-panes={context.multiplePanes}>{pane.title}</span>
|
||||
{context.composerPortalTarget ? createPortal(
|
||||
<textarea aria-label={`Composer ${pane.title}`} />, context.composerPortalTarget,
|
||||
) : null}
|
||||
</>,
|
||||
};
|
||||
|
||||
const { rerender } = render(<PaneWorkbench {...props} activePaneKey="gamma" />);
|
||||
@@ -408,6 +420,7 @@ describe("PaneWorkbench", () => {
|
||||
expect(screen.getByTestId("pane-grid").children).toHaveLength(1);
|
||||
expect(screen.getByTestId("workbench-pane-gamma")).toBeInTheDocument();
|
||||
expect(screen.getByText("gamma", { selector: "span" })).toHaveAttribute("data-multiple-panes", "false");
|
||||
expect(within(screen.getByTestId("workbench-composer-host")).getByRole("textbox", { name: "Composer gamma" })).toBeVisible();
|
||||
expect(screen.queryByRole("button", { name: "Layout" })).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole("button", { name: "Add pane" })).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole("separator")).not.toBeInTheDocument();
|
||||
@@ -415,6 +428,7 @@ describe("PaneWorkbench", () => {
|
||||
rerender(<PaneWorkbench {...props} activePaneKey="delta" />);
|
||||
expect(screen.getByTestId("pane-grid").children).toHaveLength(1);
|
||||
expect(screen.getByTestId("workbench-pane-delta")).toBeInTheDocument();
|
||||
expect(within(screen.getByTestId("workbench-composer-host")).getByRole("textbox", { name: "Composer delta" })).toBeVisible();
|
||||
expect(screen.queryByTestId("workbench-pane-gamma")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
@@ -11,6 +11,12 @@ import {
|
||||
import { preloadMarkdownText } from "@/components/MarkdownText";
|
||||
import type { UIMessage } from "@/lib/types";
|
||||
|
||||
// These DOM tests exercise disclosure/source contracts; the real shadow renderer runs in browser tests.
|
||||
vi.mock("@/components/thread/activity/DiffSyntaxHighlight", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("@/components/thread/activity/DiffSyntaxHighlight")>();
|
||||
return { ...actual, DiffSyntaxHighlight: actual.PlainDiffLines };
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
vi.unstubAllGlobals();
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import { act, render, screen } from "@testing-library/react";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import SyntaxHighlighter from "react-syntax-highlighter/dist/esm/prism-light";
|
||||
import markup from "react-syntax-highlighter/dist/esm/languages/prism/markup";
|
||||
import oneLight from "react-syntax-highlighter/dist/esm/styles/prism/one-light";
|
||||
import { codeHighlight } from "@/lib/code-highlighter";
|
||||
|
||||
import { ViewportCodeRows } from "@/components/ViewportCodeRows";
|
||||
|
||||
SyntaxHighlighter.registerLanguage("markup", markup);
|
||||
|
||||
let notify: (entries: IntersectionObserverEntry[]) => void;
|
||||
const disconnect = vi.fn();
|
||||
const observe = vi.fn();
|
||||
@@ -25,8 +21,7 @@ function sourceText() {
|
||||
return [...document.querySelectorAll("[data-highlighted]")].map(node => node.textContent).join("");
|
||||
}
|
||||
function preview(code: string) {
|
||||
return <div data-file-preview-scroll><SyntaxHighlighter language="markup" style={oneLight}
|
||||
renderer={props => <ViewportCodeRows {...props} />}>{code}</SyntaxHighlighter></div>;
|
||||
return <div data-file-preview-scroll><ViewportCodeRows lines={codeHighlight(code, "markup").read()} /></div>;
|
||||
}
|
||||
|
||||
describe("viewport code highlighting", () => {
|
||||
|
||||
@@ -70,14 +70,18 @@ describe("entryLazyFeatureImports", () => {
|
||||
expect(entryLazyFeatureImports(["assets/react-vendor-abc.js"])).toEqual([]);
|
||||
expect(entryLazyFeatureImports([
|
||||
"assets/markdown-vendor-abc.js",
|
||||
"assets/syntax-highlight-def.js",
|
||||
"assets/katex-ghi.js",
|
||||
"assets/MermaidBlock-jkl.js",
|
||||
"assets/HighlightedCode-def.js",
|
||||
"assets/code-highlighter-ghi.js",
|
||||
"assets/PierreFileDiff-jkl.js",
|
||||
"assets/katex-mno.js",
|
||||
"assets/MermaidBlock-pqr.js",
|
||||
])).toEqual([
|
||||
"assets/markdown-vendor-abc.js",
|
||||
"assets/syntax-highlight-def.js",
|
||||
"assets/katex-ghi.js",
|
||||
"assets/MermaidBlock-jkl.js",
|
||||
"assets/HighlightedCode-def.js",
|
||||
"assets/code-highlighter-ghi.js",
|
||||
"assets/PierreFileDiff-jkl.js",
|
||||
"assets/katex-mno.js",
|
||||
"assets/MermaidBlock-pqr.js",
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -100,12 +104,6 @@ describe("webuiManualChunk", () => {
|
||||
expect(webuiManualChunk("\0vite/preload-helper.js")).toBe("react-vendor");
|
||||
});
|
||||
|
||||
it("keeps Refractor's selector parser in the syntax highlighting chunk", () => {
|
||||
expect(
|
||||
webuiManualChunk("/repo/node_modules/hast-util-parse-selector/index.js"),
|
||||
).toBe("syntax-highlight");
|
||||
});
|
||||
|
||||
it("keeps markdown-only hast utilities in the markdown chunk", () => {
|
||||
expect(
|
||||
webuiManualChunk("/repo/node_modules/hast-util-to-jsx-runtime/lib/index.js"),
|
||||
@@ -132,6 +130,6 @@ describe("webuiManualChunk", () => {
|
||||
});
|
||||
|
||||
it("leaves language grammars as independently loaded chunks", () => {
|
||||
expect(webuiManualChunk("/repo/node_modules/refractor/lang/python.js")).toBeUndefined();
|
||||
expect(webuiManualChunk("/repo/node_modules/@shikijs/langs/dist/ini.mjs")).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -1,22 +0,0 @@
|
||||
declare module "react-syntax-highlighter/dist/esm/prism-async-light" {
|
||||
import * as React from "react";
|
||||
import type { SyntaxHighlighterProps } from "react-syntax-highlighter";
|
||||
|
||||
export default class SyntaxHighlighter extends React.Component<SyntaxHighlighterProps> {
|
||||
static registerLanguage(name: string, func: unknown): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "react-syntax-highlighter/dist/esm/styles/prism/one-dark" {
|
||||
import type * as React from "react";
|
||||
|
||||
const style: { [key: string]: React.CSSProperties };
|
||||
export default style;
|
||||
}
|
||||
|
||||
declare module "react-syntax-highlighter/dist/esm/styles/prism/one-light" {
|
||||
import type * as React from "react";
|
||||
|
||||
const style: { [key: string]: React.CSSProperties };
|
||||
export default style;
|
||||
}
|
||||
+3
-13
@@ -32,7 +32,7 @@ function startupSkeleton(): Plugin {
|
||||
|
||||
const GZIP_MIN_BYTES = 4 * 1024;
|
||||
const GZIP_ASSET_PATTERN = /\.(?:css|html|js|json|mjs|svg)$/i;
|
||||
const LAZY_FEATURE_CHUNK_PREFIXES = ["markdown-vendor-", "markdown-diagrams-", "MermaidBlock-", "syntax-highlight-", "katex-"];
|
||||
const LAZY_FEATURE_CHUNK_PREFIXES = ["markdown-vendor-", "markdown-diagrams-", "MermaidBlock-", "HighlightedCode-", "code-highlighter-", "PierreFileDiff-", "katex-"];
|
||||
|
||||
export function entryLazyFeatureImports(imports: string[]): string[] {
|
||||
return imports.filter((fileName) =>
|
||||
@@ -105,21 +105,9 @@ export function webuiManualChunk(id: string): string | undefined {
|
||||
) {
|
||||
return "react-vendor";
|
||||
}
|
||||
if (id.includes("node_modules/refractor/lang/")) {
|
||||
return;
|
||||
}
|
||||
// Streamdown retains a lazy viewer shell, not the native Mermaid engine.
|
||||
if (id.includes("node_modules/streamdown/dist/mermaid-")) return "markdown-diagrams";
|
||||
if (id.includes("node_modules/streamdown/dist/highlighted-body-")) return "markdown-code";
|
||||
// Refractor reaches this HAST helper through hastscript. Keeping it with
|
||||
// Refractor prevents syntax-highlight <-> markdown-vendor circular chunks.
|
||||
if (
|
||||
id.includes("node_modules/react-syntax-highlighter")
|
||||
|| id.includes("node_modules/refractor/core")
|
||||
|| id.includes("node_modules/hast-util-parse-selector")
|
||||
) {
|
||||
return "syntax-highlight";
|
||||
}
|
||||
if (
|
||||
id.includes("node_modules/streamdown")
|
||||
|| id.includes("node_modules/remend")
|
||||
@@ -159,6 +147,8 @@ export default defineConfig(({ mode }) => {
|
||||
// so nested overlays can dismiss the wrong layer in development.
|
||||
include: [
|
||||
"@radix-ui/react-dialog",
|
||||
"@pierre/diffs", "@pierre/diffs/worker", "@pierre/highlights",
|
||||
"shiki/core", "shiki/langs", "shiki/engine/javascript",
|
||||
// Vite's HTML scan does not follow the lazy Worker entry. Discovering
|
||||
// these imports on first render would reload the page and lose UI state.
|
||||
"pele/lazy", "saxes", "css-tree/parser", "css-tree/walker", "css-tree/generator",
|
||||
|
||||
Reference in new issue
Block a user