@tombi-toml/wasm-lib 1.5.8 → 1.6.0

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/index.d.ts CHANGED
@@ -6,6 +6,8 @@ export interface Diagnostic {
6
6
  code: string;
7
7
  message: string;
8
8
  range: Range;
9
+ sourceFile: string | null;
10
+ /** @deprecated Use {@link Diagnostic.sourceFile} instead. */
9
11
  source_file: string | null;
10
12
  }
11
13
 
@@ -32,16 +34,23 @@ export interface LintResult {
32
34
  diagnostics: Diagnostic[];
33
35
  }
34
36
 
35
- /**
36
- * An in-memory `tombi.toml` configuration.
37
- * When a string is provided, it is treated as the content of a virtual
38
- * `tombi.toml`.
39
- */
40
- export type Config = { content: string; path: string } | string;
37
+ /** The content of a `tombi.toml` config file at a given path. */
38
+ export interface ConfigFile {
39
+ content: string;
40
+ path: string;
41
+ }
42
+
43
+ /** @deprecated Use `string | ConfigFile` instead. */
44
+ export type Config = string | ConfigFile;
41
45
 
42
46
  /** Options shared by the formatter and linter. */
43
47
  export interface Options {
44
- config?: Config;
48
+ /**
49
+ * An in-memory `tombi.toml` configuration.
50
+ * When a string is provided, it is treated as the content of a virtual
51
+ * `tombi.toml`.
52
+ */
53
+ config?: string | ConfigFile;
45
54
  }
46
55
 
47
56
  /** Format a TOML document. */
@@ -58,7 +67,32 @@ export function lint(
58
67
  options?: Options,
59
68
  ): Promise<LintResult>;
60
69
 
61
- /** An error reported when an operation cannot be executed. */
62
- export interface TombiWasmError extends Error {
63
- readonly name: "TombiWasmError";
70
+ /**
71
+ * The error `format`/`lint` reject with when the configuration, a schema, or an
72
+ * I/O operation fails. Malformed `options` reject with a `TypeError` instead.
73
+ */
74
+ export interface TombiError extends Error {
75
+ readonly name: "TombiError";
64
76
  }
77
+
78
+ /** @deprecated Use {@link TombiError} instead. */
79
+ export type TombiWasmError = TombiError;
80
+
81
+ /** One entry of the browser-backed virtual workspace. */
82
+ export interface WorkspaceEntry {
83
+ uri: string;
84
+ kind?: "file" | "directory";
85
+ text?: string;
86
+ }
87
+
88
+ /** Update one file in the browser-backed virtual workspace. */
89
+ export function set_workspace_file(uri: string, text: string): void;
90
+
91
+ /** Remove one file from the browser-backed virtual workspace. */
92
+ export function remove_workspace_file(uri: string): void;
93
+
94
+ /** Replace the virtual workspace entries visible to `format`/`lint`. */
95
+ export function set_workspace_entries(entries: WorkspaceEntry[]): void;
96
+
97
+ /** Replace the virtual workspace files visible to `format`/`lint`. */
98
+ export function set_workspace_files(files: WorkspaceEntry[]): void;
package/dist/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "ya7010 <ya7010@outlook.com>"
6
6
  ],
7
7
  "description": "Tombi formatter, linter, and language server for WebAssembly",
8
- "version": "1.5.8",
8
+ "version": "1.6.0",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",
@@ -27,6 +27,26 @@ export function format(source: string, source_path: string, options: any): Promi
27
27
 
28
28
  export function lint(source: string, source_path: string, options: any): Promise<any>;
29
29
 
30
+ /**
31
+ * Remove one file from the browser-backed virtual workspace.
32
+ */
33
+ export function remove_workspace_file(uri: string): void;
34
+
35
+ /**
36
+ * Replace the virtual workspace entries visible to `format`/`lint`/`serve`.
37
+ */
38
+ export function set_workspace_entries(entries: any): void;
39
+
40
+ /**
41
+ * Update one file in the browser-backed virtual workspace.
42
+ */
43
+ export function set_workspace_file(uri: string, text: string): void;
44
+
45
+ /**
46
+ * Replace the virtual workspace files visible to `format`/`lint`/`serve`.
47
+ */
48
+ export function set_workspace_files(files: any): void;
49
+
30
50
  export function start(): void;
31
51
 
32
52
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
@@ -46,9 +66,13 @@ export interface InitOutput {
46
66
  readonly __wbg_set_range_start: (a: number, b: number) => void;
47
67
  readonly format: (a: number, b: number, c: number, d: number, e: number) => number;
48
68
  readonly lint: (a: number, b: number, c: number, d: number, e: number) => number;
69
+ readonly remove_workspace_file: (a: number, b: number, c: number) => void;
70
+ readonly set_workspace_entries: (a: number, b: number) => void;
71
+ readonly set_workspace_file: (a: number, b: number, c: number, d: number, e: number) => void;
72
+ readonly set_workspace_files: (a: number, b: number) => void;
49
73
  readonly start: () => void;
50
- readonly __wasm_bindgen_func_elem_9054: (a: number, b: number, c: number, d: number) => void;
51
- readonly __wasm_bindgen_func_elem_9056: (a: number, b: number, c: number, d: number) => void;
74
+ readonly __wasm_bindgen_func_elem_9200: (a: number, b: number, c: number, d: number) => void;
75
+ readonly __wasm_bindgen_func_elem_9202: (a: number, b: number, c: number, d: number) => void;
52
76
  readonly __wbindgen_export: (a: number, b: number) => number;
53
77
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
54
78
  readonly __wbindgen_export3: (a: number) => void;
@@ -134,6 +134,85 @@ export function lint(source, source_path, options) {
134
134
  return takeObject(ret);
135
135
  }
136
136
 
137
+ /**
138
+ * Remove one file from the browser-backed virtual workspace.
139
+ * @param {string} uri
140
+ */
141
+ export function remove_workspace_file(uri) {
142
+ try {
143
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
144
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_export, wasm.__wbindgen_export2);
145
+ const len0 = WASM_VECTOR_LEN;
146
+ wasm.remove_workspace_file(retptr, ptr0, len0);
147
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
148
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
149
+ if (r1) {
150
+ throw takeObject(r0);
151
+ }
152
+ } finally {
153
+ wasm.__wbindgen_add_to_stack_pointer(16);
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Replace the virtual workspace entries visible to `format`/`lint`/`serve`.
159
+ * @param {any} entries
160
+ */
161
+ export function set_workspace_entries(entries) {
162
+ try {
163
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
164
+ wasm.set_workspace_entries(retptr, addHeapObject(entries));
165
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
166
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
167
+ if (r1) {
168
+ throw takeObject(r0);
169
+ }
170
+ } finally {
171
+ wasm.__wbindgen_add_to_stack_pointer(16);
172
+ }
173
+ }
174
+
175
+ /**
176
+ * Update one file in the browser-backed virtual workspace.
177
+ * @param {string} uri
178
+ * @param {string} text
179
+ */
180
+ export function set_workspace_file(uri, text) {
181
+ try {
182
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
183
+ const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_export, wasm.__wbindgen_export2);
184
+ const len0 = WASM_VECTOR_LEN;
185
+ const ptr1 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
186
+ const len1 = WASM_VECTOR_LEN;
187
+ wasm.set_workspace_file(retptr, ptr0, len0, ptr1, len1);
188
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
189
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
190
+ if (r1) {
191
+ throw takeObject(r0);
192
+ }
193
+ } finally {
194
+ wasm.__wbindgen_add_to_stack_pointer(16);
195
+ }
196
+ }
197
+
198
+ /**
199
+ * Replace the virtual workspace files visible to `format`/`lint`/`serve`.
200
+ * @param {any} files
201
+ */
202
+ export function set_workspace_files(files) {
203
+ try {
204
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
205
+ wasm.set_workspace_files(retptr, addHeapObject(files));
206
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
207
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
208
+ if (r1) {
209
+ throw takeObject(r0);
210
+ }
211
+ } finally {
212
+ wasm.__wbindgen_add_to_stack_pointer(16);
213
+ }
214
+ }
215
+
137
216
  export function start() {
138
217
  wasm.start();
139
218
  }
@@ -378,6 +457,10 @@ function __wbg_get_imports() {
378
457
  const ret = new Map();
379
458
  return addHeapObject(ret);
380
459
  },
460
+ __wbg_new_9ca27d4bce9deee9: function(arg0, arg1) {
461
+ const ret = new TypeError(getStringFromWasm0(arg0, arg1));
462
+ return addHeapObject(ret);
463
+ },
381
464
  __wbg_new_a32a1ab6c6655abe: function(arg0, arg1) {
382
465
  const ret = new Error(getStringFromWasm0(arg0, arg1));
383
466
  return addHeapObject(ret);
@@ -401,7 +484,7 @@ function __wbg_get_imports() {
401
484
  const a = state0.a;
402
485
  state0.a = 0;
403
486
  try {
404
- return __wasm_bindgen_func_elem_9056(a, state0.b, arg0, arg1);
487
+ return __wasm_bindgen_func_elem_9202(a, state0.b, arg0, arg1);
405
488
  } finally {
406
489
  state0.a = a;
407
490
  }
@@ -455,10 +538,6 @@ function __wbg_get_imports() {
455
538
  __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
456
539
  getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
457
540
  },
458
- __wbg_set_a377297433dfea63: function() { return handleError(function (arg0, arg1, arg2) {
459
- const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
460
- return ret;
461
- }, arguments); },
462
541
  __wbg_set_bf6dde4923b9b059: function(arg0, arg1, arg2) {
463
542
  const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
464
543
  return addHeapObject(ret);
@@ -530,8 +609,8 @@ function __wbg_get_imports() {
530
609
  return addHeapObject(ret);
531
610
  },
532
611
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
533
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 2791, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
534
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_9054);
612
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 2812, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
613
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_9200);
535
614
  return addHeapObject(ret);
536
615
  },
537
616
  __wbindgen_generic_0000000000000002: function(arg0) {
@@ -568,14 +647,14 @@ function __wbg_get_imports() {
568
647
  };
569
648
  }
570
649
 
571
- function __wasm_bindgen_func_elem_9056(arg0, arg1, arg2, arg3) {
572
- wasm.__wasm_bindgen_func_elem_9056(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
650
+ function __wasm_bindgen_func_elem_9202(arg0, arg1, arg2, arg3) {
651
+ wasm.__wasm_bindgen_func_elem_9202(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
573
652
  }
574
653
 
575
- function __wasm_bindgen_func_elem_9054(arg0, arg1, arg2) {
654
+ function __wasm_bindgen_func_elem_9200(arg0, arg1, arg2) {
576
655
  try {
577
656
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
578
- wasm.__wasm_bindgen_func_elem_9054(retptr, arg0, arg1, addHeapObject(arg2));
657
+ wasm.__wasm_bindgen_func_elem_9200(retptr, arg0, arg1, addHeapObject(arg2));
579
658
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
580
659
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
581
660
  if (r1) {
Binary file
@@ -14,9 +14,13 @@ export const __wbg_set_range_end: (a: number, b: number) => void;
14
14
  export const __wbg_set_range_start: (a: number, b: number) => void;
15
15
  export const format: (a: number, b: number, c: number, d: number, e: number) => number;
16
16
  export const lint: (a: number, b: number, c: number, d: number, e: number) => number;
17
+ export const remove_workspace_file: (a: number, b: number, c: number) => void;
18
+ export const set_workspace_entries: (a: number, b: number) => void;
19
+ export const set_workspace_file: (a: number, b: number, c: number, d: number, e: number) => void;
20
+ export const set_workspace_files: (a: number, b: number) => void;
17
21
  export const start: () => void;
18
- export const __wasm_bindgen_func_elem_9054: (a: number, b: number, c: number, d: number) => void;
19
- export const __wasm_bindgen_func_elem_9056: (a: number, b: number, c: number, d: number) => void;
22
+ export const __wasm_bindgen_func_elem_9200: (a: number, b: number, c: number, d: number) => void;
23
+ export const __wasm_bindgen_func_elem_9202: (a: number, b: number, c: number, d: number) => void;
20
24
  export const __wbindgen_export: (a: number, b: number) => number;
21
25
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
22
26
  export const __wbindgen_export3: (a: number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tombi-toml/wasm-lib",
3
- "version": "1.5.8",
3
+ "version": "1.6.0",
4
4
  "description": "Tombi formatter and linter for WebAssembly",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "scripts": {
21
21
  "build": "rm -rf dist && cd ../../../rust/tombi-wasm && wasm-pack build --locked --target web --out-dir ../../typescript/@tombi-toml/wasm-lib/dist --out-name tombi_wasm -- --no-default-features --features lib && rm ../../typescript/@tombi-toml/wasm-lib/dist/.gitignore && cp ../../typescript/@tombi-toml/wasm-lib/types.d.ts ../../typescript/@tombi-toml/wasm-lib/dist/index.d.ts",
22
- "test": "pnpm run build && node ../../../rust/tombi-wasm/tests/lib-smoke.mjs",
22
+ "test": "node ../../../rust/tombi-wasm/tests/lib-smoke.mjs",
23
23
  "clean": "rm -rf dist"
24
24
  },
25
25
  "devDependencies": {