@lapikit/repl 0.0.0-insiders.f248eb2 → 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/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
@@ -2,14 +2,12 @@
2
2
 
3
3
  @lapikit/repl is a Svelte component for Lapikit. It's a add-on package for Lapikit library.
4
4
 
5
-
6
5
  ## Installation
7
6
 
8
7
  ```bash
9
8
  npm install -D @lapikit/repl
10
9
  ```
11
10
 
12
-
13
11
  ```javascript
14
12
  // svelte.config.js
15
13
 
@@ -30,7 +28,6 @@ export default config;
30
28
  <kit:repl content="console.log('hello')" />
31
29
  ```
32
30
 
33
-
34
31
  ```svelte
35
32
  <script lang="ts">
36
33
  import sampleCounter from './samples/counter.svelte?raw';
@@ -42,7 +39,6 @@ export default config;
42
39
  </kit:repl>
43
40
  ```
44
41
 
45
-
46
42
  ```svelte
47
43
  <script lang="ts">
48
44
  import sampleJson from './samples/json.json?raw';
@@ -56,14 +52,13 @@ export default config;
56
52
  content={{
57
53
  'Counter.svelte': { code: sampleCounter, lang: 'svelte' },
58
54
  'file.json': { code: sampleJson, lang: 'json' },
59
- 'Styles.css': { code: sampleCss, lang: 'css' },
55
+ 'Styles.css': { code: sampleCss, lang: 'css' }
60
56
  }}
61
57
  >
62
58
  <Counter />
63
59
  </kit:repl>
64
60
  ```
65
61
 
66
-
67
62
  ```svelte
68
63
  <script lang="ts">
69
64
  import sampleJson from './samples/json.json?raw';
@@ -76,18 +71,17 @@ export default config;
76
71
  content={{
77
72
  'Counter.svelte': { code: sampleCounter, lang: 'svelte' },
78
73
  'file.json': { code: sampleJson, lang: 'json' },
79
- 'Styles.css': { code: sampleCss, lang: 'css' },
74
+ 'Styles.css': { code: sampleCss, lang: 'css' }
80
75
  }}
81
76
  >
82
77
  <Counter />
83
78
  </kit:repl>
84
79
  ```
85
80
 
86
-
87
81
  ## Props
88
82
 
89
- | Prop | Type | Default | Description |
90
- | ----------- | --------------------------- | --------- | ------------------------------------------------------------ |
91
- | 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. |
92
- | presentation | boolean | false | If true, the REPL will be in presentation mode, showing only the output without the code editor. |
93
- | tiltle | string | '' | The title displayed on the REPL toolbar. |
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/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.f248eb2",
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
- "url": "git+https://github.com/Nycolaide/lapikit.git"
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",