@tosuapp/osu-native-wrapper 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,687 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+
6
+ // src/core/OsuNativeError.ts
7
+ var _OsuNativeError = class _OsuNativeError extends Error {
8
+ constructor(operation, errno, message, code, rawMessage) {
9
+ super(message);
10
+ __publicField(this, "errno");
11
+ __publicField(this, "operation");
12
+ __publicField(this, "rawMessage");
13
+ __publicField(this, "code");
14
+ this.name = "OsuNativeError";
15
+ this.errno = errno;
16
+ this.operation = operation;
17
+ this.rawMessage = rawMessage;
18
+ this.code = code;
19
+ }
20
+ };
21
+ __name(_OsuNativeError, "OsuNativeError");
22
+ var OsuNativeError = _OsuNativeError;
23
+
24
+ // src/core/OsuNative.ts
25
+ import raw from "@tosuapp/osu-native-napi";
26
+ var _OsuNative = class _OsuNative {
27
+ static getLastMessage() {
28
+ const msg = raw.ErrorHandler_GetLastMessage();
29
+ const trimmed = msg.trim();
30
+ return trimmed.length > 0 ? trimmed : void 0;
31
+ }
32
+ static errorCodeName(value) {
33
+ return _OsuNative.errorCodeNameByValue.get(value);
34
+ }
35
+ static toError(operation, value) {
36
+ const name = this.errorCodeName(value);
37
+ const rawMessage = this.getLastMessage();
38
+ const suffix = rawMessage ? `: ${rawMessage}` : "";
39
+ const message = `${operation} failed (${name ?? value})${suffix}`;
40
+ return new OsuNativeError(operation, value, message, name, rawMessage);
41
+ }
42
+ static assertOk(operation, value) {
43
+ if (value === raw.ErrorCode.SUCCESS) {
44
+ return;
45
+ }
46
+ throw this.toError(operation, value);
47
+ }
48
+ static assertSizeQuery(operation, value) {
49
+ if (value === raw.ErrorCode.BUFFER_SIZE_QUERY) {
50
+ return;
51
+ }
52
+ throw this.toError(operation, value);
53
+ }
54
+ static makeNullHandle() {
55
+ return new raw.ManagedObjectHandle();
56
+ }
57
+ };
58
+ __name(_OsuNative, "OsuNative");
59
+ __publicField(_OsuNative, "errorCode", raw.ErrorCode);
60
+ __publicField(_OsuNative, "errorCodeNameByValue", new Map(Object.entries(raw.ErrorCode).filter((entry) => typeof entry[1] === "number").map(([name, value]) => [
61
+ value,
62
+ name
63
+ ])));
64
+ var OsuNative = _OsuNative;
65
+
66
+ // src/internal/NativeHandleOwner.ts
67
+ var _NativeHandleOwner = class _NativeHandleOwner {
68
+ constructor(native) {
69
+ __publicField(this, "native");
70
+ __publicField(this, "destroyed", false);
71
+ this.native = native;
72
+ }
73
+ get handle() {
74
+ return this.native.handle;
75
+ }
76
+ ensureAlive() {
77
+ if (!this.destroyed) {
78
+ return;
79
+ }
80
+ throw new Error(`${this.constructor.name} is destroyed`);
81
+ }
82
+ };
83
+ __name(_NativeHandleOwner, "NativeHandleOwner");
84
+ var NativeHandleOwner = _NativeHandleOwner;
85
+
86
+ // src/objects/Beatmap.ts
87
+ import raw2 from "@tosuapp/osu-native-napi";
88
+ var _Beatmap = class _Beatmap extends NativeHandleOwner {
89
+ static fromFile(filePath) {
90
+ const native = new raw2.NativeBeatmap();
91
+ OsuNative.assertOk("Beatmap_CreateFromFile", raw2.Beatmap_CreateFromFile(filePath, native));
92
+ return new _Beatmap(native);
93
+ }
94
+ static fromText(text) {
95
+ const native = new raw2.NativeBeatmap();
96
+ OsuNative.assertOk("Beatmap_CreateFromText", raw2.Beatmap_CreateFromText(text, native));
97
+ return new _Beatmap(native);
98
+ }
99
+ constructor(native) {
100
+ super(native);
101
+ }
102
+ getTitle() {
103
+ this.ensureAlive();
104
+ const bufferSizeArr = new Int32Array([
105
+ 0
106
+ ]);
107
+ OsuNative.assertSizeQuery("Beatmap_GetTitle", raw2.Beatmap_GetTitle(this.handle, null, bufferSizeArr));
108
+ const buffer = Buffer.alloc(bufferSizeArr[0]);
109
+ OsuNative.assertOk("Beatmap_GetTitle", raw2.Beatmap_GetTitle(this.handle, buffer, bufferSizeArr));
110
+ return buffer.toString();
111
+ }
112
+ getArtist() {
113
+ this.ensureAlive();
114
+ const bufferSizeArr = new Int32Array([
115
+ 0
116
+ ]);
117
+ OsuNative.assertSizeQuery("Beatmap_GetArtist", raw2.Beatmap_GetArtist(this.handle, null, bufferSizeArr));
118
+ const buffer = Buffer.alloc(bufferSizeArr[0]);
119
+ OsuNative.assertOk("Beatmap_GetArtist", raw2.Beatmap_GetArtist(this.handle, buffer, bufferSizeArr));
120
+ return buffer.toString();
121
+ }
122
+ getVersion() {
123
+ this.ensureAlive();
124
+ const bufferSizeArr = new Int32Array([
125
+ 0
126
+ ]);
127
+ OsuNative.assertSizeQuery("Beatmap_GetVersion", raw2.Beatmap_GetVersion(this.handle, null, bufferSizeArr));
128
+ const buffer = Buffer.alloc(bufferSizeArr[0]);
129
+ OsuNative.assertOk("Beatmap_GetArtist", raw2.Beatmap_GetVersion(this.handle, buffer, bufferSizeArr));
130
+ return buffer.toString();
131
+ }
132
+ destroy() {
133
+ if (this.destroyed) {
134
+ return;
135
+ }
136
+ OsuNative.assertOk("Beatmap_Destroy", raw2.Beatmap_Destroy(this.handle));
137
+ this.destroyed = true;
138
+ }
139
+ };
140
+ __name(_Beatmap, "Beatmap");
141
+ var Beatmap = _Beatmap;
142
+
143
+ // src/objects/Mod.ts
144
+ import raw3 from "@tosuapp/osu-native-napi";
145
+ var _Mod = class _Mod extends NativeHandleOwner {
146
+ static create(acronym) {
147
+ const native = new raw3.NativeMod();
148
+ OsuNative.assertOk("Mod_Create", raw3.Mod_Create(acronym, native));
149
+ return new _Mod(native);
150
+ }
151
+ setSettingBool(key, value) {
152
+ this.ensureAlive();
153
+ OsuNative.assertOk("Mod_SetSettingBool", raw3.Mod_SetSettingBool(this.handle, key, value));
154
+ }
155
+ setSettingInteger(key, value) {
156
+ this.ensureAlive();
157
+ OsuNative.assertOk("Mod_SetSettingInteger", raw3.Mod_SetSettingInteger(this.handle, key, value));
158
+ }
159
+ setSettingFloat(key, value) {
160
+ this.ensureAlive();
161
+ OsuNative.assertOk("Mod_SetSettingFloat", raw3.Mod_SetSettingFloat(this.handle, key, value));
162
+ }
163
+ debug() {
164
+ this.ensureAlive();
165
+ OsuNative.assertOk("Mod_Debug", raw3.Mod_Debug(this.handle));
166
+ }
167
+ destroy() {
168
+ if (this.destroyed) {
169
+ return;
170
+ }
171
+ OsuNative.assertOk("Mod_Destroy", raw3.Mod_Destroy(this.handle));
172
+ this.destroyed = true;
173
+ }
174
+ };
175
+ __name(_Mod, "Mod");
176
+ var Mod = _Mod;
177
+
178
+ // src/objects/ModsCollection.ts
179
+ import raw4 from "@tosuapp/osu-native-napi";
180
+ var _ModsCollection = class _ModsCollection extends NativeHandleOwner {
181
+ constructor() {
182
+ super(...arguments);
183
+ __publicField(this, "mods", []);
184
+ }
185
+ static create() {
186
+ const native = new raw4.NativeModsCollection();
187
+ OsuNative.assertOk("ModsCollection_Create", raw4.ModsCollection_Create(native));
188
+ return new _ModsCollection(native);
189
+ }
190
+ add(mod) {
191
+ this.ensureAlive();
192
+ OsuNative.assertOk("ModsCollection_Add", raw4.ModsCollection_Add(this.handle, mod.handle));
193
+ this.mods.push(mod.handle);
194
+ }
195
+ has(mod) {
196
+ return this.mods.find((x) => x == mod.handle) !== void 0;
197
+ }
198
+ remove(mod) {
199
+ this.ensureAlive();
200
+ OsuNative.assertOk("ModsCollection_Remove", raw4.ModsCollection_Remove(this.handle, mod.handle));
201
+ this.mods = this.mods.filter((x) => x !== mod.handle);
202
+ }
203
+ debug() {
204
+ this.ensureAlive();
205
+ OsuNative.assertOk("ModsCollection_Debug", raw4.ModsCollection_Debug(this.handle));
206
+ }
207
+ destroy() {
208
+ if (this.destroyed) {
209
+ return;
210
+ }
211
+ OsuNative.assertOk("ModsCollection_Destroy", raw4.ModsCollection_Destroy(this.handle));
212
+ this.destroyed = true;
213
+ }
214
+ };
215
+ __name(_ModsCollection, "ModsCollection");
216
+ var ModsCollection = _ModsCollection;
217
+
218
+ // src/internal/rulesetShortName.ts
219
+ var RULESET_SHORT_NAME_BY_ID = /* @__PURE__ */ new Map([
220
+ [
221
+ 0,
222
+ "osu"
223
+ ],
224
+ [
225
+ 1,
226
+ "taiko"
227
+ ],
228
+ [
229
+ 2,
230
+ "catch"
231
+ ],
232
+ [
233
+ 3,
234
+ "mania"
235
+ ]
236
+ ]);
237
+
238
+ // src/objects/Ruleset.ts
239
+ import raw5 from "@tosuapp/osu-native-napi";
240
+ var _Ruleset = class _Ruleset extends NativeHandleOwner {
241
+ static fromId(rulesetId) {
242
+ const native = new raw5.NativeRuleset();
243
+ OsuNative.assertOk("Ruleset_CreateFromId", raw5.Ruleset_CreateFromId(rulesetId, native));
244
+ return new _Ruleset(native);
245
+ }
246
+ static fromShortName(shortName) {
247
+ const native = new raw5.NativeRuleset();
248
+ OsuNative.assertOk("Ruleset_CreateFromShortName", raw5.Ruleset_CreateFromShortName(shortName, native));
249
+ return new _Ruleset(native);
250
+ }
251
+ get rulesetId() {
252
+ return this.native.rulesetId;
253
+ }
254
+ get shortName() {
255
+ return RULESET_SHORT_NAME_BY_ID.get(this.rulesetId);
256
+ }
257
+ getShortName() {
258
+ this.ensureAlive();
259
+ return;
260
+ }
261
+ destroy() {
262
+ if (this.destroyed) {
263
+ return;
264
+ }
265
+ OsuNative.assertOk("Ruleset_Destroy", raw5.Ruleset_Destroy(this.handle));
266
+ this.destroyed = true;
267
+ }
268
+ };
269
+ __name(_Ruleset, "Ruleset");
270
+ var Ruleset = _Ruleset;
271
+
272
+ // src/calculators/difficulty/CatchDifficultyCalculator.ts
273
+ import raw6 from "@tosuapp/osu-native-napi";
274
+ var _CatchDifficultyCalculator = class _CatchDifficultyCalculator extends NativeHandleOwner {
275
+ constructor(native, ruleset, beatmap) {
276
+ super(native);
277
+ __publicField(this, "ruleset");
278
+ __publicField(this, "beatmap");
279
+ this.ruleset = ruleset, this.beatmap = beatmap;
280
+ }
281
+ static create(ruleset, beatmap) {
282
+ const native = new raw6.NativeCatchDifficultyCalculator();
283
+ OsuNative.assertOk("CatchDifficultyCalculator_Create", raw6.CatchDifficultyCalculator_Create(ruleset.handle, beatmap.handle, native));
284
+ return new _CatchDifficultyCalculator(native, ruleset, beatmap);
285
+ }
286
+ calculate() {
287
+ this.ensureAlive();
288
+ const attrs = new raw6.NativeCatchDifficultyAttributes();
289
+ OsuNative.assertOk("CatchDifficultyCalculator_Calculate", raw6.CatchDifficultyCalculator_Calculate(this.handle, attrs));
290
+ return attrs;
291
+ }
292
+ calculateWithMods(mods) {
293
+ this.ensureAlive();
294
+ const attrs = new raw6.NativeCatchDifficultyAttributes();
295
+ OsuNative.assertOk("CatchDifficultyCalculator_CalculateMods", raw6.CatchDifficultyCalculator_CalculateMods(this.handle, mods.handle, attrs));
296
+ return attrs;
297
+ }
298
+ calculateTimed() {
299
+ this.ensureAlive();
300
+ const bufferSize = new Int32Array(1);
301
+ OsuNative.assertSizeQuery("CatchDifficultyCalculator_CalculateTimed", raw6.CatchDifficultyCalculator_CalculateTimed(this.handle, null, bufferSize));
302
+ if (bufferSize[0] <= 0) {
303
+ return [];
304
+ }
305
+ const outAttrs = new Array(bufferSize[0]);
306
+ OsuNative.assertOk("CatchDifficultyCalculator_CalculateTimed", raw6.CatchDifficultyCalculator_CalculateTimed(this.handle, outAttrs, bufferSize));
307
+ return outAttrs;
308
+ }
309
+ calculateWithModsTimed(mods) {
310
+ this.ensureAlive();
311
+ const bufferSize = new Int32Array(1);
312
+ OsuNative.assertSizeQuery("CatchDifficultyCalculator_CalculateModsTimed", raw6.CatchDifficultyCalculator_CalculateModsTimed(this.handle, mods.handle, null, bufferSize));
313
+ if (bufferSize[0] <= 0) {
314
+ return [];
315
+ }
316
+ const outAttrs = new Array(bufferSize[0]);
317
+ OsuNative.assertOk("CatchDifficultyCalculator_CalculateModsTimed", raw6.CatchDifficultyCalculator_CalculateModsTimed(this.handle, mods.handle, outAttrs, bufferSize));
318
+ return outAttrs;
319
+ }
320
+ destroy() {
321
+ if (this.destroyed) {
322
+ return;
323
+ }
324
+ OsuNative.assertOk("CatchDifficultyCalculator_Destroy", raw6.CatchDifficultyCalculator_Destroy(this.handle));
325
+ this.destroyed = true;
326
+ }
327
+ };
328
+ __name(_CatchDifficultyCalculator, "CatchDifficultyCalculator");
329
+ var CatchDifficultyCalculator = _CatchDifficultyCalculator;
330
+
331
+ // src/calculators/difficulty/ManiaDifficultyCalculator.ts
332
+ import raw7 from "@tosuapp/osu-native-napi";
333
+ var _ManiaDifficultyCalculator = class _ManiaDifficultyCalculator extends NativeHandleOwner {
334
+ constructor(native, ruleset, beatmap) {
335
+ super(native);
336
+ __publicField(this, "ruleset");
337
+ __publicField(this, "beatmap");
338
+ this.ruleset = ruleset, this.beatmap = beatmap;
339
+ }
340
+ static create(ruleset, beatmap) {
341
+ const native = new raw7.NativeManiaDifficultyCalculator();
342
+ OsuNative.assertOk("ManiaDifficultyCalculator_Create", raw7.ManiaDifficultyCalculator_Create(ruleset.handle, beatmap.handle, native));
343
+ return new _ManiaDifficultyCalculator(native, ruleset, beatmap);
344
+ }
345
+ calculate() {
346
+ this.ensureAlive();
347
+ const attrs = new raw7.NativeManiaDifficultyAttributes();
348
+ OsuNative.assertOk("ManiaDifficultyCalculator_Calculate", raw7.ManiaDifficultyCalculator_Calculate(this.handle, attrs));
349
+ return attrs;
350
+ }
351
+ calculateWithMods(mods) {
352
+ this.ensureAlive();
353
+ const attrs = new raw7.NativeManiaDifficultyAttributes();
354
+ OsuNative.assertOk("ManiaDifficultyCalculator_CalculateMods", raw7.ManiaDifficultyCalculator_CalculateMods(this.handle, mods.handle, attrs));
355
+ return attrs;
356
+ }
357
+ calculateTimed() {
358
+ this.ensureAlive();
359
+ const bufferSize = new Int32Array(1);
360
+ OsuNative.assertSizeQuery("ManiaDifficultyCalculator_CalculateTimed", raw7.ManiaDifficultyCalculator_CalculateTimed(this.handle, null, bufferSize));
361
+ if (bufferSize[0] <= 0) {
362
+ return [];
363
+ }
364
+ const outAttrs = new Array(bufferSize[0]);
365
+ OsuNative.assertOk("ManiaDifficultyCalculator_CalculateTimed", raw7.ManiaDifficultyCalculator_CalculateTimed(this.handle, outAttrs, bufferSize));
366
+ return outAttrs;
367
+ }
368
+ calculateWithModsTimed(mods) {
369
+ this.ensureAlive();
370
+ const bufferSize = new Int32Array(1);
371
+ OsuNative.assertSizeQuery("ManiaDifficultyCalculator_CalculateModsTimed", raw7.ManiaDifficultyCalculator_CalculateModsTimed(this.handle, mods.handle, null, bufferSize));
372
+ if (bufferSize[0] <= 0) {
373
+ return [];
374
+ }
375
+ const outAttrs = new Array(bufferSize[0]);
376
+ OsuNative.assertOk("ManiaDifficultyCalculator_CalculateModsTimed", raw7.ManiaDifficultyCalculator_CalculateModsTimed(this.handle, mods.handle, outAttrs, bufferSize));
377
+ return outAttrs;
378
+ }
379
+ destroy() {
380
+ if (this.destroyed) {
381
+ return;
382
+ }
383
+ OsuNative.assertOk("ManiaDifficultyCalculator_Destroy", raw7.ManiaDifficultyCalculator_Destroy(this.handle));
384
+ this.destroyed = true;
385
+ }
386
+ };
387
+ __name(_ManiaDifficultyCalculator, "ManiaDifficultyCalculator");
388
+ var ManiaDifficultyCalculator = _ManiaDifficultyCalculator;
389
+
390
+ // src/calculators/difficulty/OsuDifficultyCalculator.ts
391
+ import raw8 from "@tosuapp/osu-native-napi";
392
+ var _OsuDifficultyCalculator = class _OsuDifficultyCalculator extends NativeHandleOwner {
393
+ constructor(native, ruleset, beatmap) {
394
+ super(native);
395
+ __publicField(this, "ruleset");
396
+ __publicField(this, "beatmap");
397
+ this.ruleset = ruleset, this.beatmap = beatmap;
398
+ }
399
+ static create(ruleset, beatmap) {
400
+ const native = new raw8.NativeOsuDifficultyCalculator();
401
+ OsuNative.assertOk("OsuDifficultyCalculator_Create", raw8.OsuDifficultyCalculator_Create(ruleset.handle, beatmap.handle, native));
402
+ return new _OsuDifficultyCalculator(native, ruleset, beatmap);
403
+ }
404
+ calculate() {
405
+ this.ensureAlive();
406
+ const attrs = new raw8.NativeOsuDifficultyAttributes();
407
+ OsuNative.assertOk("OsuDifficultyCalculator_Calculate", raw8.OsuDifficultyCalculator_Calculate(this.handle, attrs));
408
+ return attrs;
409
+ }
410
+ calculateWithMods(mods) {
411
+ this.ensureAlive();
412
+ const attrs = new raw8.NativeOsuDifficultyAttributes();
413
+ OsuNative.assertOk("OsuDifficultyCalculator_CalculateMods", raw8.OsuDifficultyCalculator_CalculateMods(this.handle, mods.handle, attrs));
414
+ return attrs;
415
+ }
416
+ calculateTimed() {
417
+ this.ensureAlive();
418
+ const bufferSize = new Int32Array(1);
419
+ OsuNative.assertSizeQuery("OsuDifficultyCalculator_CalculateTimed", raw8.OsuDifficultyCalculator_CalculateTimed(this.handle, null, bufferSize));
420
+ if (bufferSize[0] <= 0) {
421
+ return [];
422
+ }
423
+ const outAttrs = new Array(bufferSize[0]);
424
+ OsuNative.assertOk("OsuDifficultyCalculator_CalculateTimed", raw8.OsuDifficultyCalculator_CalculateTimed(this.handle, outAttrs, bufferSize));
425
+ return outAttrs;
426
+ }
427
+ calculateWithModsTimed(mods) {
428
+ this.ensureAlive();
429
+ const bufferSize = new Int32Array(1);
430
+ OsuNative.assertSizeQuery("OsuDifficultyCalculator_CalculateModsTimed", raw8.OsuDifficultyCalculator_CalculateModsTimed(this.handle, mods.handle, null, bufferSize));
431
+ if (bufferSize[0] <= 0) {
432
+ return [];
433
+ }
434
+ const outAttrs = new Array(bufferSize[0]);
435
+ OsuNative.assertOk("OsuDifficultyCalculator_CalculateModsTimed", raw8.OsuDifficultyCalculator_CalculateModsTimed(this.handle, mods.handle, outAttrs, bufferSize));
436
+ return outAttrs;
437
+ }
438
+ destroy() {
439
+ if (this.destroyed) {
440
+ return;
441
+ }
442
+ OsuNative.assertOk("OsuDifficultyCalculator_Destroy", raw8.OsuDifficultyCalculator_Destroy(this.handle));
443
+ this.destroyed = true;
444
+ }
445
+ };
446
+ __name(_OsuDifficultyCalculator, "OsuDifficultyCalculator");
447
+ var OsuDifficultyCalculator = _OsuDifficultyCalculator;
448
+
449
+ // src/calculators/difficulty/TaikoDifficultyCalculator.ts
450
+ import raw9 from "@tosuapp/osu-native-napi";
451
+ var _TaikoDifficultyCalculator = class _TaikoDifficultyCalculator extends NativeHandleOwner {
452
+ constructor(native, ruleset, beatmap) {
453
+ super(native);
454
+ __publicField(this, "ruleset");
455
+ __publicField(this, "beatmap");
456
+ this.ruleset = ruleset, this.beatmap = beatmap;
457
+ }
458
+ static create(ruleset, beatmap) {
459
+ const native = new raw9.NativeTaikoDifficultyCalculator();
460
+ OsuNative.assertOk("TaikoDifficultyCalculator_Create", raw9.TaikoDifficultyCalculator_Create(ruleset.handle, beatmap.handle, native));
461
+ return new _TaikoDifficultyCalculator(native, ruleset, beatmap);
462
+ }
463
+ calculate() {
464
+ this.ensureAlive();
465
+ const attrs = new raw9.NativeTaikoDifficultyAttributes();
466
+ OsuNative.assertOk("TaikoDifficultyCalculator_Calculate", raw9.TaikoDifficultyCalculator_Calculate(this.handle, attrs));
467
+ return attrs;
468
+ }
469
+ calculateWithMods(mods) {
470
+ this.ensureAlive();
471
+ const attrs = new raw9.NativeTaikoDifficultyAttributes();
472
+ OsuNative.assertOk("TaikoDifficultyCalculator_CalculateMods", raw9.TaikoDifficultyCalculator_CalculateMods(this.handle, mods.handle, attrs));
473
+ return attrs;
474
+ }
475
+ calculateTimed() {
476
+ this.ensureAlive();
477
+ const bufferSize = new Int32Array(1);
478
+ OsuNative.assertSizeQuery("TaikoDifficultyCalculator_CalculateTimed", raw9.TaikoDifficultyCalculator_CalculateTimed(this.handle, null, bufferSize));
479
+ if (bufferSize[0] <= 0) {
480
+ return [];
481
+ }
482
+ const outAttrs = new Array(bufferSize[0]);
483
+ OsuNative.assertOk("TaikoDifficultyCalculator_CalculateTimed", raw9.TaikoDifficultyCalculator_CalculateTimed(this.handle, outAttrs, bufferSize));
484
+ return outAttrs;
485
+ }
486
+ calculateWithModsTimed(mods) {
487
+ this.ensureAlive();
488
+ const bufferSize = new Int32Array(1);
489
+ OsuNative.assertSizeQuery("TaikoDifficultyCalculator_CalculateModsTimed", raw9.TaikoDifficultyCalculator_CalculateModsTimed(this.handle, mods.handle, null, bufferSize));
490
+ if (bufferSize[0] <= 0) {
491
+ return [];
492
+ }
493
+ const outAttrs = new Array(bufferSize[0]);
494
+ OsuNative.assertOk("TaikoDifficultyCalculator_CalculateModsTimed", raw9.TaikoDifficultyCalculator_CalculateModsTimed(this.handle, mods.handle, outAttrs, bufferSize));
495
+ return outAttrs;
496
+ }
497
+ destroy() {
498
+ if (this.destroyed) {
499
+ return;
500
+ }
501
+ OsuNative.assertOk("TaikoDifficultyCalculator_Destroy", raw9.TaikoDifficultyCalculator_Destroy(this.handle));
502
+ this.destroyed = true;
503
+ }
504
+ };
505
+ __name(_TaikoDifficultyCalculator, "TaikoDifficultyCalculator");
506
+ var TaikoDifficultyCalculator = _TaikoDifficultyCalculator;
507
+
508
+ // src/calculators/performance/CatchPerformanceCalculator.ts
509
+ import raw11 from "@tosuapp/osu-native-napi";
510
+
511
+ // src/internal/scoreInfo.ts
512
+ import raw10 from "@tosuapp/osu-native-napi";
513
+ function makeScoreInfo(input) {
514
+ const score = new raw10.NativeScoreInfo();
515
+ score.rulesetHandle = input.ruleset.handle;
516
+ score.beatmapHandle = input.beatmap.handle;
517
+ score.modsHandle = input.mods?.handle ?? OsuNative.makeNullHandle();
518
+ score.maxCombo = input.maxCombo ?? 0;
519
+ score.accuracy = input.accuracy ?? 0;
520
+ score.countMiss = input.countMiss ?? 0;
521
+ score.countMeh = input.countMeh ?? 0;
522
+ score.countOk = input.countOk ?? 0;
523
+ score.countGood = input.countGood ?? 0;
524
+ score.countGreat = input.countGreat ?? 0;
525
+ score.countPerfect = input.countPerfect ?? 0;
526
+ score.countSliderTailHit = input.countSliderTailHit ?? 0;
527
+ score.countLargeTickMiss = input.countLargeTickMiss ?? 0;
528
+ return score;
529
+ }
530
+ __name(makeScoreInfo, "makeScoreInfo");
531
+
532
+ // src/calculators/performance/CatchPerformanceCalculator.ts
533
+ var _CatchPerformanceCalculator = class _CatchPerformanceCalculator extends NativeHandleOwner {
534
+ static create() {
535
+ const native = new raw11.NativeCatchPerformanceCalculator();
536
+ OsuNative.assertOk("CatchPerformanceCalculator_Create", raw11.CatchPerformanceCalculator_Create(native));
537
+ return new _CatchPerformanceCalculator(native);
538
+ }
539
+ calculate(score, difficulty) {
540
+ this.ensureAlive();
541
+ const out = new raw11.NativeCatchPerformanceAttributes();
542
+ OsuNative.assertOk("CatchPerformanceCalculator_Calculate", raw11.CatchPerformanceCalculator_Calculate(this.handle, makeScoreInfo(score), difficulty, out));
543
+ return out;
544
+ }
545
+ destroy() {
546
+ if (this.destroyed) {
547
+ return;
548
+ }
549
+ OsuNative.assertOk("CatchPerformanceCalculator_Destroy", raw11.CatchPerformanceCalculator_Destroy(this.handle));
550
+ this.destroyed = true;
551
+ }
552
+ };
553
+ __name(_CatchPerformanceCalculator, "CatchPerformanceCalculator");
554
+ var CatchPerformanceCalculator = _CatchPerformanceCalculator;
555
+
556
+ // src/calculators/performance/ManiaPerformanceCalculator.ts
557
+ import raw12 from "@tosuapp/osu-native-napi";
558
+ var _ManiaPerformanceCalculator = class _ManiaPerformanceCalculator extends NativeHandleOwner {
559
+ static create() {
560
+ const native = new raw12.NativeManiaPerformanceCalculator();
561
+ OsuNative.assertOk("ManiaPerformanceCalculator_Create", raw12.ManiaPerformanceCalculator_Create(native));
562
+ return new _ManiaPerformanceCalculator(native);
563
+ }
564
+ calculate(score, difficulty) {
565
+ this.ensureAlive();
566
+ const out = new raw12.NativeManiaPerformanceAttributes();
567
+ OsuNative.assertOk("ManiaPerformanceCalculator_Calculate", raw12.ManiaPerformanceCalculator_Calculate(this.handle, makeScoreInfo(score), difficulty, out));
568
+ return out;
569
+ }
570
+ destroy() {
571
+ if (this.destroyed) {
572
+ return;
573
+ }
574
+ OsuNative.assertOk("ManiaPerformanceCalculator_Destroy", raw12.ManiaPerformanceCalculator_Destroy(this.handle));
575
+ this.destroyed = true;
576
+ }
577
+ };
578
+ __name(_ManiaPerformanceCalculator, "ManiaPerformanceCalculator");
579
+ var ManiaPerformanceCalculator = _ManiaPerformanceCalculator;
580
+
581
+ // src/calculators/performance/OsuPerformanceCalculator.ts
582
+ import raw13 from "@tosuapp/osu-native-napi";
583
+ var _OsuPerformanceCalculator = class _OsuPerformanceCalculator extends NativeHandleOwner {
584
+ static create() {
585
+ const native = new raw13.NativeOsuPerformanceCalculator();
586
+ OsuNative.assertOk("OsuPerformanceCalculator_Create", raw13.OsuPerformanceCalculator_Create(native));
587
+ return new _OsuPerformanceCalculator(native);
588
+ }
589
+ calculate(score, difficulty) {
590
+ this.ensureAlive();
591
+ const out = new raw13.NativeOsuPerformanceAttributes();
592
+ OsuNative.assertOk("OsuPerformanceCalculator_Calculate", raw13.OsuPerformanceCalculator_Calculate(this.handle, makeScoreInfo(score), difficulty, out));
593
+ return out;
594
+ }
595
+ destroy() {
596
+ if (this.destroyed) {
597
+ return;
598
+ }
599
+ OsuNative.assertOk("OsuPerformanceCalculator_Destroy", raw13.OsuPerformanceCalculator_Destroy(this.handle));
600
+ this.destroyed = true;
601
+ }
602
+ };
603
+ __name(_OsuPerformanceCalculator, "OsuPerformanceCalculator");
604
+ var OsuPerformanceCalculator = _OsuPerformanceCalculator;
605
+
606
+ // src/calculators/performance/TaikoPerformanceCalculator.ts
607
+ import raw14 from "@tosuapp/osu-native-napi";
608
+ var _TaikoPerformanceCalculator = class _TaikoPerformanceCalculator extends NativeHandleOwner {
609
+ static create() {
610
+ const native = new raw14.NativeTaikoPerformanceCalculator();
611
+ OsuNative.assertOk("TaikoPerformanceCalculator_Create", raw14.TaikoPerformanceCalculator_Create(native));
612
+ return new _TaikoPerformanceCalculator(native);
613
+ }
614
+ calculate(score, difficulty) {
615
+ this.ensureAlive();
616
+ const out = new raw14.NativeTaikoPerformanceAttributes();
617
+ OsuNative.assertOk("TaikoPerformanceCalculator_Calculate", raw14.TaikoPerformanceCalculator_Calculate(this.handle, makeScoreInfo(score), difficulty, out));
618
+ return out;
619
+ }
620
+ destroy() {
621
+ if (this.destroyed) {
622
+ return;
623
+ }
624
+ OsuNative.assertOk("TaikoPerformanceCalculator_Destroy", raw14.TaikoPerformanceCalculator_Destroy(this.handle));
625
+ this.destroyed = true;
626
+ }
627
+ };
628
+ __name(_TaikoPerformanceCalculator, "TaikoPerformanceCalculator");
629
+ var TaikoPerformanceCalculator = _TaikoPerformanceCalculator;
630
+
631
+ // src/factories/DifficultyCalculatorFactory.ts
632
+ var _DifficultyCalculatorFactory = class _DifficultyCalculatorFactory {
633
+ static create(ruleset, beatmap) {
634
+ switch (ruleset.rulesetId) {
635
+ case 0:
636
+ return OsuDifficultyCalculator.create(ruleset, beatmap);
637
+ case 1:
638
+ return TaikoDifficultyCalculator.create(ruleset, beatmap);
639
+ case 2:
640
+ return CatchDifficultyCalculator.create(ruleset, beatmap);
641
+ case 3:
642
+ return ManiaDifficultyCalculator.create(ruleset, beatmap);
643
+ default:
644
+ throw new Error(`Unsupported rulesetId: ${ruleset.rulesetId}`);
645
+ }
646
+ }
647
+ };
648
+ __name(_DifficultyCalculatorFactory, "DifficultyCalculatorFactory");
649
+ var DifficultyCalculatorFactory = _DifficultyCalculatorFactory;
650
+
651
+ // src/factories/PerformanceCalculatorFactory.ts
652
+ var _PerformanceCalculatorFactory = class _PerformanceCalculatorFactory {
653
+ static create(ruleset) {
654
+ switch (ruleset.rulesetId) {
655
+ case 0:
656
+ return OsuPerformanceCalculator.create();
657
+ case 1:
658
+ return TaikoPerformanceCalculator.create();
659
+ case 2:
660
+ return CatchPerformanceCalculator.create();
661
+ case 3:
662
+ return ManiaPerformanceCalculator.create();
663
+ default:
664
+ throw new Error(`Unsupported rulesetId: ${ruleset.rulesetId}`);
665
+ }
666
+ }
667
+ };
668
+ __name(_PerformanceCalculatorFactory, "PerformanceCalculatorFactory");
669
+ var PerformanceCalculatorFactory = _PerformanceCalculatorFactory;
670
+ export {
671
+ Beatmap,
672
+ CatchDifficultyCalculator,
673
+ CatchPerformanceCalculator,
674
+ DifficultyCalculatorFactory,
675
+ ManiaDifficultyCalculator,
676
+ ManiaPerformanceCalculator,
677
+ Mod,
678
+ ModsCollection,
679
+ OsuDifficultyCalculator,
680
+ OsuNative,
681
+ OsuNativeError,
682
+ OsuPerformanceCalculator,
683
+ PerformanceCalculatorFactory,
684
+ Ruleset,
685
+ TaikoDifficultyCalculator,
686
+ TaikoPerformanceCalculator
687
+ };