trame-code 1.1.0__tar.gz → 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. {trame_code-1.1.0 → trame_code-1.2.0}/.github/workflows/test_and_release.yml +14 -0
  2. {trame_code-1.1.0 → trame_code-1.2.0}/PKG-INFO +12 -3
  3. {trame_code-1.1.0 → trame_code-1.2.0}/README.rst +10 -1
  4. trame_code-1.2.0/docs/completion-hover.png +0 -0
  5. trame_code-1.2.0/example/react_editor.py +142 -0
  6. {trame_code-1.1.0 → trame_code-1.2.0}/pyproject.toml +1 -1
  7. trame_code-1.2.0/react-components/package-lock.json +5072 -0
  8. trame_code-1.2.0/react-components/package.json +33 -0
  9. trame_code-1.2.0/react-components/src/components/Editor.tsx +283 -0
  10. trame_code-1.2.0/react-components/src/main.ts +18 -0
  11. trame_code-1.2.0/react-components/src/shims.d.ts +8 -0
  12. trame_code-1.2.0/react-components/tsconfig.json +20 -0
  13. trame_code-1.2.0/react-components/vite.config.js +44 -0
  14. trame_code-1.2.0/src/trame_code/module/__init__.py +35 -0
  15. {trame_code-1.1.0 → trame_code-1.2.0}/src/trame_code/module/serve/monacoeditorwork/css.worker.bundle.js +118 -118
  16. {trame_code-1.1.0 → trame_code-1.2.0}/src/trame_code/module/serve/monacoeditorwork/editor.worker.bundle.js +118 -118
  17. {trame_code-1.1.0 → trame_code-1.2.0}/src/trame_code/module/serve/monacoeditorwork/html.worker.bundle.js +118 -118
  18. {trame_code-1.1.0 → trame_code-1.2.0}/src/trame_code/module/serve/monacoeditorwork/json.worker.bundle.js +118 -118
  19. {trame_code-1.1.0 → trame_code-1.2.0}/src/trame_code/module/serve/monacoeditorwork/ts.worker.bundle.js +118 -118
  20. {trame_code-1.1.0 → trame_code-1.2.0}/src/trame_code/module/serve/style.css +1 -1
  21. trame_code-1.2.0/src/trame_code/module/serve/trame-code-react.umd.cjs +1900 -0
  22. {trame_code-1.1.0 → trame_code-1.2.0}/src/trame_code/module/serve/trame-code.umd.js +302 -302
  23. {trame_code-1.1.0 → trame_code-1.2.0}/src/trame_code/widgets/code.py +17 -15
  24. trame_code-1.2.0/vue-components/src/use.js +11 -0
  25. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/src/utils/monacoEnv.js +10 -1
  26. trame_code-1.1.0/src/trame_code/module/__init__.py +0 -24
  27. trame_code-1.1.0/vue-components/src/use.js +0 -7
  28. {trame_code-1.1.0 → trame_code-1.2.0}/.codespellrc +0 -0
  29. {trame_code-1.1.0 → trame_code-1.2.0}/.gitignore +0 -0
  30. {trame_code-1.1.0 → trame_code-1.2.0}/.pre-commit-config.yaml +0 -0
  31. {trame_code-1.1.0 → trame_code-1.2.0}/CHANGELOG.md +0 -0
  32. {trame_code-1.1.0 → trame_code-1.2.0}/CONTRIBUTING.rst +0 -0
  33. {trame_code-1.1.0 → trame_code-1.2.0}/LICENSE +0 -0
  34. {trame_code-1.1.0 → trame_code-1.2.0}/example/language-features/app.py +0 -0
  35. {trame_code-1.1.0 → trame_code-1.2.0}/example/language-features/requirements.txt +0 -0
  36. {trame_code-1.1.0 → trame_code-1.2.0}/example/live-state/app.py +0 -0
  37. {trame_code-1.1.0 → trame_code-1.2.0}/example/live-state/requirements.txt +0 -0
  38. {trame_code-1.1.0 → trame_code-1.2.0}/example/read-only/requirements.txt +0 -0
  39. {trame_code-1.1.0 → trame_code-1.2.0}/example/read-only/viewer.py +0 -0
  40. {trame_code-1.1.0 → trame_code-1.2.0}/example/read-only/viewer_vue3.py +0 -0
  41. {trame_code-1.1.0 → trame_code-1.2.0}/example/textmate/app.py +0 -0
  42. {trame_code-1.1.0 → trame_code-1.2.0}/example/textmate/files/javascript_example.js +0 -0
  43. {trame_code-1.1.0 → trame_code-1.2.0}/example/textmate/files/latex_example.tex +0 -0
  44. {trame_code-1.1.0 → trame_code-1.2.0}/example/textmate/files/moose_example.i +0 -0
  45. {trame_code-1.1.0 → trame_code-1.2.0}/example/textmate/files/python_example.py +0 -0
  46. {trame_code-1.1.0 → trame_code-1.2.0}/example/textmate/langs/__init__.py +0 -0
  47. {trame_code-1.1.0 → trame_code-1.2.0}/example/textmate/langs/moose/__init__.py +0 -0
  48. {trame_code-1.1.0 → trame_code-1.2.0}/example/textmate/langs/moose/moose.config.json +0 -0
  49. {trame_code-1.1.0 → trame_code-1.2.0}/example/textmate/langs/moose/moose.grammar.json +0 -0
  50. {trame_code-1.1.0 → trame_code-1.2.0}/example/textmate/langs/python/__init__.py +0 -0
  51. {trame_code-1.1.0 → trame_code-1.2.0}/example/textmate/langs/python/python.config.json +0 -0
  52. {trame_code-1.1.0 → trame_code-1.2.0}/example/textmate/langs/python/python.grammar.json +0 -0
  53. {trame_code-1.1.0 → trame_code-1.2.0}/src/trame/__init__.py +0 -0
  54. {trame_code-1.1.0 → trame_code-1.2.0}/src/trame/modules/__init__.py +0 -0
  55. {trame_code-1.1.0 → trame_code-1.2.0}/src/trame/modules/code.py +0 -0
  56. {trame_code-1.1.0 → trame_code-1.2.0}/src/trame/widgets/__init__.py +0 -0
  57. {trame_code-1.1.0 → trame_code-1.2.0}/src/trame/widgets/code.py +0 -0
  58. {trame_code-1.1.0 → trame_code-1.2.0}/src/trame_code/__init__.py +0 -0
  59. {trame_code-1.1.0 → trame_code-1.2.0}/src/trame_code/module/.gitignore +0 -0
  60. {trame_code-1.1.0 → trame_code-1.2.0}/src/trame_code/widgets/__init__.py +0 -0
  61. {trame_code-1.1.0 → trame_code-1.2.0}/tests/requirements.txt +0 -0
  62. {trame_code-1.1.0 → trame_code-1.2.0}/tests/test_import.py +0 -0
  63. {trame_code-1.1.0 → trame_code-1.2.0}/tests/test_language_features.py +0 -0
  64. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/.eslintrc.cjs +0 -0
  65. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/.gitignore +0 -0
  66. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/.prettierrc.json +0 -0
  67. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/README.md +0 -0
  68. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/package-lock.json +0 -0
  69. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/package.json +0 -0
  70. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/src/components/Editor.js +0 -0
  71. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/src/components/index.js +0 -0
  72. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/src/themes/README.md +0 -0
  73. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/src/themes/dark_plus.json +0 -0
  74. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/src/themes/dark_plus_experimental.json +0 -0
  75. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/src/themes/dark_vs.json +0 -0
  76. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/src/themes/hc_black.json +0 -0
  77. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/src/themes/hc_light.json +0 -0
  78. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/src/themes/index.js +0 -0
  79. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/src/themes/light_plus.json +0 -0
  80. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/src/themes/light_plus_experimental.json +0 -0
  81. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/src/themes/light_vs.json +0 -0
  82. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/src/themes/reference-style-textmate.txt +0 -0
  83. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/src/utils/onig.js +0 -0
  84. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/src/utils/textmate.js +0 -0
  85. {trame_code-1.1.0 → trame_code-1.2.0}/vue-components/vite.config.ts +0 -0
@@ -78,6 +78,14 @@ jobs:
78
78
  npm i
79
79
  npm run build
80
80
 
81
+ # After the vue build: it runs with --emptyOutDir and both bundles share
82
+ # the serve directory.
83
+ - name: Build React Components
84
+ run: |
85
+ cd react-components
86
+ npm i
87
+ npm run build
88
+
81
89
  release:
82
90
  needs: [pre-commit, pytest, test-npm-build]
83
91
  runs-on: ubuntu-latest
@@ -105,6 +113,12 @@ jobs:
105
113
  npm i
106
114
  npm run build
107
115
 
116
+ - name: Build React Components
117
+ run: |
118
+ cd react-components
119
+ npm i
120
+ npm run build
121
+
108
122
  - name: Python Semantic Release
109
123
  id: release
110
124
  uses: python-semantic-release/python-semantic-release@v10.5.3
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: trame-code
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: Widget for Monaco VS code editor for trame
5
5
  Author: Kitware Inc.
6
6
  License: MIT License
@@ -22,7 +22,7 @@ Requires-Dist: pre-commit; extra == 'dev'
22
22
  Requires-Dist: pytest>=6; extra == 'dev'
23
23
  Description-Content-Type: text/x-rst
24
24
 
25
- .. |pypi_download| image:: https://img.shields.io/pypi/dm/trame-code
25
+ .. |pypi_download| image:: https://kitware.github.io/trame/downloads/trame-code.svg
26
26
 
27
27
  ==============================
28
28
  trame-code |pypi_download|
@@ -30,6 +30,15 @@ trame-code |pypi_download|
30
30
 
31
31
  Widget for Monaco VS code editor for trame
32
32
 
33
+ The editor can surface language features (autocomplete and hover
34
+ documentation) from your own server-side callbacks: pass ``completion``
35
+ and ``hover`` callables to the widget. The example below shows Python/VTK
36
+ completion and a hover docstring driven entirely from those callbacks.
37
+
38
+ .. image:: https://raw.githubusercontent.com/Kitware/trame-code/master/docs/completion-hover.png
39
+ :alt: Monaco editor showing Python/VTK completion and a hover docstring
40
+ :align: center
41
+
33
42
 
34
43
  License
35
44
  -----------------------------------------------------------
@@ -1,4 +1,4 @@
1
- .. |pypi_download| image:: https://img.shields.io/pypi/dm/trame-code
1
+ .. |pypi_download| image:: https://kitware.github.io/trame/downloads/trame-code.svg
2
2
 
3
3
  ==============================
4
4
  trame-code |pypi_download|
@@ -6,6 +6,15 @@ trame-code |pypi_download|
6
6
 
7
7
  Widget for Monaco VS code editor for trame
8
8
 
9
+ The editor can surface language features (autocomplete and hover
10
+ documentation) from your own server-side callbacks: pass ``completion``
11
+ and ``hover`` callables to the widget. The example below shows Python/VTK
12
+ completion and a hover docstring driven entirely from those callbacks.
13
+
14
+ .. image:: https://raw.githubusercontent.com/Kitware/trame-code/master/docs/completion-hover.png
15
+ :alt: Monaco editor showing Python/VTK completion and a hover docstring
16
+ :align: center
17
+
9
18
 
10
19
  License
11
20
  -----------------------------------------------------------
@@ -0,0 +1,142 @@
1
+ """Exercise the react build of the trame-code editor.
2
+
3
+ Checks the editor mounts, two-way binding works through value/onChange, and
4
+ the completion/hover callbacks still round-trip to Python.
5
+ """
6
+
7
+ from trame.app import TrameApp
8
+ from trame.ui.mui import MuiLayout
9
+
10
+ from trame.widgets import code, html, mui, react
11
+
12
+ CANVAS, SURFACE, INK, MUTED, LINE = (
13
+ "#F3F5F8",
14
+ "#FFFFFF",
15
+ "#172033",
16
+ "#5A6474",
17
+ "#DCE1E8",
18
+ )
19
+ ACCENT = "#0A7C8C"
20
+ SANS = "'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif"
21
+ FONTS = (
22
+ "https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500"
23
+ "&family=IBM+Plex+Sans:wght@400;500;600&display=swap"
24
+ )
25
+ THEME = {
26
+ "palette": {
27
+ "mode": "light",
28
+ "primary": {"main": ACCENT},
29
+ "background": {"default": CANVAS, "paper": SURFACE},
30
+ "text": {"primary": INK, "secondary": MUTED},
31
+ "divider": LINE,
32
+ },
33
+ "typography": {
34
+ "fontFamily": SANS,
35
+ "fontSize": 13,
36
+ "button": {"textTransform": "none", "fontWeight": 500},
37
+ },
38
+ "shape": {"borderRadius": 6},
39
+ "components": {
40
+ "MuiButton": {"defaultProps": {"disableElevation": True}},
41
+ "MuiPaper": {"styleOverrides": {"outlined": {"borderColor": LINE}}},
42
+ },
43
+ }
44
+
45
+ SAMPLE = """import vtk
46
+
47
+ sphere = vtk.vtkSphereSource()
48
+ sphere.SetRadius(1.0)
49
+ """
50
+
51
+ WORDS = [
52
+ ("vtkSphereSource", "class", "Create a polygonal sphere"),
53
+ ("vtkConeSource", "class", "Create a polygonal cone"),
54
+ ("SetRadius", "method", "SetRadius(self, radius: float) -> None"),
55
+ ("SetThetaResolution", "method", "Set the number of points in theta"),
56
+ ]
57
+
58
+
59
+ class EditorApp(TrameApp):
60
+ def __init__(self, server=None):
61
+ super().__init__(server, client_type="react")
62
+ self.state.source = SAMPLE
63
+ self.state.hits = []
64
+
65
+ with MuiLayout(self.server, theme=THEME) as self.ui:
66
+ mui.GlobalStyles(
67
+ styles=f"@import url('{FONTS}'); body {{ background: {CANVAS}; }}"
68
+ )
69
+ with html.Div(
70
+ style={
71
+ "display": "flex",
72
+ "flexDirection": "column",
73
+ "height": "100vh",
74
+ "background": CANVAS,
75
+ }
76
+ ):
77
+ with html.Header(
78
+ style={
79
+ "background": SURFACE,
80
+ "borderBottom": f"1px solid {LINE}",
81
+ "display": "flex",
82
+ "alignItems": "baseline",
83
+ "gap": "10px",
84
+ "height": "52px",
85
+ "padding": "0 20px",
86
+ }
87
+ ):
88
+ html.Span(
89
+ "trame-code",
90
+ style={
91
+ "fontWeight": 600,
92
+ "fontSize": "1.05rem",
93
+ "color": INK,
94
+ "letterSpacing": "-0.01em",
95
+ },
96
+ )
97
+ html.Span(
98
+ "react client",
99
+ style={"color": MUTED, "fontSize": "0.8rem"},
100
+ )
101
+ html.Div(style={"flex": "1"})
102
+ mui.Chip(
103
+ label=react.Bind("`${hits.length} callbacks`"),
104
+ size="small",
105
+ variant="outlined",
106
+ )
107
+ mui.Chip(
108
+ label=react.Bind("`${source.length} chars`"),
109
+ size="small",
110
+ variant="outlined",
111
+ )
112
+ with mui.Paper(
113
+ variant="outlined",
114
+ style={"flex": "1", "margin": "16px", "overflow": "hidden"},
115
+ ):
116
+ code.Editor(
117
+ value=react.Bind("source"),
118
+ onChange=react.Callback("source = $event"),
119
+ language="python",
120
+ theme="vs",
121
+ completion=self.complete,
122
+ hover=self.hover,
123
+ )
124
+
125
+ def complete(self, _text, line, column):
126
+ self.state.hits = [*self.state.hits, f"complete {line}:{column}"]
127
+ return [
128
+ {"label": label, "kind": kind, "detail": detail}
129
+ for label, kind, detail in WORDS
130
+ ]
131
+
132
+ def hover(self, _text, line, column):
133
+ self.state.hits = [*self.state.hits, f"hover {line}:{column}"]
134
+ return f"**line {line}, col {column}**\n\nhover served from Python"
135
+
136
+
137
+ def main():
138
+ EditorApp().server.start()
139
+
140
+
141
+ if __name__ == "__main__":
142
+ main()
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "trame-code"
3
- version = "1.1.0"
3
+ version = "1.2.0"
4
4
  description = "Widget for Monaco VS code editor for trame"
5
5
  authors = [
6
6
  {name = "Kitware Inc."},