@lapikit/repl 0.0.0-insiders.24a3260 → 0.0.0-insiders.39691bf
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/LICENSE +21 -0
- package/README.md +86 -0
- package/dist/Button.svelte +13 -4
- package/dist/Button.svelte.d.ts +6 -2
- package/dist/Files.svelte +23 -26
- package/dist/Repl.svelte +116 -66
- package/dist/Toolbar.svelte +46 -19
- package/dist/Toolbar.svelte.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/shiki.js +11 -8
- package/dist/types.d.ts +2 -0
- package/package.json +6 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Nycolaide <https://github.com/Nycolaide>.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1 +1,87 @@
|
|
|
1
1
|
# @Lapikit/repl
|
|
2
|
+
|
|
3
|
+
@lapikit/repl is a Svelte component for Lapikit. It's a add-on package for Lapikit library.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -D @lapikit/repl
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
// svelte.config.js
|
|
13
|
+
|
|
14
|
+
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
|
15
|
+
|
|
16
|
+
const config = {
|
|
17
|
+
preprocess: [vitePreprocess(), lapikitPreprocess({ plugins: ['repl'] })],
|
|
18
|
+
|
|
19
|
+
...
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default config;
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```svelte
|
|
28
|
+
<kit:repl content="console.log('hello')" />
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```svelte
|
|
32
|
+
<script lang="ts">
|
|
33
|
+
import sampleCounter from './samples/counter.svelte?raw';
|
|
34
|
+
import Counter from './samples/counter.svelte';
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<kit:repl presentation content={sampleCounter}>
|
|
38
|
+
<Counter />
|
|
39
|
+
</kit:repl>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```svelte
|
|
43
|
+
<script lang="ts">
|
|
44
|
+
import sampleJson from './samples/json.json?raw';
|
|
45
|
+
import sampleCounter from './samples/counter.svelte?raw';
|
|
46
|
+
import sampleCss from './samples/css.css?raw';
|
|
47
|
+
import Counter from './samples/counter.svelte';
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<kit:repl
|
|
51
|
+
presentation
|
|
52
|
+
content={{
|
|
53
|
+
'Counter.svelte': { code: sampleCounter, lang: 'svelte' },
|
|
54
|
+
'file.json': { code: sampleJson, lang: 'json' },
|
|
55
|
+
'Styles.css': { code: sampleCss, lang: 'css' }
|
|
56
|
+
}}
|
|
57
|
+
>
|
|
58
|
+
<Counter />
|
|
59
|
+
</kit:repl>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```svelte
|
|
63
|
+
<script lang="ts">
|
|
64
|
+
import sampleJson from './samples/json.json?raw';
|
|
65
|
+
import sampleCounter from './samples/counter.svelte?raw';
|
|
66
|
+
import sampleCss from './samples/css.css?raw';
|
|
67
|
+
import Counter from './samples/counter.svelte';
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<kit:repl
|
|
71
|
+
content={{
|
|
72
|
+
'Counter.svelte': { code: sampleCounter, lang: 'svelte' },
|
|
73
|
+
'file.json': { code: sampleJson, lang: 'json' },
|
|
74
|
+
'Styles.css': { code: sampleCss, lang: 'css' }
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
<Counter />
|
|
78
|
+
</kit:repl>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Props
|
|
82
|
+
|
|
83
|
+
| Prop | Type | Default | Description |
|
|
84
|
+
| ------------ | --------------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
85
|
+
| content | string \| Record<string, { code: string; lang?: string }> | '' | The code content to be displayed in the REPL. It can be a single string or an object representing multiple files. |
|
|
86
|
+
| presentation | boolean | false | If true, the REPL will be in presentation mode, showing only the output without the code editor. |
|
|
87
|
+
| tiltle | string | '' | The title displayed on the REPL toolbar. |
|
package/dist/Button.svelte
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
let { children, type = 'button', disabled = false, ...rest }: PropsTypeButton = $props();
|
|
5
|
+
|
|
6
|
+
type PropsTypeButton = {
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
type?: 'button' | 'submit' | 'reset';
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
[rest: string]: unknown;
|
|
11
|
+
};
|
|
3
12
|
</script>
|
|
4
13
|
|
|
5
|
-
<button {...rest}>
|
|
14
|
+
<button {type} {disabled} {...rest}>
|
|
6
15
|
{@render children?.()}
|
|
7
16
|
</button>
|
|
8
17
|
|
|
@@ -18,11 +27,11 @@
|
|
|
18
27
|
border-radius: 0.375rem;
|
|
19
28
|
transition: background-color 0.2s ease;
|
|
20
29
|
padding: 8px;
|
|
21
|
-
color: var(--repl-secondary);
|
|
30
|
+
color: var(--kit-repl-secondary);
|
|
22
31
|
}
|
|
23
32
|
|
|
24
33
|
button:hover {
|
|
25
|
-
color: var(--repl-primary);
|
|
34
|
+
color: var(--kit-repl-primary);
|
|
26
35
|
}
|
|
27
36
|
|
|
28
37
|
button :global(svg) {
|
package/dist/Button.svelte.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
1
2
|
declare const Button: import("svelte").Component<{
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
[rest: string]: unknown;
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
type?: "button" | "submit" | "reset";
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}, {}, "">;
|
|
4
8
|
type Button = ReturnType<typeof Button>;
|
|
5
9
|
export default Button;
|
package/dist/Files.svelte
CHANGED
|
@@ -2,13 +2,20 @@
|
|
|
2
2
|
import type { FilesProps } from './types.js';
|
|
3
3
|
import { dictionaryIcons } from './utils.js';
|
|
4
4
|
|
|
5
|
-
let { files, activeIndex = $bindable() }: FilesProps = $props();
|
|
5
|
+
let { files, activeIndex = $bindable(), modeState, viewState }: FilesProps = $props();
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
|
-
{#if files && files.length > 1}
|
|
9
|
-
<div>
|
|
8
|
+
{#if modeState !== 'playground' && viewState === 'code' && files && files.length > 1}
|
|
9
|
+
<div role="tablist" aria-label="Files">
|
|
10
10
|
{#each files as file, index (index)}
|
|
11
|
-
<button
|
|
11
|
+
<button
|
|
12
|
+
type="button"
|
|
13
|
+
role="tab"
|
|
14
|
+
aria-selected={activeIndex === index}
|
|
15
|
+
aria-label="Select {file.name}"
|
|
16
|
+
class:active={activeIndex === index}
|
|
17
|
+
onclick={() => (activeIndex = index)}
|
|
18
|
+
>
|
|
12
19
|
{#if file.lang && dictionaryIcons[file.lang]}
|
|
13
20
|
<img src={dictionaryIcons[file.lang]} alt="{file.lang} icon" />
|
|
14
21
|
{/if}
|
|
@@ -16,30 +23,30 @@
|
|
|
16
23
|
</button>
|
|
17
24
|
{/each}
|
|
18
25
|
</div>
|
|
19
|
-
|
|
20
|
-
<hr />
|
|
21
26
|
{/if}
|
|
22
27
|
|
|
23
28
|
<style>
|
|
24
29
|
div {
|
|
25
30
|
display: flex;
|
|
26
|
-
gap: calc(var(--repl-spacing) * 2);
|
|
27
|
-
padding-left: calc(5 * var(--repl-spacing));
|
|
28
|
-
padding-right: calc(5 * var(--repl-spacing));
|
|
29
|
-
padding-block: calc(var(--repl-spacing) * 2);
|
|
31
|
+
gap: calc(var(--kit-repl-spacing) * 2);
|
|
32
|
+
padding-left: calc(5 * var(--kit-repl-spacing));
|
|
33
|
+
padding-right: calc(5 * var(--kit-repl-spacing));
|
|
34
|
+
padding-block: calc(var(--kit-repl-spacing) * 2);
|
|
30
35
|
overflow-x: auto;
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
button {
|
|
34
39
|
display: flex;
|
|
35
40
|
align-items: center;
|
|
36
|
-
gap: calc(var(--repl-spacing) * 2);
|
|
37
|
-
padding: calc(var(--repl-spacing) * 2) calc(var(--repl-spacing) * 3);
|
|
38
|
-
border-radius: 0.375rem;
|
|
41
|
+
gap: calc(var(--kit-repl-spacing) * 2);
|
|
42
|
+
padding: calc(var(--kit-repl-spacing) * 2) calc(var(--kit-repl-spacing) * 3);
|
|
39
43
|
font-size: 0.875rem;
|
|
40
44
|
transition: all 0.2s ease;
|
|
41
|
-
border:
|
|
45
|
+
border: 0;
|
|
42
46
|
white-space: nowrap;
|
|
47
|
+
background-color: transparent;
|
|
48
|
+
border-bottom: 2px solid transparent;
|
|
49
|
+
cursor: pointer;
|
|
43
50
|
}
|
|
44
51
|
|
|
45
52
|
button img {
|
|
@@ -48,20 +55,10 @@
|
|
|
48
55
|
}
|
|
49
56
|
|
|
50
57
|
button:hover {
|
|
51
|
-
|
|
58
|
+
border-color: #cfcfcf;
|
|
52
59
|
}
|
|
53
60
|
|
|
54
61
|
button.active {
|
|
55
|
-
|
|
56
|
-
border-color: #d0d0d0;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
hr {
|
|
60
|
-
max-width: calc(100% - 4.5rem);
|
|
61
|
-
margin-inline-start: calc(4.5rem / 2);
|
|
62
|
-
display: block;
|
|
63
|
-
border: thin solid var(--repl-border-color);
|
|
64
|
-
margin-top: 0;
|
|
65
|
-
margin-bottom: 0;
|
|
62
|
+
border-color: #000000;
|
|
66
63
|
}
|
|
67
64
|
</style>
|
package/dist/Repl.svelte
CHANGED
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
let ref: null | HTMLElement = $state(null);
|
|
14
14
|
|
|
15
15
|
// states
|
|
16
|
-
let language = $state('
|
|
16
|
+
let language = $state('sh');
|
|
17
17
|
|
|
18
18
|
let modeState: 'code' | 'playground' | 'mixed' = $state('code');
|
|
19
19
|
let copyState = $state(false);
|
|
20
20
|
let viewState: 'code' | 'preview' = $state('code');
|
|
21
21
|
let themeState: 'light' | 'dark' = $state('light');
|
|
22
22
|
|
|
23
|
-
let codeHTML = $state(
|
|
23
|
+
let codeHTML = $state<string | null>(null);
|
|
24
24
|
let activeFileIndex = $state(0);
|
|
25
25
|
|
|
26
26
|
let files = $derived.by<FileItem[]>(() => {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
{
|
|
30
30
|
name: title || 'code',
|
|
31
31
|
content: content.code,
|
|
32
|
-
lang: content.lang || '
|
|
32
|
+
lang: content.lang || 'sh'
|
|
33
33
|
}
|
|
34
34
|
];
|
|
35
35
|
}
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
lang:
|
|
45
45
|
typeof fileContent === 'object'
|
|
46
46
|
? ((fileContent as Record<string, unknown>).lang as string)
|
|
47
|
-
: '
|
|
47
|
+
: 'sh'
|
|
48
48
|
}));
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
return content.map((item) => ({
|
|
53
53
|
name: item.name,
|
|
54
54
|
content: item.content || item.code || '',
|
|
55
|
-
lang: item.lang || '
|
|
55
|
+
lang: item.lang || 'sh'
|
|
56
56
|
}));
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
return [{ name: 'code', content: content || '', lang: '
|
|
59
|
+
return [{ name: 'code', content: content || '', lang: 'sh' }];
|
|
60
60
|
});
|
|
61
61
|
let activeFile = $derived(files[activeFileIndex]);
|
|
62
62
|
|
|
@@ -94,102 +94,152 @@
|
|
|
94
94
|
const theme = themeState;
|
|
95
95
|
|
|
96
96
|
if (file?.content) {
|
|
97
|
+
codeHTML = null;
|
|
98
|
+
language = file.lang || 'sh';
|
|
99
|
+
|
|
97
100
|
(async () => {
|
|
98
101
|
const highlighter = await getHighlighterSingleton();
|
|
99
|
-
|
|
100
|
-
language = file.lang || 'javascript';
|
|
101
102
|
const html = highlighter.codeToHtml(file.content, {
|
|
102
103
|
theme: theme === 'light' ? 'github-light' : 'github-dark',
|
|
103
104
|
lang: file.lang || language
|
|
104
105
|
});
|
|
105
|
-
|
|
106
106
|
codeHTML = html;
|
|
107
107
|
})();
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
</script>
|
|
111
111
|
|
|
112
|
-
<div class="repl
|
|
113
|
-
<Toolbar
|
|
114
|
-
{title}
|
|
115
|
-
{language}
|
|
116
|
-
{presentation}
|
|
117
|
-
bind:copyState
|
|
118
|
-
bind:viewState
|
|
119
|
-
bind:themeState
|
|
120
|
-
bind:modeState
|
|
121
|
-
/>
|
|
122
|
-
|
|
123
|
-
{#if modeState !== 'code'}
|
|
124
|
-
<hr />
|
|
125
|
-
{/if}
|
|
126
|
-
|
|
112
|
+
<div class="kit-repl">
|
|
127
113
|
{#if presentation}
|
|
128
|
-
<div class="repl-content">
|
|
129
|
-
<div
|
|
114
|
+
<div class="kit-repl-content" class:kit-repl-content--playground={presentation}>
|
|
115
|
+
<div
|
|
116
|
+
class="wrapper-playground"
|
|
117
|
+
class:dark={themeState === 'dark'}
|
|
118
|
+
class:light={themeState === 'light'}
|
|
119
|
+
>
|
|
120
|
+
{@render children?.()}
|
|
121
|
+
</div>
|
|
130
122
|
</div>
|
|
131
|
-
|
|
132
|
-
<hr />
|
|
133
123
|
{/if}
|
|
134
124
|
|
|
135
|
-
<
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
125
|
+
<div class="kit-repl-container">
|
|
126
|
+
<Toolbar
|
|
127
|
+
{title}
|
|
128
|
+
{language}
|
|
129
|
+
{presentation}
|
|
130
|
+
bind:copyState
|
|
131
|
+
bind:viewState
|
|
132
|
+
bind:themeState
|
|
133
|
+
bind:modeState
|
|
134
|
+
/>
|
|
135
|
+
|
|
136
|
+
{#if modeState !== 'code'}
|
|
137
|
+
<hr />
|
|
143
138
|
{/if}
|
|
139
|
+
|
|
140
|
+
<Files {files} bind:activeIndex={activeFileIndex} {modeState} {viewState} />
|
|
141
|
+
|
|
142
|
+
<div
|
|
143
|
+
class="kit-repl-content"
|
|
144
|
+
class:kit-repl-content--code={viewState === 'code' && !presentation}
|
|
145
|
+
>
|
|
146
|
+
{#if viewState === 'code'}
|
|
147
|
+
<div class="kit-repl-wrapper-highlight" bind:this={ref}>
|
|
148
|
+
{#if codeHTML !== null}
|
|
149
|
+
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
150
|
+
{@html codeHTML}
|
|
151
|
+
{:else}
|
|
152
|
+
<pre class="kit-repl-raw"><code>{activeFile?.content ?? ''}</code></pre>
|
|
153
|
+
{/if}
|
|
154
|
+
</div>
|
|
155
|
+
{:else}
|
|
156
|
+
<div
|
|
157
|
+
class="kit-repl-wrapper-playground"
|
|
158
|
+
class:dark={themeState === 'dark'}
|
|
159
|
+
class:light={themeState === 'light'}
|
|
160
|
+
>
|
|
161
|
+
{@render children?.()}
|
|
162
|
+
</div>
|
|
163
|
+
{/if}
|
|
164
|
+
</div>
|
|
144
165
|
</div>
|
|
145
166
|
</div>
|
|
146
167
|
|
|
147
168
|
<style>
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
--repl-
|
|
151
|
-
--repl-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
--repl-
|
|
155
|
-
--repl-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
--repl-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
169
|
+
.kit-repl {
|
|
170
|
+
/* ui */
|
|
171
|
+
--kit-repl-spacing: 0.25rem;
|
|
172
|
+
--kit-repl-radius: 1rem;
|
|
173
|
+
|
|
174
|
+
/* shiki override */
|
|
175
|
+
--kit-repl-shiki-size: 0.875rem;
|
|
176
|
+
--kit-repl-shiki-tab-size: 2;
|
|
177
|
+
|
|
178
|
+
/* colors */
|
|
179
|
+
--kit-repl-background: var(--kit-surface-3, #f9f9f9);
|
|
180
|
+
--kit-repl-border-color: var(--kit-border, #ebebeb);
|
|
181
|
+
--kit-repl-primary: var(--kit-fg, #0d0d34);
|
|
182
|
+
--kit-repl-secondary: var(--kit-muted, #8f8f8f);
|
|
183
|
+
}
|
|
184
|
+
.kit-repl-container {
|
|
185
|
+
background-color: var(--kit-repl-background);
|
|
186
|
+
border-radius: var(--kit-repl-radius);
|
|
187
|
+
border: 2px solid var(--kit-repl-border-color);
|
|
163
188
|
}
|
|
164
189
|
|
|
165
|
-
|
|
166
|
-
background-color: var(--repl-background) !important;
|
|
190
|
+
.kit-repl-container :global(pre) {
|
|
191
|
+
background-color: var(--kit-repl-background) !important;
|
|
167
192
|
}
|
|
168
193
|
|
|
169
|
-
.repl-content {
|
|
194
|
+
.kit-repl-content {
|
|
170
195
|
display: flow-root;
|
|
171
|
-
margin-top: calc(var(--repl-spacing) * 0);
|
|
172
|
-
padding-right: calc(10 * var(--repl-spacing));
|
|
173
|
-
padding-left: calc(5 * var(--repl-spacing));
|
|
174
|
-
padding-bottom: calc(4 * var(--repl-spacing));
|
|
175
|
-
padding-top: calc(3 * var(--repl-spacing));
|
|
196
|
+
margin-top: calc(var(--kit-repl-spacing) * 0);
|
|
197
|
+
padding-right: calc(10 * var(--kit-repl-spacing));
|
|
198
|
+
padding-left: calc(5 * var(--kit-repl-spacing));
|
|
199
|
+
padding-bottom: calc(4 * var(--kit-repl-spacing));
|
|
200
|
+
padding-top: calc(3 * var(--kit-repl-spacing));
|
|
176
201
|
position: relative;
|
|
177
202
|
}
|
|
178
203
|
|
|
204
|
+
.kit-repl-content--code {
|
|
205
|
+
padding-top: 0;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.kit-repl-content--playground {
|
|
209
|
+
padding-top: calc(4 * var(--kit-repl-spacing));
|
|
210
|
+
padding-bottom: calc(10 * var(--kit-repl-spacing));
|
|
211
|
+
}
|
|
212
|
+
|
|
179
213
|
hr {
|
|
180
|
-
max-width: calc(100% -
|
|
181
|
-
margin-inline-start: calc(
|
|
214
|
+
max-width: calc(100% - 2.5rem);
|
|
215
|
+
margin-inline-start: calc(2.5rem / 2);
|
|
182
216
|
display: block;
|
|
183
|
-
border: thin solid var(--repl-border-color);
|
|
217
|
+
border: thin solid var(--kit-repl-border-color);
|
|
184
218
|
margin-top: 0;
|
|
185
219
|
margin-bottom: 0;
|
|
186
220
|
}
|
|
187
221
|
|
|
188
|
-
|
|
189
|
-
font-size: var(--repl-shiki-size);
|
|
190
|
-
-moz-tab-size: var(--repl-shiki-tab-size);
|
|
191
|
-
tab-size: var(--repl-shiki-tab-size);
|
|
222
|
+
.kit-repl-raw {
|
|
223
|
+
font-size: var(--kit-repl-shiki-size);
|
|
224
|
+
-moz-tab-size: var(--kit-repl-shiki-tab-size);
|
|
225
|
+
tab-size: var(--kit-repl-shiki-tab-size);
|
|
192
226
|
white-space: pre-wrap;
|
|
193
227
|
word-break: break-word;
|
|
228
|
+
margin: 0;
|
|
229
|
+
padding: 0;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
div.kit-repl-container .kit-repl-wrapper-highlight :global(pre code) {
|
|
233
|
+
font-size: var(--kit-repl-shiki-size);
|
|
234
|
+
-moz-tab-size: var(--kit-repl-shiki-tab-size);
|
|
235
|
+
tab-size: var(--kit-repl-shiki-tab-size);
|
|
236
|
+
white-space: pre-wrap;
|
|
237
|
+
word-break: break-word;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
div.kit-repl-container .kit-repl-wrapper-playground {
|
|
241
|
+
background-color: var(--kit-repl-background);
|
|
242
|
+
border-radius: var(--kit-repl-radius);
|
|
243
|
+
padding: calc(4 * var(--kit-repl-spacing));
|
|
194
244
|
}
|
|
195
245
|
</style>
|
package/dist/Toolbar.svelte
CHANGED
|
@@ -19,8 +19,12 @@
|
|
|
19
19
|
);
|
|
20
20
|
</script>
|
|
21
21
|
|
|
22
|
-
<div class="
|
|
23
|
-
<div
|
|
22
|
+
<div class="kit-repl--toolbar">
|
|
23
|
+
<div
|
|
24
|
+
class="kit-repl--toolbar-title"
|
|
25
|
+
class:kit-repl--toolbar-title--language={!title && language}
|
|
26
|
+
class:kit-repl--toolbar-title--title={title}
|
|
27
|
+
>
|
|
24
28
|
{#if title}
|
|
25
29
|
<span>{title}</span>
|
|
26
30
|
{:else if language}
|
|
@@ -28,9 +32,13 @@
|
|
|
28
32
|
{/if}
|
|
29
33
|
</div>
|
|
30
34
|
|
|
31
|
-
<div class="
|
|
35
|
+
<div class="kit-repl--toolbar-actions">
|
|
32
36
|
{#if (modeState !== 'code' && viewState === 'preview') || presentation}
|
|
33
|
-
<Button
|
|
37
|
+
<Button
|
|
38
|
+
aria-label={themeState === 'light' ? 'Switch to dark theme' : 'Switch to light theme'}
|
|
39
|
+
aria-pressed={themeState === 'dark'}
|
|
40
|
+
onclick={() => (themeState = themeState === 'light' ? 'dark' : 'light')}
|
|
41
|
+
>
|
|
34
42
|
{#if themeState === 'light'}
|
|
35
43
|
<Moon />
|
|
36
44
|
{:else}
|
|
@@ -40,7 +48,11 @@
|
|
|
40
48
|
{/if}
|
|
41
49
|
|
|
42
50
|
{#if modeState === 'mixed' && !presentation}
|
|
43
|
-
<Button
|
|
51
|
+
<Button
|
|
52
|
+
aria-label={viewState === 'code' ? 'Show preview' : 'Show code'}
|
|
53
|
+
aria-pressed={viewState === 'preview'}
|
|
54
|
+
onclick={() => (viewState = viewState === 'code' ? 'preview' : 'code')}
|
|
55
|
+
>
|
|
44
56
|
{#if viewState === 'code'}
|
|
45
57
|
<Code />
|
|
46
58
|
{:else}
|
|
@@ -50,7 +62,10 @@
|
|
|
50
62
|
{/if}
|
|
51
63
|
|
|
52
64
|
{#if modeState !== 'playground'}
|
|
53
|
-
<Button
|
|
65
|
+
<Button
|
|
66
|
+
aria-label={copyState ? 'Code copied' : 'Copy code'}
|
|
67
|
+
onclick={() => (copyState = true)}
|
|
68
|
+
>
|
|
54
69
|
{#if copyState}
|
|
55
70
|
<Check />
|
|
56
71
|
{:else}
|
|
@@ -62,32 +77,44 @@
|
|
|
62
77
|
</div>
|
|
63
78
|
|
|
64
79
|
<style>
|
|
65
|
-
.
|
|
80
|
+
.kit-repl--toolbar {
|
|
66
81
|
display: flex;
|
|
67
82
|
align-items: center;
|
|
68
83
|
justify-content: space-between;
|
|
69
|
-
gap: calc(var(--repl-spacing) * 3);
|
|
70
|
-
padding-left: calc(5 * var(--repl-spacing));
|
|
71
|
-
padding-right: calc(var(--repl-spacing) * 2);
|
|
72
|
-
padding-block: calc(var(--repl-spacing) * 1.5);
|
|
73
|
-
border-top-left-radius: var(--repl-radius);
|
|
74
|
-
border-top-right-radius: var(--repl-radius);
|
|
84
|
+
gap: calc(var(--kit-repl-spacing) * 3);
|
|
85
|
+
padding-left: calc(5 * var(--kit-repl-spacing));
|
|
86
|
+
padding-right: calc(var(--kit-repl-spacing) * 2);
|
|
87
|
+
padding-block: calc(var(--kit-repl-spacing) * 1.5);
|
|
88
|
+
border-top-left-radius: var(--kit-repl-radius);
|
|
89
|
+
border-top-right-radius: var(--kit-repl-radius);
|
|
75
90
|
min-height: 36px;
|
|
76
91
|
}
|
|
77
92
|
|
|
78
|
-
.
|
|
93
|
+
.kit-repl--toolbar .kit-repl--toolbar-title {
|
|
79
94
|
display: flex;
|
|
80
95
|
align-items: center;
|
|
81
|
-
gap: calc(var(--repl-spacing) * 2);
|
|
82
|
-
font-weight: 600;
|
|
83
|
-
color: var(--repl-secondary);
|
|
96
|
+
gap: calc(var(--kit-repl-spacing) * 2);
|
|
84
97
|
max-width: 80%;
|
|
85
98
|
min-width: 0;
|
|
86
99
|
}
|
|
87
100
|
|
|
88
|
-
.
|
|
101
|
+
.kit-repl--toolbar-title--language {
|
|
102
|
+
font-size: 0.875rem;
|
|
103
|
+
line-height: 16px;
|
|
104
|
+
font-weight: 400;
|
|
105
|
+
color: #5d5d5d;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.kit-repl--toolbar-title--title {
|
|
109
|
+
font-weight: 500;
|
|
110
|
+
font-size: 1rem;
|
|
111
|
+
line-height: 20px;
|
|
112
|
+
color: #8f8f8f;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.kit-repl--toolbar .kit-repl--toolbar-actions {
|
|
89
116
|
display: flex;
|
|
90
117
|
align-items: center;
|
|
91
|
-
gap: calc(var(--repl-spacing) * 2);
|
|
118
|
+
gap: calc(var(--kit-repl-spacing) * 2);
|
|
92
119
|
}
|
|
93
120
|
</style>
|
package/dist/Toolbar.svelte.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ToolbarProps } from './types.js';
|
|
2
|
-
declare const Toolbar: import("svelte").Component<ToolbarProps, {}, "
|
|
2
|
+
declare const Toolbar: import("svelte").Component<ToolbarProps, {}, "modeState" | "viewState" | "copyState" | "themeState">;
|
|
3
3
|
type Toolbar = ReturnType<typeof Toolbar>;
|
|
4
4
|
export default Toolbar;
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as
|
|
1
|
+
export { default as KitRepl } from './Repl.svelte';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// components
|
|
2
|
-
export { default as
|
|
2
|
+
export { default as KitRepl } from './Repl.svelte';
|
package/dist/shiki.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { createHighlighter } from 'shiki';
|
|
2
|
-
let highlighter;
|
|
2
|
+
let highlighter = null;
|
|
3
|
+
const highlighterPromise = createHighlighter({
|
|
4
|
+
themes: ['github-light', 'github-dark'],
|
|
5
|
+
langs: ['svelte', 'typescript', 'javascript', 'html', 'css', 'json', 'bash']
|
|
6
|
+
}).then((h) => {
|
|
7
|
+
highlighter = h;
|
|
8
|
+
return h;
|
|
9
|
+
});
|
|
3
10
|
export async function getHighlighterSingleton() {
|
|
4
|
-
if (
|
|
5
|
-
highlighter
|
|
6
|
-
|
|
7
|
-
langs: ['svelte', 'typescript', 'javascript', 'html', 'css', 'json', 'bash']
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
return highlighter;
|
|
11
|
+
if (highlighter)
|
|
12
|
+
return highlighter;
|
|
13
|
+
return highlighterPromise;
|
|
11
14
|
}
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lapikit/repl",
|
|
3
|
-
"version": "0.0.0-insiders.
|
|
3
|
+
"version": "0.0.0-insiders.39691bf",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
"name": "Nycolaide",
|
|
10
10
|
"email": "contact@lapikit.dev"
|
|
11
11
|
},
|
|
12
|
+
"homepage": "https://lapikit.dev",
|
|
12
13
|
"repository": {
|
|
13
14
|
"type": "git",
|
|
14
|
-
"url": "https://github.com/
|
|
15
|
+
"url": "git+https://github.com/lapikit/lapikit-repl.git"
|
|
15
16
|
},
|
|
17
|
+
"funding": "https://buymeacoffee.com/nycolaide",
|
|
16
18
|
"scripts": {
|
|
17
19
|
"dev": "vite dev",
|
|
18
20
|
"build": "vite build && npm run prepack",
|
|
@@ -45,7 +47,8 @@
|
|
|
45
47
|
},
|
|
46
48
|
"peerDependencies": {
|
|
47
49
|
"@sveltejs/kit": "^2.0.0",
|
|
48
|
-
"svelte": "^5.0.0"
|
|
50
|
+
"svelte": "^5.0.0",
|
|
51
|
+
"lapikit": "^0.5.0"
|
|
49
52
|
},
|
|
50
53
|
"devDependencies": {
|
|
51
54
|
"@eslint/compat": "^1.4.0",
|