@react-x11/components 0.8.0 → 0.10.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 +105 -38
- package/dist/charts/node.d.ts +12 -2
- package/dist/charts/node.d.ts.map +1 -1
- package/dist/charts/node.js +50 -16
- package/dist/charts/node.js.map +1 -1
- package/dist/charts/render.d.ts +12 -3
- package/dist/charts/render.d.ts.map +1 -1
- package/dist/charts/render.js +94 -25
- package/dist/charts/render.js.map +1 -1
- package/dist/code/index.d.ts.map +1 -1
- package/dist/code/index.js +3 -1
- package/dist/code/index.js.map +1 -1
- package/dist/code-editor/completion.d.ts.map +1 -1
- package/dist/code-editor/completion.js +3 -2
- package/dist/code-editor/completion.js.map +1 -1
- package/dist/code-editor/index.d.ts.map +1 -1
- package/dist/code-editor/index.js +19 -0
- package/dist/code-editor/index.js.map +1 -1
- package/dist/code-editor/node.d.ts +177 -7
- package/dist/code-editor/node.d.ts.map +1 -1
- package/dist/code-editor/node.js +1329 -164
- package/dist/code-editor/node.js.map +1 -1
- package/dist/code-language/languages/glsl.d.ts.map +1 -1
- package/dist/code-language/languages/glsl.js +10 -2
- package/dist/code-language/languages/glsl.js.map +1 -1
- package/dist/code-language/languages/javascript.d.ts.map +1 -1
- package/dist/code-language/languages/javascript.js +18 -3
- package/dist/code-language/languages/javascript.js.map +1 -1
- package/dist/code-language/languages/json.d.ts.map +1 -1
- package/dist/code-language/languages/json.js +10 -2
- package/dist/code-language/languages/json.js.map +1 -1
- package/dist/code-language/languages/shell.d.ts.map +1 -1
- package/dist/code-language/languages/shell.js +10 -2
- package/dist/code-language/languages/shell.js.map +1 -1
- package/dist/code-language/languages/sql.d.ts.map +1 -1
- package/dist/code-language/languages/sql.js +20 -2
- package/dist/code-language/languages/sql.js.map +1 -1
- package/dist/code-language/stream.d.ts +22 -0
- package/dist/code-language/stream.d.ts.map +1 -1
- package/dist/code-language/stream.js +259 -9
- package/dist/code-language/stream.js.map +1 -1
- package/dist/code-language/types.d.ts +5 -4
- package/dist/code-language/types.d.ts.map +1 -1
- package/dist/codeblock/index.d.ts +13 -2
- package/dist/codeblock/index.d.ts.map +1 -1
- package/dist/codeblock/index.js +20 -3
- package/dist/codeblock/index.js.map +1 -1
- package/dist/embed/client.d.ts +48 -3
- package/dist/embed/client.d.ts.map +1 -1
- package/dist/embed/client.js +79 -5
- package/dist/embed/client.js.map +1 -1
- package/dist/embed/index.d.ts +1 -1
- package/dist/embed/index.d.ts.map +1 -1
- package/dist/embed/index.js +1 -1
- package/dist/embed/index.js.map +1 -1
- package/dist/flow/draw.d.ts +50 -0
- package/dist/flow/draw.d.ts.map +1 -1
- package/dist/flow/draw.js +132 -33
- package/dist/flow/draw.js.map +1 -1
- package/dist/flow/gl/color.d.ts +13 -0
- package/dist/flow/gl/color.d.ts.map +1 -0
- package/dist/flow/gl/color.js +82 -0
- package/dist/flow/gl/color.js.map +1 -0
- package/dist/flow/gl/index.d.ts +60 -0
- package/dist/flow/gl/index.d.ts.map +1 -0
- package/dist/flow/gl/index.js +283 -0
- package/dist/flow/gl/index.js.map +1 -0
- package/dist/flow/gl/pack.d.ts +133 -0
- package/dist/flow/gl/pack.d.ts.map +1 -0
- package/dist/flow/gl/pack.js +408 -0
- package/dist/flow/gl/pack.js.map +1 -0
- package/dist/flow/gl/renderer.d.ts +95 -0
- package/dist/flow/gl/renderer.d.ts.map +1 -0
- package/dist/flow/gl/renderer.js +459 -0
- package/dist/flow/gl/renderer.js.map +1 -0
- package/dist/flow/gl/shaders.d.ts +79 -0
- package/dist/flow/gl/shaders.d.ts.map +1 -0
- package/dist/flow/gl/shaders.js +346 -0
- package/dist/flow/gl/shaders.js.map +1 -0
- package/dist/flow/gl/text.d.ts +318 -0
- package/dist/flow/gl/text.d.ts.map +1 -0
- package/dist/flow/gl/text.js +1103 -0
- package/dist/flow/gl/text.js.map +1 -0
- package/dist/flow/index.d.ts +1 -1
- package/dist/flow/index.d.ts.map +1 -1
- package/dist/flow/index.js +619 -64
- package/dist/flow/index.js.map +1 -1
- package/dist/flow/node.d.ts +621 -72
- package/dist/flow/node.d.ts.map +1 -1
- package/dist/flow/node.js +2253 -1018
- package/dist/flow/node.js.map +1 -1
- package/dist/flow/paint.d.ts +35 -0
- package/dist/flow/paint.d.ts.map +1 -0
- package/dist/flow/paint.js +393 -0
- package/dist/flow/paint.js.map +1 -0
- package/dist/flow/paths.d.ts +14 -0
- package/dist/flow/paths.d.ts.map +1 -1
- package/dist/flow/paths.js +45 -19
- package/dist/flow/paths.js.map +1 -1
- package/dist/flow/scene.d.ts +584 -0
- package/dist/flow/scene.d.ts.map +1 -0
- package/dist/flow/scene.js +1453 -0
- package/dist/flow/scene.js.map +1 -0
- package/dist/flow/types.d.ts +111 -1
- package/dist/flow/types.d.ts.map +1 -1
- package/dist/html/controls.d.ts +28 -0
- package/dist/html/controls.d.ts.map +1 -1
- package/dist/html/controls.js +52 -2
- package/dist/html/controls.js.map +1 -1
- package/dist/html/css/calc.d.ts +14 -0
- package/dist/html/css/calc.d.ts.map +1 -0
- package/dist/html/css/calc.js +344 -0
- package/dist/html/css/calc.js.map +1 -0
- package/dist/html/css/cascade.d.ts +240 -6
- package/dist/html/css/cascade.d.ts.map +1 -1
- package/dist/html/css/cascade.js +1327 -66
- package/dist/html/css/cascade.js.map +1 -1
- package/dist/html/css/color.d.ts +23 -0
- package/dist/html/css/color.d.ts.map +1 -0
- package/dist/html/css/color.js +740 -0
- package/dist/html/css/color.js.map +1 -0
- package/dist/html/css/content.d.ts +92 -0
- package/dist/html/css/content.d.ts.map +1 -0
- package/dist/html/css/content.js +388 -0
- package/dist/html/css/content.js.map +1 -0
- package/dist/html/css/counter-styles.d.ts +76 -0
- package/dist/html/css/counter-styles.d.ts.map +1 -0
- package/dist/html/css/counter-styles.js +893 -0
- package/dist/html/css/counter-styles.js.map +1 -0
- package/dist/html/css/decode.d.ts +12 -0
- package/dist/html/css/decode.d.ts.map +1 -0
- package/dist/html/css/decode.js +116 -0
- package/dist/html/css/decode.js.map +1 -0
- package/dist/html/css/parse.d.ts +110 -10
- package/dist/html/css/parse.d.ts.map +1 -1
- package/dist/html/css/parse.js +1473 -180
- package/dist/html/css/parse.js.map +1 -1
- package/dist/html/css/style.d.ts +498 -15
- package/dist/html/css/style.d.ts.map +1 -1
- package/dist/html/css/style.js +3698 -206
- package/dist/html/css/style.js.map +1 -1
- package/dist/html/css/ua.d.ts.map +1 -1
- package/dist/html/css/ua.js +57 -11
- package/dist/html/css/ua.js.map +1 -1
- package/dist/html/css/values.d.ts +37 -3
- package/dist/html/css/values.d.ts.map +1 -1
- package/dist/html/css/values.js +122 -48
- package/dist/html/css/values.js.map +1 -1
- package/dist/html/css/vars.d.ts +52 -0
- package/dist/html/css/vars.d.ts.map +1 -0
- package/dist/html/css/vars.js +358 -0
- package/dist/html/css/vars.js.map +1 -0
- package/dist/html/dom.d.ts +30 -4
- package/dist/html/dom.d.ts.map +1 -1
- package/dist/html/dom.js +278 -17
- package/dist/html/dom.js.map +1 -1
- package/dist/html/fonts.d.ts +106 -0
- package/dist/html/fonts.d.ts.map +1 -0
- package/dist/html/fonts.js +565 -0
- package/dist/html/fonts.js.map +1 -0
- package/dist/html/gif.d.ts +15 -0
- package/dist/html/gif.d.ts.map +1 -0
- package/dist/html/gif.js +229 -0
- package/dist/html/gif.js.map +1 -0
- package/dist/html/index.d.ts +50 -11
- package/dist/html/index.d.ts.map +1 -1
- package/dist/html/index.js +115 -9
- package/dist/html/index.js.map +1 -1
- package/dist/html/layout/block.d.ts +226 -3
- package/dist/html/layout/block.d.ts.map +1 -1
- package/dist/html/layout/block.js +2937 -197
- package/dist/html/layout/block.js.map +1 -1
- package/dist/html/layout/boxes.d.ts +340 -17
- package/dist/html/layout/boxes.d.ts.map +1 -1
- package/dist/html/layout/boxes.js +1714 -182
- package/dist/html/layout/boxes.js.map +1 -1
- package/dist/html/layout/cache.d.ts +58 -0
- package/dist/html/layout/cache.d.ts.map +1 -0
- package/dist/html/layout/cache.js +224 -0
- package/dist/html/layout/cache.js.map +1 -0
- package/dist/html/layout/collapse.d.ts +45 -0
- package/dist/html/layout/collapse.d.ts.map +1 -0
- package/dist/html/layout/collapse.js +246 -0
- package/dist/html/layout/collapse.js.map +1 -0
- package/dist/html/layout/css-grid.d.ts +7 -0
- package/dist/html/layout/css-grid.d.ts.map +1 -0
- package/dist/html/layout/css-grid.js +900 -0
- package/dist/html/layout/css-grid.js.map +1 -0
- package/dist/html/layout/flex.d.ts.map +1 -1
- package/dist/html/layout/flex.js +1025 -89
- package/dist/html/layout/flex.js.map +1 -1
- package/dist/html/layout/floats.d.ts +45 -6
- package/dist/html/layout/floats.d.ts.map +1 -1
- package/dist/html/layout/floats.js +113 -14
- package/dist/html/layout/floats.js.map +1 -1
- package/dist/html/layout/grid-lines.d.ts +39 -0
- package/dist/html/layout/grid-lines.d.ts.map +1 -0
- package/dist/html/layout/grid-lines.js +119 -0
- package/dist/html/layout/grid-lines.js.map +1 -0
- package/dist/html/layout/grid.d.ts +53 -0
- package/dist/html/layout/grid.d.ts.map +1 -0
- package/dist/html/layout/grid.js +153 -0
- package/dist/html/layout/grid.js.map +1 -0
- package/dist/html/layout/inline.d.ts +151 -1
- package/dist/html/layout/inline.d.ts.map +1 -1
- package/dist/html/layout/inline.js +3375 -174
- package/dist/html/layout/inline.js.map +1 -1
- package/dist/html/layout/shaping.d.ts +6 -0
- package/dist/html/layout/shaping.d.ts.map +1 -0
- package/dist/html/layout/shaping.js +100 -0
- package/dist/html/layout/shaping.js.map +1 -0
- package/dist/html/layout/table.d.ts +3 -0
- package/dist/html/layout/table.d.ts.map +1 -1
- package/dist/html/layout/table.js +681 -175
- package/dist/html/layout/table.js.map +1 -1
- package/dist/html/layout/tracks.d.ts +44 -0
- package/dist/html/layout/tracks.d.ts.map +1 -0
- package/dist/html/layout/tracks.js +349 -0
- package/dist/html/layout/tracks.js.map +1 -0
- package/dist/html/node.d.ts +172 -5
- package/dist/html/node.d.ts.map +1 -1
- package/dist/html/node.js +1336 -103
- package/dist/html/node.js.map +1 -1
- package/dist/html/paint.d.ts +92 -3
- package/dist/html/paint.d.ts.map +1 -1
- package/dist/html/paint.js +3503 -141
- package/dist/html/paint.js.map +1 -1
- package/dist/html/resources.d.ts +60 -14
- package/dist/html/resources.d.ts.map +1 -1
- package/dist/html/resources.js +122 -36
- package/dist/html/resources.js.map +1 -1
- package/dist/html/surfaces.d.ts +23 -0
- package/dist/html/surfaces.d.ts.map +1 -0
- package/dist/html/surfaces.js +68 -0
- package/dist/html/surfaces.js.map +1 -0
- package/dist/html/svg.d.ts +80 -0
- package/dist/html/svg.d.ts.map +1 -0
- package/dist/html/svg.js +435 -0
- package/dist/html/svg.js.map +1 -0
- package/dist/html/url.d.ts +23 -0
- package/dist/html/url.d.ts.map +1 -0
- package/dist/html/url.js +80 -0
- package/dist/html/url.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/collate.d.ts +3 -0
- package/dist/internal/collate.d.ts.map +1 -0
- package/dist/internal/collate.js +11 -0
- package/dist/internal/collate.js.map +1 -0
- package/dist/{markdown → internal/markdown}/ast.d.ts +23 -0
- package/dist/internal/markdown/ast.d.ts.map +1 -0
- package/dist/internal/markdown/ast.js +22 -0
- package/dist/internal/markdown/ast.js.map +1 -0
- package/dist/internal/markdown/parse.d.ts.map +1 -0
- package/dist/{markdown → internal/markdown}/parse.js +221 -30
- package/dist/internal/markdown/parse.js.map +1 -0
- package/dist/internal/markdown/stringify.d.ts +4 -0
- package/dist/internal/markdown/stringify.d.ts.map +1 -0
- package/dist/internal/markdown/stringify.js +684 -0
- package/dist/internal/markdown/stringify.js.map +1 -0
- package/dist/internal/markdown/tags.d.ts.map +1 -0
- package/dist/internal/markdown/tags.js.map +1 -0
- package/dist/internal/prewarm.d.ts +18 -0
- package/dist/internal/prewarm.d.ts.map +1 -0
- package/dist/internal/prewarm.js +42 -0
- package/dist/internal/prewarm.js.map +1 -0
- package/dist/internal/scroll.d.ts +3 -2
- package/dist/internal/scroll.d.ts.map +1 -1
- package/dist/internal/scroll.js +1 -0
- package/dist/internal/scroll.js.map +1 -1
- package/dist/internal/sdf.d.ts +20 -0
- package/dist/internal/sdf.d.ts.map +1 -0
- package/dist/internal/sdf.js +216 -0
- package/dist/internal/sdf.js.map +1 -0
- package/dist/internal/splice.d.ts +12 -0
- package/dist/internal/splice.d.ts.map +1 -0
- package/dist/internal/splice.js +23 -0
- package/dist/internal/splice.js.map +1 -0
- package/dist/internal/window.d.ts +12 -0
- package/dist/internal/window.d.ts.map +1 -1
- package/dist/internal/window.js +23 -6
- package/dist/internal/window.js.map +1 -1
- package/dist/maps/anchors.d.ts +103 -0
- package/dist/maps/anchors.d.ts.map +1 -0
- package/dist/maps/anchors.js +790 -0
- package/dist/maps/anchors.js.map +1 -0
- package/dist/maps/controller.d.ts +340 -0
- package/dist/maps/controller.d.ts.map +1 -0
- package/dist/maps/controller.js +822 -0
- package/dist/maps/controller.js.map +1 -0
- package/dist/maps/gl/buckets.d.ts +99 -0
- package/dist/maps/gl/buckets.d.ts.map +1 -0
- package/dist/maps/gl/buckets.js +365 -0
- package/dist/maps/gl/buckets.js.map +1 -0
- package/dist/maps/gl/build-worker.d.ts +15 -0
- package/dist/maps/gl/build-worker.d.ts.map +1 -0
- package/dist/maps/gl/build-worker.js +44 -0
- package/dist/maps/gl/build-worker.js.map +1 -0
- package/dist/maps/gl/color.d.ts +8 -0
- package/dist/maps/gl/color.d.ts.map +1 -0
- package/dist/maps/gl/color.js +57 -0
- package/dist/maps/gl/color.js.map +1 -0
- package/dist/maps/gl/cover.d.ts +70 -0
- package/dist/maps/gl/cover.d.ts.map +1 -0
- package/dist/maps/gl/cover.js +137 -0
- package/dist/maps/gl/cover.js.map +1 -0
- package/dist/maps/gl/index.d.ts +3 -0
- package/dist/maps/gl/index.d.ts.map +1 -0
- package/dist/maps/gl/index.js +20 -0
- package/dist/maps/gl/index.js.map +1 -0
- package/dist/maps/gl/markers.d.ts +28 -0
- package/dist/maps/gl/markers.d.ts.map +1 -0
- package/dist/maps/gl/markers.js +60 -0
- package/dist/maps/gl/markers.js.map +1 -0
- package/dist/maps/gl/overlays.d.ts +68 -0
- package/dist/maps/gl/overlays.d.ts.map +1 -0
- package/dist/maps/gl/overlays.js +300 -0
- package/dist/maps/gl/overlays.js.map +1 -0
- package/dist/maps/gl/pane.d.ts +12 -0
- package/dist/maps/gl/pane.d.ts.map +1 -0
- package/dist/maps/gl/pane.js +37 -0
- package/dist/maps/gl/pane.js.map +1 -0
- package/dist/maps/gl/placement.d.ts +124 -0
- package/dist/maps/gl/placement.d.ts.map +1 -0
- package/dist/maps/gl/placement.js +642 -0
- package/dist/maps/gl/placement.js.map +1 -0
- package/dist/maps/gl/renderer.d.ts +384 -0
- package/dist/maps/gl/renderer.d.ts.map +1 -0
- package/dist/maps/gl/renderer.js +1184 -0
- package/dist/maps/gl/renderer.js.map +1 -0
- package/dist/maps/gl/shaders.d.ts +121 -0
- package/dist/maps/gl/shaders.d.ts.map +1 -0
- package/dist/maps/gl/shaders.js +453 -0
- package/dist/maps/gl/shaders.js.map +1 -0
- package/dist/maps/gl/store.d.ts +125 -0
- package/dist/maps/gl/store.d.ts.map +1 -0
- package/dist/maps/gl/store.js +512 -0
- package/dist/maps/gl/store.js.map +1 -0
- package/dist/maps/gl/text.d.ts +283 -0
- package/dist/maps/gl/text.d.ts.map +1 -0
- package/dist/maps/gl/text.js +698 -0
- package/dist/maps/gl/text.js.map +1 -0
- package/dist/maps/gl/view.d.ts +345 -0
- package/dist/maps/gl/view.d.ts.map +1 -0
- package/dist/maps/gl/view.js +1209 -0
- package/dist/maps/gl/view.js.map +1 -0
- package/dist/maps/icons.d.ts +32 -0
- package/dist/maps/icons.d.ts.map +1 -0
- package/dist/maps/icons.js +151 -0
- package/dist/maps/icons.js.map +1 -0
- package/dist/maps/index.d.ts +3 -1
- package/dist/maps/index.d.ts.map +1 -1
- package/dist/maps/index.js +218 -52
- package/dist/maps/index.js.map +1 -1
- package/dist/maps/labels.d.ts +91 -18
- package/dist/maps/labels.d.ts.map +1 -1
- package/dist/maps/labels.js +376 -140
- package/dist/maps/labels.js.map +1 -1
- package/dist/maps/node.d.ts +179 -56
- package/dist/maps/node.d.ts.map +1 -1
- package/dist/maps/node.js +663 -537
- package/dist/maps/node.js.map +1 -1
- package/dist/maps/overlay.d.ts +72 -9
- package/dist/maps/overlay.d.ts.map +1 -1
- package/dist/maps/overlay.js +108 -28
- package/dist/maps/overlay.js.map +1 -1
- package/dist/maps/paint.d.ts +3 -0
- package/dist/maps/paint.d.ts.map +1 -1
- package/dist/maps/paint.js.map +1 -1
- package/dist/maps/proj.d.ts +62 -0
- package/dist/maps/proj.d.ts.map +1 -1
- package/dist/maps/proj.js +101 -0
- package/dist/maps/proj.js.map +1 -1
- package/dist/maps/renderer.d.ts +69 -0
- package/dist/maps/renderer.d.ts.map +1 -0
- package/dist/maps/renderer.js +66 -0
- package/dist/maps/renderer.js.map +1 -0
- package/dist/maps/sources.d.ts +30 -6
- package/dist/maps/sources.d.ts.map +1 -1
- package/dist/maps/sources.js +22 -3
- package/dist/maps/sources.js.map +1 -1
- package/dist/maps/style.d.ts +35 -0
- package/dist/maps/style.d.ts.map +1 -1
- package/dist/maps/style.js.map +1 -1
- package/dist/maps/styles.d.ts +12 -0
- package/dist/maps/styles.d.ts.map +1 -1
- package/dist/maps/styles.js +120 -6
- package/dist/maps/styles.js.map +1 -1
- package/dist/maps/theme.d.ts +19 -0
- package/dist/maps/theme.d.ts.map +1 -0
- package/dist/maps/theme.js +44 -0
- package/dist/maps/theme.js.map +1 -0
- package/dist/maps/tiles.d.ts +147 -27
- package/dist/maps/tiles.d.ts.map +1 -1
- package/dist/maps/tiles.js +221 -54
- package/dist/maps/tiles.js.map +1 -1
- package/dist/maps/types.d.ts +213 -21
- package/dist/maps/types.d.ts.map +1 -1
- package/dist/markdown/expressions.d.ts +1 -1
- package/dist/markdown/expressions.d.ts.map +1 -1
- package/dist/markdown/expressions.js.map +1 -1
- package/dist/markdown/index.d.ts +7 -6
- package/dist/markdown/index.d.ts.map +1 -1
- package/dist/markdown/index.js +121 -50
- package/dist/markdown/index.js.map +1 -1
- package/dist/markdown/spans.d.ts +1 -1
- package/dist/markdown/spans.d.ts.map +1 -1
- package/dist/markdown/spans.js +6 -0
- package/dist/markdown/spans.js.map +1 -1
- package/dist/media-player/index.d.ts +11 -3
- package/dist/media-player/index.d.ts.map +1 -1
- package/dist/media-player/index.js +13 -2
- package/dist/media-player/index.js.map +1 -1
- package/dist/qml/containers.d.ts.map +1 -1
- package/dist/qml/containers.js +6 -1
- package/dist/qml/containers.js.map +1 -1
- package/dist/qml/interaction.d.ts.map +1 -1
- package/dist/qml/interaction.js +38 -5
- package/dist/qml/interaction.js.map +1 -1
- package/dist/qml/layouts.d.ts.map +1 -1
- package/dist/qml/layouts.js +21 -6
- package/dist/qml/layouts.js.map +1 -1
- package/dist/qml/qtquick.d.ts.map +1 -1
- package/dist/qml/qtquick.js +9 -2
- package/dist/qml/qtquick.js.map +1 -1
- package/dist/qml/react.d.ts.map +1 -1
- package/dist/qml/react.js +9 -7
- package/dist/qml/react.js.map +1 -1
- package/dist/reorder/clock.d.ts +7 -0
- package/dist/reorder/clock.d.ts.map +1 -0
- package/dist/reorder/clock.js +26 -0
- package/dist/reorder/clock.js.map +1 -0
- package/dist/reorder/index.d.ts +25 -3
- package/dist/reorder/index.d.ts.map +1 -1
- package/dist/reorder/index.js +64 -19
- package/dist/reorder/index.js.map +1 -1
- package/dist/rich-text-editor/clipboard.d.ts +23 -0
- package/dist/rich-text-editor/clipboard.d.ts.map +1 -0
- package/dist/rich-text-editor/clipboard.js +307 -0
- package/dist/rich-text-editor/clipboard.js.map +1 -0
- package/dist/rich-text-editor/collab.d.ts +32 -0
- package/dist/rich-text-editor/collab.d.ts.map +1 -0
- package/dist/rich-text-editor/collab.js +55 -0
- package/dist/rich-text-editor/collab.js.map +1 -0
- package/dist/rich-text-editor/commands.d.ts +50 -0
- package/dist/rich-text-editor/commands.d.ts.map +1 -0
- package/dist/rich-text-editor/commands.js +376 -0
- package/dist/rich-text-editor/commands.js.map +1 -0
- package/dist/rich-text-editor/drag.d.ts +68 -0
- package/dist/rich-text-editor/drag.d.ts.map +1 -0
- package/dist/rich-text-editor/drag.js +148 -0
- package/dist/rich-text-editor/drag.js.map +1 -0
- package/dist/rich-text-editor/html.d.ts +145 -0
- package/dist/rich-text-editor/html.d.ts.map +1 -0
- package/dist/rich-text-editor/html.js +516 -0
- package/dist/rich-text-editor/html.js.map +1 -0
- package/dist/rich-text-editor/index.d.ts +252 -0
- package/dist/rich-text-editor/index.d.ts.map +1 -0
- package/dist/rich-text-editor/index.js +856 -0
- package/dist/rich-text-editor/index.js.map +1 -0
- package/dist/rich-text-editor/inline.d.ts +94 -0
- package/dist/rich-text-editor/inline.d.ts.map +1 -0
- package/dist/rich-text-editor/inline.js +252 -0
- package/dist/rich-text-editor/inline.js.map +1 -0
- package/dist/rich-text-editor/keymap.d.ts +71 -0
- package/dist/rich-text-editor/keymap.d.ts.map +1 -0
- package/dist/rich-text-editor/keymap.js +394 -0
- package/dist/rich-text-editor/keymap.js.map +1 -0
- package/dist/rich-text-editor/keys.d.ts +40 -0
- package/dist/rich-text-editor/keys.d.ts.map +1 -0
- package/dist/rich-text-editor/keys.js +202 -0
- package/dist/rich-text-editor/keys.js.map +1 -0
- package/dist/rich-text-editor/look.d.ts +71 -0
- package/dist/rich-text-editor/look.d.ts.map +1 -0
- package/dist/rich-text-editor/look.js +342 -0
- package/dist/rich-text-editor/look.js.map +1 -0
- package/dist/rich-text-editor/markdown.d.ts +18 -0
- package/dist/rich-text-editor/markdown.d.ts.map +1 -0
- package/dist/rich-text-editor/markdown.js +496 -0
- package/dist/rich-text-editor/markdown.js.map +1 -0
- package/dist/rich-text-editor/marks.d.ts +9 -0
- package/dist/rich-text-editor/marks.d.ts.map +1 -0
- package/dist/rich-text-editor/marks.js +83 -0
- package/dist/rich-text-editor/marks.js.map +1 -0
- package/dist/rich-text-editor/nodes.d.ts +135 -0
- package/dist/rich-text-editor/nodes.d.ts.map +1 -0
- package/dist/rich-text-editor/nodes.js +397 -0
- package/dist/rich-text-editor/nodes.js.map +1 -0
- package/dist/rich-text-editor/render.d.ts +68 -0
- package/dist/rich-text-editor/render.d.ts.map +1 -0
- package/dist/rich-text-editor/render.js +518 -0
- package/dist/rich-text-editor/render.js.map +1 -0
- package/dist/rich-text-editor/schema.d.ts +16 -0
- package/dist/rich-text-editor/schema.d.ts.map +1 -0
- package/dist/rich-text-editor/schema.js +386 -0
- package/dist/rich-text-editor/schema.js.map +1 -0
- package/dist/rich-text-editor/store.d.ts +11 -0
- package/dist/rich-text-editor/store.d.ts.map +1 -0
- package/dist/rich-text-editor/store.js +43 -0
- package/dist/rich-text-editor/store.js.map +1 -0
- package/dist/rich-text-editor/suggest.d.ts +127 -0
- package/dist/rich-text-editor/suggest.d.ts.map +1 -0
- package/dist/rich-text-editor/suggest.js +0 -0
- package/dist/rich-text-editor/suggest.js.map +1 -0
- package/dist/rich-text-editor/tables.d.ts +41 -0
- package/dist/rich-text-editor/tables.d.ts.map +1 -0
- package/dist/rich-text-editor/tables.js +204 -0
- package/dist/rich-text-editor/tables.js.map +1 -0
- package/dist/rich-text-editor/toolbar.d.ts +58 -0
- package/dist/rich-text-editor/toolbar.d.ts.map +1 -0
- package/dist/rich-text-editor/toolbar.js +548 -0
- package/dist/rich-text-editor/toolbar.js.map +1 -0
- package/dist/rich-text-editor/view.d.ts +368 -0
- package/dist/rich-text-editor/view.d.ts.map +1 -0
- package/dist/rich-text-editor/view.js +1968 -0
- package/dist/rich-text-editor/view.js.map +1 -0
- package/dist/rich-text-editor/virtual.d.ts +54 -0
- package/dist/rich-text-editor/virtual.d.ts.map +1 -0
- package/dist/rich-text-editor/virtual.js +279 -0
- package/dist/rich-text-editor/virtual.js.map +1 -0
- package/dist/richtext/node.d.ts +71 -4
- package/dist/richtext/node.d.ts.map +1 -1
- package/dist/richtext/node.js +233 -28
- package/dist/richtext/node.js.map +1 -1
- package/dist/richtext/runs.d.ts +13 -8
- package/dist/richtext/runs.d.ts.map +1 -1
- package/dist/richtext/runs.js +18 -8
- package/dist/richtext/runs.js.map +1 -1
- package/dist/table/index.d.ts.map +1 -1
- package/dist/table/index.js +23 -0
- package/dist/table/index.js.map +1 -1
- package/dist/table/rows.d.ts +3 -2
- package/dist/table/rows.d.ts.map +1 -1
- package/dist/table/rows.js +20 -6
- package/dist/table/rows.js.map +1 -1
- package/dist/terminal/backends.d.ts +4 -1
- package/dist/terminal/backends.d.ts.map +1 -1
- package/dist/terminal/backends.js.map +1 -1
- package/dist/terminal/index.d.ts +18 -7
- package/dist/terminal/index.d.ts.map +1 -1
- package/dist/terminal/index.js +32 -11
- package/dist/terminal/index.js.map +1 -1
- package/dist/terminal/vt/pty.d.ts +13 -2
- package/dist/terminal/vt/pty.d.ts.map +1 -1
- package/dist/terminal/vt/pty.js +18 -3
- package/dist/terminal/vt/pty.js.map +1 -1
- package/dist/terminal-output/index.d.ts.map +1 -1
- package/dist/terminal-output/index.js +6 -1
- package/dist/terminal-output/index.js.map +1 -1
- package/dist/three/canvas.d.ts.map +1 -1
- package/dist/three/canvas.js +85 -7
- package/dist/three/canvas.js.map +1 -1
- package/dist/three/events.d.ts +22 -4
- package/dist/three/events.d.ts.map +1 -1
- package/dist/three/events.js +34 -4
- package/dist/three/events.js.map +1 -1
- package/dist/tree/index.d.ts.map +1 -1
- package/dist/tree/index.js +17 -0
- package/dist/tree/index.js.map +1 -1
- package/package.json +59 -31
- package/src/charts/node.ts +68 -28
- package/src/charts/render.ts +120 -30
- package/src/code/index.ts +3 -1
- package/src/code-editor/completion.ts +3 -2
- package/src/code-editor/index.ts +19 -0
- package/src/code-editor/node.ts +1574 -184
- package/src/code-language/languages/glsl.ts +12 -2
- package/src/code-language/languages/javascript.ts +21 -4
- package/src/code-language/languages/json.ts +12 -2
- package/src/code-language/languages/shell.ts +12 -2
- package/src/code-language/languages/sql.ts +22 -2
- package/src/code-language/stream.ts +257 -17
- package/src/code-language/types.ts +5 -4
- package/src/codeblock/index.ts +20 -3
- package/src/embed/client.ts +102 -8
- package/src/embed/index.ts +2 -0
- package/src/flow/draw.ts +167 -41
- package/src/flow/gl/color.ts +85 -0
- package/src/flow/gl/index.ts +342 -0
- package/src/flow/gl/pack.ts +585 -0
- package/src/flow/gl/renderer.ts +679 -0
- package/src/flow/gl/shaders.ts +371 -0
- package/src/flow/gl/text.ts +1295 -0
- package/src/flow/index.ts +794 -67
- package/src/flow/node.ts +2496 -1256
- package/src/flow/paint.ts +511 -0
- package/src/flow/paths.ts +80 -15
- package/src/flow/scene.ts +2199 -0
- package/src/flow/types.ts +113 -1
- package/src/html/controls.ts +73 -2
- package/src/html/css/calc.ts +385 -0
- package/src/html/css/cascade.ts +1403 -62
- package/src/html/css/color.ts +755 -0
- package/src/html/css/content.ts +417 -0
- package/src/html/css/counter-styles.ts +973 -0
- package/src/html/css/decode.ts +130 -0
- package/src/html/css/parse.ts +1514 -160
- package/src/html/css/style.ts +4102 -222
- package/src/html/css/ua.ts +58 -12
- package/src/html/css/values.ts +150 -50
- package/src/html/css/vars.ts +348 -0
- package/src/html/dom.ts +284 -17
- package/src/html/fonts.ts +641 -0
- package/src/html/gif.ts +233 -0
- package/src/html/index.ts +180 -20
- package/src/html/layout/block.ts +3456 -230
- package/src/html/layout/boxes.ts +2100 -190
- package/src/html/layout/cache.ts +289 -0
- package/src/html/layout/collapse.ts +317 -0
- package/src/html/layout/css-grid.ts +1063 -0
- package/src/html/layout/flex.ts +1115 -106
- package/src/html/layout/floats.ts +128 -14
- package/src/html/layout/grid-lines.ts +141 -0
- package/src/html/layout/grid.ts +181 -0
- package/src/html/layout/inline.ts +3943 -192
- package/src/html/layout/shaping.ts +140 -0
- package/src/html/layout/table.ts +696 -186
- package/src/html/layout/tracks.ts +437 -0
- package/src/html/node.ts +1486 -121
- package/src/html/paint.ts +4293 -169
- package/src/html/resources.ts +161 -50
- package/src/html/surfaces.ts +81 -0
- package/src/html/svg.ts +493 -0
- package/src/html/url.ts +86 -0
- package/src/index.ts +4 -0
- package/src/internal/collate.ts +12 -0
- package/src/{markdown → internal/markdown}/ast.ts +35 -7
- package/src/{markdown → internal/markdown}/parse.ts +288 -35
- package/src/internal/markdown/stringify.ts +772 -0
- package/src/internal/prewarm.ts +45 -0
- package/src/internal/scroll.ts +5 -3
- package/src/internal/sdf.ts +227 -0
- package/src/internal/splice.ts +25 -0
- package/src/internal/window.ts +36 -5
- package/src/maps/anchors.ts +913 -0
- package/src/maps/controller.ts +1084 -0
- package/src/maps/gl/buckets.ts +461 -0
- package/src/maps/gl/build-worker.ts +66 -0
- package/src/maps/gl/color.ts +62 -0
- package/src/maps/gl/cover.ts +205 -0
- package/src/maps/gl/index.ts +23 -0
- package/src/maps/gl/markers.ts +83 -0
- package/src/maps/gl/overlays.ts +379 -0
- package/src/maps/gl/pane.ts +42 -0
- package/src/maps/gl/placement.ts +968 -0
- package/src/maps/gl/renderer.ts +1660 -0
- package/src/maps/gl/shaders.ts +489 -0
- package/src/maps/gl/store.ts +615 -0
- package/src/maps/gl/text.ts +868 -0
- package/src/maps/gl/view.ts +1489 -0
- package/src/maps/icons.ts +183 -0
- package/src/maps/index.ts +274 -81
- package/src/maps/labels.ts +457 -144
- package/src/maps/node.ts +832 -665
- package/src/maps/overlay.ts +148 -43
- package/src/maps/paint.ts +3 -0
- package/src/maps/proj.ts +118 -0
- package/src/maps/renderer.ts +155 -0
- package/src/maps/sources.ts +43 -6
- package/src/maps/style.ts +32 -0
- package/src/maps/styles.ts +215 -4
- package/src/maps/theme.ts +51 -0
- package/src/maps/tiles.ts +253 -62
- package/src/maps/types.ts +213 -21
- package/src/markdown/expressions.ts +5 -1
- package/src/markdown/index.ts +163 -78
- package/src/markdown/spans.ts +6 -1
- package/src/media-player/index.ts +18 -4
- package/src/qml/containers.tsx +6 -1
- package/src/qml/interaction.tsx +42 -5
- package/src/qml/layouts.tsx +21 -6
- package/src/qml/qtquick.tsx +9 -2
- package/src/qml/react.tsx +7 -5
- package/src/reorder/clock.ts +27 -0
- package/src/reorder/index.ts +100 -27
- package/src/rich-text-editor/clipboard.ts +439 -0
- package/src/rich-text-editor/collab.ts +91 -0
- package/src/rich-text-editor/commands.ts +448 -0
- package/src/rich-text-editor/dom-globals.d.ts +23 -0
- package/src/rich-text-editor/drag.ts +211 -0
- package/src/rich-text-editor/html.ts +619 -0
- package/src/rich-text-editor/index.ts +1364 -0
- package/src/rich-text-editor/inline.ts +345 -0
- package/src/rich-text-editor/keymap.ts +510 -0
- package/src/rich-text-editor/keys.ts +228 -0
- package/src/rich-text-editor/look.ts +427 -0
- package/src/rich-text-editor/markdown.ts +653 -0
- package/src/rich-text-editor/marks.ts +101 -0
- package/src/rich-text-editor/nodes.ts +497 -0
- package/src/rich-text-editor/render.ts +837 -0
- package/src/rich-text-editor/schema.ts +431 -0
- package/src/rich-text-editor/store.ts +39 -0
- package/src/rich-text-editor/suggest.ts +597 -0
- package/src/rich-text-editor/tables.ts +272 -0
- package/src/rich-text-editor/toolbar.ts +724 -0
- package/src/rich-text-editor/view.ts +2287 -0
- package/src/rich-text-editor/virtual.ts +372 -0
- package/src/richtext/node.ts +294 -44
- package/src/richtext/runs.ts +23 -12
- package/src/table/index.ts +29 -0
- package/src/table/rows.ts +18 -8
- package/src/terminal/backends.ts +4 -1
- package/src/terminal/index.ts +47 -15
- package/src/terminal/vt/pty.ts +16 -2
- package/src/terminal-output/index.ts +6 -1
- package/src/three/canvas.ts +102 -8
- package/src/three/events.ts +49 -9
- package/src/tree/index.ts +19 -0
- package/dist/markdown/ast.d.ts.map +0 -1
- package/dist/markdown/ast.js +0 -17
- package/dist/markdown/ast.js.map +0 -1
- package/dist/markdown/parse.d.ts.map +0 -1
- package/dist/markdown/parse.js.map +0 -1
- package/dist/markdown/tags.d.ts.map +0 -1
- package/dist/markdown/tags.js.map +0 -1
- /package/dist/{markdown → internal/markdown}/parse.d.ts +0 -0
- /package/dist/{markdown → internal/markdown}/tags.d.ts +0 -0
- /package/dist/{markdown → internal/markdown}/tags.js +0 -0
- /package/src/{markdown → internal/markdown}/tags.ts +0 -0
package/dist/embed/client.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ import type { ExitInfo, ProcessHost, SpawnedProcess } from './host.js';
|
|
|
6
6
|
* with no terminal emulator installed, or no mpv, is an ordinary machine.
|
|
7
7
|
* Both components render their `fallback` on it, the way
|
|
8
8
|
* `useDesktopCalendarEvents` reports "no bus, no ical.js" rather than
|
|
9
|
-
* throwing.
|
|
9
|
+
* throwing. So is an app on a react-x11 backend that cannot embed another
|
|
10
|
+
* program's window at all — the native macOS one — and `error` says which of
|
|
11
|
+
* the two it is: a `BackendUnavailableError` or an `EmbedUnsupportedError`.
|
|
10
12
|
*/
|
|
11
13
|
export type EmbedStatus = 'idle' | 'starting' | 'running' | 'exited' | 'unavailable';
|
|
12
14
|
/**
|
|
@@ -20,6 +22,41 @@ export declare class BackendUnavailableError extends Error {
|
|
|
20
22
|
readonly tried: readonly string[];
|
|
21
23
|
constructor(what: string, tried: readonly string[]);
|
|
22
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* This app cannot host another program's window at all.
|
|
27
|
+
*
|
|
28
|
+
* Embedding is XEmbed, and XEmbed is X protocol — a reparent into a
|
|
29
|
+
* container, the save set, ClientMessages — which only react-x11's X11
|
|
30
|
+
* backend has. The native macOS backend has no cross-process window
|
|
31
|
+
* embedding (react-x11 `docs/macos.md`, "What this is, and is not"), so there
|
|
32
|
+
* is no window to hand a program and nothing to spawn.
|
|
33
|
+
*
|
|
34
|
+
* `useEmbeddedClient` reports it as `status: 'unavailable'`, the status a
|
|
35
|
+
* `BackendUnavailableError` gets, and for the same reason: it is an ordinary
|
|
36
|
+
* state of a healthy app, and the component renders its `fallback`. The class
|
|
37
|
+
* is what tells the two apart, because "install xterm" is the wrong advice
|
|
38
|
+
* here.
|
|
39
|
+
*/
|
|
40
|
+
export declare class EmbedUnsupportedError extends Error {
|
|
41
|
+
constructor();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Can this app host another program's window?
|
|
45
|
+
*
|
|
46
|
+
* Asked of the connection, because `<foreign>` cannot be the one to say: on
|
|
47
|
+
* react-x11's Cocoa backend it still calls `onReady`, with an undefined
|
|
48
|
+
* `windowId`, and on the headless mock mounting one throws from the commit.
|
|
49
|
+
* The test is `<TrayHost>`'s — its
|
|
50
|
+
* manager reports `'unavailable'` when `app.X` has no `SetSelectionOwner`,
|
|
51
|
+
* which is what core's Cocoa `X` lacks (react-x11 `src/cocoa/app.js`: a stub
|
|
52
|
+
* carrying only the few requests core makes there) and what the headless
|
|
53
|
+
* mock's `X` lacks too. `ReparentWindow` is asked as well, because it is the
|
|
54
|
+
* request an embed is actually made of.
|
|
55
|
+
*
|
|
56
|
+
* Takes the app rather than calling `useApp()`, so it can be asked off the
|
|
57
|
+
* render path — of `createRoot()`'s result, before there is a tree.
|
|
58
|
+
*/
|
|
59
|
+
export declare function canHostXEmbed(app: unknown): boolean;
|
|
23
60
|
/** What to run, and what to do with it once it is running. */
|
|
24
61
|
export interface LaunchPlan {
|
|
25
62
|
/** Absolute path or a name on `PATH`. */
|
|
@@ -68,12 +105,14 @@ export interface UseEmbeddedClientOptions {
|
|
|
68
105
|
backend?: string;
|
|
69
106
|
}) => void;
|
|
70
107
|
onExit?: (info: ExitInfo) => void;
|
|
71
|
-
/** Spawn failures
|
|
108
|
+
/** Spawn failures, missing backends, and an app that cannot host an
|
|
109
|
+
* embedded window at all (`EmbedUnsupportedError`). */
|
|
72
110
|
onError?: (err: Error) => void;
|
|
73
111
|
}
|
|
74
112
|
export interface EmbeddedClient {
|
|
75
113
|
status: EmbedStatus;
|
|
76
|
-
/** The last failure, including a `BackendUnavailableError
|
|
114
|
+
/** The last failure, including a `BackendUnavailableError` or an
|
|
115
|
+
* `EmbedUnsupportedError`. */
|
|
77
116
|
error: Error | null;
|
|
78
117
|
pid: number | null;
|
|
79
118
|
/** The container window, once `<foreign>` has one. */
|
|
@@ -101,6 +140,12 @@ export interface EmbeddedClient {
|
|
|
101
140
|
* element's props — style, focus, the `onEmbedded`/`onClientGone` handlers a
|
|
102
141
|
* component may want to compose with — belong to the component, not to the
|
|
103
142
|
* lifecycle.
|
|
143
|
+
*
|
|
144
|
+
* **On an app that cannot host XEmbed** (`canHostXEmbed` is false — the
|
|
145
|
+
* native macOS backend), `status` is `'unavailable'` from the first render,
|
|
146
|
+
* `error` is an `EmbedUnsupportedError`, and nothing is probed or spawned.
|
|
147
|
+
* The caller should render no `<foreign>` there either: it has no socket to
|
|
148
|
+
* be.
|
|
104
149
|
*/
|
|
105
150
|
export declare function useEmbeddedClient(options: UseEmbeddedClientOptions): EmbeddedClient;
|
|
106
151
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/embed/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/embed/client.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEvE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,WAAW,GACrB,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,CAAC;AAE7D;;;;;;GAMG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAElC,YAAY,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,EAQjD;CACF;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,cAQC;CACF;AASD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,GAAG,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AO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,WAAW,CAAC;IACpB;mCAC+B;IAC/B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,sDAAsD;IACtD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,qCAAqC;IACrC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,4CAA4C;IAC5C,WAAW,EAAE,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAClD,mEAAmE;IACnE,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,qDAAqD;IACrD,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;CACtC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,wBAAwB,GAChC,cAAc,CAuKhB;AAED;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,CAAC,SAAS;IAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,EAC5E,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,SAAS,CAAC,EAAE,GACvB,OAAO,CAAC;IAAE,OAAO,EAAE,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAUvC"}
|
package/dist/embed/client.js
CHANGED
|
@@ -12,8 +12,12 @@
|
|
|
12
12
|
// `onReady` — because core's `<foreign>` already owns the protocol
|
|
13
13
|
// (react-x11#269, ntk#246): the reparent, the save set, `_XEMBED_INFO`, the
|
|
14
14
|
// synthetic ConfigureNotify, and handing the client back on unmount without
|
|
15
|
-
// ever destroying it.
|
|
15
|
+
// ever destroying it. The one thing asked of the connection directly is
|
|
16
|
+
// whether it has that protocol at all (`canHostXEmbed`), because on a backend
|
|
17
|
+
// that does not, `onReady` is no evidence either way: the Cocoa backend's
|
|
18
|
+
// `<foreign>` still calls it, with `windowId: undefined`.
|
|
16
19
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
20
|
+
import { useApp } from 'react-x11';
|
|
17
21
|
import { nodeProcessHost } from './host.js';
|
|
18
22
|
/**
|
|
19
23
|
* No backend for this component is installed.
|
|
@@ -32,6 +36,52 @@ export class BackendUnavailableError extends Error {
|
|
|
32
36
|
this.tried = tried;
|
|
33
37
|
}
|
|
34
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* This app cannot host another program's window at all.
|
|
41
|
+
*
|
|
42
|
+
* Embedding is XEmbed, and XEmbed is X protocol — a reparent into a
|
|
43
|
+
* container, the save set, ClientMessages — which only react-x11's X11
|
|
44
|
+
* backend has. The native macOS backend has no cross-process window
|
|
45
|
+
* embedding (react-x11 `docs/macos.md`, "What this is, and is not"), so there
|
|
46
|
+
* is no window to hand a program and nothing to spawn.
|
|
47
|
+
*
|
|
48
|
+
* `useEmbeddedClient` reports it as `status: 'unavailable'`, the status a
|
|
49
|
+
* `BackendUnavailableError` gets, and for the same reason: it is an ordinary
|
|
50
|
+
* state of a healthy app, and the component renders its `fallback`. The class
|
|
51
|
+
* is what tells the two apart, because "install xterm" is the wrong advice
|
|
52
|
+
* here.
|
|
53
|
+
*/
|
|
54
|
+
export class EmbedUnsupportedError extends Error {
|
|
55
|
+
constructor() {
|
|
56
|
+
super('@react-x11/components: this react-x11 backend cannot embed another ' +
|
|
57
|
+
"program's window — XEmbed needs the X11 backend, and the native " +
|
|
58
|
+
'macOS one has no cross-process window embedding at all. Pass ' +
|
|
59
|
+
'`fallback` to render something else.');
|
|
60
|
+
this.name = 'EmbedUnsupportedError';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Can this app host another program's window?
|
|
65
|
+
*
|
|
66
|
+
* Asked of the connection, because `<foreign>` cannot be the one to say: on
|
|
67
|
+
* react-x11's Cocoa backend it still calls `onReady`, with an undefined
|
|
68
|
+
* `windowId`, and on the headless mock mounting one throws from the commit.
|
|
69
|
+
* The test is `<TrayHost>`'s — its
|
|
70
|
+
* manager reports `'unavailable'` when `app.X` has no `SetSelectionOwner`,
|
|
71
|
+
* which is what core's Cocoa `X` lacks (react-x11 `src/cocoa/app.js`: a stub
|
|
72
|
+
* carrying only the few requests core makes there) and what the headless
|
|
73
|
+
* mock's `X` lacks too. `ReparentWindow` is asked as well, because it is the
|
|
74
|
+
* request an embed is actually made of.
|
|
75
|
+
*
|
|
76
|
+
* Takes the app rather than calling `useApp()`, so it can be asked off the
|
|
77
|
+
* render path — of `createRoot()`'s result, before there is a tree.
|
|
78
|
+
*/
|
|
79
|
+
export function canHostXEmbed(app) {
|
|
80
|
+
const X = app?.X;
|
|
81
|
+
return (!!X &&
|
|
82
|
+
typeof X.SetSelectionOwner === 'function' &&
|
|
83
|
+
typeof X.ReparentWindow === 'function');
|
|
84
|
+
}
|
|
35
85
|
/**
|
|
36
86
|
* Run a program inside a `<foreign>`.
|
|
37
87
|
*
|
|
@@ -44,10 +94,19 @@ export class BackendUnavailableError extends Error {
|
|
|
44
94
|
* element's props — style, focus, the `onEmbedded`/`onClientGone` handlers a
|
|
45
95
|
* component may want to compose with — belong to the component, not to the
|
|
46
96
|
* lifecycle.
|
|
97
|
+
*
|
|
98
|
+
* **On an app that cannot host XEmbed** (`canHostXEmbed` is false — the
|
|
99
|
+
* native macOS backend), `status` is `'unavailable'` from the first render,
|
|
100
|
+
* `error` is an `EmbedUnsupportedError`, and nothing is probed or spawned.
|
|
101
|
+
* The caller should render no `<foreign>` there either: it has no socket to
|
|
102
|
+
* be.
|
|
47
103
|
*/
|
|
48
104
|
export function useEmbeddedClient(options) {
|
|
49
105
|
const { plan, enabled = true, stopSignal = 'SIGTERM' } = options;
|
|
50
106
|
const host = useMemo(() => options.host ?? nodeProcessHost(), [options.host]);
|
|
107
|
+
// Asked every render: two property reads, and an app does not change
|
|
108
|
+
// backend under a mounted tree.
|
|
109
|
+
const embeddable = canHostXEmbed(useApp());
|
|
51
110
|
const [windowId, setWindowId] = useState(null);
|
|
52
111
|
const [status, setStatus] = useState('idle');
|
|
53
112
|
const [error, setError] = useState(null);
|
|
@@ -62,6 +121,21 @@ export function useEmbeddedClient(options) {
|
|
|
62
121
|
// fresh arrow function every render does not restart its child.
|
|
63
122
|
const handlers = useRef(options);
|
|
64
123
|
handlers.current = options;
|
|
124
|
+
// No XEmbed on this connection means no window for a program to draw into,
|
|
125
|
+
// whatever `<foreign>` reports: the Cocoa backend's calls `onReady` with an
|
|
126
|
+
// undefined `windowId`, which slipped past a `windowId === null` guard and
|
|
127
|
+
// spawned `xterm -into undefined`. So the app decides, and the lifecycle
|
|
128
|
+
// below starts nothing without it. Decided while rendering rather than in
|
|
129
|
+
// an effect, so the first commit can already be the `fallback`, and
|
|
130
|
+
// reported from an effect keyed on the error itself, so `onError` hears it
|
|
131
|
+
// once rather than once per plan. `enabled` false still means "hold off": a
|
|
132
|
+
// pane nobody can see yet reports nothing.
|
|
133
|
+
const unsupported = enabled && !embeddable;
|
|
134
|
+
const unsupportedError = useMemo(() => (unsupported ? new EmbedUnsupportedError() : null), [unsupported]);
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
if (unsupportedError)
|
|
137
|
+
handlers.current.onError?.(unsupportedError);
|
|
138
|
+
}, [unsupportedError]);
|
|
65
139
|
const handleReady = useCallback((info) => {
|
|
66
140
|
setWindowId(info.windowId);
|
|
67
141
|
}, []);
|
|
@@ -71,7 +145,7 @@ export function useEmbeddedClient(options) {
|
|
|
71
145
|
return child ? child.kill(sig) : false;
|
|
72
146
|
}, []);
|
|
73
147
|
useEffect(() => {
|
|
74
|
-
if (!enabled || windowId === null) {
|
|
148
|
+
if (!enabled || !embeddable || windowId === null) {
|
|
75
149
|
setStatus('idle');
|
|
76
150
|
return undefined;
|
|
77
151
|
}
|
|
@@ -167,10 +241,10 @@ export function useEmbeddedClient(options) {
|
|
|
167
241
|
void planned?.dispose?.();
|
|
168
242
|
};
|
|
169
243
|
// `plan` is the restart signal — see the note on the option.
|
|
170
|
-
}, [enabled, windowId, plan, host, stopSignal, generation]);
|
|
244
|
+
}, [enabled, embeddable, windowId, plan, host, stopSignal, generation]);
|
|
171
245
|
return {
|
|
172
|
-
status,
|
|
173
|
-
error,
|
|
246
|
+
status: unsupported ? 'unavailable' : status,
|
|
247
|
+
error: unsupportedError ?? error,
|
|
174
248
|
pid,
|
|
175
249
|
windowId,
|
|
176
250
|
backend,
|
package/dist/embed/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/embed/client.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,sBAAsB;AACtB,EAAE;AACF,0EAA0E;AAC1E,6EAA6E;AAC7E,8EAA8E;AAC9E,8EAA8E;AAC9E,6EAA6E;AAC7E,WAAW;AACX,EAAE;AACF,oEAAoE;AACpE,mEAAmE;AACnE,4EAA4E;AAC5E,4EAA4E;AAC5E,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/embed/client.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,sBAAsB;AACtB,EAAE;AACF,0EAA0E;AAC1E,6EAA6E;AAC7E,8EAA8E;AAC9E,8EAA8E;AAC9E,6EAA6E;AAC7E,WAAW;AACX,EAAE;AACF,oEAAoE;AACpE,mEAAmE;AACnE,4EAA4E;AAC5E,4EAA4E;AAC5E,wEAAwE;AACxE,8EAA8E;AAC9E,0EAA0E;AAC1E,0DAA0D;AAC1D,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAA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iC;YACnC,CAAC;YACD,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;YACxB,KAAK,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC;QAC5B,CAAC,CAAC;QACF,6DAA6D;IAC/D,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;IAExE,OAAO;QACL,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM;QAC5C,KAAK,EAAE,gBAAgB,IAAI,KAAK;QAChC,GAAG;QACH,QAAQ;QACR,OAAO;QACP,WAAW;QACX,OAAO;QACP,MAAM;KACP,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,IAAiB,EACjB,IAAY,EACZ,UAAwB;IAExB,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,OAAO,IAAI,UAAU,EAAE,CAAC;QACjC,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACtC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACnB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACtC,IAAI,IAAI;gBAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACrC,CAAC;IACH,CAAC;IACD,MAAM,IAAI,uBAAuB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACjD,CAAC"}
|
package/dist/embed/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { BackendUnavailableError, resolveBackend, useEmbeddedClient, } from './client.js';
|
|
1
|
+
export { BackendUnavailableError, EmbedUnsupportedError, canHostXEmbed, resolveBackend, useEmbeddedClient, } from './client.js';
|
|
2
2
|
export type { EmbedStatus, EmbeddedClient, LaunchPlan, PlanContext, PlanFactory, UseEmbeddedClientOptions, } from './client.js';
|
|
3
3
|
export { IpcConnectError, connectWhenReady, nodeProcessHost } from './host.js';
|
|
4
4
|
export type { ExitInfo, IpcSocket, ProcessHost, ScratchSocket, SpawnOptions, SpawnedProcess, } from './host.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/embed/index.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,WAAW,EACX,cAAc,EACd,UAAU,EACV,WAAW,EACX,WAAW,EACX,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC/E,YAAY,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,aAAa,EACb,YAAY,EACZ,cAAc,GACf,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/embed/index.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,WAAW,EACX,cAAc,EACd,UAAU,EACV,WAAW,EACX,WAAW,EACX,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC/E,YAAY,EACV,QAAQ,EACR,SAAS,EACT,WAAW,EACX,aAAa,EACb,YAAY,EACZ,cAAc,GACf,MAAM,WAAW,CAAC"}
|
package/dist/embed/index.js
CHANGED
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
// reasons — `ProcessHost` is the seam an app needs to run the child somewhere
|
|
9
9
|
// else (a container, an ssh host, a sandbox), and a fourth wrapper around some
|
|
10
10
|
// other `-into WID` program should not have to copy this file to exist.
|
|
11
|
-
export { BackendUnavailableError, resolveBackend, useEmbeddedClient, } from './client.js';
|
|
11
|
+
export { BackendUnavailableError, EmbedUnsupportedError, canHostXEmbed, resolveBackend, useEmbeddedClient, } from './client.js';
|
|
12
12
|
export { IpcConnectError, connectWhenReady, nodeProcessHost } from './host.js';
|
|
13
13
|
//# sourceMappingURL=index.js.map
|
package/dist/embed/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/embed/index.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,iEAAiE;AACjE,EAAE;AACF,yEAAyE;AACzE,8EAA8E;AAC9E,6EAA6E;AAC7E,qEAAqE;AACrE,8EAA8E;AAC9E,+EAA+E;AAC/E,wEAAwE;AACxE,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAUrB,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/embed/index.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,iEAAiE;AACjE,EAAE;AACF,yEAAyE;AACzE,8EAA8E;AAC9E,6EAA6E;AAC7E,qEAAqE;AACrE,8EAA8E;AAC9E,+EAA+E;AAC/E,wEAAwE;AACxE,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAUrB,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/flow/draw.d.ts
CHANGED
|
@@ -3,6 +3,18 @@ interface LayoutLike {
|
|
|
3
3
|
width: number;
|
|
4
4
|
height: number;
|
|
5
5
|
draw(ctx: unknown, x: number, y: number): void;
|
|
6
|
+
/** The engine's own coverage of the layout, one byte a device pixel, with
|
|
7
|
+
* `pad` round its box — where the engine answers it (react-x11#673). */
|
|
8
|
+
coverage?(options?: {
|
|
9
|
+
pad?: number;
|
|
10
|
+
}): TextCoverage | null;
|
|
11
|
+
}
|
|
12
|
+
/** A layout's coverage: `width` × `height` bytes, the layout's origin at
|
|
13
|
+
* (pad, pad). */
|
|
14
|
+
export interface TextCoverage {
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
data: Uint8Array;
|
|
6
18
|
}
|
|
7
19
|
/** One shaped string, kept between frames. `width` and `height` are
|
|
8
20
|
* logical; the layout itself was shaped at device size. */
|
|
@@ -39,6 +51,14 @@ export interface PainterOptions {
|
|
|
39
51
|
* no amount of batching on the wire would have fixed.
|
|
40
52
|
*/
|
|
41
53
|
cache: Map<string, CachedText>;
|
|
54
|
+
/**
|
|
55
|
+
* While a zoom gesture moves: a label may be drawn from a layout shaped
|
|
56
|
+
* at another size, scaled to the one asked for, rather than shaped again
|
|
57
|
+
* at every step. The pane sets it only where the context scales text
|
|
58
|
+
* with its transform (`scalesText`), and paints the exact sizes once the
|
|
59
|
+
* gesture rests.
|
|
60
|
+
*/
|
|
61
|
+
approximateText?: boolean;
|
|
42
62
|
}
|
|
43
63
|
/**
|
|
44
64
|
* A logical value on the device grid.
|
|
@@ -50,10 +70,40 @@ export interface PainterOptions {
|
|
|
50
70
|
* of a bezier's control point is not something to snap.
|
|
51
71
|
*/
|
|
52
72
|
export declare function toDevice(value: number, scale: number): number;
|
|
73
|
+
/**
|
|
74
|
+
* `Math.round` for a place on the device grid, deaf to floating-point noise
|
|
75
|
+
* at a half. A pan moves the graph by whole device pixels, and its blit
|
|
76
|
+
* takes a shift within a hair of whole as whole (`toDevice`: the viewport
|
|
77
|
+
* `-66.4` panned 27 down is `-39.400000000000006`). A place worked out from
|
|
78
|
+
* the new viewport can then sit a hair below the half the old one sat on,
|
|
79
|
+
* or above it, and round the other way — a node or a label a pixel from
|
|
80
|
+
* where the copy put it. Nudged past any such hair, a half rounds up on
|
|
81
|
+
* both sides of the blit.
|
|
82
|
+
*/
|
|
83
|
+
export declare function snapToGrid(value: number): number;
|
|
84
|
+
/**
|
|
85
|
+
* Text metrics without a drawing context. The pane needs these *outside* a
|
|
86
|
+
* repaint — a node with no explicit size is measured when the graph changes,
|
|
87
|
+
* which is also when a hit test has to know how big it is — so measuring
|
|
88
|
+
* cannot live behind the painter the way drawing does.
|
|
89
|
+
*
|
|
90
|
+
* Exported for the GL renderer's label atlas (`./gl/text.ts`), which draws
|
|
91
|
+
* the layout it measured onto a staging surface of its own.
|
|
92
|
+
*/
|
|
93
|
+
export declare function shape(opts: PainterOptions, text: string, options: TextOptions | undefined): CachedText | null;
|
|
53
94
|
export declare function measureText(opts: PainterOptions, text: string, options?: TextOptions): {
|
|
54
95
|
width: number;
|
|
55
96
|
height: number;
|
|
56
97
|
};
|
|
98
|
+
/**
|
|
99
|
+
* Cut a string to fit `max` logical pixels, with an ellipsis. Linear from
|
|
100
|
+
* the end rather than a binary search: labels that need it are short, and
|
|
101
|
+
* the widths it walks through are the ones the cache already holds.
|
|
102
|
+
*
|
|
103
|
+
* Both renderers call this, so a label cut on one is cut the same on the
|
|
104
|
+
* other — the GL one sets whatever this returns as a raster.
|
|
105
|
+
*/
|
|
106
|
+
export declare function fitText(opts: PainterOptions, text: string, options: TextOptions | undefined, max: number): string;
|
|
57
107
|
/**
|
|
58
108
|
* A painter over this context, or `null` when the backend cannot draw paths
|
|
59
109
|
* — which is the signal to skip drawing entirely rather than to throw.
|
package/dist/flow/draw.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draw.d.ts","sourceRoot":"","sources":["../../src/flow/draw.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EACV,WAAW,EAGX,WAAW,EAEZ,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"draw.d.ts","sourceRoot":"","sources":["../../src/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;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAmBD;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI7D;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAiBD;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CACnB,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,WAAW,GAAG,SAAS,GAC/B,UAAU,GAAG,IAAI,CA8BnB;AAqCD,wBAAgB,WAAW,CACzB,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,WAAW,GACpB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAUnC;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CACrB,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,WAAW,GAAG,SAAS,EAChC,GAAG,EAAE,MAAM,GACV,MAAM,CASR;AA2SD;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE,cAAc,GACtB,WAAW,GAAG,IAAI,CAGpB"}
|
package/dist/flow/draw.js
CHANGED
|
@@ -4,6 +4,9 @@ function isCanvas(ctx) {
|
|
|
4
4
|
}
|
|
5
5
|
/** Bound, so a pathological graph cannot turn the width cache into a leak. */
|
|
6
6
|
const CACHE_LIMIT = 4000;
|
|
7
|
+
/** The sizes each string has been shaped at, per cache — what a label drawn
|
|
8
|
+
* mid-zoom looks for instead of shaping itself again (`approximateText`). */
|
|
9
|
+
const shapedSizes = new WeakMap();
|
|
7
10
|
/**
|
|
8
11
|
* A logical value on the device grid.
|
|
9
12
|
*
|
|
@@ -18,6 +21,19 @@ export function toDevice(value, scale) {
|
|
|
18
21
|
const whole = Math.round(out);
|
|
19
22
|
return Math.abs(out - whole) < 1e-6 ? whole : out;
|
|
20
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* `Math.round` for a place on the device grid, deaf to floating-point noise
|
|
26
|
+
* at a half. A pan moves the graph by whole device pixels, and its blit
|
|
27
|
+
* takes a shift within a hair of whole as whole (`toDevice`: the viewport
|
|
28
|
+
* `-66.4` panned 27 down is `-39.400000000000006`). A place worked out from
|
|
29
|
+
* the new viewport can then sit a hair below the half the old one sat on,
|
|
30
|
+
* or above it, and round the other way — a node or a label a pixel from
|
|
31
|
+
* where the copy put it. Nudged past any such hair, a half rounds up on
|
|
32
|
+
* both sides of the blit.
|
|
33
|
+
*/
|
|
34
|
+
export function snapToGrid(value) {
|
|
35
|
+
return Math.round(value + 1e-4);
|
|
36
|
+
}
|
|
21
37
|
function fontStyle(opts, options) {
|
|
22
38
|
return {
|
|
23
39
|
family: options?.family ?? opts.family,
|
|
@@ -34,8 +50,11 @@ function fontStyle(opts, options) {
|
|
|
34
50
|
* repaint — a node with no explicit size is measured when the graph changes,
|
|
35
51
|
* which is also when a hit test has to know how big it is — so measuring
|
|
36
52
|
* cannot live behind the painter the way drawing does.
|
|
53
|
+
*
|
|
54
|
+
* Exported for the GL renderer's label atlas (`./gl/text.ts`), which draws
|
|
55
|
+
* the layout it measured onto a staging surface of its own.
|
|
37
56
|
*/
|
|
38
|
-
function shape(opts, text, options) {
|
|
57
|
+
export function shape(opts, text, options) {
|
|
39
58
|
const { fonts, cache } = opts;
|
|
40
59
|
if (!fonts)
|
|
41
60
|
return null;
|
|
@@ -44,13 +63,17 @@ function shape(opts, text, options) {
|
|
|
44
63
|
// The colour is part of the key: it is baked into the layout, so two
|
|
45
64
|
// labels that differ only in ink are two shaped runs. The scale is not:
|
|
46
65
|
// it is constant for the life of the pane that owns the cache.
|
|
47
|
-
const
|
|
66
|
+
const base = `${family}|${options?.weight ?? 400}|${options?.color ?? opts.color}|${text}`;
|
|
67
|
+
const key = `${size}|${base}`;
|
|
48
68
|
const hit = cache.get(key);
|
|
49
69
|
if (hit)
|
|
50
70
|
return hit;
|
|
51
71
|
const layout = fonts.layout(text, fontStyle(opts, options));
|
|
52
|
-
|
|
72
|
+
let sizes = shapedSizes.get(cache);
|
|
73
|
+
if (cache.size >= CACHE_LIMIT) {
|
|
53
74
|
cache.clear();
|
|
75
|
+
sizes?.clear();
|
|
76
|
+
}
|
|
54
77
|
const s = opts.scale;
|
|
55
78
|
const entry = {
|
|
56
79
|
width: layout.width / s,
|
|
@@ -58,17 +81,77 @@ function shape(opts, text, options) {
|
|
|
58
81
|
layout,
|
|
59
82
|
};
|
|
60
83
|
cache.set(key, entry);
|
|
84
|
+
if (!sizes)
|
|
85
|
+
shapedSizes.set(cache, (sizes = new Map()));
|
|
86
|
+
const shaped = sizes.get(base);
|
|
87
|
+
if (shaped)
|
|
88
|
+
shaped.push(size);
|
|
89
|
+
else
|
|
90
|
+
sizes.set(base, [size]);
|
|
61
91
|
return entry;
|
|
62
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* The layout a label is drawn from, and the scale it is drawn at: its own
|
|
95
|
+
* size where it has one, and mid-zoom (`approximateText`) the size nearest
|
|
96
|
+
* it that was shaped already — the one the gesture started from, for every
|
|
97
|
+
* label on screen. Shaping is most of what a zoom step costs in text, and
|
|
98
|
+
* a step that re-shapes every label at a size the next step moves off was
|
|
99
|
+
* paying it for nothing.
|
|
100
|
+
*/
|
|
101
|
+
function shapeNear(opts, text, options) {
|
|
102
|
+
if (opts.approximateText) {
|
|
103
|
+
const size = options?.size ?? 13;
|
|
104
|
+
const family = options?.family ?? opts.family;
|
|
105
|
+
const base = `${family}|${options?.weight ?? 400}|${options?.color ?? opts.color}|${text}`;
|
|
106
|
+
const exact = opts.cache.get(`${size}|${base}`);
|
|
107
|
+
if (exact)
|
|
108
|
+
return { entry: exact, scale: 1 };
|
|
109
|
+
const shaped = shapedSizes.get(opts.cache)?.get(base);
|
|
110
|
+
if (shaped && shaped.length > 0) {
|
|
111
|
+
let best = shaped[0];
|
|
112
|
+
for (const at of shaped) {
|
|
113
|
+
if (Math.abs(Math.log(at / size)) < Math.abs(Math.log(best / size))) {
|
|
114
|
+
best = at;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const entry = opts.cache.get(`${best}|${base}`);
|
|
118
|
+
if (entry)
|
|
119
|
+
return { entry, scale: size / best };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const entry = shape(opts, text, options);
|
|
123
|
+
return entry ? { entry, scale: 1 } : null;
|
|
124
|
+
}
|
|
63
125
|
export function measureText(opts, text, options) {
|
|
64
126
|
const size = options?.size ?? 13;
|
|
65
|
-
const
|
|
66
|
-
if (!
|
|
127
|
+
const near = shapeNear(opts, text, options);
|
|
128
|
+
if (!near) {
|
|
67
129
|
// No font stack to ask. An estimate keeps layout plausible rather than
|
|
68
130
|
// collapsing every node to its own padding.
|
|
69
131
|
return { width: text.length * size * 0.55, height: size * 1.3 };
|
|
70
132
|
}
|
|
71
|
-
|
|
133
|
+
const { entry, scale } = near;
|
|
134
|
+
return { width: entry.width * scale, height: entry.height * scale };
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Cut a string to fit `max` logical pixels, with an ellipsis. Linear from
|
|
138
|
+
* the end rather than a binary search: labels that need it are short, and
|
|
139
|
+
* the widths it walks through are the ones the cache already holds.
|
|
140
|
+
*
|
|
141
|
+
* Both renderers call this, so a label cut on one is cut the same on the
|
|
142
|
+
* other — the GL one sets whatever this returns as a raster.
|
|
143
|
+
*/
|
|
144
|
+
export function fitText(opts, text, options, max) {
|
|
145
|
+
if (measureText(opts, text, options).width <= max)
|
|
146
|
+
return text;
|
|
147
|
+
let cut = text.length;
|
|
148
|
+
while (cut > 1) {
|
|
149
|
+
cut--;
|
|
150
|
+
const candidate = `${text.slice(0, cut).trimEnd()}…`;
|
|
151
|
+
if (measureText(opts, candidate, options).width <= max)
|
|
152
|
+
return candidate;
|
|
153
|
+
}
|
|
154
|
+
return '…';
|
|
72
155
|
}
|
|
73
156
|
class Painter {
|
|
74
157
|
raw;
|
|
@@ -106,6 +189,14 @@ class Painter {
|
|
|
106
189
|
const { ctx } = this;
|
|
107
190
|
ctx.strokeStyle = options.stroke ?? this.opts.color;
|
|
108
191
|
ctx.lineWidth = this.d(options.lineWidth ?? 1);
|
|
192
|
+
// Every stroke says how it joins and ends; `polyline` and `strokeRuns`
|
|
193
|
+
// then round both. A context keeps whatever the last stroke set, so a
|
|
194
|
+
// pass that drew an edge before a handle stroked the handle with round
|
|
195
|
+
// joins and caps, and one that reached no edge — a node's own box,
|
|
196
|
+
// repainted by itself — stroked it mitred and butt-ended, and the same
|
|
197
|
+
// ring came out two ways depending on what else the pass drew.
|
|
198
|
+
ctx.lineJoin = 'miter';
|
|
199
|
+
ctx.lineCap = 'butt';
|
|
109
200
|
if (typeof ctx.setLineDash === 'function') {
|
|
110
201
|
ctx.setLineDash(options.dash ? options.dash.map((v) => this.d(v)) : []);
|
|
111
202
|
if ('lineDashOffset' in ctx) {
|
|
@@ -175,6 +266,10 @@ class Painter {
|
|
|
175
266
|
const { ctx } = this;
|
|
176
267
|
ctx.beginPath();
|
|
177
268
|
ctx.arc(this.d(x), this.d(y), this.d(r), 0, Math.PI * 2);
|
|
269
|
+
// Closed, so the ring is one loop with a join where it started: open,
|
|
270
|
+
// its two ends meet edge to edge, and a stroke with butt ends shows a
|
|
271
|
+
// hairline where they touch.
|
|
272
|
+
ctx.closePath();
|
|
178
273
|
if (options.fill) {
|
|
179
274
|
ctx.fillStyle = options.fill;
|
|
180
275
|
ctx.fill();
|
|
@@ -219,6 +314,15 @@ class Painter {
|
|
|
219
314
|
if (!any)
|
|
220
315
|
return;
|
|
221
316
|
this.applyStroke(options);
|
|
317
|
+
// Set, not inherited: this was whatever the last `polyline` left, so a
|
|
318
|
+
// pass that stroked an edge alone before the zoom controls drew their
|
|
319
|
+
// glyphs with round ends, and one that reached only the controls drew
|
|
320
|
+
// them square — a panel repainted by itself, as a pan repaints its
|
|
321
|
+
// pinned furniture every frame, came out lighter than the panel it
|
|
322
|
+
// replaced. The same for batched edges, whose joins changed with what
|
|
323
|
+
// the pass had drawn first.
|
|
324
|
+
ctx.lineJoin = 'round';
|
|
325
|
+
ctx.lineCap = 'round';
|
|
222
326
|
ctx.stroke();
|
|
223
327
|
this.clearDash();
|
|
224
328
|
}
|
|
@@ -276,40 +380,35 @@ class Painter {
|
|
|
276
380
|
measureText(text, options) {
|
|
277
381
|
return measureText(this.opts, text, options);
|
|
278
382
|
}
|
|
279
|
-
/** Cut a string to fit, with an ellipsis. Linear from the end rather than
|
|
280
|
-
* a binary search: labels that need it are short, and the widths it walks
|
|
281
|
-
* through are the ones the cache already holds. */
|
|
282
|
-
fit(text, options, max) {
|
|
283
|
-
if (this.measureText(text, options).width <= max)
|
|
284
|
-
return text;
|
|
285
|
-
let cut = text.length;
|
|
286
|
-
while (cut > 1) {
|
|
287
|
-
cut--;
|
|
288
|
-
const candidate = `${text.slice(0, cut).trimEnd()}…`;
|
|
289
|
-
if (this.measureText(candidate, options).width <= max)
|
|
290
|
-
return candidate;
|
|
291
|
-
}
|
|
292
|
-
return '…';
|
|
293
|
-
}
|
|
294
383
|
text(text, x, y, options) {
|
|
295
384
|
if (!text)
|
|
296
385
|
return;
|
|
297
386
|
const shown = options?.maxWidth
|
|
298
|
-
? this.
|
|
387
|
+
? fitText(this.opts, text, options, options.maxWidth)
|
|
299
388
|
: text;
|
|
300
|
-
const
|
|
301
|
-
if (!
|
|
389
|
+
const near = shapeNear(this.opts, shown, options);
|
|
390
|
+
if (!near)
|
|
302
391
|
return;
|
|
303
|
-
const
|
|
392
|
+
const { entry, scale } = near;
|
|
393
|
+
const width = entry.width * scale;
|
|
394
|
+
const height = entry.height * scale;
|
|
304
395
|
const align = options?.align ?? 'left';
|
|
305
|
-
const dx = align === 'center'
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
396
|
+
const dx = align === 'center' ? -width / 2 : align === 'right' ? -width : 0;
|
|
397
|
+
const dy = options?.baseline === 'middle' ? -height / 2 : 0;
|
|
398
|
+
if (scale === 1) {
|
|
399
|
+
// Rounded on the device grid, where the glyphs land.
|
|
400
|
+
entry.layout.draw(this.raw, snapToGrid(this.d(x + dx)), snapToGrid(this.d(y + dy)));
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
// Mid-zoom, a layout shaped at another size, scaled through the context
|
|
404
|
+
// — which draws it as outlines, glyphs and all (`scalesText`). Not on
|
|
405
|
+
// the grid: the whole label is moving, and it is set exactly at rest.
|
|
406
|
+
const ctx = this.ctx;
|
|
407
|
+
ctx.save();
|
|
408
|
+
ctx.translate(this.d(x + dx), this.d(y + dy));
|
|
409
|
+
ctx.scale(scale, scale);
|
|
410
|
+
entry.layout.draw(this.raw, 0, 0);
|
|
411
|
+
ctx.restore();
|
|
313
412
|
}
|
|
314
413
|
}
|
|
315
414
|
/**
|