@nsis/dent-ui 0.2.6 → 0.3.1
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/.gitignore +12 -0
- package/CHANGELOG.md +20 -0
- package/index.html +1 -1
- package/package.json +5 -4
- package/src/App.svelte +15 -3
- package/src/Editor.svelte +3 -1
- package/test/App.test.ts +9 -1
- package/test/Editor.test.ts +11 -0
- package/.turbo/turbo-build.log +0 -15
package/.gitignore
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @nsis/dent-ui
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2057e9a: allow selecting output viewer text
|
|
8
|
+
|
|
9
|
+
## 0.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 5e3783a: add property that allows passing default script
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [a7e61df]
|
|
18
|
+
- Updated dependencies [29fec7f]
|
|
19
|
+
- Updated dependencies [4792830]
|
|
20
|
+
- @nsis/codemirror@0.14.5
|
|
21
|
+
- @nsis/dent@0.14.1
|
|
22
|
+
|
|
3
23
|
## 0.2.6
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/index.html
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nsis/dent-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Web UI for the Dent NSIS code formatter",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"@codemirror/state": "^6.7.1",
|
|
31
31
|
"@codemirror/view": "^6.43.8",
|
|
32
32
|
"@lezer/highlight": "^1.2.3",
|
|
33
|
-
"
|
|
34
|
-
"@nsis/
|
|
35
|
-
"
|
|
33
|
+
"@nsis/codemirror": "0.14.5",
|
|
34
|
+
"@nsis/dent": "0.14.1",
|
|
35
|
+
"svelte": "^5.56.9"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@sveltejs/vite-plugin-svelte": "^7.3.0",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"lint:biome": "biome check",
|
|
52
52
|
"lint:biome:ci": "biome ci",
|
|
53
53
|
"check": "svelte-check --tsconfig ./tsconfig.json",
|
|
54
|
+
"pretest": "playwright install chromium",
|
|
54
55
|
"test": "vitest run"
|
|
55
56
|
}
|
|
56
57
|
}
|
package/src/App.svelte
CHANGED
|
@@ -7,7 +7,7 @@ import { createFormatter } from '@nsis/dent';
|
|
|
7
7
|
import { onDestroy, onMount } from 'svelte';
|
|
8
8
|
import Editor from './Editor.svelte';
|
|
9
9
|
|
|
10
|
-
let { strict = false }: { strict?: boolean } = $props();
|
|
10
|
+
let { strict = false, sample = '' }: { strict?: boolean; sample?: string } = $props();
|
|
11
11
|
|
|
12
12
|
let dark = $state(document.documentElement.dataset.theme !== 'light');
|
|
13
13
|
let themePreference = $state(localStorage.getItem('theme') || 'system');
|
|
@@ -35,6 +35,12 @@ function handleColorSchemeChange() {
|
|
|
35
35
|
|
|
36
36
|
onMount(() => {
|
|
37
37
|
mql.addEventListener('change', handleColorSchemeChange);
|
|
38
|
+
|
|
39
|
+
// Child editors have mounted by now, so both views exist. CodeMirror's
|
|
40
|
+
// updateListener doesn't fire for the initial document, which means a
|
|
41
|
+
// seeded input never triggers the auto-format path on its own.
|
|
42
|
+
if (sample) formatInput();
|
|
43
|
+
|
|
38
44
|
return () => mql.removeEventListener('change', handleColorSchemeChange);
|
|
39
45
|
});
|
|
40
46
|
|
|
@@ -132,11 +138,11 @@ const inputExtensions = [
|
|
|
132
138
|
}),
|
|
133
139
|
];
|
|
134
140
|
|
|
135
|
-
const outputExtensions = [EditorState.readOnly.of(true), EditorView.
|
|
141
|
+
const outputExtensions = [EditorState.readOnly.of(true), EditorView.lineWrapping];
|
|
136
142
|
</script>
|
|
137
143
|
|
|
138
144
|
<header>
|
|
139
|
-
<h1>Dent
|
|
145
|
+
<h1>Dent</h1>
|
|
140
146
|
<fieldset class="settings" aria-label="Formatter settings">
|
|
141
147
|
<label
|
|
142
148
|
><input
|
|
@@ -204,6 +210,7 @@ const outputExtensions = [EditorState.readOnly.of(true), EditorView.editable.of(
|
|
|
204
210
|
<Editor
|
|
205
211
|
{dark}
|
|
206
212
|
{strict}
|
|
213
|
+
doc={sample}
|
|
207
214
|
extensions={inputExtensions}
|
|
208
215
|
label="NSIS input editor"
|
|
209
216
|
oncreate={(v) => {
|
|
@@ -373,6 +380,11 @@ const outputExtensions = [EditorState.readOnly.of(true), EditorView.editable.of(
|
|
|
373
380
|
min-height: 0;
|
|
374
381
|
}
|
|
375
382
|
|
|
383
|
+
.editor-pane :global(.cm-content) {
|
|
384
|
+
-webkit-user-select: text;
|
|
385
|
+
user-select: text;
|
|
386
|
+
}
|
|
387
|
+
|
|
376
388
|
.editor-pane:first-child {
|
|
377
389
|
border-right: 1px solid var(--border);
|
|
378
390
|
}
|
package/src/Editor.svelte
CHANGED
|
@@ -7,12 +7,14 @@ import { darkTheme, editorTheme, lightTheme } from './themes.ts';
|
|
|
7
7
|
|
|
8
8
|
let {
|
|
9
9
|
dark = true,
|
|
10
|
+
doc = '',
|
|
10
11
|
extensions = [],
|
|
11
12
|
label = '',
|
|
12
13
|
strict = false,
|
|
13
14
|
oncreate,
|
|
14
15
|
}: {
|
|
15
16
|
dark?: boolean;
|
|
17
|
+
doc?: string;
|
|
16
18
|
extensions?: Extension[];
|
|
17
19
|
label?: string;
|
|
18
20
|
strict?: boolean;
|
|
@@ -27,7 +29,7 @@ const langCompartment = new Compartment();
|
|
|
27
29
|
onMount(() => {
|
|
28
30
|
view = new EditorView({
|
|
29
31
|
state: EditorState.create({
|
|
30
|
-
doc
|
|
32
|
+
doc,
|
|
31
33
|
extensions: [
|
|
32
34
|
themeCompartment.of(dark ? darkTheme : lightTheme),
|
|
33
35
|
langCompartment.of(nsis({ strict })),
|
package/test/App.test.ts
CHANGED
|
@@ -7,7 +7,7 @@ describe('App', () => {
|
|
|
7
7
|
it('renders the heading', async () => {
|
|
8
8
|
render(App);
|
|
9
9
|
|
|
10
|
-
await expect.element(page.getByRole('heading', { name: 'Dent
|
|
10
|
+
await expect.element(page.getByRole('heading', { name: 'Dent' })).toBeVisible();
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
it('renders formatter settings fieldset', async () => {
|
|
@@ -46,6 +46,14 @@ describe('App', () => {
|
|
|
46
46
|
await expect.element(page.getByRole('checkbox', { name: 'Auto-format' })).toBeChecked();
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
+
it('formats a seeded sample on mount, enabling Copy', async () => {
|
|
50
|
+
render(App, {
|
|
51
|
+
props: { sample: "name 'x'\nSection\nnop\nSectionEnd\n" },
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
await expect.element(page.getByRole('button', { name: 'Copy' })).toBeEnabled();
|
|
55
|
+
});
|
|
56
|
+
|
|
49
57
|
it('renders both editor panes', async () => {
|
|
50
58
|
render(App);
|
|
51
59
|
|
package/test/Editor.test.ts
CHANGED
|
@@ -35,4 +35,15 @@ describe('Editor', () => {
|
|
|
35
35
|
const view = oncreate.mock.calls[0]?.[0];
|
|
36
36
|
expect(view?.state.doc.toString()).toBe('');
|
|
37
37
|
});
|
|
38
|
+
|
|
39
|
+
it('initialises with the doc prop', () => {
|
|
40
|
+
const oncreate = vi.fn();
|
|
41
|
+
|
|
42
|
+
render(Editor, {
|
|
43
|
+
props: { label: 'Test editor', doc: 'Name "Test"', oncreate },
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const view = oncreate.mock.calls[0]?.[0];
|
|
47
|
+
expect(view?.state.doc.toString()).toBe('Name "Test"');
|
|
48
|
+
});
|
|
38
49
|
});
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
$ vite build
|
|
2
|
-
10:01:22 PM [vite-plugin-svelte] no Svelte config found at /home/runner/work/nsis-org/nsis-org/packages/dent-ui - using default configuration.
|
|
3
|
-
[36mvite v8.2.1 [32mbuilding client environment for production...[36m[39m
|
|
4
|
-
[2K
|
|
5
|
-
rendering chunks...
|
|
6
|
-
computing gzip size...
|
|
7
|
-
dist/index.html 0.32 kB │ gzip: 0.23 kB
|
|
8
|
-
dist/assets/index-t2NToYOv.js 559.24 kB │ gzip: 182.66 kB
|
|
9
|
-
|
|
10
|
-
[32m✓ built in 277ms[39m
|
|
11
|
-
[33m[plugin builtin:vite-reporter]
|
|
12
|
-
(!) Some chunks are larger than 500 kB after minification. Consider:
|
|
13
|
-
- Using dynamic import() to code-split the application
|
|
14
|
-
- Use build.rolldownOptions.output.codeSplitting to improve chunking: https://rolldown.rs/reference/OutputOptions.codeSplitting
|
|
15
|
-
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.[39m
|