jsx-repl 0.0.1 → 0.0.4

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 (47) hide show
  1. package/README.md +6 -86
  2. package/dist/assets/editor.worker-CqwF3o_e.js +12504 -0
  3. package/dist/assets/worker--hrro0Pu.js +27053 -0
  4. package/dist/favicon.svg +6 -0
  5. package/dist/{monaco-editor.css → index.css} +475 -6
  6. package/dist/index.js +202238 -0
  7. package/dist/src/Message.d.ts +20 -0
  8. package/dist/src/Repl.d.ts +53 -0
  9. package/dist/src/SplitPane.d.ts +24 -0
  10. package/dist/src/editor/EditorContainer.d.ts +19 -0
  11. package/dist/src/editor/FileSelector.d.ts +23 -0
  12. package/dist/src/editor/ToggleButton.d.ts +20 -0
  13. package/dist/src/editor/sourceMap.d.ts +1 -0
  14. package/dist/src/index.d.ts +6 -0
  15. package/dist/src/monaco/Monaco.d.ts +30 -0
  16. package/dist/src/monaco/env.d.ts +13 -0
  17. package/dist/src/monaco/highlight.d.ts +4 -0
  18. package/dist/src/monaco/language-configs.d.ts +5 -0
  19. package/dist/src/monaco/utils.d.ts +2 -0
  20. package/dist/src/monaco/worker.d.ts +7 -0
  21. package/dist/src/output/Devtools.d.ts +20 -0
  22. package/dist/src/output/Output.d.ts +29 -0
  23. package/dist/src/output/Preview.d.ts +21 -0
  24. package/dist/src/output/PreviewProxy.d.ts +16 -0
  25. package/dist/src/output/SourceMap.d.ts +14 -0
  26. package/dist/src/output/diff.d.ts +1 -0
  27. package/dist/src/output/moduleCompiler.d.ts +2 -0
  28. package/dist/src/output/user/Login.d.ts +14 -0
  29. package/dist/src/output/user/Project.d.ts +14 -0
  30. package/dist/src/presets/index.d.ts +128 -0
  31. package/dist/src/store.d.ts +124 -0
  32. package/dist/src/transform.d.ts +7 -0
  33. package/dist/src/types.d.ts +49 -0
  34. package/dist/src/utils.d.ts +7 -0
  35. package/dist/test/main.d.ts +1 -0
  36. package/package.json +65 -48
  37. package/dist/assets/editor.worker-DPra3Uc7.js +0 -14976
  38. package/dist/assets/vue.worker-Cp3kHWjt.js +0 -35302
  39. package/dist/chunks/utils-CzF1MxZ1.js +0 -954
  40. package/dist/codemirror-editor.css +0 -591
  41. package/dist/codemirror-editor.d.ts +0 -22
  42. package/dist/codemirror-editor.js +0 -15544
  43. package/dist/monaco-editor.d.ts +0 -22
  44. package/dist/monaco-editor.js +0 -191031
  45. package/dist/vue-repl.css +0 -393
  46. package/dist/vue-repl.d.ts +0 -327
  47. package/dist/vue-repl.js +0 -18142
package/README.md CHANGED
@@ -1,10 +1,8 @@
1
1
  # jsx-repl
2
2
 
3
- JSX REPL, support Vite plugins and Volar plugins.
3
+ Supports Vite plugins and Volar plugins.
4
4
 
5
- ## Basic Usage
6
-
7
- **Note: `jsx-repl` supports Monaco Editor, but also requires explicitly passing in the editor to be used for tree-shaking.**
5
+ ## Setup
8
6
 
9
7
  ```ts
10
8
  // vite.config.ts
@@ -17,89 +15,11 @@ export default defineConfig({
17
15
  })
18
16
  ```
19
17
 
20
- ### With CodeMirror Editor
21
-
22
- Basic editing experience with no intellisense. Lighter weight, fewer network requests, better for embedding use cases.
18
+ ## Usage
23
19
 
24
- ```vue
25
- <script setup>
20
+ ```jsx
21
+ // src/App.jsx
26
22
  import { Repl } from 'jsx-repl'
27
- import CodeMirror from 'jsx-repl/codemirror-editor'
28
- </script>
29
-
30
- <template>
31
- <Repl :editor="CodeMirror" />
32
- </template>
33
- ```
34
-
35
- ### With Monaco Editor
36
-
37
- With Volar support, autocomplete, type inference, and semantic highlighting. Heavier bundle, loads dts files from CDN, better for standalone use cases.
38
-
39
- ```vue
40
- <script setup>
41
- import { Repl } from 'jsx-repl'
42
- import Monaco from 'jsx-repl/monaco-editor'
43
- </script>
44
-
45
- <template>
46
- <Repl :editor="Monaco" />
47
- </template>
48
- ```
49
-
50
- ## Advanced Usage
51
-
52
- Customize the behavior of the REPL by manually initializing the store.
53
-
54
- See [v4 Migration Guide](https://github.com/vuejs/repl/releases/tag/v4.0.0)
55
-
56
- ```vue
57
- <script setup>
58
- import { watchEffect, ref } from 'vue'
59
- import { Repl, useStore, useVueImportMap } from 'jsx-repl'
60
- import Monaco from 'jsx-repl/monaco-editor'
61
-
62
- // retrieve some configuration options from the URL
63
- const query = new URLSearchParams(location.search)
64
-
65
- const {
66
- importMap: builtinImportMap,
67
- vueVersion,
68
- productionMode,
69
- } = useVueImportMap({
70
- // specify the default URL to import Vue runtime from in the sandbox
71
- // default is the CDN link from jsdelivr.com with version matching Vue's version
72
- // from peerDependency
73
- runtimeDev: 'cdn link to vue.runtime.esm-browser.js',
74
- runtimeProd: 'cdn link to vue.runtime.esm-browser.prod.js',
75
- serverRenderer: 'cdn link to server-renderer.esm-browser.js',
76
- })
77
-
78
- const store = useStore(
79
- {
80
- // pre-set import map
81
- builtinImportMap,
82
- vueVersion,
83
- // starts on the output pane (mobile only) if the URL has a showOutput query
84
- showOutput: ref(query.has('showOutput')),
85
- // starts on a different tab on the output pane if the URL has a outputMode query
86
- // and default to the "preview" tab
87
- outputMode: ref(query.get('outputMode') || 'preview'),
88
- },
89
- // initialize repl with previously serialized state
90
- location.hash,
91
- )
92
-
93
- // persist state to URL hash
94
- watchEffect(() => history.replaceState({}, '', store.serialize()))
95
-
96
- // use a specific version of Vue
97
- vueVersion.value = '3.2.8'
98
- // production mode is enabled
99
- productionMode.value = true
100
- </script>
101
23
 
102
- <template>
103
- <Repl :store="store" :editor="Monaco" :showCompileOutput="true" />
104
- </template>
24
+ export default () => <Repl />
105
25
  ```