@nsis/dent-ui 0.4.0 → 0.4.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.
@@ -1,15 +1,17 @@
1
1
  $ vite build
2
- 6:45:36 PM [vite-plugin-svelte] no Svelte config found at /home/runner/work/nsis-org/nsis-org/packages/dent-ui - using default configuration.
2
+ 6:24:22 AM [vite-plugin-svelte] no Svelte config found at /home/runner/work/nsis-org/nsis-org/packages/dent-ui - using default configuration.
3
3
  vite v8.3.4 building client environment for production...
4
4
  transforming...
5
- ✓ 136 modules transformed.
5
+ ✓ 149 modules transformed.
6
6
  rendering chunks...
7
7
  computing gzip size...
8
8
  dist/index.html 0.34 kB │ gzip: 0.24 kB
9
9
  dist/assets/ardent_wasm_bg-Bz5RQ-Nz.wasm 209.73 kB │ gzip: 87.81 kB
10
- dist/assets/index-DisujktT.js 522.48 kB │ gzip: 172.68 kB
10
+ dist/assets/web-CQZZv1Rg.js 6.65 kB │ gzip: 2.73 kB
11
+ dist/assets/dent-CuDUSuip.js 58.47 kB │ gzip: 17.01 kB
12
+ dist/assets/index-COh98auV.js 517.77 kB │ gzip: 170.87 kB
11
13
 
12
- ✓ built in 376ms
14
+ ✓ built in 364ms
13
15
  [plugin builtin:vite-reporter]
14
16
  (!) Some chunks are larger than 500 kB after minification. Consider:
15
17
  - Using dynamic import() to code-split the application
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @nsis/dent-ui
2
2
 
3
+ ## 0.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 4875a1f: add engine prop
8
+
3
9
  ## 0.4.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  [![Version](https://img.shields.io/npm/v/@nsis/dent-ui?style=for-the-badge)](https://www.npmjs.org/package/@nsis/dent-ui)
7
7
  [![Build](https://img.shields.io/github/actions/workflow/status/idleberg/nsis-org/ci.yml?style=for-the-badge)](https://github.com/idleberg/nsis-org/actions)
8
8
 
9
- [Demo Time](https://idleberg.github.io/nsis-org/dent/) 🙌
9
+ [Demo Time](https://idleberg.github.io/nsis-org/dent-ui/) 🙌
10
10
 
11
11
  ## Usage
12
12
 
@@ -21,6 +21,8 @@
21
21
  > [!NOTE]
22
22
  > By default, NSIS keywords are matched case-insensitively (e.g. `messagebox` and `MessageBox` are both highlighted). Set `strict` to `true` to require canonical casing.
23
23
 
24
+ Formatting uses [`@nsis/ardent-wasm`](../ardent-wasm#readme). Set `engine` to `"dent"` to use the classic [`@nsis/dent`](../dent#readme) instead. Only the selected engine is downloaded.
25
+
24
26
  ## License
25
27
 
26
28
  This work is licensed under [The MIT License](LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nsis/dent-ui",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Web UI for the Dent NSIS code formatter",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -32,6 +32,7 @@
32
32
  "@lezer/highlight": "^1.2.5",
33
33
  "@nsis/codemirror": "0.14.6",
34
34
  "@nsis/ardent-wasm": "0.1.0",
35
+ "@nsis/dent": "0.17.0",
35
36
  "svelte": "^5.57.2"
36
37
  },
37
38
  "devDependencies": {
package/src/App.svelte CHANGED
@@ -3,11 +3,35 @@ import { defaultKeymap, history, historyKeymap } from '@codemirror/commands';
3
3
  import { indentOnInput } from '@codemirror/language';
4
4
  import { EditorState } from '@codemirror/state';
5
5
  import { EditorView, keymap } from '@codemirror/view';
6
- import { createFormatter } from '@nsis/ardent-wasm';
7
6
  import { onDestroy, onMount } from 'svelte';
8
7
  import Editor from './Editor.svelte';
9
8
 
10
- let { strict = false, sample = '' }: { strict?: boolean; sample?: string } = $props();
9
+ let {
10
+ strict = false,
11
+ sample = '',
12
+ engine = 'ardent',
13
+ }: { strict?: boolean; sample?: string; engine?: 'ardent' | 'dent' } = $props();
14
+
15
+ // Each engine is its own chunk, so neither weighs on the initial bundle.
16
+ const engines = {
17
+ ardent: () => import('@nsis/ardent-wasm'),
18
+ dent: () => import('@nsis/dent'),
19
+ };
20
+
21
+ // Re-imports only when `engine` changes; the module cache makes repeat switches free.
22
+ const formatter = $derived(engines[engine]());
23
+ let loading = $state(true);
24
+
25
+ // Reading `formatter` here starts the download on mount rather than on the first format.
26
+ $effect(() => {
27
+ const pending = formatter;
28
+ const done = () => {
29
+ if (pending === formatter) loading = false;
30
+ };
31
+
32
+ loading = true;
33
+ pending.then(done, done);
34
+ });
11
35
 
12
36
  let dark = $state(document.documentElement.dataset.theme !== 'light');
13
37
  let themePreference = $state(localStorage.getItem('theme') || 'system');
@@ -69,16 +93,23 @@ function scheduleAutoFormat() {
69
93
  debounceTimer = setTimeout(formatInput, 400);
70
94
  }
71
95
 
72
- function formatInput() {
73
- error = '';
74
- const source = inputView?.state.doc.toString() ?? '';
75
-
76
- if (!source.trim()) {
77
- setOutput('');
78
- return;
79
- }
96
+ async function formatInput() {
97
+ const requested = engine;
80
98
 
81
99
  try {
100
+ const { createFormatter } = await formatter;
101
+
102
+ // A newer engine took over while this one loaded.
103
+ if (requested !== engine) return;
104
+
105
+ error = '';
106
+ const source = inputView?.state.doc.toString() ?? '';
107
+
108
+ if (!source.trim()) {
109
+ setOutput('');
110
+ return;
111
+ }
112
+
82
113
  const { format } = createFormatter({
83
114
  useTabs,
84
115
  singleQuote,
@@ -247,7 +278,9 @@ const outputExtensions = [EditorState.readOnly.of(true), EditorView.lineWrapping
247
278
  <label class="auto-label">
248
279
  <input type="checkbox" bind:checked={autoFormat} /> Auto-format
249
280
  </label>
250
- {#if status}
281
+ {#if loading}
282
+ <span class="status" role="status" aria-live="polite">Loading formatter engine…</span>
283
+ {:else if status}
251
284
  <span class="status" role="status" aria-live="polite">{status}</span>
252
285
  {/if}
253
286
  {#if error}