@botiverse/porthole 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/THIRD_PARTY_NOTICES.md +421 -0
- package/dist/bridge/bounded-text.d.ts +34 -0
- package/dist/bridge/bounded-text.js +188 -0
- package/dist/bridge/bridge.d.ts +25 -5
- package/dist/bridge/bridge.js +311 -73
- package/dist/bridge/json-data.d.ts +28 -0
- package/dist/bridge/json-data.js +86 -0
- package/dist/bridge/navigation.d.ts +5 -0
- package/dist/bridge/navigation.js +7 -0
- package/dist/bridge/refusal.js +1 -0
- package/dist/bridge/types.d.ts +32 -1
- package/dist/check/page-source.js +1 -1
- package/dist/check/page.js +2 -0
- package/dist/compile/compile.d.ts +6 -0
- package/dist/compile/compile.js +3 -1
- package/dist/compile/policy.d.ts +38 -2
- package/dist/compile/policy.js +122 -7
- package/dist/config/capabilities.d.ts +23 -4
- package/dist/config/capabilities.js +12 -2
- package/dist/config/schema.d.ts +11 -0
- package/dist/config/validate.d.ts +8 -2
- package/dist/config/validate.js +28 -6
- package/dist/config/warnings.d.ts +20 -0
- package/dist/config/warnings.js +25 -0
- package/dist/conformance/behavior.js +46 -1
- package/dist/conformance/cookies.d.ts +15 -0
- package/dist/conformance/cookies.js +80 -0
- package/dist/conformance/harness/page.d.ts +1 -0
- package/dist/conformance/harness/page.js +9 -2
- package/dist/conformance/harness-source.js +1 -1
- package/dist/conformance/host-kit.js +5 -1
- package/dist/conformance/index.d.ts +10 -0
- package/dist/conformance/limits.js +38 -1
- package/dist/conformance/runtime.js +10 -0
- package/dist/conformance/served.d.ts +2 -0
- package/dist/conformance/served.js +737 -4
- package/dist/files/paths.js +4 -0
- package/dist/guide/gates.d.ts +7 -1
- package/dist/guide/gates.js +12 -0
- package/dist/guide/guide.js +2 -2
- package/dist/guide/runtime.js +11 -3
- package/dist/host/create-host.js +49 -37
- package/dist/host/pages-of-set.d.ts +43 -0
- package/dist/host/pages-of-set.js +196 -0
- package/dist/host/types.d.ts +8 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +3 -2
- package/dist/mcp/adapter.js +11 -15
- package/dist/node/index.d.ts +36 -4
- package/dist/node/index.js +402 -101
- package/dist/presets/presets.d.ts +16 -8
- package/dist/presets/presets.js +39 -8
- package/dist/protocol/live-data.d.ts +6 -2
- package/dist/protocol/live-data.js +20 -1
- package/dist/protocol/mcp-apps.d.ts +13 -2
- package/dist/protocol/mcp-apps.js +10 -2
- package/dist/protocol/message-text.d.ts +8 -0
- package/dist/protocol/message-text.js +29 -0
- package/dist/protocol/runtime-calls.js +3 -0
- package/dist/protocol/shell-adapter.js +16 -22
- package/dist/react/context-notice.d.ts +32 -0
- package/dist/react/context-notice.js +28 -0
- package/dist/react/dialog.js +62 -18
- package/dist/react/frame.d.ts +12 -1
- package/dist/react/frame.js +79 -2
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +2 -1
- package/dist/runtime/contract.d.ts +9 -1
- package/dist/runtime/contract.js +31 -2
- package/dist/runtime/db.d.ts +41 -6
- package/dist/runtime/db.js +120 -16
- package/dist/runtime/declaration.d.ts +15 -1
- package/dist/runtime/declaration.js +184 -87
- package/dist/runtime/requests.js +27 -11
- package/dist/runtime/types.generated.js +1 -1
- package/dist/server/files.d.ts +5 -0
- package/dist/server/files.js +22 -7
- package/dist/server/host.d.ts +18 -1
- package/dist/server/host.js +132 -2
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/peer.d.ts +4 -0
- package/dist/server/peer.js +19 -0
- package/dist/server/proxy.d.ts +6 -0
- package/dist/server/proxy.js +12 -3
- package/dist/server/server.js +113 -26
- package/dist/server/types.d.ts +6 -3
- package/dist/shell/document.d.ts +8 -0
- package/dist/shell/document.js +3 -0
- package/dist/shell/runtime.js +361 -14
- package/docs/ADOPTING.md +119 -14
- package/docs/ARCHITECTURE.md +13 -3
- package/docs/DECISIONS.md +1455 -8
- package/docs/DESIGN.md +79 -25
- package/docs/THREAT_MODEL.md +616 -0
- package/package.json +14 -3
- package/src/bridge/bounded-text.ts +240 -0
- package/src/bridge/bridge.ts +373 -84
- package/src/bridge/json-data.ts +95 -0
- package/src/bridge/navigation.ts +10 -0
- package/src/bridge/refusal.ts +1 -0
- package/src/bridge/types.ts +30 -1
- package/src/check/page.ts +2 -0
- package/src/compile/compile.ts +9 -1
- package/src/compile/policy.ts +130 -7
- package/src/config/capabilities.ts +22 -3
- package/src/config/schema.ts +11 -0
- package/src/config/validate.ts +43 -5
- package/src/config/warnings.ts +42 -0
- package/src/conformance/behavior.ts +54 -1
- package/src/conformance/cookies.ts +93 -0
- package/src/conformance/harness/page.ts +11 -2
- package/src/conformance/host-kit.ts +10 -1
- package/src/conformance/index.ts +10 -0
- package/src/conformance/limits.ts +39 -1
- package/src/conformance/runtime.ts +21 -0
- package/src/conformance/served.ts +888 -4
- package/src/files/paths.ts +4 -0
- package/src/guide/gates.ts +13 -1
- package/src/guide/guide.ts +3 -3
- package/src/guide/runtime.ts +12 -3
- package/src/host/create-host.ts +54 -36
- package/src/host/pages-of-set.ts +226 -0
- package/src/host/types.ts +15 -1
- package/src/index.ts +5 -0
- package/src/mcp/adapter.ts +16 -20
- package/src/node/index.ts +507 -116
- package/src/presets/presets.ts +60 -17
- package/src/protocol/live-data.ts +31 -3
- package/src/protocol/mcp-apps.ts +11 -2
- package/src/protocol/message-text.ts +36 -0
- package/src/protocol/runtime-calls.ts +3 -0
- package/src/protocol/shell-adapter.ts +27 -23
- package/src/react/context-notice.tsx +95 -0
- package/src/react/dialog.tsx +77 -17
- package/src/react/frame.tsx +101 -0
- package/src/react/index.ts +8 -1
- package/src/runtime/contract.ts +36 -2
- package/src/runtime/db.ts +140 -20
- package/src/runtime/declaration.ts +227 -89
- package/src/runtime/requests.ts +27 -11
- package/src/runtime/types.generated.ts +1 -1
- package/src/server/files.ts +29 -11
- package/src/server/host.ts +158 -3
- package/src/server/index.ts +1 -0
- package/src/server/peer.ts +21 -0
- package/src/server/proxy.ts +13 -3
- package/src/server/server.ts +139 -36
- package/src/server/types.ts +6 -3
- package/src/shell/document.ts +8 -0
- package/src/shell/runtime.ts +361 -14
- package/types/runtime/v1/context.d.ts +13 -2
package/README.md
CHANGED
|
@@ -112,6 +112,8 @@ width, light and dark, before anyone sees it, and tells the agent what broke in
|
|
|
112
112
|
CSP, Workers, local development, the agent's tools, conformance, troubleshooting.
|
|
113
113
|
- [Choosing egress](docs/ADOPTING.md#choosing-egress): what content may load (closed, library
|
|
114
114
|
CDNs, passive media from any https site), what each level opens and the risk it re-opens.
|
|
115
|
+
- [docs/THREAT_MODEL.md](docs/THREAT_MODEL.md): what Porthole protects and from whom; for each
|
|
116
|
+
use, what it guarantees, what is left to you, and what isn't covered.
|
|
115
117
|
- [docs/DESIGN.md](docs/DESIGN.md): how it works. [docs/DECISIONS.md](docs/DECISIONS.md): why,
|
|
116
118
|
by P-number (the code cites them).
|
|
117
119
|
|
|
@@ -122,7 +124,7 @@ width, light and dark, before anyone sees it, and tells the agent what broke in
|
|
|
122
124
|
| `@botiverse/porthole` | `createHost`, `presets`, `defineDisplays`, `portholeClient`, `lintContent`, the tools (browser and server) |
|
|
123
125
|
| `@botiverse/porthole/react` | `PortholeProvider`, `PortholeFrame`, `PortholeView` |
|
|
124
126
|
| `@botiverse/porthole/server` | `createContentHost` (`routes`), `contentHostFor`, `prefixedName`, `d1TicketStore` (any runtime) |
|
|
125
|
-
| `@botiverse/porthole/node` | `nodeServer`, `nodeHost`, `nodeProbe` (Node's http server) |
|
|
127
|
+
| `@botiverse/porthole/node` | `nodeServer`, `nodeHost`, `nodeListener`, `nodeProbe` (Node's http server) |
|
|
126
128
|
| `@botiverse/porthole/mcp` | the MCP Apps adapter |
|
|
127
129
|
| `@botiverse/porthole/check` | `checkPage`, `playwrightDriver`, `cdpDriver`: the agent's pre-show check |
|
|
128
130
|
| `@botiverse/porthole/conformance` | `defineHostConformance`: the suite, against your app (Playwright) |
|
|
@@ -131,4 +133,9 @@ width, light and dark, before anyone sees it, and tells the agent what broke in
|
|
|
131
133
|
|
|
132
134
|
Apache-2.0. `/server` also serves copies of [Chart.js](https://www.chartjs.org) 4.5.1 (MIT) and
|
|
133
135
|
[D3](https://d3js.org) 7.9.0 (ISC) to live widgets (P079), each with its license beside it
|
|
134
|
-
(`/__porthole/lib/<name>@<version>/`), from `src/libraries/files.generated.ts
|
|
136
|
+
(`/__porthole/lib/<name>@<version>/`), from `src/libraries/files.generated.ts`; their notices,
|
|
137
|
+
and those of the packages their files bundle, are in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|
|
138
|
+
|
|
139
|
+
Found a vulnerability? Report it privately, as
|
|
140
|
+
[SECURITY.md](https://github.com/botiverse/porthole/blob/main/SECURITY.md) says, never in a public
|
|
141
|
+
issue.
|
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
`@botiverse/porthole` is licensed under Apache-2.0 ([LICENSE](LICENSE)). It also ships
|
|
4
|
+
third-party code: the libraries `/server` serves to live widgets (P079), copied byte for byte
|
|
5
|
+
from their npm packages into `src/libraries/files.generated.ts` (and `dist/`), each served with
|
|
6
|
+
its own license beside it. Each library's file bundles the packages listed under it. Their
|
|
7
|
+
license texts follow, as the packages pnpm installs for it carry them (the library's authors
|
|
8
|
+
may have built its file from earlier releases of the same majors).
|
|
9
|
+
|
|
10
|
+
Generated by `scripts/notices.ts` from the installed packages (P097): do not edit.
|
|
11
|
+
|
|
12
|
+
## Chart.js 4.5.1
|
|
13
|
+
|
|
14
|
+
Served at `/__porthole/lib/chart.js@4.5.1/dist/chart.umd.min.js` (npm's `dist/chart.umd.min.js`), bundling:
|
|
15
|
+
|
|
16
|
+
- chart.js 4.5.1: MIT
|
|
17
|
+
- @kurkle/color 0.3.4: MIT
|
|
18
|
+
|
|
19
|
+
## D3 7.9.0
|
|
20
|
+
|
|
21
|
+
Served at `/__porthole/lib/d3@7.9.0/dist/d3.min.js` (npm's `dist/d3.min.js`), bundling:
|
|
22
|
+
|
|
23
|
+
- d3 7.9.0: ISC
|
|
24
|
+
- d3-array 3.2.4: ISC
|
|
25
|
+
- d3-axis 3.0.0: ISC
|
|
26
|
+
- d3-brush 3.0.0: ISC
|
|
27
|
+
- d3-chord 3.0.1: ISC
|
|
28
|
+
- d3-color 3.1.0: ISC
|
|
29
|
+
- d3-contour 4.0.2: ISC
|
|
30
|
+
- d3-delaunay 6.0.4: ISC
|
|
31
|
+
- d3-dispatch 3.0.1: ISC
|
|
32
|
+
- d3-drag 3.0.0: ISC
|
|
33
|
+
- d3-dsv 3.0.1: ISC
|
|
34
|
+
- d3-ease 3.0.1: BSD-3-Clause
|
|
35
|
+
- d3-fetch 3.0.1: ISC
|
|
36
|
+
- d3-force 3.0.0: ISC
|
|
37
|
+
- d3-format 3.1.2: ISC
|
|
38
|
+
- d3-geo 3.1.1: ISC
|
|
39
|
+
- d3-hierarchy 3.1.2: ISC
|
|
40
|
+
- d3-interpolate 3.0.1: ISC
|
|
41
|
+
- d3-path 3.1.0: ISC
|
|
42
|
+
- d3-polygon 3.0.1: ISC
|
|
43
|
+
- d3-quadtree 3.0.1: ISC
|
|
44
|
+
- d3-random 3.0.1: ISC
|
|
45
|
+
- d3-scale 4.0.2: ISC
|
|
46
|
+
- d3-scale-chromatic 3.1.0: ISC
|
|
47
|
+
- d3-selection 3.0.0: ISC
|
|
48
|
+
- d3-shape 3.2.0: ISC
|
|
49
|
+
- d3-time 3.1.0: ISC
|
|
50
|
+
- d3-time-format 4.1.0: ISC
|
|
51
|
+
- d3-timer 3.0.1: ISC
|
|
52
|
+
- d3-transition 3.0.1: ISC
|
|
53
|
+
- d3-zoom 3.0.0: ISC
|
|
54
|
+
- delaunator 5.1.0: ISC
|
|
55
|
+
- internmap 2.0.3: ISC
|
|
56
|
+
- robust-predicates 3.0.3: Unlicense
|
|
57
|
+
|
|
58
|
+
## License texts
|
|
59
|
+
|
|
60
|
+
### chart.js 4.5.1
|
|
61
|
+
|
|
62
|
+
````text
|
|
63
|
+
The MIT License (MIT)
|
|
64
|
+
|
|
65
|
+
Copyright (c) 2014-2024 Chart.js Contributors
|
|
66
|
+
|
|
67
|
+
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:
|
|
68
|
+
|
|
69
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
70
|
+
|
|
71
|
+
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.
|
|
72
|
+
````
|
|
73
|
+
|
|
74
|
+
### @kurkle/color 0.3.4
|
|
75
|
+
|
|
76
|
+
````text
|
|
77
|
+
The MIT License (MIT)
|
|
78
|
+
|
|
79
|
+
Copyright (c) 2018-2024 Jukka Kurkela
|
|
80
|
+
|
|
81
|
+
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:
|
|
82
|
+
|
|
83
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
84
|
+
|
|
85
|
+
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.
|
|
86
|
+
````
|
|
87
|
+
|
|
88
|
+
### d3 7.9.0, d3-array 3.2.4
|
|
89
|
+
|
|
90
|
+
````text
|
|
91
|
+
Copyright 2010-2023 Mike Bostock
|
|
92
|
+
|
|
93
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
94
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
95
|
+
and this permission notice appear in all copies.
|
|
96
|
+
|
|
97
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
98
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
99
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
100
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
101
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
102
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
103
|
+
THIS SOFTWARE.
|
|
104
|
+
````
|
|
105
|
+
|
|
106
|
+
### d3-axis 3.0.0, d3-brush 3.0.0, d3-chord 3.0.1, d3-dispatch 3.0.1, d3-drag 3.0.0, d3-force 3.0.0, d3-hierarchy 3.1.2, d3-interpolate 3.0.1, d3-polygon 3.0.1, d3-quadtree 3.0.1, d3-random 3.0.1, d3-scale 4.0.2, d3-selection 3.0.0, d3-time-format 4.1.0, d3-timer 3.0.1, d3-transition 3.0.1, d3-zoom 3.0.0
|
|
107
|
+
|
|
108
|
+
````text
|
|
109
|
+
Copyright 2010-2021 Mike Bostock
|
|
110
|
+
|
|
111
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
112
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
113
|
+
and this permission notice appear in all copies.
|
|
114
|
+
|
|
115
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
116
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
117
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
118
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
119
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
120
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
121
|
+
THIS SOFTWARE.
|
|
122
|
+
````
|
|
123
|
+
|
|
124
|
+
### d3-color 3.1.0, d3-shape 3.2.0, d3-time 3.1.0
|
|
125
|
+
|
|
126
|
+
````text
|
|
127
|
+
Copyright 2010-2022 Mike Bostock
|
|
128
|
+
|
|
129
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
130
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
131
|
+
and this permission notice appear in all copies.
|
|
132
|
+
|
|
133
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
134
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
135
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
136
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
137
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
138
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
139
|
+
THIS SOFTWARE.
|
|
140
|
+
````
|
|
141
|
+
|
|
142
|
+
### d3-contour 4.0.2
|
|
143
|
+
|
|
144
|
+
````text
|
|
145
|
+
Copyright 2012-2023 Mike Bostock
|
|
146
|
+
|
|
147
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
148
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
149
|
+
and this permission notice appear in all copies.
|
|
150
|
+
|
|
151
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
152
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
153
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
154
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
155
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
156
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
157
|
+
THIS SOFTWARE.
|
|
158
|
+
````
|
|
159
|
+
|
|
160
|
+
### d3-delaunay 6.0.4
|
|
161
|
+
|
|
162
|
+
````text
|
|
163
|
+
Copyright 2018-2021 Observable, Inc.
|
|
164
|
+
Copyright 2021 Mapbox
|
|
165
|
+
|
|
166
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
167
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
168
|
+
and this permission notice appear in all copies.
|
|
169
|
+
|
|
170
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
171
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
172
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
173
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
174
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
175
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
176
|
+
THIS SOFTWARE.
|
|
177
|
+
````
|
|
178
|
+
|
|
179
|
+
### d3-dsv 3.0.1
|
|
180
|
+
|
|
181
|
+
````text
|
|
182
|
+
Copyright 2013-2021 Mike Bostock
|
|
183
|
+
|
|
184
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
185
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
186
|
+
and this permission notice appear in all copies.
|
|
187
|
+
|
|
188
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
189
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
190
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
191
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
192
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
193
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
194
|
+
THIS SOFTWARE.
|
|
195
|
+
````
|
|
196
|
+
|
|
197
|
+
### d3-ease 3.0.1
|
|
198
|
+
|
|
199
|
+
````text
|
|
200
|
+
Copyright 2010-2021 Mike Bostock
|
|
201
|
+
Copyright 2001 Robert Penner
|
|
202
|
+
All rights reserved.
|
|
203
|
+
|
|
204
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
205
|
+
are permitted provided that the following conditions are met:
|
|
206
|
+
|
|
207
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
208
|
+
list of conditions and the following disclaimer.
|
|
209
|
+
|
|
210
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
211
|
+
this list of conditions and the following disclaimer in the documentation
|
|
212
|
+
and/or other materials provided with the distribution.
|
|
213
|
+
|
|
214
|
+
* Neither the name of the author nor the names of contributors may be used to
|
|
215
|
+
endorse or promote products derived from this software without specific prior
|
|
216
|
+
written permission.
|
|
217
|
+
|
|
218
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
219
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
220
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
221
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
222
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
223
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
224
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
225
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
226
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
227
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
228
|
+
````
|
|
229
|
+
|
|
230
|
+
### d3-fetch 3.0.1
|
|
231
|
+
|
|
232
|
+
````text
|
|
233
|
+
Copyright 2016-2021 Mike Bostock
|
|
234
|
+
|
|
235
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
236
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
237
|
+
and this permission notice appear in all copies.
|
|
238
|
+
|
|
239
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
240
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
241
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
242
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
243
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
244
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
245
|
+
THIS SOFTWARE.
|
|
246
|
+
````
|
|
247
|
+
|
|
248
|
+
### d3-format 3.1.2
|
|
249
|
+
|
|
250
|
+
````text
|
|
251
|
+
Copyright 2010-2026 Mike Bostock
|
|
252
|
+
|
|
253
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
254
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
255
|
+
and this permission notice appear in all copies.
|
|
256
|
+
|
|
257
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
258
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
259
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
260
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
261
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
262
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
263
|
+
THIS SOFTWARE.
|
|
264
|
+
````
|
|
265
|
+
|
|
266
|
+
### d3-geo 3.1.1
|
|
267
|
+
|
|
268
|
+
````text
|
|
269
|
+
Copyright 2010-2024 Mike Bostock
|
|
270
|
+
|
|
271
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
272
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
273
|
+
and this permission notice appear in all copies.
|
|
274
|
+
|
|
275
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
276
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
277
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
278
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
279
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
280
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
281
|
+
THIS SOFTWARE.
|
|
282
|
+
|
|
283
|
+
This license applies to GeographicLib, versions 1.12 and later.
|
|
284
|
+
|
|
285
|
+
Copyright 2008-2012 Charles Karney
|
|
286
|
+
|
|
287
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
288
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
289
|
+
the Software without restriction, including without limitation the rights to
|
|
290
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
291
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
292
|
+
subject to the following conditions:
|
|
293
|
+
|
|
294
|
+
The above copyright notice and this permission notice shall be included in all
|
|
295
|
+
copies or substantial portions of the Software.
|
|
296
|
+
|
|
297
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
298
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
299
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
300
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
301
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
302
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
303
|
+
````
|
|
304
|
+
|
|
305
|
+
### d3-path 3.1.0
|
|
306
|
+
|
|
307
|
+
````text
|
|
308
|
+
Copyright 2015-2022 Mike Bostock
|
|
309
|
+
|
|
310
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
311
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
312
|
+
and this permission notice appear in all copies.
|
|
313
|
+
|
|
314
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
315
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
316
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
317
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
318
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
319
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
320
|
+
THIS SOFTWARE.
|
|
321
|
+
````
|
|
322
|
+
|
|
323
|
+
### d3-scale-chromatic 3.1.0
|
|
324
|
+
|
|
325
|
+
````text
|
|
326
|
+
Copyright 2010-2024 Mike Bostock
|
|
327
|
+
|
|
328
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
329
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
330
|
+
and this permission notice appear in all copies.
|
|
331
|
+
|
|
332
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
333
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
334
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
335
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
336
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
337
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
338
|
+
THIS SOFTWARE.
|
|
339
|
+
|
|
340
|
+
Apache-Style Software License for ColorBrewer software and ColorBrewer Color Schemes
|
|
341
|
+
|
|
342
|
+
Copyright 2002 Cynthia Brewer, Mark Harrower, and The Pennsylvania State University
|
|
343
|
+
|
|
344
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
345
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
346
|
+
License at
|
|
347
|
+
|
|
348
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
349
|
+
|
|
350
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
351
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
352
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
353
|
+
specific language governing permissions and limitations under the License.
|
|
354
|
+
````
|
|
355
|
+
|
|
356
|
+
### delaunator 5.1.0
|
|
357
|
+
|
|
358
|
+
````text
|
|
359
|
+
ISC License
|
|
360
|
+
|
|
361
|
+
Copyright (c) 2026, Mapbox
|
|
362
|
+
|
|
363
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
364
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
365
|
+
and this permission notice appear in all copies.
|
|
366
|
+
|
|
367
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
368
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
369
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
370
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
371
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
372
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
373
|
+
THIS SOFTWARE.
|
|
374
|
+
````
|
|
375
|
+
|
|
376
|
+
### internmap 2.0.3
|
|
377
|
+
|
|
378
|
+
````text
|
|
379
|
+
Copyright 2021 Mike Bostock
|
|
380
|
+
|
|
381
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
382
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
383
|
+
and this permission notice appear in all copies.
|
|
384
|
+
|
|
385
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
386
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
387
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
388
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
389
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
390
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
391
|
+
THIS SOFTWARE.
|
|
392
|
+
````
|
|
393
|
+
|
|
394
|
+
### robust-predicates 3.0.3
|
|
395
|
+
|
|
396
|
+
````text
|
|
397
|
+
This is free and unencumbered software released into the public domain.
|
|
398
|
+
|
|
399
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
400
|
+
distribute this software, either in source code form or as a compiled
|
|
401
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
402
|
+
means.
|
|
403
|
+
|
|
404
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
405
|
+
of this software dedicate any and all copyright interest in the
|
|
406
|
+
software to the public domain. We make this dedication for the benefit
|
|
407
|
+
of the public at large and to the detriment of our heirs and
|
|
408
|
+
successors. We intend this dedication to be an overt act of
|
|
409
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
410
|
+
software under copyright law.
|
|
411
|
+
|
|
412
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
413
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
414
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
415
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
416
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
417
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
418
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
419
|
+
|
|
420
|
+
For more information, please refer to <http://unlicense.org>
|
|
421
|
+
````
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What content said, as text a host can show (S05, P095), at a cost bounded whatever the frame
|
|
3
|
+
* sent. A frame's messages come structured-cloned, which keeps cycles and shared references (13
|
|
4
|
+
* objects each holding the next twice are 2^13 nodes written as a tree) and carries BigInt, Maps
|
|
5
|
+
* and nesting of any depth: `JSON.stringify` throws on the first and the second, and is
|
|
6
|
+
* exponential in the third.
|
|
7
|
+
*
|
|
8
|
+
* A string is as it is, cut. Anything else is written the way JSON writes it, with each object
|
|
9
|
+
* read once (`"[Circular]"` where it is inside itself, `"[Repeated]"` where it was written
|
|
10
|
+
* already), at most `nodes` values (`…` where it stops) and `depth` levels (`"[Object]"`,
|
|
11
|
+
* `"[Array]"` below), a boxed primitive as its value (as JSON does), a BigInt as `"5n"`
|
|
12
|
+
* (`"[BigInt]"` past 2,000 digits), a Date as its time, an Error as its name and message, any other
|
|
13
|
+
* object as its kind (`"[Map]"`), and anything that throws when read as `"[unreadable]"`; any of
|
|
14
|
+
* these but a boxed primitive and a Date means the text isn't `whole`. Every cut is `cutText`'s:
|
|
15
|
+
* no part of a sealed address's access is left at one. Never throws.
|
|
16
|
+
*/
|
|
17
|
+
export interface TextLimits {
|
|
18
|
+
/** The longest the text is. */
|
|
19
|
+
readonly chars: number;
|
|
20
|
+
/** The most values read. */
|
|
21
|
+
readonly nodes: number;
|
|
22
|
+
/** The deepest an object or array is read. */
|
|
23
|
+
readonly depth: number;
|
|
24
|
+
}
|
|
25
|
+
/** An error report's: read past what the bridge keeps (2,000 characters, after the scrub). */
|
|
26
|
+
export declare const REPORT_TEXT_LIMITS: TextLimits;
|
|
27
|
+
/** The text, and whether it is all of the value (nothing cut, stopped or left below the depth). */
|
|
28
|
+
export interface BoundedText {
|
|
29
|
+
readonly text: string;
|
|
30
|
+
readonly whole: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** `value` as bounded text (above); with `indent`, as `JSON.stringify(value, null, indent)` lays it out. */
|
|
33
|
+
export declare function boundedText(value: unknown, limits?: TextLimits, indent?: number): string;
|
|
34
|
+
export declare function formatBounded(value: unknown, limits: TextLimits, indent?: number): BoundedText;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { cutText } from "./navigation.js";
|
|
2
|
+
/** An error report's: read past what the bridge keeps (2,000 characters, after the scrub). */
|
|
3
|
+
export const REPORT_TEXT_LIMITS = { chars: 8_000, nodes: 1_000, depth: 16 };
|
|
4
|
+
/** A BigInt past this has more digits than a report shows; its decimal text is superlinear. */
|
|
5
|
+
const BIGGEST = 10n ** 2000n;
|
|
6
|
+
/** A boxed primitive's value, read by its own prototype's `valueOf` (which throws for a fake). */
|
|
7
|
+
function unboxed(kind, boxed) {
|
|
8
|
+
switch (kind) {
|
|
9
|
+
case "String":
|
|
10
|
+
return String.prototype.valueOf.call(boxed);
|
|
11
|
+
case "Number":
|
|
12
|
+
return Number.prototype.valueOf.call(boxed);
|
|
13
|
+
case "Boolean":
|
|
14
|
+
return Boolean.prototype.valueOf.call(boxed);
|
|
15
|
+
default:
|
|
16
|
+
return BigInt.prototype.valueOf.call(boxed);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** A field whose read threw (a getter, a proxy: what structured clone never delivers). */
|
|
20
|
+
const UNREADABLE = Symbol("unreadable");
|
|
21
|
+
/** `value` as bounded text (above); with `indent`, as `JSON.stringify(value, null, indent)` lays it out. */
|
|
22
|
+
export function boundedText(value, limits = REPORT_TEXT_LIMITS, indent = 0) {
|
|
23
|
+
return formatBounded(value, limits, indent).text;
|
|
24
|
+
}
|
|
25
|
+
export function formatBounded(value, limits, indent = 0) {
|
|
26
|
+
if (typeof value === "string") {
|
|
27
|
+
const text = cutText(value, limits.chars);
|
|
28
|
+
return { text, whole: text === value };
|
|
29
|
+
}
|
|
30
|
+
let out = "";
|
|
31
|
+
let nodes = limits.nodes;
|
|
32
|
+
let stopped = false;
|
|
33
|
+
let whole = true;
|
|
34
|
+
const written = new WeakSet();
|
|
35
|
+
const inside = new WeakSet();
|
|
36
|
+
const colon = indent > 0 ? ": " : ":";
|
|
37
|
+
const quoted = (text) => {
|
|
38
|
+
const room = Math.max(0, limits.chars - out.length);
|
|
39
|
+
if (text.length > room) {
|
|
40
|
+
whole = false;
|
|
41
|
+
}
|
|
42
|
+
return JSON.stringify(cutText(text, room));
|
|
43
|
+
};
|
|
44
|
+
/** Where a nested value starts, at `depth`: a new line, indented, when laid out. */
|
|
45
|
+
const line = (depth) => (indent > 0 ? `\n${" ".repeat(indent * depth)}` : "");
|
|
46
|
+
/** Whether there is room for another value; if not, `…` once (after `separator`), then none. */
|
|
47
|
+
const room = (separator) => {
|
|
48
|
+
nodes -= 1;
|
|
49
|
+
if (!stopped && (nodes < 0 || out.length >= limits.chars)) {
|
|
50
|
+
stopped = true;
|
|
51
|
+
whole = false;
|
|
52
|
+
out += `${separator}…`;
|
|
53
|
+
}
|
|
54
|
+
return !stopped;
|
|
55
|
+
};
|
|
56
|
+
/** What JSON leaves out of an object (and writes as null in an array). */
|
|
57
|
+
const unwritten = (each) => each === undefined || typeof each === "function" || typeof each === "symbol";
|
|
58
|
+
function write(each, depth) {
|
|
59
|
+
switch (typeof each) {
|
|
60
|
+
case "string":
|
|
61
|
+
out += quoted(each);
|
|
62
|
+
return;
|
|
63
|
+
case "number":
|
|
64
|
+
out += Number.isFinite(each) ? String(each) : "null";
|
|
65
|
+
return;
|
|
66
|
+
case "boolean":
|
|
67
|
+
out += each ? "true" : "false";
|
|
68
|
+
return;
|
|
69
|
+
case "bigint":
|
|
70
|
+
// No JSON for it: its digits, or past 2,000 of them its kind, and either way not whole.
|
|
71
|
+
whole = false;
|
|
72
|
+
out += each < BIGGEST && each > -BIGGEST ? `"${String(each)}n"` : '"[BigInt]"';
|
|
73
|
+
return;
|
|
74
|
+
case "object":
|
|
75
|
+
break;
|
|
76
|
+
default:
|
|
77
|
+
out += "null";
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (each === null) {
|
|
81
|
+
out += "null";
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (inside.has(each)) {
|
|
85
|
+
whole = false;
|
|
86
|
+
out += '"[Circular]"';
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (written.has(each)) {
|
|
90
|
+
whole = false;
|
|
91
|
+
out += '"[Repeated]"';
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
written.add(each);
|
|
95
|
+
if (Array.isArray(each)) {
|
|
96
|
+
if (depth >= limits.depth) {
|
|
97
|
+
whole = false;
|
|
98
|
+
out += '"[Array]"';
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const list = each;
|
|
102
|
+
inside.add(list);
|
|
103
|
+
out += "[";
|
|
104
|
+
const inner = line(depth + 1);
|
|
105
|
+
for (let index = 0; index < list.length && room(index === 0 ? inner : `,${inner}`); index += 1) {
|
|
106
|
+
out += index === 0 ? inner : `,${inner}`;
|
|
107
|
+
guarded(list[index], depth + 1);
|
|
108
|
+
}
|
|
109
|
+
out += list.length === 0 ? "]" : `${line(depth)}]`;
|
|
110
|
+
inside.delete(list);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const kind = Object.prototype.toString.call(each).slice(8, -1);
|
|
114
|
+
const proto = Object.getPrototypeOf(each);
|
|
115
|
+
// A boxed primitive is its value, as JSON writes it (`new String("x")` is "x").
|
|
116
|
+
if (kind === "String" || kind === "Number" || kind === "Boolean" || kind === "BigInt") {
|
|
117
|
+
write(unboxed(kind, each), depth);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (kind === "Date") {
|
|
121
|
+
const time = Date.prototype.getTime.call(each);
|
|
122
|
+
out += quoted(Number.isFinite(time) ? new Date(time).toISOString() : "Invalid Date");
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (kind === "Error") {
|
|
126
|
+
whole = false;
|
|
127
|
+
const { name, message } = each;
|
|
128
|
+
out += quoted(`${typeof name === "string" ? cutText(name, 100) : "Error"}: ${typeof message === "string" ? cutText(message, limits.chars) : ""}`);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
132
|
+
// A Map, a typed array, a Blob: its kind only, so the text is no longer all of it.
|
|
133
|
+
whole = false;
|
|
134
|
+
out += quoted(`[${kind}]`);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (depth >= limits.depth) {
|
|
138
|
+
whole = false;
|
|
139
|
+
out += '"[Object]"';
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
inside.add(each);
|
|
143
|
+
out += "{";
|
|
144
|
+
const inner = line(depth + 1);
|
|
145
|
+
let first = true;
|
|
146
|
+
for (const key of Object.keys(each)) {
|
|
147
|
+
if (!room(first ? inner : `,${inner}`)) {
|
|
148
|
+
first = false;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
let field;
|
|
152
|
+
try {
|
|
153
|
+
field = each[key];
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
field = UNREADABLE;
|
|
157
|
+
}
|
|
158
|
+
if (field !== UNREADABLE && unwritten(field)) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
out += `${first ? inner : `,${inner}`}${quoted(key)}${colon}`;
|
|
162
|
+
first = false;
|
|
163
|
+
guarded(field, depth + 1);
|
|
164
|
+
}
|
|
165
|
+
out += first ? "}" : `${line(depth)}}`;
|
|
166
|
+
inside.delete(each);
|
|
167
|
+
}
|
|
168
|
+
/** One value, or `"[unreadable]"` where reading it throws (a getter, a proxy: never cloned). */
|
|
169
|
+
function guarded(each, depth) {
|
|
170
|
+
if (each === UNREADABLE) {
|
|
171
|
+
out += '"[unreadable]"';
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const before = out.length;
|
|
175
|
+
try {
|
|
176
|
+
write(each, depth);
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
whole = false;
|
|
180
|
+
out = `${out.slice(0, before)}"[unreadable]"`;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
nodes -= 1;
|
|
184
|
+
guarded(value, 0);
|
|
185
|
+
// Cut past the length, it still ends in `…`.
|
|
186
|
+
const text = out.length <= limits.chars ? out : `${cutText(out, limits.chars - 1)}…`;
|
|
187
|
+
return { text, whole: whole && text === out };
|
|
188
|
+
}
|