coh-content-db 2.0.0-rc.3 → 2.0.0-rc.5
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 +28 -4
- package/dist/coh-content-db.d.ts +189 -67
- package/dist/coh-content-db.js +296 -167
- package/dist/coh-content-db.js.map +1 -1
- package/dist/coh-content-db.mjs +290 -166
- package/dist/coh-content-db.mjs.map +1 -1
- package/package.json +1 -1
- package/src/main/api/alternate-data.ts +2 -2
- package/src/main/api/badge-data.ts +5 -10
- package/src/main/api/badge-partial-data.ts +6 -5
- package/src/main/api/change.ts +5 -2
- package/src/main/api/content-bundle.ts +2 -3
- package/src/main/api/markdown-string.ts +4 -0
- package/src/main/api/vidiot-map-point-of-interest-data.ts +3 -3
- package/src/main/changelog.ts +4 -2
- package/src/main/db/alignments.ts +17 -0
- package/src/main/db/alternates.ts +8 -14
- package/src/main/db/badge-index.ts +87 -0
- package/src/main/db/badge-partial.ts +54 -6
- package/src/main/db/badge-search-options.ts +51 -0
- package/src/main/db/badge.ts +8 -13
- package/src/main/db/bundle-metadata.ts +2 -3
- package/src/main/db/coh-content-database.ts +20 -10
- package/src/main/db/paged.ts +7 -0
- package/src/main/db/vidiot-map-point-of-interest.ts +2 -3
- package/src/main/index.ts +7 -1
- package/src/main/util.ts +36 -6
- package/src/test/api/alignments.test.ts +40 -0
- package/src/test/api/badge-partial-data.fixture.ts +1 -1
- package/src/test/db/alternates.test.ts +16 -74
- package/src/test/db/badge-index.test.ts +488 -0
- package/src/test/db/coh-content-database.test.ts +15 -0
- package/src/test/index.test.ts +4 -2
- package/src/test/util.test.ts +49 -13
package/dist/coh-content-db.mjs
CHANGED
|
@@ -62,13 +62,105 @@ const PLAQUE_TYPE = [
|
|
|
62
62
|
|
|
63
63
|
const SEX = ["M", "F"];
|
|
64
64
|
|
|
65
|
+
var __defProp$8 = Object.defineProperty;
|
|
66
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
67
|
+
var __publicField$8 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
68
|
+
class Alignments {
|
|
69
|
+
constructor(raw) {
|
|
70
|
+
__publicField$8(this, "items");
|
|
71
|
+
__publicField$8(this, "hero");
|
|
72
|
+
__publicField$8(this, "villain");
|
|
73
|
+
__publicField$8(this, "praetorian");
|
|
74
|
+
__publicField$8(this, "primal");
|
|
75
|
+
this.items = raw;
|
|
76
|
+
this.hero = raw.includes("H");
|
|
77
|
+
this.villain = raw.includes("V");
|
|
78
|
+
this.praetorian = raw.includes("P");
|
|
79
|
+
this.primal = !this.praetorian && (this.hero || this.villain);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
var __typeError$4 = (msg) => {
|
|
84
|
+
throw TypeError(msg);
|
|
85
|
+
};
|
|
86
|
+
var __accessCheck$4 = (obj, member, msg) => member.has(obj) || __typeError$4("Cannot " + msg);
|
|
87
|
+
var __privateGet$4 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
88
|
+
var __privateAdd$4 = (obj, member, value) => member.has(obj) ? __typeError$4("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
89
|
+
var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
|
|
90
|
+
var __privateMethod$2 = (obj, member, method) => (__accessCheck$4(obj, member, "access private method"), method);
|
|
91
|
+
var _sortedValues, _Alternates_instances, compareAlternates_fn, compareAlignment_fn, compareSex_fn;
|
|
92
|
+
const ALIGNMENT_SORT = { H: 2, V: 1, P: 0 };
|
|
93
|
+
const SEX_SORT = { M: 1, F: 0 };
|
|
94
|
+
class Alternates {
|
|
95
|
+
constructor(values) {
|
|
96
|
+
__privateAdd$4(this, _Alternates_instances);
|
|
97
|
+
__privateAdd$4(this, _sortedValues, []);
|
|
98
|
+
__privateSet$3(this, _sortedValues, values.sort());
|
|
99
|
+
__privateGet$4(this, _sortedValues).sort((a, b) => __privateMethod$2(this, _Alternates_instances, compareAlternates_fn).call(this, a, b));
|
|
100
|
+
}
|
|
101
|
+
getValue(alignment, sex) {
|
|
102
|
+
for (let index = __privateGet$4(this, _sortedValues).length; index--; ) {
|
|
103
|
+
const entry = __privateGet$4(this, _sortedValues)[index];
|
|
104
|
+
if ((entry.alignment === void 0 || entry.alignment === alignment) && (entry.sex === void 0 || entry.sex === sex)) return entry.value;
|
|
105
|
+
}
|
|
106
|
+
return this.default?.value;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Get the default value for this list of alternates, the value with the highest priority and lowest specificity.
|
|
110
|
+
*/
|
|
111
|
+
get default() {
|
|
112
|
+
return __privateGet$4(this, _sortedValues)[0];
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get the list of alternates sorted in canonical order (alignment then sex, low to high specificity).
|
|
116
|
+
*/
|
|
117
|
+
get canonical() {
|
|
118
|
+
return __privateGet$4(this, _sortedValues);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Create a joined string from the alternate values in canonical order.
|
|
122
|
+
* @param separator Separator to use. Default is ' / '
|
|
123
|
+
*/
|
|
124
|
+
toString(separator) {
|
|
125
|
+
return this.canonical.map((x) => x.value).join(separator);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
_sortedValues = new WeakMap();
|
|
129
|
+
_Alternates_instances = new WeakSet();
|
|
130
|
+
compareAlternates_fn = function(a, b) {
|
|
131
|
+
const aSpecificity = (a.alignment ? 2 : 0) + (a.sex ? 1 : 0);
|
|
132
|
+
const bSpecificity = (b.alignment ? 2 : 0) + (b.sex ? 1 : 0);
|
|
133
|
+
if (aSpecificity !== bSpecificity) return aSpecificity - bSpecificity;
|
|
134
|
+
const alignmentComparison = __privateMethod$2(this, _Alternates_instances, compareAlignment_fn).call(this, a.alignment, b.alignment);
|
|
135
|
+
if (alignmentComparison !== 0) return alignmentComparison;
|
|
136
|
+
const sexComparison = __privateMethod$2(this, _Alternates_instances, compareSex_fn).call(this, a.sex, b.sex);
|
|
137
|
+
if (sexComparison !== 0) return sexComparison;
|
|
138
|
+
return String(a.value).localeCompare(String(b.value));
|
|
139
|
+
};
|
|
140
|
+
compareAlignment_fn = function(a, b) {
|
|
141
|
+
if (a === b) return 0;
|
|
142
|
+
if (a === void 0 && b !== void 0) return -1;
|
|
143
|
+
if (b === void 0 && a !== void 0) return 1;
|
|
144
|
+
const aSort = a === void 0 ? -1 : ALIGNMENT_SORT[a] ?? -1;
|
|
145
|
+
const bSort = b === void 0 ? -1 : ALIGNMENT_SORT[b] ?? -1;
|
|
146
|
+
return bSort - aSort;
|
|
147
|
+
};
|
|
148
|
+
compareSex_fn = function(a, b) {
|
|
149
|
+
if (a === b) return 0;
|
|
150
|
+
if (a === void 0 && b !== void 0) return -1;
|
|
151
|
+
if (b === void 0 && a !== void 0) return 1;
|
|
152
|
+
const aSort = SEX_SORT[a ?? -1] ?? -1;
|
|
153
|
+
const bSort = SEX_SORT[b ?? -1] ?? -1;
|
|
154
|
+
return bSort - aSort;
|
|
155
|
+
};
|
|
156
|
+
|
|
65
157
|
var __typeError$3 = (msg) => {
|
|
66
158
|
throw TypeError(msg);
|
|
67
159
|
};
|
|
68
160
|
var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Cannot " + msg);
|
|
69
161
|
var __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
70
162
|
var __privateAdd$3 = (obj, member, value) => member.has(obj) ? __typeError$3("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
71
|
-
var __privateSet$
|
|
163
|
+
var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
|
|
72
164
|
var __privateMethod$1 = (obj, member, method) => (__accessCheck$3(obj, member, "access private method"), method);
|
|
73
165
|
var _value, _Key_instances, validateKey_fn;
|
|
74
166
|
const INVALID_KEY_PATTERN = /[^a-z0-9-]/;
|
|
@@ -77,7 +169,7 @@ class Key {
|
|
|
77
169
|
__privateAdd$3(this, _Key_instances);
|
|
78
170
|
__privateAdd$3(this, _value);
|
|
79
171
|
__privateMethod$1(this, _Key_instances, validateKey_fn).call(this, value);
|
|
80
|
-
__privateSet$
|
|
172
|
+
__privateSet$2(this, _value, value);
|
|
81
173
|
}
|
|
82
174
|
get value() {
|
|
83
175
|
return __privateGet$3(this, _value);
|
|
@@ -108,24 +200,60 @@ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key,
|
|
|
108
200
|
var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
109
201
|
class BadgePartial {
|
|
110
202
|
constructor(data) {
|
|
203
|
+
/**
|
|
204
|
+
* Key.
|
|
205
|
+
*/
|
|
111
206
|
__publicField$6(this, "key");
|
|
207
|
+
/**
|
|
208
|
+
* Type of partial.
|
|
209
|
+
*/
|
|
112
210
|
__publicField$6(this, "type");
|
|
211
|
+
/**
|
|
212
|
+
* Map the partial is located on.
|
|
213
|
+
*/
|
|
113
214
|
__publicField$6(this, "mapKey");
|
|
215
|
+
/**
|
|
216
|
+
* /loc coordinates.
|
|
217
|
+
*/
|
|
114
218
|
__publicField$6(this, "loc");
|
|
219
|
+
/**
|
|
220
|
+
* Is it a wall plaque or a physical monument?
|
|
221
|
+
*/
|
|
115
222
|
__publicField$6(this, "plaqueType");
|
|
116
|
-
|
|
223
|
+
/**
|
|
224
|
+
* Plaque inscription.
|
|
225
|
+
*/
|
|
226
|
+
__publicField$6(this, "plaqueInscription");
|
|
227
|
+
/**
|
|
228
|
+
* The number or letter the partial appears as on Vidiot Maps.
|
|
229
|
+
*/
|
|
117
230
|
__publicField$6(this, "vidiotMapKey");
|
|
231
|
+
/**
|
|
232
|
+
* The badge required for this partial.
|
|
233
|
+
*/
|
|
118
234
|
__publicField$6(this, "badgeKey");
|
|
235
|
+
/**
|
|
236
|
+
* Level of the invention required.
|
|
237
|
+
*/
|
|
119
238
|
__publicField$6(this, "inventionLevel");
|
|
239
|
+
/**
|
|
240
|
+
* The types of enhancements required to be crafted.
|
|
241
|
+
*/
|
|
120
242
|
__publicField$6(this, "inventionTypes");
|
|
243
|
+
/**
|
|
244
|
+
* Number of invention crafts required.
|
|
245
|
+
*/
|
|
121
246
|
__publicField$6(this, "inventionCount");
|
|
247
|
+
/**
|
|
248
|
+
* Any additional notes.
|
|
249
|
+
*/
|
|
122
250
|
__publicField$6(this, "notes");
|
|
123
251
|
this.key = new Key(data.key).value;
|
|
124
252
|
this.type = data.type;
|
|
125
253
|
this.mapKey = data.mapKey;
|
|
126
254
|
this.loc = data.loc;
|
|
127
255
|
this.plaqueType = data.plaqueType;
|
|
128
|
-
this.
|
|
256
|
+
this.plaqueInscription = data.plaqueInscription;
|
|
129
257
|
this.vidiotMapKey = data.vidiotMapKey;
|
|
130
258
|
this.badgeKey = data.badgeKey;
|
|
131
259
|
this.inventionLevel = data.inventionLevel;
|
|
@@ -135,95 +263,19 @@ class BadgePartial {
|
|
|
135
263
|
}
|
|
136
264
|
}
|
|
137
265
|
|
|
266
|
+
var __defProp$5 = Object.defineProperty;
|
|
138
267
|
var __typeError$2 = (msg) => {
|
|
139
268
|
throw TypeError(msg);
|
|
140
269
|
};
|
|
270
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
271
|
+
var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
141
272
|
var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
|
|
142
273
|
var __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
143
274
|
var __privateAdd$2 = (obj, member, value) => member.has(obj) ? __typeError$2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
144
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), member.set(obj, value), value);
|
|
145
|
-
var __privateMethod = (obj, member, method) => (__accessCheck$2(obj, member, "access private method"), method);
|
|
146
|
-
var _sortedValues, _Alternates_instances, compareAlternates_fn, compareAlignment_fn, compareSex_fn;
|
|
147
|
-
const ALIGNMENT_SORT = { H: 2, V: 1, P: 0 };
|
|
148
|
-
const SEX_SORT = { M: 1, F: 0 };
|
|
149
|
-
class Alternates {
|
|
150
|
-
constructor(values) {
|
|
151
|
-
__privateAdd$2(this, _Alternates_instances);
|
|
152
|
-
__privateAdd$2(this, _sortedValues, []);
|
|
153
|
-
__privateSet(this, _sortedValues, values.sort());
|
|
154
|
-
__privateGet$2(this, _sortedValues).sort((a, b) => __privateMethod(this, _Alternates_instances, compareAlternates_fn).call(this, a, b));
|
|
155
|
-
}
|
|
156
|
-
getValue(alignment, sex) {
|
|
157
|
-
for (let index = __privateGet$2(this, _sortedValues).length; index--; ) {
|
|
158
|
-
const entry = __privateGet$2(this, _sortedValues)[index];
|
|
159
|
-
if ((entry.alignment === void 0 || entry.alignment === alignment) && (entry.sex === void 0 || entry.sex === sex)) return entry.value;
|
|
160
|
-
}
|
|
161
|
-
return this.default;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Get the default value for this list of alternates, the value with the highest priority and lowest specificity.
|
|
165
|
-
*/
|
|
166
|
-
get default() {
|
|
167
|
-
return __privateGet$2(this, _sortedValues)[0]?.value;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Get the list of alternates sorted in canonical order (alignment then sex, low to high specificity).
|
|
171
|
-
*/
|
|
172
|
-
get canonical() {
|
|
173
|
-
return __privateGet$2(this, _sortedValues);
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Create a joined string from the alternate values in canonical order.
|
|
177
|
-
* @param separator Separator to use. Default is ' / '
|
|
178
|
-
*/
|
|
179
|
-
toString(separator) {
|
|
180
|
-
return this.canonical.map((x) => x.value).join(separator);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
_sortedValues = new WeakMap();
|
|
184
|
-
_Alternates_instances = new WeakSet();
|
|
185
|
-
compareAlternates_fn = function(a, b) {
|
|
186
|
-
const aSpecificity = (a.alignment ? 2 : 0) + (a.sex ? 1 : 0);
|
|
187
|
-
const bSpecificity = (b.alignment ? 2 : 0) + (b.sex ? 1 : 0);
|
|
188
|
-
if (aSpecificity !== bSpecificity) return aSpecificity - bSpecificity;
|
|
189
|
-
const alignmentComparison = __privateMethod(this, _Alternates_instances, compareAlignment_fn).call(this, a.alignment, b.alignment);
|
|
190
|
-
if (alignmentComparison !== 0) return alignmentComparison;
|
|
191
|
-
const sexComparison = __privateMethod(this, _Alternates_instances, compareSex_fn).call(this, a.sex, b.sex);
|
|
192
|
-
if (sexComparison !== 0) return sexComparison;
|
|
193
|
-
return String(a.value).localeCompare(String(b.value));
|
|
194
|
-
};
|
|
195
|
-
compareAlignment_fn = function(a, b) {
|
|
196
|
-
if (a === b) return 0;
|
|
197
|
-
if (a === void 0 && b !== void 0) return -1;
|
|
198
|
-
if (b === void 0 && a !== void 0) return 1;
|
|
199
|
-
const aSort = a === void 0 ? -1 : ALIGNMENT_SORT[a] ?? -1;
|
|
200
|
-
const bSort = b === void 0 ? -1 : ALIGNMENT_SORT[b] ?? -1;
|
|
201
|
-
if (aSort !== bSort) return bSort - aSort;
|
|
202
|
-
return a?.localeCompare(b ?? "") ?? 0;
|
|
203
|
-
};
|
|
204
|
-
compareSex_fn = function(a, b) {
|
|
205
|
-
if (a === b) return 0;
|
|
206
|
-
if (a === void 0 && b !== void 0) return -1;
|
|
207
|
-
if (b === void 0 && a !== void 0) return 1;
|
|
208
|
-
const aSort = SEX_SORT[a ?? -1] ?? -1;
|
|
209
|
-
const bSort = SEX_SORT[b ?? -1] ?? -1;
|
|
210
|
-
if (aSort !== bSort) return bSort - aSort;
|
|
211
|
-
return a?.localeCompare(b ?? "") ?? 0;
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
var __defProp$5 = Object.defineProperty;
|
|
215
|
-
var __typeError$1 = (msg) => {
|
|
216
|
-
throw TypeError(msg);
|
|
217
|
-
};
|
|
218
|
-
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
219
|
-
var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
220
|
-
var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
|
|
221
|
-
var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
222
|
-
var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
223
275
|
var _partialsIndex;
|
|
224
276
|
class Badge {
|
|
225
277
|
constructor(data) {
|
|
226
|
-
__privateAdd$
|
|
278
|
+
__privateAdd$2(this, _partialsIndex, {});
|
|
227
279
|
/**
|
|
228
280
|
* The database key for this badge.
|
|
229
281
|
*/
|
|
@@ -248,8 +300,6 @@ class Badge {
|
|
|
248
300
|
__publicField$5(this, "badgeText");
|
|
249
301
|
/**
|
|
250
302
|
* Description of how to acquire the badge.
|
|
251
|
-
*
|
|
252
|
-
* Supports {@link https://www.markdownguide.org/|Markdown} format.
|
|
253
303
|
*/
|
|
254
304
|
__publicField$5(this, "acquisition");
|
|
255
305
|
/**
|
|
@@ -260,8 +310,6 @@ class Badge {
|
|
|
260
310
|
__publicField$5(this, "icon");
|
|
261
311
|
/**
|
|
262
312
|
* Freeform notes or tips about the badge.
|
|
263
|
-
*
|
|
264
|
-
* Supports {@link https://www.markdownguide.org/|Markdown} format.
|
|
265
313
|
*/
|
|
266
314
|
__publicField$5(this, "notes");
|
|
267
315
|
/**
|
|
@@ -286,8 +334,6 @@ class Badge {
|
|
|
286
334
|
__publicField$5(this, "setTitle");
|
|
287
335
|
/**
|
|
288
336
|
* A description of the effect the badge will have, such as a buff or granting a temporary power.
|
|
289
|
-
*
|
|
290
|
-
* Supports {@link https://www.markdownguide.org/|Markdown} format.
|
|
291
337
|
*/
|
|
292
338
|
__publicField$5(this, "effect");
|
|
293
339
|
/**
|
|
@@ -301,7 +347,7 @@ class Badge {
|
|
|
301
347
|
this.key = new Key(data.key).value;
|
|
302
348
|
this.type = data.type;
|
|
303
349
|
this.name = new Alternates(data.name);
|
|
304
|
-
this.alignment = data.alignment;
|
|
350
|
+
this.alignment = new Alignments(data.alignment);
|
|
305
351
|
this.badgeText = new Alternates(data.badgeText ?? []);
|
|
306
352
|
this.acquisition = data.acquisition;
|
|
307
353
|
this.icon = new Alternates(data.icon ?? []);
|
|
@@ -314,23 +360,124 @@ class Badge {
|
|
|
314
360
|
this.setTitle = data.setTitle;
|
|
315
361
|
this.ignoreInTotals = data.ignoreInTotals ?? false;
|
|
316
362
|
this.partials = data.partials?.map((data2) => {
|
|
317
|
-
if (__privateGet$
|
|
363
|
+
if (__privateGet$2(this, _partialsIndex)[data2.key] !== void 0) throw new Error(`Duplicate badge partial key [${data2.key}]`);
|
|
318
364
|
const badge = new BadgePartial(data2);
|
|
319
|
-
__privateGet$
|
|
365
|
+
__privateGet$2(this, _partialsIndex)[badge.key] = badge;
|
|
320
366
|
return badge;
|
|
321
367
|
});
|
|
322
368
|
}
|
|
323
369
|
getPartial(key) {
|
|
324
|
-
const result = __privateGet$
|
|
370
|
+
const result = __privateGet$2(this, _partialsIndex)[key];
|
|
325
371
|
if (result === void 0) throw new Error(`Unknown badge partial key [${key}]`);
|
|
326
372
|
return result;
|
|
327
373
|
}
|
|
328
374
|
}
|
|
329
375
|
_partialsIndex = new WeakMap();
|
|
330
376
|
|
|
377
|
+
var __typeError$1 = (msg) => {
|
|
378
|
+
throw TypeError(msg);
|
|
379
|
+
};
|
|
380
|
+
var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
|
|
381
|
+
var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
382
|
+
var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
383
|
+
var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
|
|
384
|
+
var __privateMethod = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
|
|
385
|
+
var _badges, _badgeIndex$1, _mapOrder, _BadgeIndex_instances, satisfiesQueryPredicate_fn, satisfiesFilterPredicate_fn, sort_fn;
|
|
386
|
+
class BadgeIndex {
|
|
387
|
+
constructor(badges, maps) {
|
|
388
|
+
__privateAdd$1(this, _BadgeIndex_instances);
|
|
389
|
+
__privateAdd$1(this, _badges, []);
|
|
390
|
+
__privateAdd$1(this, _badgeIndex$1, {});
|
|
391
|
+
__privateAdd$1(this, _mapOrder, {});
|
|
392
|
+
__privateSet$1(this, _mapOrder, Object.fromEntries(
|
|
393
|
+
maps?.sort((a, b) => a.name.localeCompare(b.name))?.map((x, index) => [x.key, index]) ?? []
|
|
394
|
+
));
|
|
395
|
+
__privateSet$1(this, _badges, badges);
|
|
396
|
+
for (const badge of badges) {
|
|
397
|
+
if (__privateGet$1(this, _badgeIndex$1)[badge.key] !== void 0) throw new Error(`Duplicate badge key [${badge.key}]`);
|
|
398
|
+
__privateGet$1(this, _badgeIndex$1)[badge.key] = badge;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
getBadge(key) {
|
|
402
|
+
const result = __privateGet$1(this, _badgeIndex$1)[key];
|
|
403
|
+
if (result === void 0) throw new Error(`Unknown badge key [${key}]`);
|
|
404
|
+
return result;
|
|
405
|
+
}
|
|
406
|
+
searchBadges(options) {
|
|
407
|
+
const filtered = options?.query || options?.filter ? __privateGet$1(this, _badges).filter((badge) => __privateMethod(this, _BadgeIndex_instances, satisfiesQueryPredicate_fn).call(this, badge, options?.query) && __privateMethod(this, _BadgeIndex_instances, satisfiesFilterPredicate_fn).call(this, badge, options?.filter)) : __privateGet$1(this, _badges);
|
|
408
|
+
const paged = options?.pageSize ? filtered.slice(((options?.page ?? 1) - 1) * options.pageSize, (options?.page ?? 1) * options?.pageSize) : filtered;
|
|
409
|
+
const sorted = __privateMethod(this, _BadgeIndex_instances, sort_fn).call(this, paged, options?.sort);
|
|
410
|
+
return {
|
|
411
|
+
items: sorted,
|
|
412
|
+
page: options?.page ?? 1,
|
|
413
|
+
pageSize: options?.pageSize,
|
|
414
|
+
totalItems: filtered.length,
|
|
415
|
+
totalPages: options?.pageSize ? Math.ceil(filtered.length / options?.pageSize) : 1
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
_badges = new WeakMap();
|
|
420
|
+
_badgeIndex$1 = new WeakMap();
|
|
421
|
+
_mapOrder = new WeakMap();
|
|
422
|
+
_BadgeIndex_instances = new WeakSet();
|
|
423
|
+
satisfiesQueryPredicate_fn = function(badge, query) {
|
|
424
|
+
const queryString = query?.str?.toLowerCase() ?? "";
|
|
425
|
+
return !!((query?.on?.name ?? true) && badge.name.canonical.some((x) => x.value.toLowerCase().includes(queryString)) || query?.on?.badgeText && badge.badgeText.canonical.some((x) => x.value.toLowerCase().includes(queryString)) || query?.on?.acquisition && badge.acquisition?.toLowerCase().includes(queryString) || query?.on?.effect && badge.effect?.toLowerCase().includes(queryString) || query?.on?.notes && badge.notes?.toLowerCase().includes(queryString) || query?.on?.setTitle && (badge.setTitle?.id?.toString().includes(queryString) || badge.setTitle?.praetorianId?.toString().includes(queryString)));
|
|
426
|
+
};
|
|
427
|
+
satisfiesFilterPredicate_fn = function(badge, filter) {
|
|
428
|
+
return (!filter?.type || badge.type === filter.type) && (!filter?.mapKey || badge.mapKey === filter.mapKey) && (!filter?.alignment || badge.alignment.items.includes(filter.alignment));
|
|
429
|
+
};
|
|
430
|
+
sort_fn = function(badges, sort) {
|
|
431
|
+
if (!sort) return badges;
|
|
432
|
+
const ascending = sort.dir !== "DESC";
|
|
433
|
+
if (!sort.by || sort.by === "CANONICAL") return sort.dir === "DESC" ? badges.reverse() : badges;
|
|
434
|
+
if (sort.by === "BADGE_NAME") return ascending ? badges.sort((a, b) => a.name.default?.value.localeCompare(b.name.default?.value ?? "") ?? 0) : badges.sort((a, b) => b.name.default?.value.localeCompare(a.name.default?.value ?? "") ?? 0);
|
|
435
|
+
return badges.sort((a, b) => {
|
|
436
|
+
const aIndex = __privateGet$1(this, _mapOrder)[a.mapKey ?? ""];
|
|
437
|
+
const bIndex = __privateGet$1(this, _mapOrder)[b.mapKey ?? ""];
|
|
438
|
+
if (aIndex === bIndex) return 0;
|
|
439
|
+
if (aIndex === void 0) return ascending ? 1 : -1;
|
|
440
|
+
if (bIndex === void 0) return ascending ? -1 : 1;
|
|
441
|
+
return ascending ? aIndex - bIndex : bIndex - aIndex;
|
|
442
|
+
});
|
|
443
|
+
};
|
|
444
|
+
|
|
331
445
|
var __defProp$4 = Object.defineProperty;
|
|
332
446
|
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
333
447
|
var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
448
|
+
class BundleMetadata {
|
|
449
|
+
constructor(bundle) {
|
|
450
|
+
/**
|
|
451
|
+
* Name of the server group.
|
|
452
|
+
*/
|
|
453
|
+
__publicField$4(this, "name");
|
|
454
|
+
/**
|
|
455
|
+
* Description of the server group.
|
|
456
|
+
*/
|
|
457
|
+
__publicField$4(this, "description");
|
|
458
|
+
/**
|
|
459
|
+
* Repository where the db content package is maintained.
|
|
460
|
+
*/
|
|
461
|
+
__publicField$4(this, "repository");
|
|
462
|
+
/**
|
|
463
|
+
* List of external links for this Server Group. Wiki, forums, etc.
|
|
464
|
+
*/
|
|
465
|
+
__publicField$4(this, "links");
|
|
466
|
+
/**
|
|
467
|
+
* Change log for this data package.
|
|
468
|
+
*/
|
|
469
|
+
__publicField$4(this, "changelog");
|
|
470
|
+
this.name = bundle.name;
|
|
471
|
+
this.description = bundle.description;
|
|
472
|
+
this.repository = bundle.repository;
|
|
473
|
+
this.links = bundle.links ?? [];
|
|
474
|
+
this.changelog = bundle.changelog ?? [];
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
var __defProp$3 = Object.defineProperty;
|
|
479
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
480
|
+
var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
334
481
|
class VidiotMapPointOfInterest {
|
|
335
482
|
constructor(data) {
|
|
336
483
|
/**
|
|
@@ -338,25 +485,23 @@ class VidiotMapPointOfInterest {
|
|
|
338
485
|
*
|
|
339
486
|
* Screen-space, pixels from top-left `[0, 0]`.
|
|
340
487
|
*/
|
|
341
|
-
__publicField$
|
|
488
|
+
__publicField$3(this, "pos");
|
|
342
489
|
/**
|
|
343
490
|
* Freeform notes about the PoI.
|
|
344
|
-
*
|
|
345
|
-
* Supports {@link https://www.markdownguide.org/|Markdown} format.
|
|
346
491
|
*/
|
|
347
|
-
__publicField$
|
|
492
|
+
__publicField$3(this, "notes");
|
|
348
493
|
/**
|
|
349
494
|
* If the POI is a zone transfer, the map it transfers to.
|
|
350
495
|
*/
|
|
351
|
-
__publicField$
|
|
496
|
+
__publicField$3(this, "mapKey");
|
|
352
497
|
/**
|
|
353
498
|
* If the POI is a badge, the badge.
|
|
354
499
|
*/
|
|
355
|
-
__publicField$
|
|
500
|
+
__publicField$3(this, "badgeKey");
|
|
356
501
|
/**
|
|
357
502
|
* If the POI is a partial for a badge, the partial key.
|
|
358
503
|
*/
|
|
359
|
-
__publicField$
|
|
504
|
+
__publicField$3(this, "badgePartialKey");
|
|
360
505
|
this.pos = data.pos;
|
|
361
506
|
this.notes = data.notes;
|
|
362
507
|
this.mapKey = data.mapKey;
|
|
@@ -365,50 +510,50 @@ class VidiotMapPointOfInterest {
|
|
|
365
510
|
}
|
|
366
511
|
}
|
|
367
512
|
|
|
368
|
-
var __defProp$
|
|
369
|
-
var __defNormalProp$
|
|
370
|
-
var __publicField$
|
|
513
|
+
var __defProp$2 = Object.defineProperty;
|
|
514
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
515
|
+
var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
371
516
|
class VidiotMap {
|
|
372
517
|
constructor(data) {
|
|
373
518
|
/**
|
|
374
519
|
* URL of the map image.
|
|
375
520
|
*/
|
|
376
|
-
__publicField$
|
|
521
|
+
__publicField$2(this, "imageUrl");
|
|
377
522
|
/**
|
|
378
523
|
* Name to display for the Vidiot map.
|
|
379
524
|
*/
|
|
380
|
-
__publicField$
|
|
525
|
+
__publicField$2(this, "name");
|
|
381
526
|
/**
|
|
382
527
|
* List of Points of Interest labelled on the image.
|
|
383
528
|
*/
|
|
384
|
-
__publicField$
|
|
529
|
+
__publicField$2(this, "pointsOfInterest");
|
|
385
530
|
this.imageUrl = data.imageUrl;
|
|
386
531
|
this.name = data.name;
|
|
387
532
|
this.pointsOfInterest = data.pointsOfInterest?.map((data2) => new VidiotMapPointOfInterest(data2));
|
|
388
533
|
}
|
|
389
534
|
}
|
|
390
535
|
|
|
391
|
-
var __defProp$
|
|
392
|
-
var __defNormalProp$
|
|
393
|
-
var __publicField$
|
|
536
|
+
var __defProp$1 = Object.defineProperty;
|
|
537
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
538
|
+
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
394
539
|
class GameMap {
|
|
395
540
|
constructor(data) {
|
|
396
541
|
/**
|
|
397
542
|
* The database key for this map.
|
|
398
543
|
*/
|
|
399
|
-
__publicField$
|
|
544
|
+
__publicField$1(this, "key");
|
|
400
545
|
/**
|
|
401
546
|
* The name of the map as it appears in-game.
|
|
402
547
|
*/
|
|
403
|
-
__publicField$
|
|
548
|
+
__publicField$1(this, "name");
|
|
404
549
|
/**
|
|
405
550
|
* List of external links for this Map. Wiki, forums, etc.
|
|
406
551
|
*/
|
|
407
|
-
__publicField$
|
|
552
|
+
__publicField$1(this, "links");
|
|
408
553
|
/**
|
|
409
554
|
* List of Vidiot Map assets for this map.
|
|
410
555
|
*/
|
|
411
|
-
__publicField$
|
|
556
|
+
__publicField$1(this, "vidiotMaps");
|
|
412
557
|
this.key = new Key(data.key).value;
|
|
413
558
|
this.name = data.name;
|
|
414
559
|
this.links = data.links;
|
|
@@ -416,41 +561,6 @@ class GameMap {
|
|
|
416
561
|
}
|
|
417
562
|
}
|
|
418
563
|
|
|
419
|
-
var __defProp$1 = Object.defineProperty;
|
|
420
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
421
|
-
var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
422
|
-
class BundleMetadata {
|
|
423
|
-
constructor(bundle) {
|
|
424
|
-
/**
|
|
425
|
-
* Name of the server group.
|
|
426
|
-
*/
|
|
427
|
-
__publicField$1(this, "name");
|
|
428
|
-
/**
|
|
429
|
-
* Description of the server group.
|
|
430
|
-
*
|
|
431
|
-
* Supports {@link https://www.markdownguide.org/|Markdown} format.
|
|
432
|
-
*/
|
|
433
|
-
__publicField$1(this, "description");
|
|
434
|
-
/**
|
|
435
|
-
* Repository where the db content package is maintained.
|
|
436
|
-
*/
|
|
437
|
-
__publicField$1(this, "repository");
|
|
438
|
-
/**
|
|
439
|
-
* List of external links for this Server Group. Wiki, forums, etc.
|
|
440
|
-
*/
|
|
441
|
-
__publicField$1(this, "links");
|
|
442
|
-
/**
|
|
443
|
-
* Change log for this data package.
|
|
444
|
-
*/
|
|
445
|
-
__publicField$1(this, "changelog");
|
|
446
|
-
this.name = bundle.name;
|
|
447
|
-
this.description = bundle.description;
|
|
448
|
-
this.repository = bundle.repository;
|
|
449
|
-
this.links = bundle.links ?? [];
|
|
450
|
-
this.changelog = bundle.changelog ?? [];
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
|
|
454
564
|
var __defProp = Object.defineProperty;
|
|
455
565
|
var __typeError = (msg) => {
|
|
456
566
|
throw TypeError(msg);
|
|
@@ -460,6 +570,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
460
570
|
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
461
571
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
462
572
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
573
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
|
463
574
|
var _archetypeIndex, _mapIndex, _badgeIndex;
|
|
464
575
|
class CohContentDatabase {
|
|
465
576
|
/**
|
|
@@ -469,7 +580,7 @@ class CohContentDatabase {
|
|
|
469
580
|
constructor(bundle) {
|
|
470
581
|
__privateAdd(this, _archetypeIndex, {});
|
|
471
582
|
__privateAdd(this, _mapIndex, {});
|
|
472
|
-
__privateAdd(this, _badgeIndex
|
|
583
|
+
__privateAdd(this, _badgeIndex);
|
|
473
584
|
/**
|
|
474
585
|
* Metadata about the content bundle.
|
|
475
586
|
*/
|
|
@@ -505,12 +616,8 @@ class CohContentDatabase {
|
|
|
505
616
|
__privateGet(this, _mapIndex)[map.key] = map;
|
|
506
617
|
return map;
|
|
507
618
|
}) ?? [];
|
|
508
|
-
this.badges = bundle.badges?.map((data) =>
|
|
509
|
-
|
|
510
|
-
const badge = new Badge(data);
|
|
511
|
-
__privateGet(this, _badgeIndex)[badge.key] = badge;
|
|
512
|
-
return badge;
|
|
513
|
-
}) ?? [];
|
|
619
|
+
this.badges = bundle.badges?.map((data) => new Badge(data)) ?? [];
|
|
620
|
+
__privateSet(this, _badgeIndex, new BadgeIndex(this.badges, this.maps));
|
|
514
621
|
}
|
|
515
622
|
getArchetype(key) {
|
|
516
623
|
const result = __privateGet(this, _archetypeIndex)[key];
|
|
@@ -523,9 +630,16 @@ class CohContentDatabase {
|
|
|
523
630
|
return result;
|
|
524
631
|
}
|
|
525
632
|
getBadge(key) {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
633
|
+
return __privateGet(this, _badgeIndex).getBadge(key);
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Search, sort and filter the badge list.
|
|
637
|
+
* This is a fairly brute-forced approach and will not be as performant as loading the badge data into a traditional
|
|
638
|
+
* database engine, but is sufficient for most operations.
|
|
639
|
+
* @param options {@link BadgeSearchOptions}
|
|
640
|
+
*/
|
|
641
|
+
searchBadges(options) {
|
|
642
|
+
return __privateGet(this, _badgeIndex).searchBadges(options);
|
|
529
643
|
}
|
|
530
644
|
}
|
|
531
645
|
_archetypeIndex = new WeakMap();
|
|
@@ -538,13 +652,15 @@ const CHANGELOG = [
|
|
|
538
652
|
date: /* @__PURE__ */ new Date("2025-03-12"),
|
|
539
653
|
description: `* Replaced redundant interfaces with their concrete equivalents.
|
|
540
654
|
* Server groups are now referred to as 'forks'.
|
|
541
|
-
* Replaced enums with
|
|
655
|
+
* Replaced enums with union types.
|
|
542
656
|
* \`IServerGroupData\` is now \`ContentBundle\` and each database instance is now designed to accept only a single server group.
|
|
543
657
|
* Removed the \`serverGroup\` property from entities to simplify the object tree given that only a single context can exist per db now.
|
|
658
|
+
* Added a simple indexing and search function for badge names, text and acquisition info.
|
|
659
|
+
* Map and badge references now follow a standard Markdown link format with a \`badge://\` or \`map://\` protocol.
|
|
544
660
|
* Standardized pluralization of some field names (name, icon).
|
|
545
661
|
* Combined \`settitle\` ids into a single tuple field.
|
|
546
662
|
* Change from GNU to The Unlicense.
|
|
547
|
-
* Removed
|
|
663
|
+
* Removed all third-party dependencies.
|
|
548
664
|
* Moved from webpack to rollup for packaging.
|
|
549
665
|
* Add eslint for linting.
|
|
550
666
|
* Add jest for unit tests.
|
|
@@ -553,14 +669,22 @@ const CHANGELOG = [
|
|
|
553
669
|
}
|
|
554
670
|
];
|
|
555
671
|
|
|
556
|
-
function
|
|
672
|
+
function badgeUri(target) {
|
|
673
|
+
const key = typeof target === "string" ? target : target.key;
|
|
674
|
+
return `badge://${key}`;
|
|
675
|
+
}
|
|
676
|
+
function badgeLink(target) {
|
|
677
|
+
const key = typeof target === "string" ? target : target.key;
|
|
678
|
+
return `[${key}](${badgeUri(target)})`;
|
|
679
|
+
}
|
|
680
|
+
function mapUri(target) {
|
|
557
681
|
const key = typeof target === "string" ? target : target.key;
|
|
558
|
-
return `
|
|
682
|
+
return `map://${key}`;
|
|
559
683
|
}
|
|
560
|
-
function
|
|
684
|
+
function mapLink(target) {
|
|
561
685
|
const key = typeof target === "string" ? target : target.key;
|
|
562
|
-
return `[
|
|
686
|
+
return `[${key}](${mapUri(target)})`;
|
|
563
687
|
}
|
|
564
688
|
|
|
565
|
-
export { ALIGNMENT, Archetype, BADGE_PARTIAL_TYPE, BADGE_TYPE, Badge, BadgePartial, BundleMetadata, CHANGELOG, CohContentDatabase, ENHANCEMENT_CATEGORY, GameMap, Key, PLAQUE_TYPE, SEX, VidiotMap, VidiotMapPointOfInterest,
|
|
689
|
+
export { ALIGNMENT, Alignments, Alternates, Archetype, BADGE_PARTIAL_TYPE, BADGE_TYPE, Badge, BadgeIndex, BadgePartial, BundleMetadata, CHANGELOG, CohContentDatabase, ENHANCEMENT_CATEGORY, GameMap, Key, PLAQUE_TYPE, SEX, VidiotMap, VidiotMapPointOfInterest, badgeLink, badgeUri, mapLink, mapUri };
|
|
566
690
|
//# sourceMappingURL=coh-content-db.mjs.map
|