@matter/general 0.16.0-alpha.0-20250923-7147b4b8a → 0.16.0-alpha.0-20250926-3a74283f6
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/cjs/environment/Environmental.d.ts +1 -10
- package/dist/cjs/environment/Environmental.d.ts.map +1 -1
- package/dist/cjs/environment/Environmental.js.map +1 -1
- package/dist/cjs/environment/RuntimeService.d.ts +1 -5
- package/dist/cjs/environment/RuntimeService.d.ts.map +1 -1
- package/dist/cjs/environment/RuntimeService.js +1 -1
- package/dist/cjs/environment/RuntimeService.js.map +1 -1
- package/dist/cjs/environment/ServiceBundle.d.ts.map +1 -1
- package/dist/cjs/environment/ServiceBundle.js +1 -2
- package/dist/cjs/environment/ServiceBundle.js.map +1 -1
- package/dist/cjs/environment/VariableService.d.ts +1 -1
- package/dist/cjs/environment/VariableService.d.ts.map +1 -1
- package/dist/cjs/log/Diagnostic.d.ts +9 -57
- package/dist/cjs/log/Diagnostic.d.ts.map +1 -1
- package/dist/cjs/log/Diagnostic.js +28 -35
- package/dist/cjs/log/Diagnostic.js.map +2 -2
- package/dist/cjs/log/DiagnosticPresentation.d.ts +65 -0
- package/dist/cjs/log/DiagnosticPresentation.d.ts.map +1 -0
- package/dist/cjs/log/DiagnosticPresentation.js +47 -0
- package/dist/cjs/log/DiagnosticPresentation.js.map +6 -0
- package/dist/cjs/log/DiagnosticSource.d.ts +4 -3
- package/dist/cjs/log/DiagnosticSource.d.ts.map +1 -1
- package/dist/cjs/log/DiagnosticSource.js +4 -4
- package/dist/cjs/log/DiagnosticSource.js.map +1 -1
- package/dist/cjs/log/LogFormat.js +16 -16
- package/dist/cjs/log/LogFormat.js.map +1 -1
- package/dist/cjs/log/index.d.ts +1 -0
- package/dist/cjs/log/index.d.ts.map +1 -1
- package/dist/cjs/log/index.js +1 -0
- package/dist/cjs/log/index.js.map +1 -1
- package/dist/cjs/storage/StorageService.d.ts +1 -1
- package/dist/cjs/storage/StorageService.d.ts.map +1 -1
- package/dist/esm/environment/Environmental.d.ts +1 -10
- package/dist/esm/environment/Environmental.d.ts.map +1 -1
- package/dist/esm/environment/Environmental.js.map +1 -1
- package/dist/esm/environment/RuntimeService.d.ts +1 -5
- package/dist/esm/environment/RuntimeService.d.ts.map +1 -1
- package/dist/esm/environment/RuntimeService.js +1 -1
- package/dist/esm/environment/RuntimeService.js.map +1 -1
- package/dist/esm/environment/ServiceBundle.d.ts.map +1 -1
- package/dist/esm/environment/ServiceBundle.js +1 -2
- package/dist/esm/environment/ServiceBundle.js.map +1 -1
- package/dist/esm/environment/VariableService.d.ts +1 -1
- package/dist/esm/environment/VariableService.d.ts.map +1 -1
- package/dist/esm/log/Diagnostic.d.ts +9 -57
- package/dist/esm/log/Diagnostic.d.ts.map +1 -1
- package/dist/esm/log/Diagnostic.js +28 -35
- package/dist/esm/log/Diagnostic.js.map +2 -2
- package/dist/esm/log/DiagnosticPresentation.d.ts +65 -0
- package/dist/esm/log/DiagnosticPresentation.d.ts.map +1 -0
- package/dist/esm/log/DiagnosticPresentation.js +27 -0
- package/dist/esm/log/DiagnosticPresentation.js.map +6 -0
- package/dist/esm/log/DiagnosticSource.d.ts +4 -3
- package/dist/esm/log/DiagnosticSource.d.ts.map +1 -1
- package/dist/esm/log/DiagnosticSource.js +4 -4
- package/dist/esm/log/DiagnosticSource.js.map +1 -1
- package/dist/esm/log/LogFormat.js +16 -16
- package/dist/esm/log/LogFormat.js.map +1 -1
- package/dist/esm/log/index.d.ts +1 -0
- package/dist/esm/log/index.d.ts.map +1 -1
- package/dist/esm/log/index.js +1 -0
- package/dist/esm/log/index.js.map +1 -1
- package/dist/esm/storage/StorageService.d.ts +1 -1
- package/dist/esm/storage/StorageService.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/environment/Environmental.ts +1 -12
- package/src/environment/RuntimeService.ts +1 -6
- package/src/environment/ServiceBundle.ts +1 -2
- package/src/log/Diagnostic.ts +33 -84
- package/src/log/DiagnosticPresentation.ts +77 -0
- package/src/log/DiagnosticSource.ts +6 -4
- package/src/log/LogFormat.ts +17 -17
- package/src/log/index.ts +1 -0
|
@@ -18,7 +18,6 @@ const logger = new Logger("ServiceBundle");
|
|
|
18
18
|
*/
|
|
19
19
|
export class ServiceBundle extends BasicSet<ServiceBundle.Factory> {
|
|
20
20
|
static #default = new ServiceBundle();
|
|
21
|
-
#factories = new Set<(env: Environment) => void>();
|
|
22
21
|
#environments = new Set<WeakRef<Environment>>();
|
|
23
22
|
|
|
24
23
|
constructor() {
|
|
@@ -65,7 +64,7 @@ export class ServiceBundle extends BasicSet<ServiceBundle.Factory> {
|
|
|
65
64
|
* as well.
|
|
66
65
|
*/
|
|
67
66
|
deploy(env: Environment) {
|
|
68
|
-
for (const factory of this
|
|
67
|
+
for (const factory of this) {
|
|
69
68
|
this.#deployFactory(factory, env);
|
|
70
69
|
}
|
|
71
70
|
this.#environments.add(new WeakRef(env));
|
package/src/log/Diagnostic.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { Timestamp } from "#time/Timestamp.js";
|
|
|
10
10
|
import { Millis } from "#time/TimeUnit.js";
|
|
11
11
|
import { Bytes } from "#util/Bytes.js";
|
|
12
12
|
import type { Lifecycle } from "../util/Lifecycle.js";
|
|
13
|
+
import { DiagnosticPresentation } from "./DiagnosticPresentation.js";
|
|
13
14
|
import { LogLevel } from "./LogLevel.js";
|
|
14
15
|
|
|
15
16
|
let errorCollector: undefined | ((error: {}) => boolean);
|
|
@@ -20,10 +21,10 @@ let errorCollector: undefined | ((error: {}) => boolean);
|
|
|
20
21
|
* You can use the utility functions such as {@link Diagnostic.dict} to create
|
|
21
22
|
* Diagnostics from common value types.
|
|
22
23
|
*/
|
|
23
|
-
export
|
|
24
|
+
export type Diagnostic = {
|
|
24
25
|
readonly [Diagnostic.presentation]?: Diagnostic.Presentation | Lifecycle.Status;
|
|
25
26
|
readonly [Diagnostic.value]?: unknown;
|
|
26
|
-
}
|
|
27
|
+
};
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* Create a diagnostic giving a value a specific presentation.
|
|
@@ -51,64 +52,18 @@ export interface DiagnosticError extends Error {
|
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
export namespace Diagnostic {
|
|
54
|
-
export
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
List = "list",
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Render iterables without intervening spaces.
|
|
70
|
-
*/
|
|
71
|
-
Squash = "squash",
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* An emphasized diagnostic. Rendered to draw attention.
|
|
75
|
-
*/
|
|
76
|
-
Strong = "strong",
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* A deemphasized diagnostic. Rendered to draw less attention than default rendering.
|
|
80
|
-
*/
|
|
81
|
-
Weak = "weak",
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* A keylike diagnostic to list flags. The key gets suppressed and the value is rendered as a key.
|
|
85
|
-
*/
|
|
86
|
-
Flag = "flag",
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* An error message diagnostic.
|
|
90
|
-
*/
|
|
91
|
-
Error = "error",
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* A key/value diagnostic. Rendered as a group of key/value pairs.
|
|
95
|
-
*/
|
|
96
|
-
Dictionary = "dictionary",
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Path, resource or session identifier.
|
|
100
|
-
*/
|
|
101
|
-
Via = "via",
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Resource that was added.
|
|
105
|
-
*/
|
|
106
|
-
Added = "added",
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Resource that was removed.
|
|
110
|
-
*/
|
|
111
|
-
Deleted = "deleted",
|
|
55
|
+
export type Presentation = `${DiagnosticPresentation}`;
|
|
56
|
+
export const Presentation = DiagnosticPresentation;
|
|
57
|
+
|
|
58
|
+
export const presentation = DiagnosticPresentation.presentation;
|
|
59
|
+
export const value = DiagnosticPresentation.value;
|
|
60
|
+
|
|
61
|
+
export function presentationOf(diagnostic: unknown) {
|
|
62
|
+
return (diagnostic as Diagnostic)?.[Diagnostic.presentation];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function valueOf(diagnostic: unknown) {
|
|
66
|
+
return (diagnostic as Diagnostic)?.[Diagnostic.value];
|
|
112
67
|
}
|
|
113
68
|
|
|
114
69
|
export interface Context {
|
|
@@ -162,11 +117,8 @@ export namespace Diagnostic {
|
|
|
162
117
|
};
|
|
163
118
|
}
|
|
164
119
|
|
|
165
|
-
export const presentation = Symbol("presentation");
|
|
166
|
-
export const value = Symbol("value");
|
|
167
|
-
|
|
168
120
|
export interface Message {
|
|
169
|
-
[presentation]?:
|
|
121
|
+
[presentation]?: "message";
|
|
170
122
|
now: Date;
|
|
171
123
|
level: LogLevel;
|
|
172
124
|
facility: string;
|
|
@@ -194,28 +146,28 @@ export namespace Diagnostic {
|
|
|
194
146
|
* Create a value presented emphatically.
|
|
195
147
|
*/
|
|
196
148
|
export function strong(value: unknown) {
|
|
197
|
-
return Diagnostic(
|
|
149
|
+
return Diagnostic("strong", value);
|
|
198
150
|
}
|
|
199
151
|
|
|
200
152
|
/**
|
|
201
153
|
* Create a value presented less emphatically than the default.
|
|
202
154
|
*/
|
|
203
155
|
export function weak(value: unknown) {
|
|
204
|
-
return Diagnostic(
|
|
156
|
+
return Diagnostic("weak", value);
|
|
205
157
|
}
|
|
206
158
|
|
|
207
159
|
/**
|
|
208
160
|
* Create a value presented as key
|
|
209
161
|
*/
|
|
210
162
|
export function flag(value: string) {
|
|
211
|
-
return Diagnostic(
|
|
163
|
+
return Diagnostic("flag", value);
|
|
212
164
|
}
|
|
213
165
|
|
|
214
166
|
/**
|
|
215
167
|
* Create a value identifying the source of a diagnostic event.
|
|
216
168
|
*/
|
|
217
169
|
export function via(value: string) {
|
|
218
|
-
if ((value
|
|
170
|
+
if (Diagnostic.presentationOf(value)) {
|
|
219
171
|
return value;
|
|
220
172
|
}
|
|
221
173
|
const via = new String(value);
|
|
@@ -227,14 +179,14 @@ export namespace Diagnostic {
|
|
|
227
179
|
* Create a value identifying a resource that was added.
|
|
228
180
|
*/
|
|
229
181
|
export function added(value: unknown) {
|
|
230
|
-
return Diagnostic(
|
|
182
|
+
return Diagnostic("added", value);
|
|
231
183
|
}
|
|
232
184
|
|
|
233
185
|
/**
|
|
234
186
|
* Create a value identifying a resource that was removed.
|
|
235
187
|
*/
|
|
236
188
|
export function deleted(value: unknown) {
|
|
237
|
-
return Diagnostic(
|
|
189
|
+
return Diagnostic("deleted", value);
|
|
238
190
|
}
|
|
239
191
|
|
|
240
192
|
/**
|
|
@@ -256,14 +208,14 @@ export namespace Diagnostic {
|
|
|
256
208
|
* Create a value presenting as a list of separate lines.
|
|
257
209
|
*/
|
|
258
210
|
export function list(value: Iterable<unknown>) {
|
|
259
|
-
return Diagnostic(
|
|
211
|
+
return Diagnostic("list", value);
|
|
260
212
|
}
|
|
261
213
|
|
|
262
214
|
/**
|
|
263
215
|
* Create a value presenting as segments of the same string without intervening spaces.
|
|
264
216
|
*/
|
|
265
217
|
export function squash(...values: unknown[]) {
|
|
266
|
-
return Diagnostic(
|
|
218
|
+
return Diagnostic("squash", values);
|
|
267
219
|
}
|
|
268
220
|
|
|
269
221
|
/**
|
|
@@ -272,7 +224,7 @@ export namespace Diagnostic {
|
|
|
272
224
|
export function dict(entries: object, suppressUndefinedValues = true): Record<string, unknown> & Diagnostic {
|
|
273
225
|
const result: any = {
|
|
274
226
|
...entries,
|
|
275
|
-
[presentation]:
|
|
227
|
+
[presentation]: "dictionary",
|
|
276
228
|
};
|
|
277
229
|
if (suppressUndefinedValues) {
|
|
278
230
|
for (const key in result) {
|
|
@@ -535,7 +487,7 @@ export namespace Diagnostic {
|
|
|
535
487
|
}
|
|
536
488
|
}
|
|
537
489
|
|
|
538
|
-
function formatError(error: unknown, options: { messagePrefix?: string; parentStack?: string[] } = {}) {
|
|
490
|
+
function formatError(error: unknown, options: { messagePrefix?: string; parentStack?: string[] } = {}): unknown {
|
|
539
491
|
const { messagePrefix, parentStack } = options;
|
|
540
492
|
|
|
541
493
|
const messageAndStack = Diagnostic.messageAndStackFor(error, parentStack);
|
|
@@ -556,10 +508,7 @@ function formatError(error: unknown, options: { messagePrefix?: string; parentSt
|
|
|
556
508
|
}
|
|
557
509
|
messageDiagnostic.push(message);
|
|
558
510
|
|
|
559
|
-
message = Diagnostic.upgrade(
|
|
560
|
-
message,
|
|
561
|
-
Diagnostic(Diagnostic.Presentation.Error, Diagnostic.squash(...messageDiagnostic)),
|
|
562
|
-
);
|
|
511
|
+
message = Diagnostic.upgrade(message, Diagnostic("error", Diagnostic.squash(...messageDiagnostic)));
|
|
563
512
|
|
|
564
513
|
let cause, errors, secondary;
|
|
565
514
|
if (typeof error === "object" && error !== null) {
|
|
@@ -579,20 +528,20 @@ function formatError(error: unknown, options: { messagePrefix?: string; parentSt
|
|
|
579
528
|
return message;
|
|
580
529
|
}
|
|
581
530
|
|
|
582
|
-
const list: Array<
|
|
531
|
+
const list: Array<unknown> = [message];
|
|
583
532
|
if (stack === undefined) {
|
|
584
533
|
// Ensure line break in case of no stack
|
|
585
|
-
list.push(Diagnostic(
|
|
534
|
+
list.push(Diagnostic("list", []));
|
|
586
535
|
} else {
|
|
587
|
-
list.push(Diagnostic(
|
|
536
|
+
list.push(Diagnostic("list", stack));
|
|
588
537
|
}
|
|
589
538
|
|
|
590
539
|
// We render chained causes at the same level as the parent. They are displayed atomically and there can be
|
|
591
540
|
// only one so this is not ambiguous. If we did not do this we would end up with a lot of indent levels
|
|
592
541
|
for (; typeof cause === "object" && cause !== null; cause = (cause as Error).cause) {
|
|
593
542
|
let formatted = formatError(cause, { messagePrefix: "Caused by:", parentStack: stackLines });
|
|
594
|
-
if ((formatted
|
|
595
|
-
formatted = (formatted
|
|
543
|
+
if (Diagnostic.presentationOf(formatted) === "list") {
|
|
544
|
+
formatted = (Diagnostic.valueOf(formatted) ?? formatted) as string | Diagnostic;
|
|
596
545
|
}
|
|
597
546
|
|
|
598
547
|
if (Array.isArray(formatted)) {
|
|
@@ -619,5 +568,5 @@ function formatError(error: unknown, options: { messagePrefix?: string; parentSt
|
|
|
619
568
|
list.push(Diagnostic.list([formatError(secondary, { messagePrefix: "Secondary error during disposal:" })]));
|
|
620
569
|
}
|
|
621
570
|
|
|
622
|
-
return list
|
|
571
|
+
return list;
|
|
623
572
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export enum DiagnosticPresentation {
|
|
8
|
+
/**
|
|
9
|
+
* Render an object as a log message.
|
|
10
|
+
*/
|
|
11
|
+
Message = "message",
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* By default iterables render as a single line with spaces separating. The "list" presentation treats elements
|
|
15
|
+
* instead as separate entities which typically means presentation on different lines.
|
|
16
|
+
*
|
|
17
|
+
* Within an iterable, a list also serves to present contained items as subordinate to the previous item.
|
|
18
|
+
*/
|
|
19
|
+
List = "list",
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Render iterables without intervening spaces.
|
|
23
|
+
*/
|
|
24
|
+
Squash = "squash",
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* An emphasized diagnostic. Rendered to draw attention.
|
|
28
|
+
*/
|
|
29
|
+
Strong = "strong",
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A deemphasized diagnostic. Rendered to draw less attention than default rendering.
|
|
33
|
+
*/
|
|
34
|
+
Weak = "weak",
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A keylike diagnostic to list flags. The key gets suppressed and the value is rendered as a key.
|
|
38
|
+
*/
|
|
39
|
+
Flag = "flag",
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* An error message diagnostic.
|
|
43
|
+
*/
|
|
44
|
+
Error = "error",
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A key/value diagnostic. Rendered as a group of key/value pairs.
|
|
48
|
+
*/
|
|
49
|
+
Dictionary = "dictionary",
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Path, resource or session identifier.
|
|
53
|
+
*/
|
|
54
|
+
Via = "via",
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Resource that was added.
|
|
58
|
+
*/
|
|
59
|
+
Added = "added",
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Resource that was removed.
|
|
63
|
+
*/
|
|
64
|
+
Deleted = "deleted",
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export namespace DiagnosticPresentation {
|
|
68
|
+
/**
|
|
69
|
+
* Property name allowing objects to indicate their preferred presentation.
|
|
70
|
+
*/
|
|
71
|
+
export const presentation: unique symbol = Symbol("presentation");
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Property name that redirects diagnostic presentation.
|
|
75
|
+
*/
|
|
76
|
+
export const value: unique symbol = Symbol.for("value");
|
|
77
|
+
}
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
// Note we cannot import diagnostic directly as it causes circular reference
|
|
8
|
+
import type { Diagnostic } from "./Diagnostic.js";
|
|
9
|
+
import { DiagnosticPresentation } from "./DiagnosticPresentation.js";
|
|
8
10
|
|
|
9
11
|
const sources = new Set<Diagnostic>();
|
|
10
12
|
|
|
@@ -20,11 +22,11 @@ export const DiagnosticSource = {
|
|
|
20
22
|
sources.delete(source);
|
|
21
23
|
},
|
|
22
24
|
|
|
23
|
-
get [
|
|
24
|
-
return
|
|
25
|
+
get [DiagnosticPresentation.presentation]() {
|
|
26
|
+
return DiagnosticPresentation.List;
|
|
25
27
|
},
|
|
26
28
|
|
|
27
|
-
get [
|
|
29
|
+
get [DiagnosticPresentation.value]() {
|
|
28
30
|
return sources;
|
|
29
31
|
},
|
|
30
32
|
};
|
package/src/log/LogFormat.ts
CHANGED
|
@@ -535,7 +535,7 @@ function renderDictionary(value: object, formatter: Formatter) {
|
|
|
535
535
|
if (parts.length) {
|
|
536
536
|
parts.push(" ");
|
|
537
537
|
}
|
|
538
|
-
const suppressKey = isObject(v) && (v
|
|
538
|
+
const suppressKey = isObject(v) && Diagnostic.presentationOf(v) === "flag";
|
|
539
539
|
if (!suppressKey) {
|
|
540
540
|
parts.push(formatter.key(k));
|
|
541
541
|
}
|
|
@@ -558,7 +558,7 @@ function valueFor(value: unknown) {
|
|
|
558
558
|
return value;
|
|
559
559
|
}
|
|
560
560
|
if (Diagnostic.value in value) {
|
|
561
|
-
const proxied = (value
|
|
561
|
+
const proxied = Diagnostic.valueOf(value);
|
|
562
562
|
if (proxied === value) {
|
|
563
563
|
throw new InternalError("Diagnostic value proxies to itself");
|
|
564
564
|
}
|
|
@@ -571,10 +571,10 @@ function presentationFor(value: unknown) {
|
|
|
571
571
|
if (typeof value !== "object" || value === null) {
|
|
572
572
|
return;
|
|
573
573
|
}
|
|
574
|
-
if (Diagnostic.presentation in
|
|
575
|
-
return (value
|
|
574
|
+
if (Diagnostic.presentation in value) {
|
|
575
|
+
return Diagnostic.presentationOf(value);
|
|
576
576
|
}
|
|
577
|
-
const proxied = (value
|
|
577
|
+
const proxied = Diagnostic.valueOf(value);
|
|
578
578
|
if (proxied && proxied !== value) {
|
|
579
579
|
if (proxied === value) {
|
|
580
580
|
throw new InternalError("Diagnostic value proxies to itself");
|
|
@@ -602,43 +602,43 @@ function renderDiagnostic(value: unknown, formatter: Formatter, ignorePresentati
|
|
|
602
602
|
case undefined:
|
|
603
603
|
return renderValue(value, formatter, false);
|
|
604
604
|
|
|
605
|
-
case
|
|
605
|
+
case "message":
|
|
606
606
|
if (value === undefined || value === null) {
|
|
607
607
|
throw new ImplementationError("Diagnostic message is not an object");
|
|
608
608
|
}
|
|
609
609
|
return formatter.message(Diagnostic.message(value));
|
|
610
610
|
|
|
611
|
-
case
|
|
611
|
+
case "list":
|
|
612
612
|
if (typeof (value as Iterable<unknown>)?.[Symbol.iterator] !== "function") {
|
|
613
613
|
throw new ImplementationError("Diagnostic list is not iterable");
|
|
614
614
|
}
|
|
615
615
|
return renderIndentedList(value as Iterable<unknown>, formatter);
|
|
616
616
|
|
|
617
|
-
case
|
|
617
|
+
case "squash":
|
|
618
618
|
return renderValue(value, formatter, true);
|
|
619
619
|
|
|
620
|
-
case
|
|
620
|
+
case "strong":
|
|
621
621
|
return formatter.strong(() => renderDiagnostic(value, formatter, ignorePresentation));
|
|
622
622
|
|
|
623
|
-
case
|
|
623
|
+
case "weak":
|
|
624
624
|
return formatter.weak(() => renderDiagnostic(value, formatter, ignorePresentation));
|
|
625
625
|
|
|
626
|
-
case
|
|
626
|
+
case "added":
|
|
627
627
|
return formatter.added(() => renderDiagnostic(value, formatter, ignorePresentation));
|
|
628
628
|
|
|
629
|
-
case
|
|
629
|
+
case "deleted":
|
|
630
630
|
return formatter.deleted(() => renderDiagnostic(value, formatter, ignorePresentation));
|
|
631
631
|
|
|
632
|
-
case
|
|
632
|
+
case "flag":
|
|
633
633
|
return (value as string).length ? formatter.keylike(value as string) : "";
|
|
634
634
|
|
|
635
|
-
case
|
|
635
|
+
case "error":
|
|
636
636
|
return formatter.error(() => renderDiagnostic(value, formatter, ignorePresentation));
|
|
637
637
|
|
|
638
|
-
case
|
|
638
|
+
case "via":
|
|
639
639
|
return formatter.via(`${value}`);
|
|
640
640
|
|
|
641
|
-
case
|
|
641
|
+
case "dictionary":
|
|
642
642
|
if (typeof value !== "object") {
|
|
643
643
|
throw new ImplementationError("Diagnostic dictionary is not an object");
|
|
644
644
|
}
|
|
@@ -665,7 +665,7 @@ function sequenceToList(sequence: Iterable<unknown>) {
|
|
|
665
665
|
let group: unknown[] | undefined;
|
|
666
666
|
const list = Array<unknown[]>();
|
|
667
667
|
for (const value of sequence) {
|
|
668
|
-
if (presentationFor(value) ===
|
|
668
|
+
if (presentationFor(value) === "list") {
|
|
669
669
|
group = undefined;
|
|
670
670
|
list.push(value as unknown[]);
|
|
671
671
|
continue;
|