@dpuse/dpuse-shared 0.3.816 → 0.3.822
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/README.md +45 -9
- package/dist/{componentConfig.schema-Dxqinpxy.js → componentConfig.schema-DT3mO5rS.js} +80 -64
- package/dist/componentConfig.schema-DT3mO5rS.js.map +1 -0
- package/dist/dpuse-shared-component.es.js +2 -2
- package/dist/dpuse-shared-component.es.js.map +1 -0
- package/dist/dpuse-shared-componentDataView.es.js +1 -1
- package/dist/dpuse-shared-componentDataView.es.js.map +1 -0
- package/dist/dpuse-shared-componentModuleConnector.es.js +17 -17
- package/dist/dpuse-shared-componentModuleConnector.es.js.map +1 -0
- package/dist/dpuse-shared-componentModuleCookbook.es.js +5 -5
- package/dist/dpuse-shared-componentModuleCookbook.es.js.map +1 -0
- package/dist/dpuse-shared-componentModulePresenter.es.js +6 -6
- package/dist/dpuse-shared-componentModulePresenter.es.js.map +1 -0
- package/dist/dpuse-shared-componentModuleTool.es.js.map +1 -0
- package/dist/dpuse-shared-componentRecipe.es.js.map +1 -0
- package/dist/dpuse-shared-encoding.es.js +232 -120
- package/dist/dpuse-shared-encoding.es.js.map +1 -0
- package/dist/dpuse-shared-errors.es.js.map +1 -0
- package/dist/dpuse-shared-locale.es.js +8 -24
- package/dist/dpuse-shared-locale.es.js.map +1 -0
- package/dist/dpuse-shared-utilities.es.js +4 -11
- package/dist/dpuse-shared-utilities.es.js.map +1 -0
- package/dist/label-DexpXrnC.js +19 -0
- package/dist/label-DexpXrnC.js.map +1 -0
- package/dist/moduleConfig.schema-aYmFWSrn.js +22 -0
- package/dist/moduleConfig.schema-aYmFWSrn.js.map +1 -0
- package/dist/types/src/baseConfig.schema.d.ts +2 -2
- package/dist/types/src/component/componentConfig.schema.d.ts +13 -14
- package/dist/types/src/component/connection/index.d.ts +1 -1
- package/dist/types/src/component/context/model/dimension/hierarchy/index.d.ts +1 -1
- package/dist/types/src/component/context/model/entity/dataItem/index.d.ts +1 -1
- package/dist/types/src/component/context/model/entity/event/index.d.ts +1 -1
- package/dist/types/src/component/context/model/entity/index.d.ts +1 -1
- package/dist/types/src/component/context/model/entity/primaryMeasure/index.d.ts +1 -1
- package/dist/types/src/component/index.d.ts +3 -3
- package/dist/types/src/component/module/connector/connectorConfig.schema.d.ts +14 -14
- package/dist/types/src/component/module/cookbook/cookbookConfig.schema.d.ts +7 -7
- package/dist/types/src/component/module/engine/index.d.ts +3 -2
- package/dist/types/src/component/module/moduleConfig.schema.d.ts +7 -7
- package/dist/types/src/component/module/presenter/presenterConfig.schema.d.ts +7 -7
- package/dist/types/src/encoding/index.d.ts +467 -6
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/locale/index.d.ts +2 -14
- package/dist/types/src/locale/label.d.ts +13 -0
- package/dist/types/src/locale/locale.schema.d.ts +3 -3
- package/package.json +15 -9
- package/dist/moduleConfig.schema-B_EBeUaj.js +0 -22
- package/dist/types/eslint.config.d.ts +0 -3
- package/dist/types/tests/errors/index.test.d.ts +0 -1
- package/dist/types/tests/locale/index.test.d.ts +0 -1
- package/dist/types/tests/schema/index.test.d.ts +0 -1
- package/dist/types/tests/utilities/index.test.d.ts +0 -1
- package/dist/types/vite.config.d.ts +0 -2
- package/dist/types/vitest.config.d.ts +0 -2
|
@@ -1,355 +1,467 @@
|
|
|
1
|
-
|
|
1
|
+
import "./label-DexpXrnC.js";
|
|
2
2
|
//#region src/encoding/index.ts
|
|
3
3
|
var e = {
|
|
4
|
+
arabic: {
|
|
5
|
+
id: "arabic",
|
|
6
|
+
label: {
|
|
7
|
+
en: "Arabic",
|
|
8
|
+
es: "Árabe"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
baltic: {
|
|
12
|
+
id: "baltic",
|
|
13
|
+
label: {
|
|
14
|
+
en: "Baltic",
|
|
15
|
+
es: "Báltico"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
celtic: {
|
|
19
|
+
id: "celtic",
|
|
20
|
+
label: {
|
|
21
|
+
en: "Celtic",
|
|
22
|
+
es: "Celta"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
centralEuropean: {
|
|
26
|
+
id: "centralEuropean",
|
|
27
|
+
label: {
|
|
28
|
+
en: "Central European",
|
|
29
|
+
es: "Centroeuropeo"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
chineseSimplified: {
|
|
33
|
+
id: "chineseSimplified",
|
|
34
|
+
label: {
|
|
35
|
+
en: "Chinese Simplified",
|
|
36
|
+
es: "Chino simplificado"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
chineseTraditional: {
|
|
40
|
+
id: "chineseTraditional",
|
|
41
|
+
label: {
|
|
42
|
+
en: "Chinese Traditional",
|
|
43
|
+
es: "Chino tradicional"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
cyrillic: {
|
|
47
|
+
id: "cyrillic",
|
|
48
|
+
label: {
|
|
49
|
+
en: "Cyrillic",
|
|
50
|
+
es: "Cirílico"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
greek: {
|
|
54
|
+
id: "greek",
|
|
55
|
+
label: {
|
|
56
|
+
en: "Greek",
|
|
57
|
+
es: "Griego"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
hebrew: {
|
|
61
|
+
id: "hebrew",
|
|
62
|
+
label: {
|
|
63
|
+
en: "Hebrew",
|
|
64
|
+
es: "Hebreo"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
japanese: {
|
|
68
|
+
id: "japanese",
|
|
69
|
+
label: {
|
|
70
|
+
en: "Japanese",
|
|
71
|
+
es: "Japonés"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
korean: {
|
|
75
|
+
id: "korean",
|
|
76
|
+
label: {
|
|
77
|
+
en: "Korean",
|
|
78
|
+
es: "Coreano"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
nordic: {
|
|
82
|
+
id: "nordic",
|
|
83
|
+
label: {
|
|
84
|
+
en: "Nordic",
|
|
85
|
+
es: "Nórdico"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
other: {
|
|
89
|
+
id: "other",
|
|
90
|
+
label: {
|
|
91
|
+
en: "Other",
|
|
92
|
+
es: "Otro"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
romanian: {
|
|
96
|
+
id: "romanian",
|
|
97
|
+
label: {
|
|
98
|
+
en: "Romanian",
|
|
99
|
+
es: "Rumano"
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
southernEuropean: {
|
|
103
|
+
id: "southernEuropean",
|
|
104
|
+
label: {
|
|
105
|
+
en: "Southern European",
|
|
106
|
+
es: "Europeo meridional"
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
thai: {
|
|
110
|
+
id: "thai",
|
|
111
|
+
label: {
|
|
112
|
+
en: "Thai",
|
|
113
|
+
es: "Tailandés"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
turkish: {
|
|
117
|
+
id: "turkish",
|
|
118
|
+
label: {
|
|
119
|
+
en: "Turkish",
|
|
120
|
+
es: "Turco"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
unicode16: {
|
|
124
|
+
id: "unicode16",
|
|
125
|
+
label: {
|
|
126
|
+
en: "Unicode 16",
|
|
127
|
+
es: "Unicode 16"
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
unicode32: {
|
|
131
|
+
id: "unicode32",
|
|
132
|
+
label: {
|
|
133
|
+
en: "Unicode 32",
|
|
134
|
+
es: "Unicode 32"
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
vietnamese: {
|
|
138
|
+
id: "vietnamese",
|
|
139
|
+
label: {
|
|
140
|
+
en: "Vietnamese",
|
|
141
|
+
es: "Vietnamita"
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
western: {
|
|
145
|
+
id: "western",
|
|
146
|
+
label: {
|
|
147
|
+
en: "Western",
|
|
148
|
+
es: "Occidental"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}, t = {
|
|
4
152
|
ascii: {
|
|
5
153
|
id: "ascii",
|
|
6
|
-
|
|
7
|
-
label: "ascii",
|
|
154
|
+
groupId: null,
|
|
8
155
|
isDetectable: !1,
|
|
9
156
|
isDecodable: !0
|
|
10
157
|
},
|
|
11
158
|
big5: {
|
|
12
159
|
id: "big5",
|
|
13
|
-
|
|
14
|
-
label: "Chinese Traditional (big5)",
|
|
160
|
+
groupId: "chineseTraditional",
|
|
15
161
|
isDetectable: !0,
|
|
16
162
|
isDecodable: !0
|
|
17
163
|
},
|
|
18
164
|
"euc-jp": {
|
|
19
165
|
id: "euc-jp",
|
|
20
|
-
|
|
21
|
-
label: "Japanese (euc-jp)",
|
|
166
|
+
groupId: "japanese",
|
|
22
167
|
isDetectable: !0,
|
|
23
168
|
isDecodable: !0
|
|
24
169
|
},
|
|
25
170
|
"euc-kr": {
|
|
26
171
|
id: "euc-kr",
|
|
27
|
-
|
|
28
|
-
label: "Korean (euc-kr)",
|
|
172
|
+
groupId: "korean",
|
|
29
173
|
isDetectable: !0,
|
|
30
174
|
isDecodable: !0
|
|
31
175
|
},
|
|
32
176
|
gb18030: {
|
|
33
177
|
id: "gb18030",
|
|
34
|
-
|
|
35
|
-
label: "Chinese Simplified (gb18030)",
|
|
178
|
+
groupId: "chineseSimplified",
|
|
36
179
|
isDetectable: !0,
|
|
37
180
|
isDecodable: !0
|
|
38
181
|
},
|
|
39
182
|
gbk: {
|
|
40
183
|
id: "gbk",
|
|
41
|
-
|
|
42
|
-
label: "Chinese Simplified (gbk)",
|
|
184
|
+
groupId: "chineseSimplified",
|
|
43
185
|
isDetectable: !1,
|
|
44
186
|
isDecodable: !0
|
|
45
187
|
},
|
|
46
188
|
ibm866: {
|
|
47
189
|
id: "ibm866",
|
|
48
|
-
|
|
49
|
-
label: "Cyrillic (ibm866)",
|
|
190
|
+
groupId: "cyrillic",
|
|
50
191
|
isDetectable: !1,
|
|
51
192
|
isDecodable: !0
|
|
52
193
|
},
|
|
53
194
|
"iso-2022-cn": {
|
|
54
195
|
id: "iso-2022-cn",
|
|
55
|
-
|
|
56
|
-
label: "Japanese (iso-2022-cn)",
|
|
196
|
+
groupId: "chineseSimplified",
|
|
57
197
|
isDetectable: !0,
|
|
58
198
|
isDecodable: !1
|
|
59
199
|
},
|
|
60
200
|
"iso-2022-jp": {
|
|
61
201
|
id: "iso-2022-jp",
|
|
62
|
-
|
|
63
|
-
label: "Japanese (iso-2022-jp)",
|
|
202
|
+
groupId: "japanese",
|
|
64
203
|
isDetectable: !0,
|
|
65
204
|
isDecodable: !0
|
|
66
205
|
},
|
|
67
206
|
"iso-2022-kr": {
|
|
68
207
|
id: "iso-2022-kr",
|
|
69
|
-
|
|
70
|
-
label: "Korean (iso-2022-kr)",
|
|
208
|
+
groupId: "korean",
|
|
71
209
|
isDetectable: !0,
|
|
72
210
|
isDecodable: !1
|
|
73
211
|
},
|
|
74
212
|
"iso-8859-1": {
|
|
75
213
|
id: "iso-8859-1",
|
|
76
|
-
|
|
77
|
-
label: "Western (iso-8859-1)",
|
|
214
|
+
groupId: "western",
|
|
78
215
|
isDetectable: !0,
|
|
79
216
|
isDecodable: !0
|
|
80
217
|
},
|
|
81
218
|
"iso-8859-2": {
|
|
82
219
|
id: "iso-8859-2",
|
|
83
|
-
|
|
84
|
-
label: "Central European (iso-8859-2)",
|
|
220
|
+
groupId: "centralEuropean",
|
|
85
221
|
isDetectable: !0,
|
|
86
222
|
isDecodable: !0
|
|
87
223
|
},
|
|
88
224
|
"iso-8859-3": {
|
|
89
225
|
id: "iso-8859-3",
|
|
90
|
-
|
|
91
|
-
label: "Southern European (iso-8859-3)",
|
|
226
|
+
groupId: "southernEuropean",
|
|
92
227
|
isDetectable: !1,
|
|
93
228
|
isDecodable: !0
|
|
94
229
|
},
|
|
95
230
|
"iso-8859-4": {
|
|
96
231
|
id: "iso-8859-4",
|
|
97
|
-
|
|
98
|
-
label: "Baltic (iso-8859-4)",
|
|
232
|
+
groupId: "baltic",
|
|
99
233
|
isDetectable: !1,
|
|
100
234
|
isDecodable: !0
|
|
101
235
|
},
|
|
102
236
|
"iso-8859-5": {
|
|
103
237
|
id: "iso-8859-5",
|
|
104
|
-
|
|
105
|
-
label: "Cyrillic (iso-8859-5)",
|
|
238
|
+
groupId: "cyrillic",
|
|
106
239
|
isDetectable: !0,
|
|
107
240
|
isDecodable: !0
|
|
108
241
|
},
|
|
109
242
|
"iso-8859-6": {
|
|
110
243
|
id: "iso-8859-6",
|
|
111
|
-
|
|
112
|
-
label: "Arabic (iso-8859-6)",
|
|
244
|
+
groupId: "arabic",
|
|
113
245
|
isDetectable: !0,
|
|
114
246
|
isDecodable: !0
|
|
115
247
|
},
|
|
116
248
|
"iso-8859-7": {
|
|
117
249
|
id: "iso-8859-7",
|
|
118
|
-
|
|
119
|
-
label: "Greek (iso-8859-7)",
|
|
250
|
+
groupId: "greek",
|
|
120
251
|
isDetectable: !0,
|
|
121
252
|
isDecodable: !0
|
|
122
253
|
},
|
|
123
254
|
"iso-8859-8": {
|
|
124
255
|
id: "iso-8859-8",
|
|
125
|
-
|
|
126
|
-
label: "Hebrew (iso-8859-8)",
|
|
256
|
+
groupId: "hebrew",
|
|
127
257
|
isDetectable: !0,
|
|
128
258
|
isDecodable: !0
|
|
129
259
|
},
|
|
130
260
|
"iso-8859-9": {
|
|
131
261
|
id: "iso-8859-9",
|
|
132
|
-
|
|
133
|
-
label: "Turkish (iso-8859-9)",
|
|
262
|
+
groupId: "turkish",
|
|
134
263
|
isDetectable: !0,
|
|
135
264
|
isDecodable: !0
|
|
136
265
|
},
|
|
137
266
|
"iso-8859-10": {
|
|
138
267
|
id: "iso-8859-10",
|
|
139
|
-
|
|
140
|
-
label: "Nordic (iso-8859-10)",
|
|
268
|
+
groupId: "nordic",
|
|
141
269
|
isDetectable: !1,
|
|
142
270
|
isDecodable: !0
|
|
143
271
|
},
|
|
144
272
|
"iso-8859-11": {
|
|
145
273
|
id: "iso-8859-11",
|
|
146
|
-
|
|
147
|
-
label: "Thai (iso-8859-11)",
|
|
274
|
+
groupId: "thai",
|
|
148
275
|
isDetectable: !1,
|
|
149
276
|
isDecodable: !0
|
|
150
277
|
},
|
|
151
278
|
"iso-8859-13": {
|
|
152
279
|
id: "iso-8859-13",
|
|
153
|
-
|
|
154
|
-
label: "Baltic (iso-8859-13)",
|
|
280
|
+
groupId: "baltic",
|
|
155
281
|
isDetectable: !1,
|
|
156
282
|
isDecodable: !0
|
|
157
283
|
},
|
|
158
284
|
"iso-8859-14": {
|
|
159
285
|
id: "iso-8859-14",
|
|
160
|
-
|
|
161
|
-
label: "Celtic (iso-8859-14)",
|
|
286
|
+
groupId: "celtic",
|
|
162
287
|
isDetectable: !1,
|
|
163
288
|
isDecodable: !0
|
|
164
289
|
},
|
|
165
290
|
"iso-8859-15": {
|
|
166
291
|
id: "iso-8859-15",
|
|
167
|
-
|
|
168
|
-
label: "Western (iso-8859-15)",
|
|
292
|
+
groupId: "western",
|
|
169
293
|
isDetectable: !1,
|
|
170
294
|
isDecodable: !0
|
|
171
295
|
},
|
|
172
296
|
"iso-8859-16": {
|
|
173
297
|
id: "iso-8859-16",
|
|
174
|
-
|
|
175
|
-
label: "Romanian (iso-8859-16)",
|
|
298
|
+
groupId: "romanian",
|
|
176
299
|
isDetectable: !1,
|
|
177
300
|
isDecodable: !0
|
|
178
301
|
},
|
|
179
|
-
"
|
|
302
|
+
"koi8-r": {
|
|
180
303
|
id: "koi8-r",
|
|
181
|
-
|
|
182
|
-
label: "Cyrillic (koi8-r)",
|
|
304
|
+
groupId: "cyrillic",
|
|
183
305
|
isDetectable: !0,
|
|
184
306
|
isDecodable: !0
|
|
185
307
|
},
|
|
186
|
-
"
|
|
308
|
+
"koi8-u": {
|
|
187
309
|
id: "koi8-u",
|
|
188
|
-
|
|
189
|
-
label: "Cyrillic (koi8-u)",
|
|
310
|
+
groupId: "cyrillic",
|
|
190
311
|
isDetectable: !1,
|
|
191
312
|
isDecodable: !0
|
|
192
313
|
},
|
|
193
314
|
latin1: {
|
|
194
315
|
id: "latin1",
|
|
195
|
-
|
|
196
|
-
label: "Western (latin1)",
|
|
316
|
+
groupId: "western",
|
|
197
317
|
isDetectable: !1,
|
|
198
318
|
isDecodable: !0
|
|
199
319
|
},
|
|
200
320
|
macintosh: {
|
|
201
321
|
id: "macintosh",
|
|
202
|
-
|
|
203
|
-
label: "Western (macintosh)",
|
|
322
|
+
groupId: "western",
|
|
204
323
|
isDetectable: !1,
|
|
205
324
|
isDecodable: !0
|
|
206
325
|
},
|
|
207
326
|
shift_jis: {
|
|
208
327
|
id: "shift_jis",
|
|
209
|
-
|
|
210
|
-
label: "Japanese (shift_jis)",
|
|
328
|
+
groupId: "japanese",
|
|
211
329
|
isDetectable: !0,
|
|
212
330
|
isDecodable: !0
|
|
213
331
|
},
|
|
214
332
|
"tis-620": {
|
|
215
333
|
id: "tis-620",
|
|
216
|
-
|
|
217
|
-
label: "Thai (tis-620)",
|
|
334
|
+
groupId: "thai",
|
|
218
335
|
isDetectable: !1,
|
|
219
336
|
isDecodable: !0
|
|
220
337
|
},
|
|
221
|
-
|
|
222
|
-
id: "
|
|
223
|
-
|
|
224
|
-
label: "Unicode 16 (utf16)",
|
|
338
|
+
"utf-16": {
|
|
339
|
+
id: "utf-16",
|
|
340
|
+
groupId: "unicode16",
|
|
225
341
|
isDetectable: !1,
|
|
226
342
|
isDecodable: !0
|
|
227
343
|
},
|
|
228
|
-
|
|
229
|
-
id: "
|
|
230
|
-
|
|
231
|
-
label: "Unicode 16 (utf16be)",
|
|
344
|
+
"utf-16be": {
|
|
345
|
+
id: "utf-16be",
|
|
346
|
+
groupId: "unicode16",
|
|
232
347
|
isDetectable: !0,
|
|
233
348
|
isDecodable: !0
|
|
234
349
|
},
|
|
235
|
-
|
|
236
|
-
id: "
|
|
237
|
-
|
|
238
|
-
label: "Unicode 16 (utf16le)",
|
|
350
|
+
"utf-16le": {
|
|
351
|
+
id: "utf-16le",
|
|
352
|
+
groupId: "unicode16",
|
|
239
353
|
isDetectable: !0,
|
|
240
354
|
isDecodable: !0
|
|
241
355
|
},
|
|
242
|
-
|
|
243
|
-
id: "
|
|
244
|
-
|
|
245
|
-
label: "Unicode 32 (utf32be)",
|
|
356
|
+
"utf-32be": {
|
|
357
|
+
id: "utf-32be",
|
|
358
|
+
groupId: "unicode32",
|
|
246
359
|
isDetectable: !0,
|
|
247
360
|
isDecodable: !1
|
|
248
361
|
},
|
|
249
|
-
|
|
250
|
-
id: "
|
|
251
|
-
|
|
252
|
-
label: "Unicode 32 (utf32le)",
|
|
362
|
+
"utf-32le": {
|
|
363
|
+
id: "utf-32le",
|
|
364
|
+
groupId: "unicode32",
|
|
253
365
|
isDetectable: !0,
|
|
254
366
|
isDecodable: !1
|
|
255
367
|
},
|
|
256
|
-
|
|
257
|
-
id: "
|
|
258
|
-
|
|
259
|
-
label: "utf8",
|
|
368
|
+
"utf-8": {
|
|
369
|
+
id: "utf-8",
|
|
370
|
+
groupId: null,
|
|
260
371
|
isDetectable: !0,
|
|
261
372
|
isDecodable: !0
|
|
262
373
|
},
|
|
263
374
|
"windows-1250": {
|
|
264
375
|
id: "windows-1250",
|
|
265
|
-
|
|
266
|
-
label: "Central European (windows-1250)",
|
|
376
|
+
groupId: "centralEuropean",
|
|
267
377
|
isDetectable: !0,
|
|
268
378
|
isDecodable: !0
|
|
269
379
|
},
|
|
270
380
|
"windows-1251": {
|
|
271
381
|
id: "windows-1251",
|
|
272
|
-
|
|
273
|
-
label: "Cyrillic (windows-1251)",
|
|
382
|
+
groupId: "cyrillic",
|
|
274
383
|
isDetectable: !0,
|
|
275
384
|
isDecodable: !0
|
|
276
385
|
},
|
|
277
386
|
"windows-1252": {
|
|
278
387
|
id: "windows-1252",
|
|
279
|
-
|
|
280
|
-
label: "Western (windows-1252)",
|
|
388
|
+
groupId: "western",
|
|
281
389
|
isDetectable: !0,
|
|
282
390
|
isDecodable: !0
|
|
283
391
|
},
|
|
284
392
|
"windows-1253": {
|
|
285
393
|
id: "windows-1253",
|
|
286
|
-
|
|
287
|
-
label: "Greek (windows-1253)",
|
|
394
|
+
groupId: "greek",
|
|
288
395
|
isDetectable: !0,
|
|
289
396
|
isDecodable: !0
|
|
290
397
|
},
|
|
291
398
|
"windows-1254": {
|
|
292
399
|
id: "windows-1254",
|
|
293
|
-
|
|
294
|
-
label: "Turkish (windows-1254)",
|
|
400
|
+
groupId: "turkish",
|
|
295
401
|
isDetectable: !0,
|
|
296
402
|
isDecodable: !0
|
|
297
403
|
},
|
|
298
404
|
"windows-1255": {
|
|
299
405
|
id: "windows-1255",
|
|
300
|
-
|
|
301
|
-
label: "Hebrew (windows-1255)",
|
|
406
|
+
groupId: "hebrew",
|
|
302
407
|
isDetectable: !0,
|
|
303
408
|
isDecodable: !0
|
|
304
409
|
},
|
|
305
410
|
"windows-1256": {
|
|
306
411
|
id: "windows-1256",
|
|
307
|
-
|
|
308
|
-
label: "Arabic (windows-1256)",
|
|
412
|
+
groupId: "arabic",
|
|
309
413
|
isDetectable: !0,
|
|
310
414
|
isDecodable: !0
|
|
311
415
|
},
|
|
312
416
|
"windows-1257": {
|
|
313
417
|
id: "windows-1257",
|
|
314
|
-
|
|
315
|
-
label: "Baltic (windows-1257)",
|
|
418
|
+
groupId: "baltic",
|
|
316
419
|
isDetectable: !1,
|
|
317
420
|
isDecodable: !0
|
|
318
421
|
},
|
|
319
422
|
"windows-1258": {
|
|
320
423
|
id: "windows-1258",
|
|
321
|
-
|
|
322
|
-
label: "Vietnamese (windows-1258)",
|
|
424
|
+
groupId: "vietnamese",
|
|
323
425
|
isDetectable: !1,
|
|
324
426
|
isDecodable: !0
|
|
325
427
|
},
|
|
326
428
|
"windows-874": {
|
|
327
429
|
id: "windows-874",
|
|
328
|
-
|
|
329
|
-
label: "Thai (windows-874)",
|
|
430
|
+
groupId: "thai",
|
|
330
431
|
isDetectable: !1,
|
|
331
432
|
isDecodable: !0
|
|
332
433
|
},
|
|
333
434
|
"x-mac-cyrillic": {
|
|
334
435
|
id: "x-mac-cyrillic",
|
|
335
|
-
|
|
336
|
-
label: "Cyrillic (x-mac-cyrillic)",
|
|
436
|
+
groupId: "cyrillic",
|
|
337
437
|
isDetectable: !1,
|
|
338
438
|
isDecodable: !0
|
|
339
439
|
},
|
|
340
440
|
"x-user-defined": {
|
|
341
441
|
id: "x-user-defined",
|
|
342
|
-
|
|
343
|
-
label: "Other (x-user-defined)",
|
|
442
|
+
groupId: "other",
|
|
344
443
|
isDetectable: !1,
|
|
345
444
|
isDecodable: !0
|
|
346
445
|
}
|
|
347
|
-
};
|
|
348
|
-
function
|
|
349
|
-
return
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
446
|
+
}, n = e, r = t;
|
|
447
|
+
function i(e) {
|
|
448
|
+
return Object.hasOwn(r, e);
|
|
449
|
+
}
|
|
450
|
+
function a(e = "en") {
|
|
451
|
+
return Array.from(Object.values(r), ({ groupId: t, id: n, isDecodable: r, isDetectable: i }) => {
|
|
452
|
+
let a = t == null ? "" : o(t, e);
|
|
453
|
+
return {
|
|
454
|
+
id: n,
|
|
455
|
+
groupLabel: a,
|
|
456
|
+
label: a ? `${a} (${n})` : n,
|
|
457
|
+
isDetectable: i,
|
|
458
|
+
isDecodable: r
|
|
459
|
+
};
|
|
460
|
+
}).toSorted((t, n) => t.groupLabel.localeCompare(n.groupLabel, e) || t.label.localeCompare(n.label, e));
|
|
461
|
+
}
|
|
462
|
+
function o(e, t) {
|
|
463
|
+
let r = n[e].label;
|
|
464
|
+
return r[t] ?? r.en ?? e;
|
|
353
465
|
}
|
|
354
466
|
//#endregion
|
|
355
|
-
export {
|
|
467
|
+
export { n as ENCODING_GROUP_CONFIG_MAP, r as ENCODING_TYPE_CONFIG_MAP, a as getEncodingTypeConfigs, i as isEncodingTypeId };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dpuse-shared-encoding.es.js","names":[],"sources":["../src/encoding/index.ts"],"sourcesContent":["// ── DPUse Framework\nimport { DEFAULT_LOCALE_ID, type LocaleId, type LocaleLabel } from '@/locale/label';\n\n// ── Types ────────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nexport type EncodingGroupId = keyof typeof ENCODING_GROUP_CONFIG_DATA;\nexport type EncodingTypeId = keyof typeof ENCODING_TYPE_CONFIG_DATA;\n\nexport interface EncodingGroupConfig {\n id: EncodingGroupId;\n label: LocaleLabel;\n}\n\nexport interface EncodingTypeConfig {\n id: EncodingTypeId;\n groupId: EncodingGroupId | null; // Null for encodings that belong to no group, e.g. 'ascii' and 'utf-8'.\n isDetectable: boolean;\n isDecodable: boolean;\n}\nexport interface EncodingTypeConfigLocalised {\n id: EncodingTypeId;\n groupLabel: string;\n label: string;\n isDetectable: boolean;\n isDecodable: boolean;\n}\n\nexport interface EncodingDetectionConfig {\n id: EncodingTypeId;\n confidenceLevel: number | undefined;\n}\n\n// ── Constants ────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nconst ENCODING_GROUP_CONFIG_DATA = {\n arabic: { id: 'arabic', label: { en: 'Arabic', es: 'Árabe' } },\n baltic: { id: 'baltic', label: { en: 'Baltic', es: 'Báltico' } },\n celtic: { id: 'celtic', label: { en: 'Celtic', es: 'Celta' } },\n centralEuropean: { id: 'centralEuropean', label: { en: 'Central European', es: 'Centroeuropeo' } },\n chineseSimplified: { id: 'chineseSimplified', label: { en: 'Chinese Simplified', es: 'Chino simplificado' } },\n chineseTraditional: { id: 'chineseTraditional', label: { en: 'Chinese Traditional', es: 'Chino tradicional' } },\n cyrillic: { id: 'cyrillic', label: { en: 'Cyrillic', es: 'Cirílico' } },\n greek: { id: 'greek', label: { en: 'Greek', es: 'Griego' } },\n hebrew: { id: 'hebrew', label: { en: 'Hebrew', es: 'Hebreo' } },\n japanese: { id: 'japanese', label: { en: 'Japanese', es: 'Japonés' } },\n korean: { id: 'korean', label: { en: 'Korean', es: 'Coreano' } },\n nordic: { id: 'nordic', label: { en: 'Nordic', es: 'Nórdico' } },\n other: { id: 'other', label: { en: 'Other', es: 'Otro' } },\n romanian: { id: 'romanian', label: { en: 'Romanian', es: 'Rumano' } },\n southernEuropean: { id: 'southernEuropean', label: { en: 'Southern European', es: 'Europeo meridional' } },\n thai: { id: 'thai', label: { en: 'Thai', es: 'Tailandés' } },\n turkish: { id: 'turkish', label: { en: 'Turkish', es: 'Turco' } },\n unicode16: { id: 'unicode16', label: { en: 'Unicode 16', es: 'Unicode 16' } },\n unicode32: { id: 'unicode32', label: { en: 'Unicode 32', es: 'Unicode 32' } },\n vietnamese: { id: 'vietnamese', label: { en: 'Vietnamese', es: 'Vietnamita' } },\n western: { id: 'western', label: { en: 'Western', es: 'Occidental' } }\n} as const satisfies Record<string, { id: string; label: LocaleLabel }>;\n\nconst ENCODING_TYPE_CONFIG_DATA = {\n ascii: { id: 'ascii', groupId: null, isDetectable: false, isDecodable: true },\n big5: { id: 'big5', groupId: 'chineseTraditional', isDetectable: true, isDecodable: true },\n 'euc-jp': { id: 'euc-jp', groupId: 'japanese', isDetectable: true, isDecodable: true },\n 'euc-kr': { id: 'euc-kr', groupId: 'korean', isDetectable: true, isDecodable: true },\n gb18030: { id: 'gb18030', groupId: 'chineseSimplified', isDetectable: true, isDecodable: true },\n gbk: { id: 'gbk', groupId: 'chineseSimplified', isDetectable: false, isDecodable: true },\n ibm866: { id: 'ibm866', groupId: 'cyrillic', isDetectable: false, isDecodable: true },\n 'iso-2022-cn': { id: 'iso-2022-cn', groupId: 'chineseSimplified', isDetectable: true, isDecodable: false },\n 'iso-2022-jp': { id: 'iso-2022-jp', groupId: 'japanese', isDetectable: true, isDecodable: true },\n 'iso-2022-kr': { id: 'iso-2022-kr', groupId: 'korean', isDetectable: true, isDecodable: false },\n 'iso-8859-1': { id: 'iso-8859-1', groupId: 'western', isDetectable: true, isDecodable: true },\n 'iso-8859-2': { id: 'iso-8859-2', groupId: 'centralEuropean', isDetectable: true, isDecodable: true },\n 'iso-8859-3': { id: 'iso-8859-3', groupId: 'southernEuropean', isDetectable: false, isDecodable: true },\n 'iso-8859-4': { id: 'iso-8859-4', groupId: 'baltic', isDetectable: false, isDecodable: true },\n 'iso-8859-5': { id: 'iso-8859-5', groupId: 'cyrillic', isDetectable: true, isDecodable: true },\n 'iso-8859-6': { id: 'iso-8859-6', groupId: 'arabic', isDetectable: true, isDecodable: true },\n 'iso-8859-7': { id: 'iso-8859-7', groupId: 'greek', isDetectable: true, isDecodable: true },\n 'iso-8859-8': { id: 'iso-8859-8', groupId: 'hebrew', isDetectable: true, isDecodable: true },\n 'iso-8859-9': { id: 'iso-8859-9', groupId: 'turkish', isDetectable: true, isDecodable: true },\n 'iso-8859-10': { id: 'iso-8859-10', groupId: 'nordic', isDetectable: false, isDecodable: true },\n 'iso-8859-11': { id: 'iso-8859-11', groupId: 'thai', isDetectable: false, isDecodable: true },\n 'iso-8859-13': { id: 'iso-8859-13', groupId: 'baltic', isDetectable: false, isDecodable: true },\n 'iso-8859-14': { id: 'iso-8859-14', groupId: 'celtic', isDetectable: false, isDecodable: true },\n 'iso-8859-15': { id: 'iso-8859-15', groupId: 'western', isDetectable: false, isDecodable: true },\n 'iso-8859-16': { id: 'iso-8859-16', groupId: 'romanian', isDetectable: false, isDecodable: true },\n 'koi8-r': { id: 'koi8-r', groupId: 'cyrillic', isDetectable: true, isDecodable: true },\n 'koi8-u': { id: 'koi8-u', groupId: 'cyrillic', isDetectable: false, isDecodable: true },\n latin1: { id: 'latin1', groupId: 'western', isDetectable: false, isDecodable: true },\n macintosh: { id: 'macintosh', groupId: 'western', isDetectable: false, isDecodable: true },\n shift_jis: { id: 'shift_jis', groupId: 'japanese', isDetectable: true, isDecodable: true },\n 'tis-620': { id: 'tis-620', groupId: 'thai', isDetectable: false, isDecodable: true },\n 'utf-16': { id: 'utf-16', groupId: 'unicode16', isDetectable: false, isDecodable: true },\n 'utf-16be': { id: 'utf-16be', groupId: 'unicode16', isDetectable: true, isDecodable: true },\n 'utf-16le': { id: 'utf-16le', groupId: 'unicode16', isDetectable: true, isDecodable: true },\n 'utf-32be': { id: 'utf-32be', groupId: 'unicode32', isDetectable: true, isDecodable: false },\n 'utf-32le': { id: 'utf-32le', groupId: 'unicode32', isDetectable: true, isDecodable: false },\n 'utf-8': { id: 'utf-8', groupId: null, isDetectable: true, isDecodable: true },\n 'windows-1250': { id: 'windows-1250', groupId: 'centralEuropean', isDetectable: true, isDecodable: true },\n 'windows-1251': { id: 'windows-1251', groupId: 'cyrillic', isDetectable: true, isDecodable: true },\n 'windows-1252': { id: 'windows-1252', groupId: 'western', isDetectable: true, isDecodable: true },\n 'windows-1253': { id: 'windows-1253', groupId: 'greek', isDetectable: true, isDecodable: true },\n 'windows-1254': { id: 'windows-1254', groupId: 'turkish', isDetectable: true, isDecodable: true },\n 'windows-1255': { id: 'windows-1255', groupId: 'hebrew', isDetectable: true, isDecodable: true },\n 'windows-1256': { id: 'windows-1256', groupId: 'arabic', isDetectable: true, isDecodable: true },\n 'windows-1257': { id: 'windows-1257', groupId: 'baltic', isDetectable: false, isDecodable: true },\n 'windows-1258': { id: 'windows-1258', groupId: 'vietnamese', isDetectable: false, isDecodable: true },\n 'windows-874': { id: 'windows-874', groupId: 'thai', isDetectable: false, isDecodable: true },\n 'x-mac-cyrillic': { id: 'x-mac-cyrillic', groupId: 'cyrillic', isDetectable: false, isDecodable: true },\n 'x-user-defined': { id: 'x-user-defined', groupId: 'other', isDetectable: false, isDecodable: true }\n} as const satisfies Record<string, { id: string; groupId: keyof typeof ENCODING_GROUP_CONFIG_DATA | null; isDetectable: boolean; isDecodable: boolean }>;\n\nexport const ENCODING_GROUP_CONFIG_MAP = ENCODING_GROUP_CONFIG_DATA as Record<EncodingGroupId, EncodingGroupConfig>;\nexport const ENCODING_TYPE_CONFIG_MAP = ENCODING_TYPE_CONFIG_DATA as Record<EncodingTypeId, EncodingTypeConfig>;\n\n// ── Actions ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Narrows a name from outside the app, such as one reported by encoding detection, to a known encoding id. Check with\n// this once where the name arrives, so everything after it works with 'EncodingTypeId'.\nexport function isEncodingTypeId(value: string): value is EncodingTypeId {\n return Object.hasOwn(ENCODING_TYPE_CONFIG_MAP, value);\n}\n\nexport function getEncodingTypeConfigs(localeId: LocaleId = DEFAULT_LOCALE_ID): EncodingTypeConfigLocalised[] {\n const encodingTypeConfigs: EncodingTypeConfigLocalised[] = Array.from(Object.values(ENCODING_TYPE_CONFIG_MAP), ({ groupId, id, isDecodable, isDetectable }) => {\n const groupLabel = groupId == null ? '' : resolveGroupLabel(groupId, localeId);\n return { id, groupLabel, label: groupLabel ? `${groupLabel} (${id})` : id, isDetectable, isDecodable };\n });\n return encodingTypeConfigs.toSorted((left, right) => left.groupLabel.localeCompare(right.groupLabel, localeId) || left.label.localeCompare(right.label, localeId));\n}\n\n// ── Helpers ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\nfunction resolveGroupLabel(groupId: EncodingGroupId, localeId: LocaleId): string {\n const labels = ENCODING_GROUP_CONFIG_MAP[groupId].label;\n return labels[localeId] ?? labels[DEFAULT_LOCALE_ID] ?? groupId;\n}\n"],"mappings":";;AAkCA,IAAM,IAA6B;CAC/B,QAAQ;EAAE,IAAI;EAAU,OAAO;GAAE,IAAI;GAAU,IAAI;EAAQ;CAAE;CAC7D,QAAQ;EAAE,IAAI;EAAU,OAAO;GAAE,IAAI;GAAU,IAAI;EAAU;CAAE;CAC/D,QAAQ;EAAE,IAAI;EAAU,OAAO;GAAE,IAAI;GAAU,IAAI;EAAQ;CAAE;CAC7D,iBAAiB;EAAE,IAAI;EAAmB,OAAO;GAAE,IAAI;GAAoB,IAAI;EAAgB;CAAE;CACjG,mBAAmB;EAAE,IAAI;EAAqB,OAAO;GAAE,IAAI;GAAsB,IAAI;EAAqB;CAAE;CAC5G,oBAAoB;EAAE,IAAI;EAAsB,OAAO;GAAE,IAAI;GAAuB,IAAI;EAAoB;CAAE;C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AAc,EAAM,OAAO,CAAQ,CAAC;AACrK;AAIA,SAAS,EAAkB,GAA0B,GAA4B;CAC7E,IAAM,IAAS,EAA0B,EAAQ,CAAC;CAClD,OAAO,EAAO,MAAa,EAAA,MAA6B;AAC5D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dpuse-shared-errors.es.js","names":[],"sources":["../src/errors/index.ts"],"sourcesContent":["// ── Types ────────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Serializable representation of an error; used for transporting errors across api and worker boundaries\nexport interface SerialisedError {\n data: Record<string, unknown> | undefined;\n locator: string; // Error locator 'package.module.method'\n message: string; // Human-readable error message\n name: string; // Error class or type name\n stack: string | undefined; // Stack trace if available\n}\n\n// ── Constants ───────────────────────────────────────────────────────────────────────────────────────────────────────\n\nconst RESPONSE_ERROR_BODY_LIMIT = 2048;\n\n// ── Errors ───────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Base class for all DPUse errors; includes a locator for the error; never thrown directly\nexport class DPUseError extends Error {\n readonly data: Record<string, unknown> | undefined;\n readonly locator: string; // Error locator 'package.module.method'\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, options);\n this.name = 'DPUseError';\n this.data = data;\n this.locator = locator;\n }\n}\n\n// Thrown when an app (studio/assistant) error occurs\nexport class AppError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'AppError';\n }\n}\n\n// Thrown when an API request fails\nexport class APIError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'APIError';\n }\n}\n\n// Thrown when an engine request fails\nexport class EngineError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'EngineError';\n }\n}\n\n// Thrown when an connector operation fails; will always be wrapped in an engine error\nexport class ConnectorError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'ConnectorError';\n }\n}\n\n// Thrown when an HTTP request fails; may include a sanitized portion of the response body for diagnostic purposes\nexport class FetchError extends DPUseError {\n constructor(message: string, locator: string, data?: Record<string, unknown>, options?: ErrorOptions) {\n super(message, locator, data, options);\n this.name = 'FetchError';\n }\n}\n\n// ── Actions ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Builds a fetch error from an HTTP response; includes a text copy of the response body\nexport async function buildFetchError(response: { status: number; statusText: string; text: () => Promise<string> }, message: string, locator: string): Promise<FetchError> {\n const responseStatusStuff = ` - ${response.statusText}`;\n const fetchMessage = `${message} Response status '${String(response.status)}${response.statusText ? responseStatusStuff : ''}' received.`;\n let bodyText: string;\n try {\n bodyText = await response.text();\n } catch (error) {\n const normalised = normalizeToError(error);\n bodyText = `<body unavailable: ${normalised.message}>`;\n }\n return new FetchError(fetchMessage, locator, { body: sanitizeResponseErrorBody(bodyText) });\n}\n\n// Concatenates serialized error messages into a single string\nexport function concatenateSerialisedErrorMessages(serialisedErrors: SerialisedError[]): string {\n return serialisedErrors.map((serialisedError) => serialisedError.message).join(' ');\n}\n\n// Ignore best-effort cleanup errors to keep teardown noise-free\nexport function ignoreErrors(action: () => void): void {\n try {\n action();\n } catch {\n // Intentionally ignore errors\n }\n}\n\n// Normalizes an unknown thrown value into an error\nexport function normalizeToError(value: unknown): Error {\n if (value instanceof Error) return value;\n if (typeof value === 'string') return new Error(value);\n if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') return new Error(String(value));\n if (typeof value === 'symbol') return new Error(value.description ?? 'Unknown error');\n if (typeof value === 'object') {\n try {\n return new Error(JSON.stringify(value));\n } catch {\n return new Error('Unknown error');\n }\n }\n return new Error('Unknown error');\n}\n\n// Serializes an error and its cause chain into a array of serialised error objects;\n// errors are ordered from outermost to root cause;\n// cycles in the cause chain are safely ignored;\n// messages are normalized to end with punctuation\nexport function serialiseError(error?: unknown): SerialisedError[] {\n const seenCauses = new Set();\n const serialisedErrors: SerialisedError[] = [];\n let cause: Error | null = normalizeToError(error);\n while (cause != null && !seenCauses.has(cause)) {\n seenCauses.add(cause);\n const [serialisedError, nextCause] = serialiseSingleError(cause);\n if (!/(?:\\.{3}|[.!?])$/.test(serialisedError.message)) serialisedError.message += '.';\n serialisedErrors.push(serialisedError);\n cause = nextCause;\n }\n return serialisedErrors;\n}\n\n// Unserialises an array of serialised error objects back into an error with a cause chain;\n// reconstructs the appropriate error class based on serialized properties;\n// chains errors from outermost to root cause using the `cause` option;\n// returns a placeholder error if the input array is empty\nexport function unserialiseError(serialisedErrors: SerialisedError[]): Error {\n // Build the error chain from root cause (end) to outermost (start)\n let rebuiltError: Error | undefined;\n for (const serialised of serialisedErrors.toReversed()) {\n const error = reconstructError(serialised, rebuiltError);\n if (serialised.stack !== undefined) error.stack = serialised.stack; // Restore stack trace if available\n rebuiltError = error;\n }\n return rebuiltError ?? new Error('No error to unserialise.');\n}\n\n// ── Helpers ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n// Builds a fallback message for non-error throwables\nfunction buildFallbackMessage(cause: unknown): string {\n let fallbackMessage: string;\n try {\n fallbackMessage = JSON.stringify(cause);\n } catch {\n if (typeof cause === 'symbol') fallbackMessage = cause.description ?? 'Unknown error';\n else if (typeof cause === 'bigint') fallbackMessage = cause.toString();\n else fallbackMessage = 'Unknown error';\n }\n if (fallbackMessage === '') fallbackMessage = 'Unknown error';\n return fallbackMessage;\n}\n\nfunction reconstructError(serialised: SerialisedError, cause: Error | undefined): Error {\n switch (serialised.name) {\n case 'APIError':\n return new APIError(serialised.message, serialised.locator, serialised.data, { cause });\n case 'AppError':\n return new AppError(serialised.message, serialised.locator, serialised.data, { cause });\n case 'ConnectorError':\n return new ConnectorError(serialised.message, serialised.locator, serialised.data, { cause });\n case 'EngineError':\n return new EngineError(serialised.message, serialised.locator, serialised.data, { cause });\n case 'FetchError':\n return new FetchError(serialised.message, serialised.locator, serialised.data, { cause });\n default: {\n const name = serialised.name;\n return new (class extends Error {\n override name = name;\n })(serialised.message, { cause });\n }\n }\n}\n\n// Sanitizes a response body; limits body size to avoid excessive payloads when logging\nfunction sanitizeResponseErrorBody(body?: string): string | undefined {\n if (body == null || body === '') return undefined;\n return body.length > RESPONSE_ERROR_BODY_LIMIT ? `${body.slice(0, RESPONSE_ERROR_BODY_LIMIT)}... [truncated]` : body;\n}\n\nfunction serialiseSingleError(cause: Error): [SerialisedError, Error | null] {\n const nextCause = cause.cause == null ? null : normalizeToError(cause.cause);\n if (cause instanceof DPUseError) {\n return [{ data: cause.data, locator: cause.locator, message: cause.message, name: cause.name, stack: cause.stack }, nextCause];\n }\n const customProperties = Object.fromEntries(Object.entries(cause).filter(([k]) => k !== 'cause'));\n return cause.name\n ? [{ data: customProperties, locator: '', message: cause.message, name: cause.name, stack: cause.stack }, nextCause]\n : [{ data: customProperties, locator: '', message: buildFallbackMessage(cause), name: 'Error', stack: undefined }, null];\n}\n"],"mappings":";AAaA,IAAM,IAA4B,MAKrB,IAAb,cAAgC,MAAM;CAClC;CACA;CACA,YAAY,GAAiB,GAAiB,GAAgC,GAAwB;EAIlG,AAHA,MAAM,GAAS,CAAO,GACtB,KAAK,OAAO,cACZ,KAAK,OAAO,GACZ,KAAK,UAAU;CACnB;AACJ,GAGa,IAAb,cAA8B,EAAW;CACrC,YAAY,GAAiB,GAAiB,GAAgC,GAAwB;EAElG,AADA,MAAM,GAAS,GAAS,GAAM,CAAO,GACrC,KAAK,OAAO;CAChB;AACJ,GAGa,IAAb,cAA8B,EAAW;CACrC,YAAY,GAAiB,GAAiB,GAAgC,GAAwB;EAElG,AADA,MAAM,GAAS,GAAS,GAAM,CAAO,GACrC,KAAK,OAAO;CAChB;AACJ,GAGa,IAAb,cAAiC,EAAW;CACxC,YAAY,GAAiB,GAAiB,GAAgC,GAAwB;EAElG,AADA,MAAM,GAAS,GAAS,GAAM,CAAO,GAC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