@lapikit/repl 0.0.0-insiders.aa0c2f0 → 0.0.0-insiders.ab10c58
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/dist/Repl.svelte +22 -6
- package/dist/shiki.js +11 -8
- package/package.json +5 -2
package/dist/Repl.svelte
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
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[]>(() => {
|
|
@@ -94,15 +94,15 @@
|
|
|
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 || 'sh';
|
|
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
|
}
|
|
@@ -144,8 +144,14 @@
|
|
|
144
144
|
class:kit-repl-content--code={viewState === 'code' && !presentation}
|
|
145
145
|
>
|
|
146
146
|
{#if viewState === 'code'}
|
|
147
|
-
|
|
148
|
-
|
|
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>
|
|
149
155
|
{:else}
|
|
150
156
|
<div
|
|
151
157
|
class="kit-repl-wrapper-playground"
|
|
@@ -213,6 +219,16 @@
|
|
|
213
219
|
margin-bottom: 0;
|
|
214
220
|
}
|
|
215
221
|
|
|
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);
|
|
226
|
+
white-space: pre-wrap;
|
|
227
|
+
word-break: break-word;
|
|
228
|
+
margin: 0;
|
|
229
|
+
padding: 0;
|
|
230
|
+
}
|
|
231
|
+
|
|
216
232
|
div.kit-repl-container .kit-repl-wrapper-highlight :global(pre code) {
|
|
217
233
|
font-size: var(--kit-repl-shiki-size);
|
|
218
234
|
-moz-tab-size: var(--kit-repl-shiki-tab-size);
|
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/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.ab10c58",
|
|
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
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",
|