@lapikit/repl 0.0.0-insiders.ee3de8e → 0.0.0-insiders.fbbe434

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 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[]>(() => {
@@ -91,18 +91,19 @@
91
91
 
92
92
  $effect(() => {
93
93
  const file = activeFile;
94
- const theme = themeState;
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
- theme: theme === 'light' ? 'github-light' : 'github-dark',
103
+ // theme: theme === 'light' ? 'github-light' : 'github-dark',
104
+ theme: 'github-light',
103
105
  lang: file.lang || language
104
106
  });
105
-
106
107
  codeHTML = html;
107
108
  })();
108
109
  }
@@ -144,8 +145,14 @@
144
145
  class:kit-repl-content--code={viewState === 'code' && !presentation}
145
146
  >
146
147
  {#if viewState === 'code'}
147
- <!-- eslint-disable-next-line svelte/no-at-html-tags -->
148
- <div class="kit-repl-wrapper-highlight" bind:this={ref}>{@html codeHTML}</div>
148
+ <div class="kit-repl-wrapper-highlight" bind:this={ref}>
149
+ {#if codeHTML !== null}
150
+ <!-- eslint-disable-next-line svelte/no-at-html-tags -->
151
+ {@html codeHTML}
152
+ {:else}
153
+ <pre class="kit-repl-raw"><code>{activeFile?.content ?? ''}</code></pre>
154
+ {/if}
155
+ </div>
149
156
  {:else}
150
157
  <div
151
158
  class="kit-repl-wrapper-playground"
@@ -170,10 +177,10 @@
170
177
  --kit-repl-shiki-tab-size: 2;
171
178
 
172
179
  /* colors */
173
- --kit-repl-background: #f9f9f9;
174
- --kit-repl-border-color: #ebebeb;
175
- --kit-repl-primary: #0d0d34;
176
- --kit-repl-secondary: #8f8f8f;
180
+ --kit-repl-background: var(--kit-surface-3, #f9f9f9);
181
+ --kit-repl-border-color: var(--kit-border, #ebebeb);
182
+ --kit-repl-primary: var(--kit-fg, #0d0d34);
183
+ --kit-repl-secondary: var(--kit-muted, #8f8f8f);
177
184
  }
178
185
  .kit-repl-container {
179
186
  background-color: var(--kit-repl-background);
@@ -182,7 +189,7 @@
182
189
  }
183
190
 
184
191
  .kit-repl-container :global(pre) {
185
- background-color: var(--kit-repl-background) !important;
192
+ background-color: #f9f9f9 !important;
186
193
  }
187
194
 
188
195
  .kit-repl-content {
@@ -213,6 +220,16 @@
213
220
  margin-bottom: 0;
214
221
  }
215
222
 
223
+ .kit-repl-raw {
224
+ font-size: var(--kit-repl-shiki-size);
225
+ -moz-tab-size: var(--kit-repl-shiki-tab-size);
226
+ tab-size: var(--kit-repl-shiki-tab-size);
227
+ white-space: pre-wrap;
228
+ word-break: break-word;
229
+ margin: 0;
230
+ padding: 0;
231
+ }
232
+
216
233
  div.kit-repl-container .kit-repl-wrapper-highlight :global(pre code) {
217
234
  font-size: var(--kit-repl-shiki-size);
218
235
  -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 (!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
+ 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.ee3de8e",
3
+ "version": "0.0.0-insiders.fbbe434",
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",