@lapikit/repl 0.0.0-insiders.24a3260
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 +1 -0
- package/dist/Button.svelte +32 -0
- package/dist/Button.svelte.d.ts +5 -0
- package/dist/Files.svelte +67 -0
- package/dist/Files.svelte.d.ts +4 -0
- package/dist/Repl.svelte +195 -0
- package/dist/Repl.svelte.d.ts +4 -0
- package/dist/Toolbar.svelte +93 -0
- package/dist/Toolbar.svelte.d.ts +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/languages/css.svg +6 -0
- package/dist/languages/html.svg +6 -0
- package/dist/languages/javascript.svg +6 -0
- package/dist/languages/shell.svg +5 -0
- package/dist/languages/svelte.svg +2 -0
- package/dist/languages/typescript.svg +12 -0
- package/dist/shiki.d.ts +2 -0
- package/dist/shiki.js +11 -0
- package/dist/types.d.ts +25 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +7 -0
- package/dist/utils.js +61 -0
- package/package.json +81 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @Lapikit/repl
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
let { children, ...rest } = $props();
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<button {...rest}>
|
|
6
|
+
{@render children?.()}
|
|
7
|
+
</button>
|
|
8
|
+
|
|
9
|
+
<style>
|
|
10
|
+
button {
|
|
11
|
+
background: none;
|
|
12
|
+
border: none;
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
display: flex;
|
|
15
|
+
align-self: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
font-size: 0.875rem;
|
|
18
|
+
border-radius: 0.375rem;
|
|
19
|
+
transition: background-color 0.2s ease;
|
|
20
|
+
padding: 8px;
|
|
21
|
+
color: var(--repl-secondary);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
button:hover {
|
|
25
|
+
color: var(--repl-primary);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
button :global(svg) {
|
|
29
|
+
height: 20px;
|
|
30
|
+
width: 20px;
|
|
31
|
+
}
|
|
32
|
+
</style>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { FilesProps } from './types.js';
|
|
3
|
+
import { dictionaryIcons } from './utils.js';
|
|
4
|
+
|
|
5
|
+
let { files, activeIndex = $bindable() }: FilesProps = $props();
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
{#if files && files.length > 1}
|
|
9
|
+
<div>
|
|
10
|
+
{#each files as file, index (index)}
|
|
11
|
+
<button class:active={activeIndex === index} onclick={() => (activeIndex = index)}>
|
|
12
|
+
{#if file.lang && dictionaryIcons[file.lang]}
|
|
13
|
+
<img src={dictionaryIcons[file.lang]} alt="{file.lang} icon" />
|
|
14
|
+
{/if}
|
|
15
|
+
<span>{file.name}</span>
|
|
16
|
+
</button>
|
|
17
|
+
{/each}
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<hr />
|
|
21
|
+
{/if}
|
|
22
|
+
|
|
23
|
+
<style>
|
|
24
|
+
div {
|
|
25
|
+
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);
|
|
30
|
+
overflow-x: auto;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
button {
|
|
34
|
+
display: flex;
|
|
35
|
+
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;
|
|
39
|
+
font-size: 0.875rem;
|
|
40
|
+
transition: all 0.2s ease;
|
|
41
|
+
border: 1px solid transparent;
|
|
42
|
+
white-space: nowrap;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
button img {
|
|
46
|
+
width: 16px;
|
|
47
|
+
height: 16px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
button:hover {
|
|
51
|
+
background-color: #f5f5f5;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
button.active {
|
|
55
|
+
background-color: #f0f0f0;
|
|
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;
|
|
66
|
+
}
|
|
67
|
+
</style>
|
package/dist/Repl.svelte
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { copyToClipboard } from './utils.js';
|
|
3
|
+
import { getHighlighterSingleton } from './shiki.js';
|
|
4
|
+
import type { FileItem, ReplProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
// components
|
|
7
|
+
import Toolbar from './Toolbar.svelte';
|
|
8
|
+
import Files from './Files.svelte';
|
|
9
|
+
|
|
10
|
+
let { title, content, children, presentation }: ReplProps = $props();
|
|
11
|
+
|
|
12
|
+
// refs
|
|
13
|
+
let ref: null | HTMLElement = $state(null);
|
|
14
|
+
|
|
15
|
+
// states
|
|
16
|
+
let language = $state('javascript');
|
|
17
|
+
|
|
18
|
+
let modeState: 'code' | 'playground' | 'mixed' = $state('code');
|
|
19
|
+
let copyState = $state(false);
|
|
20
|
+
let viewState: 'code' | 'preview' = $state('code');
|
|
21
|
+
let themeState: 'light' | 'dark' = $state('light');
|
|
22
|
+
|
|
23
|
+
let codeHTML = $state('');
|
|
24
|
+
let activeFileIndex = $state(0);
|
|
25
|
+
|
|
26
|
+
let files = $derived.by<FileItem[]>(() => {
|
|
27
|
+
if (typeof content === 'object' && content !== null && 'code' in content) {
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
name: title || 'code',
|
|
31
|
+
content: content.code,
|
|
32
|
+
lang: content.lang || 'javascript'
|
|
33
|
+
}
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (typeof content === 'object' && content !== null && !Array.isArray(content)) {
|
|
38
|
+
return Object.entries(content).map(([name, fileContent]) => ({
|
|
39
|
+
name,
|
|
40
|
+
content:
|
|
41
|
+
typeof fileContent === 'string'
|
|
42
|
+
? fileContent
|
|
43
|
+
: (fileContent as Record<string, unknown>).code || '',
|
|
44
|
+
lang:
|
|
45
|
+
typeof fileContent === 'object'
|
|
46
|
+
? ((fileContent as Record<string, unknown>).lang as string)
|
|
47
|
+
: 'javascript'
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (Array.isArray(content)) {
|
|
52
|
+
return content.map((item) => ({
|
|
53
|
+
name: item.name,
|
|
54
|
+
content: item.content || item.code || '',
|
|
55
|
+
lang: item.lang || 'javascript'
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return [{ name: 'code', content: content || '', lang: 'javascript' }];
|
|
60
|
+
});
|
|
61
|
+
let activeFile = $derived(files[activeFileIndex]);
|
|
62
|
+
|
|
63
|
+
$effect.pre(() => {
|
|
64
|
+
if (children && content && !presentation) {
|
|
65
|
+
modeState = 'mixed';
|
|
66
|
+
viewState = 'preview';
|
|
67
|
+
} else if (presentation) {
|
|
68
|
+
modeState = 'mixed';
|
|
69
|
+
viewState = 'code';
|
|
70
|
+
} else if (children && !content) {
|
|
71
|
+
modeState = 'playground';
|
|
72
|
+
viewState = 'preview';
|
|
73
|
+
} else {
|
|
74
|
+
modeState = 'code';
|
|
75
|
+
viewState = 'code';
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
$effect(() => {
|
|
80
|
+
if (copyState) {
|
|
81
|
+
if (ref?.textContent) {
|
|
82
|
+
copyToClipboard(ref?.textContent);
|
|
83
|
+
copyState = true;
|
|
84
|
+
|
|
85
|
+
setTimeout(() => {
|
|
86
|
+
copyState = false;
|
|
87
|
+
}, 1500);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
$effect(() => {
|
|
93
|
+
const file = activeFile;
|
|
94
|
+
const theme = themeState;
|
|
95
|
+
|
|
96
|
+
if (file?.content) {
|
|
97
|
+
(async () => {
|
|
98
|
+
const highlighter = await getHighlighterSingleton();
|
|
99
|
+
|
|
100
|
+
language = file.lang || 'javascript';
|
|
101
|
+
const html = highlighter.codeToHtml(file.content, {
|
|
102
|
+
theme: theme === 'light' ? 'github-light' : 'github-dark',
|
|
103
|
+
lang: file.lang || language
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
codeHTML = html;
|
|
107
|
+
})();
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
</script>
|
|
111
|
+
|
|
112
|
+
<div class="repl-container">
|
|
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
|
+
|
|
127
|
+
{#if presentation}
|
|
128
|
+
<div class="repl-content">
|
|
129
|
+
<div>{@render children?.()}</div>
|
|
130
|
+
</div>
|
|
131
|
+
|
|
132
|
+
<hr />
|
|
133
|
+
{/if}
|
|
134
|
+
|
|
135
|
+
<Files {files} bind:activeIndex={activeFileIndex} />
|
|
136
|
+
|
|
137
|
+
<div class="repl-content">
|
|
138
|
+
{#if viewState === 'code'}
|
|
139
|
+
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
140
|
+
<div class="wrapper-highlight" bind:this={ref}>{@html codeHTML}</div>
|
|
141
|
+
{:else}
|
|
142
|
+
<div>{@render children?.()}</div>
|
|
143
|
+
{/if}
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
<style>
|
|
148
|
+
div.repl-container {
|
|
149
|
+
--repl-spacing: 0.25rem;
|
|
150
|
+
--repl-radius: 1rem;
|
|
151
|
+
--repl-shiki-size: 1rem;
|
|
152
|
+
--repl-shiki-tab-size: 2;
|
|
153
|
+
|
|
154
|
+
--repl-background: #f9f9f9;
|
|
155
|
+
--repl-border-color: #ebebeb;
|
|
156
|
+
|
|
157
|
+
--repl-primary: #0d0d34;
|
|
158
|
+
--repl-secondary: #8f8f8f;
|
|
159
|
+
|
|
160
|
+
background-color: var(--repl-background);
|
|
161
|
+
border-radius: var(--repl-radius);
|
|
162
|
+
border: 2px solid var(--repl-border-color);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
div.repl-container :global(pre) {
|
|
166
|
+
background-color: var(--repl-background) !important;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.repl-content {
|
|
170
|
+
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));
|
|
176
|
+
position: relative;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
hr {
|
|
180
|
+
max-width: calc(100% - 4.5rem);
|
|
181
|
+
margin-inline-start: calc(4.5rem / 2);
|
|
182
|
+
display: block;
|
|
183
|
+
border: thin solid var(--repl-border-color);
|
|
184
|
+
margin-top: 0;
|
|
185
|
+
margin-bottom: 0;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
div.repl-container .wrapper-highlight :global(pre code) {
|
|
189
|
+
font-size: var(--repl-shiki-size);
|
|
190
|
+
-moz-tab-size: var(--repl-shiki-tab-size);
|
|
191
|
+
tab-size: var(--repl-shiki-tab-size);
|
|
192
|
+
white-space: pre-wrap;
|
|
193
|
+
word-break: break-word;
|
|
194
|
+
}
|
|
195
|
+
</style>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ToolbarProps } from './types.js';
|
|
3
|
+
import Button from './Button.svelte';
|
|
4
|
+
import { dictionary } from './utils.js';
|
|
5
|
+
import { Copy, Check, Code, Codesandbox, Moon, Sun } from '@lucide/svelte';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
title,
|
|
9
|
+
language,
|
|
10
|
+
presentation,
|
|
11
|
+
copyState = $bindable(),
|
|
12
|
+
viewState = $bindable(),
|
|
13
|
+
themeState = $bindable(),
|
|
14
|
+
modeState = $bindable()
|
|
15
|
+
}: ToolbarProps = $props();
|
|
16
|
+
|
|
17
|
+
let languageKey = $derived(
|
|
18
|
+
Object.entries(dictionary).find(([, values]) => values.includes(language))?.[0] || language
|
|
19
|
+
);
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<div class="lpk-repl--toolbar">
|
|
23
|
+
<div class="lpk-repl--toolbar-title">
|
|
24
|
+
{#if title}
|
|
25
|
+
<span>{title}</span>
|
|
26
|
+
{:else if language}
|
|
27
|
+
<span>{languageKey}</span>
|
|
28
|
+
{/if}
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<div class="lpk-repl--toolbar-actions">
|
|
32
|
+
{#if (modeState !== 'code' && viewState === 'preview') || presentation}
|
|
33
|
+
<Button onclick={() => (themeState = themeState === 'light' ? 'dark' : 'light')}>
|
|
34
|
+
{#if themeState === 'light'}
|
|
35
|
+
<Moon />
|
|
36
|
+
{:else}
|
|
37
|
+
<Sun />
|
|
38
|
+
{/if}
|
|
39
|
+
</Button>
|
|
40
|
+
{/if}
|
|
41
|
+
|
|
42
|
+
{#if modeState === 'mixed' && !presentation}
|
|
43
|
+
<Button onclick={() => (viewState = viewState === 'code' ? 'preview' : 'code')}>
|
|
44
|
+
{#if viewState === 'code'}
|
|
45
|
+
<Code />
|
|
46
|
+
{:else}
|
|
47
|
+
<Codesandbox />
|
|
48
|
+
{/if}
|
|
49
|
+
</Button>
|
|
50
|
+
{/if}
|
|
51
|
+
|
|
52
|
+
{#if modeState !== 'playground'}
|
|
53
|
+
<Button onclick={() => (copyState = true)}>
|
|
54
|
+
{#if copyState}
|
|
55
|
+
<Check />
|
|
56
|
+
{:else}
|
|
57
|
+
<Copy />
|
|
58
|
+
{/if}
|
|
59
|
+
</Button>
|
|
60
|
+
{/if}
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<style>
|
|
65
|
+
.lpk-repl--toolbar {
|
|
66
|
+
display: flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
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);
|
|
75
|
+
min-height: 36px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.lpk-repl--toolbar .lpk-repl--toolbar-title {
|
|
79
|
+
display: flex;
|
|
80
|
+
align-items: center;
|
|
81
|
+
gap: calc(var(--repl-spacing) * 2);
|
|
82
|
+
font-weight: 600;
|
|
83
|
+
color: var(--repl-secondary);
|
|
84
|
+
max-width: 80%;
|
|
85
|
+
min-width: 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.lpk-repl--toolbar .lpk-repl--toolbar-actions {
|
|
89
|
+
display: flex;
|
|
90
|
+
align-items: center;
|
|
91
|
+
gap: calc(var(--repl-spacing) * 2);
|
|
92
|
+
}
|
|
93
|
+
</style>
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as KitCode } from './Repl.svelte';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
|
2
|
+
<svg width="800px" height="800px" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path d="M6 28L4 3H28L26 28L16 31L6 28Z" fill="#1172B8"/>
|
|
4
|
+
<path d="M26 5H16V29.5L24 27L26 5Z" fill="#33AADD"/>
|
|
5
|
+
<path d="M19.5 17.5H9.5L9 14L17 11.5H9L8.5 8.5H24L23.5 12L17 14.5H23L22 24L16 26L10 24L9.5 19H12.5L13 21.5L16 22.5L19 21.5L19.5 17.5Z" fill="white"/>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
|
2
|
+
<svg width="800px" height="800px" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<path d="M6 28L4 3H28L26 28L16 31L6 28Z" fill="#E44D26"/>
|
|
4
|
+
<path d="M26 5H16V29.5L24 27L26 5Z" fill="#F16529"/>
|
|
5
|
+
<path d="M9.5 17.5L8.5 8H24L23.5 11H11.5L12 14.5H23L22 24L16 26L10 24L9.5 19H12.5L13 21.5L16 22.5L19 21.5L19.5 17.5H9.5Z" fill="white"/>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
|
2
|
+
<svg width="800px" height="800px" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<rect x="2" y="2" width="28" height="28" fill="#FFCA28"/>
|
|
4
|
+
<path d="M19 25.2879L21.0615 23.9237C21.2231 24.4313 22.2462 25.6368 23.5385 25.6368C24.8308 25.6368 25.4308 24.931 25.4308 24.463C25.4308 23.1878 24.1112 22.7382 23.4774 22.5223C23.374 22.4871 23.289 22.4581 23.2308 22.4328C23.2009 22.4198 23.1558 22.4025 23.0979 22.3804C22.393 22.1111 19.7923 21.1175 19.7923 18.2373C19.7923 15.065 22.8538 14.7002 23.5462 14.7002C23.9991 14.7002 26.1769 14.7557 27.2615 16.7939L25.2615 18.1898C24.8231 17.3015 24.0946 17.0081 23.6462 17.0081C22.5385 17.0081 22.3077 17.8201 22.3077 18.1898C22.3077 19.227 23.5112 19.6919 24.5273 20.0844C24.7932 20.1871 25.0462 20.2848 25.2615 20.3866C26.3692 20.91 28 21.7666 28 24.463C28 25.8136 26.8672 28.0002 24.0154 28.0002C20.1846 28.0002 19.1692 25.7003 19 25.2879Z" fill="#3E3E3E"/>
|
|
5
|
+
<path d="M9 25.5587L11.1487 24.1953C11.317 24.7026 11.9713 25.638 12.9205 25.638C13.8698 25.638 14.3557 24.663 14.3557 24.1953V15.0002H16.9982V24.1953C17.041 25.4636 16.3376 28.0002 13.2332 28.0002C10.379 28.0002 9.19242 26.3039 9 25.5587Z" fill="#3E3E3E"/>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
|
2
|
+
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<rect width="24" height="24" fill="none"/>
|
|
4
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.29291 14.2929C6.90238 14.6834 6.90238 15.3166 7.29291 15.7071C7.68343 16.0976 8.31659 16.0976 8.70712 15.7071L11.2071 13.2071C11.8738 12.5404 11.8738 11.4596 11.2071 10.7929L8.70712 8.29289C8.3166 7.90237 7.68343 7.90237 7.29291 8.29289C6.90238 8.68342 6.90238 9.31658 7.29291 9.70711L9.5858 12L7.29291 14.2929ZM13 14C12.4477 14 12 14.4477 12 15C12 15.5523 12.4477 16 13 16H16C16.5523 16 17 15.5523 17 15C17 14.4477 16.5523 14 16 14H13ZM22 7.93418C22 7.95604 22 7.97799 22 8.00001L22 16.0658C22.0001 16.9523 22.0001 17.7161 21.9179 18.3278C21.8297 18.9833 21.631 19.6117 21.1213 20.1213C20.6117 20.631 19.9833 20.8297 19.3278 20.9179C18.7161 21.0001 17.9523 21.0001 17.0658 21L6.9342 21C6.0477 21.0001 5.28388 21.0001 4.67222 20.9179C4.0167 20.8297 3.38835 20.631 2.87869 20.1213C2.36902 19.6117 2.17028 18.9833 2.08215 18.3278C1.99991 17.7161 1.99995 16.9523 2 16.0658L2 7.9342C1.99995 7.0477 1.99991 6.28388 2.08215 5.67221C2.17028 5.0167 2.36902 4.38835 2.87869 3.87868C3.38835 3.36902 4.0167 3.17028 4.67222 3.08215C5.28388 2.99991 6.04769 2.99995 6.93418 3L17 3.00001C17.022 3.00001 17.044 3 17.0658 3C17.9523 2.99995 18.7161 2.99991 19.3278 3.08215C19.9833 3.17028 20.6117 3.36902 21.1213 3.87869C21.631 4.38835 21.8297 5.0167 21.9179 5.67221C22.0001 6.28387 22.0001 7.04769 22 7.93418Z" fill="#323232"/>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
|
2
|
+
<svg width="800px" height="800px" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><title>file_type_svelte</title><path d="M26.47,5.7A8.973,8.973,0,0,0,14.677,3.246L7.96,7.4a7.461,7.461,0,0,0-3.481,5.009,7.686,7.686,0,0,0,.8,5.058,7.358,7.358,0,0,0-1.151,2.8,7.789,7.789,0,0,0,1.4,6.028,8.977,8.977,0,0,0,11.794,2.458L24.04,24.6a7.468,7.468,0,0,0,3.481-5.009,7.673,7.673,0,0,0-.8-5.062,7.348,7.348,0,0,0,1.152-2.8A7.785,7.785,0,0,0,26.47,5.7" style="fill:#ff3e00"/><path d="M14.022,26.64A5.413,5.413,0,0,1,8.3,24.581a4.678,4.678,0,0,1-.848-3.625,4.307,4.307,0,0,1,.159-.61l.127-.375.344.238a8.76,8.76,0,0,0,2.628,1.274l.245.073-.025.237a1.441,1.441,0,0,0,.271.968,1.63,1.63,0,0,0,1.743.636,1.512,1.512,0,0,0,.411-.175l6.7-4.154a1.366,1.366,0,0,0,.633-.909,1.407,1.407,0,0,0-.244-1.091,1.634,1.634,0,0,0-1.726-.622,1.509,1.509,0,0,0-.413.176l-2.572,1.584a4.934,4.934,0,0,1-1.364.582,5.415,5.415,0,0,1-5.727-2.06A4.678,4.678,0,0,1,7.811,13.1,4.507,4.507,0,0,1,9.9,10.09l6.708-4.154a4.932,4.932,0,0,1,1.364-.581A5.413,5.413,0,0,1,23.7,7.414a4.679,4.679,0,0,1,.848,3.625,4.272,4.272,0,0,1-.159.61l-.127.375-.344-.237a8.713,8.713,0,0,0-2.628-1.274l-.245-.074.025-.237a1.438,1.438,0,0,0-.272-.968,1.629,1.629,0,0,0-1.725-.622,1.484,1.484,0,0,0-.411.176l-6.722,4.14a1.353,1.353,0,0,0-.631.908,1.394,1.394,0,0,0,.244,1.092,1.634,1.634,0,0,0,1.726.621,1.538,1.538,0,0,0,.413-.175l2.562-1.585a4.9,4.9,0,0,1,1.364-.581,5.417,5.417,0,0,1,5.728,2.059,4.681,4.681,0,0,1,.843,3.625A4.5,4.5,0,0,1,22.1,21.905l-6.707,4.154a4.9,4.9,0,0,1-1.364.581" style="fill:#fff"/></svg>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
|
3
|
+
<svg width="800px" height="800px" viewBox="0 0 256 256" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid">
|
|
4
|
+
<g>
|
|
5
|
+
<polygon fill="#007ACC" transform="translate(128.000000, 128.000000) scale(1, -1) translate(-128.000000, -128.000000) " points="0 128 0 0 128 0 256 0 256 128 256 256 128 256 0 256">
|
|
6
|
+
|
|
7
|
+
<path d="M146.658132,223.436863 L146.739401,212.953054 L130.079084,212.953054 L113.418767,212.953054 L113.418767,165.613371 L113.418767,118.273689 L101.63464,118.273689 L89.8505126,118.273689 L89.8505126,165.613371 L89.8505126,212.953054 L73.1901951,212.953054 L56.5298776,212.953054 L56.5298776,223.233689 C56.5298776,228.922577 56.6517824,233.676863 56.8143221,233.798768 C56.9362269,233.961308 77.2130522,234.042577 101.797179,234.001943 L146.536227,233.880038 L146.658132,223.436863 Z" fill="#FFFFFF" transform="translate(101.634640, 176.142993) rotate(-180.000000) translate(-101.634640, -176.142993) ">
|
|
8
|
+
|
|
9
|
+
<path d="M206.566631,234.272145 C213.068219,232.646748 218.025679,229.761668 222.57679,225.048018 C224.933616,222.528653 228.428219,217.936907 228.712663,216.839764 C228.793933,216.514684 217.659965,209.037859 210.914568,204.852462 C210.670758,204.689922 209.69552,205.74643 208.598377,207.371827 C205.306949,212.166748 201.852981,214.239129 196.570441,214.604843 C188.809171,215.133097 183.811076,211.069605 183.851711,204.283573 C183.851711,202.292462 184.136155,201.114049 184.948854,199.488653 C186.65552,195.953414 189.825044,193.840399 199.7806,189.533097 C218.106949,181.649922 225.949489,176.448653 230.825679,169.053097 C236.270758,160.804208 237.489806,147.638494 233.792028,137.845478 C229.728536,127.199129 219.651076,119.966113 205.469489,117.568653 C201.080917,116.796589 190.678377,116.918494 185.964727,117.771827 C175.684092,119.600399 165.931711,124.679764 159.917743,131.343891 C157.560917,133.944526 152.969171,140.730557 153.253616,141.218176 C153.37552,141.380716 154.432028,142.030875 155.610441,142.721668 C156.748219,143.371827 161.05552,145.850557 165.119012,148.207383 L172.473933,152.474049 L174.01806,150.198494 C176.171711,146.907065 180.885362,142.396589 183.729806,140.893097 C191.897425,136.585795 203.112663,137.195319 208.639012,142.15278 C210.995838,144.30643 211.971076,146.541351 211.971076,149.83278 C211.971076,152.799129 211.605362,154.099446 210.061235,156.334367 C208.070123,159.178811 204.006631,161.576272 192.466314,166.574367 C179.259965,172.263256 173.571076,175.798494 168.369806,181.406113 C165.362822,184.656907 162.518377,189.858176 161.339965,194.206113 C160.364727,197.822621 160.120917,206.884208 160.892981,210.541351 C163.61552,223.300716 173.245996,232.199764 187.143139,234.841034 C191.653616,235.694367 202.137425,235.369287 206.566631,234.272145 Z" fill="#FFFFFF" transform="translate(194.578507, 176.190240) scale(1, -1) translate(-194.578507, -176.190240) ">
|
|
10
|
+
|
|
11
|
+
</g>
|
|
12
|
+
</svg>
|
package/dist/shiki.d.ts
ADDED
package/dist/shiki.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createHighlighter } from 'shiki';
|
|
2
|
+
let highlighter;
|
|
3
|
+
export async function getHighlighterSingleton() {
|
|
4
|
+
if (!highlighter) {
|
|
5
|
+
highlighter = await createHighlighter({
|
|
6
|
+
themes: ['github-light', 'github-dark'],
|
|
7
|
+
langs: ['svelte', 'typescript', 'javascript', 'html', 'css', 'json', 'bash']
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
return highlighter;
|
|
11
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export interface ReplProps {
|
|
3
|
+
title?: string;
|
|
4
|
+
content?: string | Record<string, string | Record<string, unknown>>;
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
presentation?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ToolbarProps {
|
|
9
|
+
title?: string;
|
|
10
|
+
language: string;
|
|
11
|
+
copyState?: boolean;
|
|
12
|
+
presentation?: boolean;
|
|
13
|
+
viewState?: 'code' | 'preview';
|
|
14
|
+
themeState?: 'light' | 'dark';
|
|
15
|
+
modeState?: 'code' | 'playground' | 'mixed';
|
|
16
|
+
}
|
|
17
|
+
export interface FilesProps {
|
|
18
|
+
files?: FileItem[];
|
|
19
|
+
activeIndex: number;
|
|
20
|
+
}
|
|
21
|
+
export interface FileItem {
|
|
22
|
+
name: string;
|
|
23
|
+
content: string;
|
|
24
|
+
lang?: string;
|
|
25
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils.d.ts
ADDED
package/dist/utils.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import javascript from './languages/javascript.svg';
|
|
2
|
+
import typescript from './languages/typescript.svg';
|
|
3
|
+
import svelte from './languages/svelte.svg';
|
|
4
|
+
import css from './languages/css.svg';
|
|
5
|
+
import html from './languages/html.svg';
|
|
6
|
+
import shell from './languages/shell.svg';
|
|
7
|
+
export const copyToClipboard = (value) => {
|
|
8
|
+
if (navigator.clipboard && window.isSecureContext) {
|
|
9
|
+
navigator.clipboard
|
|
10
|
+
.writeText(value)
|
|
11
|
+
.then(function () {
|
|
12
|
+
console.log('Success copy: ' + value);
|
|
13
|
+
})
|
|
14
|
+
.catch(function (err) {
|
|
15
|
+
console.error('Error copying to clipboard: ', err);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
// Fallback (legacy browser)
|
|
20
|
+
const zoneTexte = document.createElement('textarea');
|
|
21
|
+
zoneTexte.value = value;
|
|
22
|
+
zoneTexte.style.position = 'fixed';
|
|
23
|
+
zoneTexte.style.left = '-9999px';
|
|
24
|
+
document.body.appendChild(zoneTexte);
|
|
25
|
+
zoneTexte.focus();
|
|
26
|
+
zoneTexte.select();
|
|
27
|
+
try {
|
|
28
|
+
document.execCommand('copy');
|
|
29
|
+
console.log('Success copy: ' + value);
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
console.error('Error copying to clipboard: ', err);
|
|
33
|
+
}
|
|
34
|
+
document.body.removeChild(zoneTexte);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export const dictionary = {
|
|
38
|
+
javascript: ['js', 'javascript'],
|
|
39
|
+
typescript: ['ts', 'typescript'],
|
|
40
|
+
svelte: ['svelte', 'svelte.ts', 'svelte.js'],
|
|
41
|
+
css: ['css', 'scss', 'less'],
|
|
42
|
+
html: ['html', 'htm'],
|
|
43
|
+
json: ['json'],
|
|
44
|
+
shell: ['bash', 'sh', 'shell']
|
|
45
|
+
};
|
|
46
|
+
export const dictionaryIcons = {
|
|
47
|
+
js: javascript,
|
|
48
|
+
ts: typescript,
|
|
49
|
+
'svelte.ts': svelte,
|
|
50
|
+
'svelte.js': svelte,
|
|
51
|
+
svelte: svelte,
|
|
52
|
+
shell: shell,
|
|
53
|
+
bash: shell,
|
|
54
|
+
sh: shell,
|
|
55
|
+
css: css,
|
|
56
|
+
scss: css,
|
|
57
|
+
less: css,
|
|
58
|
+
html: html,
|
|
59
|
+
htm: html,
|
|
60
|
+
json: shell
|
|
61
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lapikit/repl",
|
|
3
|
+
"version": "0.0.0-insiders.24a3260",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "Nycolaide",
|
|
10
|
+
"email": "contact@lapikit.dev"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/Nycolaide/lapikit.git"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"dev": "vite dev",
|
|
18
|
+
"build": "vite build && npm run prepack",
|
|
19
|
+
"preview": "vite preview",
|
|
20
|
+
"prepare": "svelte-kit sync || echo ''",
|
|
21
|
+
"prepack": "svelte-kit sync && svelte-package && publint",
|
|
22
|
+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
23
|
+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
24
|
+
"format": "prettier --write .",
|
|
25
|
+
"lint": "prettier --check . && eslint .",
|
|
26
|
+
"test:unit": "vitest",
|
|
27
|
+
"test": "npm run test:unit -- --run"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"!dist/**/*.test.*",
|
|
32
|
+
"!dist/**/*.spec.*"
|
|
33
|
+
],
|
|
34
|
+
"sideEffects": [
|
|
35
|
+
"**/*.css"
|
|
36
|
+
],
|
|
37
|
+
"svelte": "./dist/index.js",
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"type": "module",
|
|
40
|
+
"exports": {
|
|
41
|
+
".": {
|
|
42
|
+
"types": "./dist/index.d.ts",
|
|
43
|
+
"svelte": "./dist/index.js"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@sveltejs/kit": "^2.0.0",
|
|
48
|
+
"svelte": "^5.0.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@eslint/compat": "^1.4.0",
|
|
52
|
+
"@eslint/js": "^9.39.1",
|
|
53
|
+
"@sveltejs/adapter-auto": "^7.0.0",
|
|
54
|
+
"@sveltejs/kit": "^2.49.1",
|
|
55
|
+
"@sveltejs/package": "^2.5.7",
|
|
56
|
+
"@sveltejs/vite-plugin-svelte": "^6.2.1",
|
|
57
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
58
|
+
"@testing-library/svelte": "^5.2.4",
|
|
59
|
+
"eslint": "^9.39.1",
|
|
60
|
+
"eslint-config-prettier": "^10.1.8",
|
|
61
|
+
"eslint-plugin-svelte": "^3.13.1",
|
|
62
|
+
"globals": "^16.5.0",
|
|
63
|
+
"jsdom": "^26.0.0",
|
|
64
|
+
"prettier": "^3.7.4",
|
|
65
|
+
"prettier-plugin-svelte": "^3.4.0",
|
|
66
|
+
"publint": "^0.3.15",
|
|
67
|
+
"svelte": "^5.45.6",
|
|
68
|
+
"svelte-check": "^4.3.4",
|
|
69
|
+
"typescript": "^5.9.3",
|
|
70
|
+
"typescript-eslint": "^8.48.1",
|
|
71
|
+
"vite": "^7.2.6",
|
|
72
|
+
"vitest": "^4.0.15"
|
|
73
|
+
},
|
|
74
|
+
"keywords": [
|
|
75
|
+
"svelte"
|
|
76
|
+
],
|
|
77
|
+
"dependencies": {
|
|
78
|
+
"@lucide/svelte": "^0.562.0",
|
|
79
|
+
"shiki": "^3.20.0"
|
|
80
|
+
}
|
|
81
|
+
}
|