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.
- package/README.md +6 -86
- package/dist/assets/editor.worker-CqwF3o_e.js +12504 -0
- package/dist/assets/worker--hrro0Pu.js +27053 -0
- package/dist/favicon.svg +6 -0
- package/dist/{monaco-editor.css → index.css} +475 -6
- package/dist/index.js +202238 -0
- package/dist/src/Message.d.ts +20 -0
- package/dist/src/Repl.d.ts +53 -0
- package/dist/src/SplitPane.d.ts +24 -0
- package/dist/src/editor/EditorContainer.d.ts +19 -0
- package/dist/src/editor/FileSelector.d.ts +23 -0
- package/dist/src/editor/ToggleButton.d.ts +20 -0
- package/dist/src/editor/sourceMap.d.ts +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/monaco/Monaco.d.ts +30 -0
- package/dist/src/monaco/env.d.ts +13 -0
- package/dist/src/monaco/highlight.d.ts +4 -0
- package/dist/src/monaco/language-configs.d.ts +5 -0
- package/dist/src/monaco/utils.d.ts +2 -0
- package/dist/src/monaco/worker.d.ts +7 -0
- package/dist/src/output/Devtools.d.ts +20 -0
- package/dist/src/output/Output.d.ts +29 -0
- package/dist/src/output/Preview.d.ts +21 -0
- package/dist/src/output/PreviewProxy.d.ts +16 -0
- package/dist/src/output/SourceMap.d.ts +14 -0
- package/dist/src/output/diff.d.ts +1 -0
- package/dist/src/output/moduleCompiler.d.ts +2 -0
- package/dist/src/output/user/Login.d.ts +14 -0
- package/dist/src/output/user/Project.d.ts +14 -0
- package/dist/src/presets/index.d.ts +128 -0
- package/dist/src/store.d.ts +124 -0
- package/dist/src/transform.d.ts +7 -0
- package/dist/src/types.d.ts +49 -0
- package/dist/src/utils.d.ts +7 -0
- package/dist/test/main.d.ts +1 -0
- package/package.json +65 -48
- package/dist/assets/editor.worker-DPra3Uc7.js +0 -14976
- package/dist/assets/vue.worker-Cp3kHWjt.js +0 -35302
- package/dist/chunks/utils-CzF1MxZ1.js +0 -954
- package/dist/codemirror-editor.css +0 -591
- package/dist/codemirror-editor.d.ts +0 -22
- package/dist/codemirror-editor.js +0 -15544
- package/dist/monaco-editor.d.ts +0 -22
- package/dist/monaco-editor.js +0 -191031
- package/dist/vue-repl.css +0 -393
- package/dist/vue-repl.d.ts +0 -327
- package/dist/vue-repl.js +0 -18142
package/README.md
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# jsx-repl
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Supports Vite plugins and Volar plugins.
|
|
4
4
|
|
|
5
|
-
##
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
Basic editing experience with no intellisense. Lighter weight, fewer network requests, better for embedding use cases.
|
|
18
|
+
## Usage
|
|
23
19
|
|
|
24
|
-
```
|
|
25
|
-
|
|
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
|
-
<
|
|
103
|
-
<Repl :store="store" :editor="Monaco" :showCompileOutput="true" />
|
|
104
|
-
</template>
|
|
24
|
+
export default () => <Repl />
|
|
105
25
|
```
|