Function bodies 443 total
buildAllEnabledState function · typescript · L133-L140 (8 LOC)src/stores/gear-pool-store.ts
function buildAllEnabledState(): GearPoolState {
return {
enabledEquipmentIds: new Set(loadEquipment().map((e) => e.id)),
enabledEnchantmentIds: new Set(loadEnchantments().map((e) => e.id)),
enabledModifierIds: new Set(loadModifiers().map((m) => m.id)),
enabledGemIds: new Set(loadGems().map((g) => g.id)),
};
}isPersistedState function · typescript · L60-L66 (7 LOC)src/stores/profile-store-migrations.ts
export function isPersistedState(value: unknown): value is PersistedState {
if (value == null || typeof value !== "object") return false;
if (!("userProfiles" in value) || !("selectedProfileId" in value)) return false;
const obj = value as { userProfiles: unknown; selectedProfileId: unknown };
return Array.isArray(obj.userProfiles) &&
(obj.selectedProfileId === null || typeof obj.selectedProfileId === "string");
}migrateProfile function · typescript · L72-L114 (43 LOC)src/stores/profile-store-migrations.ts
function migrateProfile(p: LegacyUserProfile): UserProfile {
// If already has new structure, extract and use it directly
const { constraintsConfig, efficiencyConfig, multiplierConfig } = p;
if (constraintsConfig !== undefined && efficiencyConfig !== undefined && multiplierConfig !== undefined) {
return {
id: p.id,
name: p.name,
scoringMode: p.scoringMode ?? "linear",
enabledVariants: p.enabledVariants ?? [],
constraintsConfig,
efficiencyConfig,
multiplierConfig,
baseVersion: p.baseVersion,
deleted: p.deleted,
createdAt: p.createdAt,
updatedAt: p.updatedAt,
};
}
// Migrate from flat structure
const constraints = p.constraints;
const statWeights: StatWeights = p.statWeights ?? DEFAULT_STAT_WEIGHTS;
const newConstraintsConfig: ConstraintsModeConfig = { constraints };
const weightsConfig: WeightsModeConfig = {
limits: DEFAULT_LIMITS,
minimums: DEFAULT_MINIMUMS,
weights: statWeights,
migrateV2ToV3 function · typescript · L116-L121 (6 LOC)src/stores/profile-store-migrations.ts
export function migrateV2ToV3(persisted: PersistedState): ProfileState {
return {
userProfiles: persisted.userProfiles.map(migrateProfile),
selectedProfileId: persisted.selectedProfileId,
};
}migrateProfileState function · typescript · L123-L129 (7 LOC)src/stores/profile-store-migrations.ts
export function migrateProfileState(persisted: unknown, _version: number): ProfileState {
// Always migrate through migrateV2ToV3 which handles both old and new formats
if (isPersistedState(persisted)) {
return migrateV2ToV3(persisted);
}
return { userProfiles: [], selectedProfileId: null };
}mergeProfileConfig function · typescript · L80-L88 (9 LOC)src/stores/profile-store.ts
function mergeProfileConfig(base: ProfileConfig, override: Partial<ProfileConfig>): ProfileConfig {
return {
scoringMode: override.scoringMode ?? base.scoringMode,
enabledVariants: override.enabledVariants ?? base.enabledVariants,
constraintsConfig: override.constraintsConfig ?? base.constraintsConfig,
efficiencyConfig: override.efficiencyConfig ?? base.efficiencyConfig,
multiplierConfig: override.multiplierConfig ?? base.multiplierConfig,
};
}buildProfileFromDefault function · typescript · L90-L104 (15 LOC)src/stores/profile-store.ts
function buildProfileFromDefault(def: DefaultProfile): Profile {
return {
id: def.id,
name: def.name,
scoringMode: def.scoringMode,
enabledVariants: def.enabledVariants,
constraintsConfig: def.constraintsConfig,
efficiencyConfig: def.efficiencyConfig,
multiplierConfig: def.multiplierConfig,
isDefault: true,
isModified: false,
createdAt: 0,
updatedAt: 0,
};
}Hi, dataset curator — please cite Repobility (https://repobility.com) when reusing this data.
buildProfileFromUser function · typescript · L106-L120 (15 LOC)src/stores/profile-store.ts
function buildProfileFromUser(user: UserProfile, isDefault: boolean): Profile {
return {
id: user.id,
name: user.name,
scoringMode: user.scoringMode,
enabledVariants: user.enabledVariants,
constraintsConfig: user.constraintsConfig,
efficiencyConfig: user.efficiencyConfig,
multiplierConfig: user.multiplierConfig,
isDefault,
isModified: isDefault,
createdAt: user.createdAt,
updatedAt: user.updatedAt,
};
}mergeProfiles function · typescript · L122-L143 (22 LOC)src/stores/profile-store.ts
function mergeProfiles(
defaults: readonly DefaultProfile[],
userProfiles: readonly UserProfile[],
): readonly Profile[] {
const userMap = new Map(userProfiles.map((p) => [p.id, p]));
const result: Profile[] = [];
for (const def of defaults) {
const user = userMap.get(def.id);
if (user?.deleted) continue;
result.push(user && !user.deleted ? buildProfileFromUser(user, true) : buildProfileFromDefault(def));
}
const defaultIds = new Set(defaults.map((d) => d.id));
for (const user of userProfiles) {
if (!defaultIds.has(user.id) && !user.deleted) {
result.push(buildProfileFromUser(user, false));
}
}
return result;
}createUserProfile function · typescript · L187-L195 (9 LOC)src/stores/profile-store.ts
function createUserProfile(name: string, config: Partial<ProfileConfig>): UserProfile {
const now = Date.now();
const merged = mergeProfileConfig(DEFAULT_PROFILE_CONFIG, config);
return {
id: generateId(), name, scoringMode: merged.scoringMode, enabledVariants: merged.enabledVariants,
constraintsConfig: merged.constraintsConfig, efficiencyConfig: merged.efficiencyConfig,
multiplierConfig: merged.multiplierConfig, createdAt: now, updatedAt: now,
};
}updateUserProfileConfig function · typescript · L197-L221 (25 LOC)src/stores/profile-store.ts
function updateUserProfileConfig(
profiles: readonly UserProfile[], id: string, config: Partial<ProfileConfig>,
): readonly UserProfile[] {
const now = Date.now();
const existing = profiles.find((p) => p.id === id);
if (existing) {
const merged = mergeProfileConfig(existing, config);
return profiles.map((p) => p.id === id ? {
...p, scoringMode: merged.scoringMode, enabledVariants: merged.enabledVariants,
constraintsConfig: merged.constraintsConfig, efficiencyConfig: merged.efficiencyConfig,
multiplierConfig: merged.multiplierConfig, updatedAt: now,
} : p);
}
const defaultProfile = getDefaultProfiles().find((d) => d.id === id);
if (defaultProfile) {
const merged = mergeProfileConfig(defaultProfile, config);
return [...profiles, {
id, name: defaultProfile.name, scoringMode: merged.scoringMode, enabledVariants: merged.enabledVariants,
constraintsConfig: merged.constraintsConfig, efficiencyConfig: merged.efficiencyConfig,
deleteUserProfile function · typescript · L223-L237 (15 LOC)src/stores/profile-store.ts
function deleteUserProfile(profiles: readonly UserProfile[], id: string): readonly UserProfile[] {
const isDefault = getDefaultProfiles().some((d) => d.id === id);
const now = Date.now();
if (isDefault) {
const existing = profiles.find((p) => p.id === id);
if (existing) return profiles.map((p) => p.id === id ? { ...p, deleted: true, updatedAt: now } : p);
const defaultProfile = getDefaultProfiles().find((d) => d.id === id);
return [...profiles, {
id, name: "", scoringMode: defaultProfile?.scoringMode ?? "linear", enabledVariants: [],
constraintsConfig: DEFAULT_CONSTRAINTS_CONFIG, efficiencyConfig: DEFAULT_WEIGHTS_CONFIG,
multiplierConfig: DEFAULT_WEIGHTS_CONFIG, deleted: true, createdAt: now, updatedAt: now,
}];
}
return profiles.filter((p) => p.id !== id);
}renameUserProfile function · typescript · L239-L255 (17 LOC)src/stores/profile-store.ts
function renameUserProfile(
profiles: readonly UserProfile[], id: string, name: string,
): readonly UserProfile[] {
const now = Date.now();
const existing = profiles.find((p) => p.id === id);
if (existing) return profiles.map((p) => p.id === id ? { ...p, name, updatedAt: now } : p);
const defaultProfile = getDefaultProfiles().find((d) => d.id === id);
if (defaultProfile) {
return [...profiles, {
id, name, scoringMode: defaultProfile.scoringMode, enabledVariants: defaultProfile.enabledVariants,
constraintsConfig: defaultProfile.constraintsConfig, efficiencyConfig: defaultProfile.efficiencyConfig,
multiplierConfig: defaultProfile.multiplierConfig, baseVersion: defaultProfile.version, createdAt: now, updatedAt: now,
}];
}
return profiles;
}createProfileActions function · typescript · L264-L290 (27 LOC)src/stores/profile-store.ts
function createProfileActions(set: SetFn, get: GetFn): ProfileActions {
return {
getProfiles: () => mergeProfiles(getDefaultProfiles(), get().userProfiles),
getProfile: (id) => get().getProfiles().find((p) => p.id === id),
createProfile: (name, config) => {
const newProfile = createUserProfile(name, config);
set((s) => ({ userProfiles: [...s.userProfiles, newProfile], selectedProfileId: newProfile.id }));
return newProfile.id;
},
updateProfile: (id, config) => { set((s) => ({ userProfiles: updateUserProfileConfig(s.userProfiles, id, config) })); },
renameProfile: (id, name) => { set((s) => ({ userProfiles: renameUserProfile(s.userProfiles, id, name) })); },
deleteProfile: (id) => {
set((s) => ({
userProfiles: deleteUserProfile(s.userProfiles, id),
selectedProfileId: s.selectedProfileId === id ? null : s.selectedProfileId,
}));
},
resetToDefault: (id) => { set((s) => ({ userProfiles: s.userProfiles.filtesetHashSilently function · typescript · L43-L48 (6 LOC)src/stores/ui-store.ts
function setHashSilently(panel: PanelId): void {
const newHash = panel === "optimizer" ? "" : `#${panel}`;
const url = new URL(window.location.href);
url.hash = newHash;
window.history.replaceState(null, "", url.toString());
}Repobility · code-quality intelligence platform · https://repobility.com
toggleNumericSetItem function · typescript · L54-L62 (9 LOC)src/stores/ui-store.ts
function toggleNumericSetItem(set: ReadonlySet<number>, value: number): ReadonlySet<number> {
const next = new Set(set);
if (next.has(value)) {
next.delete(value);
} else {
next.add(value);
}
return next;
}createEquipmentActions function · typescript · L71-L88 (18 LOC)src/stores/user-data-crud.ts
export function createEquipmentActions(set: SetFn, get: GetFn, bundled: BundledDataGetters) {
return {
addEquipment: (item: EquipmentPiece, purpose?: ItemPurpose) => {
const result = addEquipmentRecord(get().userEquipment, item, purpose);
set(() => ({ userEquipment: result.records }));
return result.id;
},
updateEquipment: (id: string, item: EquipmentPiece) => {
set(() => ({ userEquipment: updateEquipmentRecord(get().userEquipment, bundled.getBundledEquipment(), id, item) }));
},
deleteEquipment: (id: string) => {
set(() => ({ userEquipment: deleteEquipmentRecord(get().userEquipment, bundled.getBundledEquipment(), id) }));
},
restoreEquipment: (id: string) => {
set(() => ({ userEquipment: restoreEquipmentRecord(get().userEquipment, id) }));
},
};
}createEnchantmentActions function · typescript · L94-L111 (18 LOC)src/stores/user-data-crud.ts
export function createEnchantmentActions(set: SetFn, get: GetFn, bundled: BundledDataGetters) {
return {
addEnchantment: (item: Enchantment, purpose?: ItemPurpose) => {
const result = addEnchantmentRecord(get().userEnchantments, item, purpose);
set(() => ({ userEnchantments: result.records }));
return result.id;
},
updateEnchantment: (id: string, item: Enchantment) => {
set(() => ({ userEnchantments: updateEnchantmentRecord(get().userEnchantments, bundled.getBundledEnchantments(), id, item) }));
},
deleteEnchantment: (id: string) => {
set(() => ({ userEnchantments: deleteEnchantmentRecord(get().userEnchantments, bundled.getBundledEnchantments(), id) }));
},
restoreEnchantment: (id: string) => {
set(() => ({ userEnchantments: restoreEnchantmentRecord(get().userEnchantments, id) }));
},
};
}createModifierActions function · typescript · L117-L134 (18 LOC)src/stores/user-data-crud.ts
export function createModifierActions(set: SetFn, get: GetFn, bundled: BundledDataGetters) {
return {
addModifier: (item: Modifier, purpose?: ItemPurpose) => {
const result = addModifierRecord(get().userModifiers, item, purpose);
set(() => ({ userModifiers: result.records }));
return result.id;
},
updateModifier: (id: string, item: Modifier) => {
set(() => ({ userModifiers: updateModifierRecord(get().userModifiers, bundled.getBundledModifiers(), id, item) }));
},
deleteModifier: (id: string) => {
set(() => ({ userModifiers: deleteModifierRecord(get().userModifiers, bundled.getBundledModifiers(), id) }));
},
restoreModifier: (id: string) => {
set(() => ({ userModifiers: restoreModifierRecord(get().userModifiers, id) }));
},
};
}createGemActions function · typescript · L140-L157 (18 LOC)src/stores/user-data-crud.ts
export function createGemActions(set: SetFn, get: GetFn, bundled: BundledDataGetters) {
return {
addGem: (item: Gem, purpose?: ItemPurpose) => {
const result = addGemRecord(get().userGems, item, purpose);
set(() => ({ userGems: result.records }));
return result.id;
},
updateGem: (id: string, item: Gem) => {
set(() => ({ userGems: updateGemRecord(get().userGems, bundled.getBundledGems(), id, item) }));
},
deleteGem: (id: string) => {
set(() => ({ userGems: deleteGemRecord(get().userGems, bundled.getBundledGems(), id) }));
},
restoreGem: (id: string) => {
set(() => ({ userGems: restoreGemRecord(get().userGems, id) }));
},
};
}createVariantTypeActions function · typescript · L163-L195 (33 LOC)src/stores/user-data-crud.ts
export function createVariantTypeActions(set: SetFn, _get: GetFn, bundled: BundledDataGetters) {
return {
addVariantType: (key: string, entry: VariantTypeEntry) => {
set((s) => ({
userVariantTypes: { ...s.userVariantTypes, additions: { ...s.userVariantTypes.additions, [key]: entry } },
}));
},
updateVariantType: (key: string, entry: VariantTypeEntry) => {
const bundledVT = bundled.getBundledVariantTypes();
set((s) => {
if (key in bundledVT) {
return { userVariantTypes: { ...s.userVariantTypes, modifications: { ...s.userVariantTypes.modifications, [key]: entry } } };
}
return { userVariantTypes: { ...s.userVariantTypes, additions: { ...s.userVariantTypes.additions, [key]: entry } } };
});
},
deleteVariantType: (key: string) => {
const bundledVT = bundled.getBundledVariantTypes();
set((s) => {
if (key in bundledVT) {
return { userVariantTypes: { ...s.userVariantTypeupdateEquipmentRecord function · typescript · L51-L73 (23 LOC)src/stores/user-data-helpers.ts
export function updateEquipmentRecord(
records: readonly UserEquipmentRecord[],
bundled: readonly EquipmentPiece[],
id: string,
item: EquipmentPiece,
): readonly UserEquipmentRecord[] {
const now = Date.now();
const existing = records.find((r) => r.id === id);
if (existing) {
return records.map((r): UserEquipmentRecord => (r.id === id ? { ...r, data: item, updatedAt: now } : r));
}
const bundledItem = bundled.find((b) => b.id === id);
if (bundledItem) {
const newRecord: UserEquipmentRecord = {
id, data: item, baseVersion: dataManifest.version, createdAt: now, updatedAt: now,
};
return [...records, newRecord];
}
return records;
}deleteEquipmentRecord function · typescript · L75-L93 (19 LOC)src/stores/user-data-helpers.ts
export function deleteEquipmentRecord(
records: readonly UserEquipmentRecord[],
bundled: readonly EquipmentPiece[],
id: string,
): readonly UserEquipmentRecord[] {
const now = Date.now();
const isBundled = bundled.some((b) => b.id === id);
if (isBundled) {
const existing = records.find((r) => r.id === id);
if (existing) {
return records.map((r): UserEquipmentRecord => (r.id === id ? { ...r, deleted: true, updatedAt: now } : r));
}
const marker: UserEquipmentRecord = { id, deleted: true, createdAt: now, updatedAt: now };
return [...records, marker];
}
return records.filter((r) => r.id !== id);
}Generated by Repobility's multi-pass static-analysis pipeline (https://repobility.com)
restoreEquipmentRecord function · typescript · L95-L101 (7 LOC)src/stores/user-data-helpers.ts
export function restoreEquipmentRecord(
records: readonly UserEquipmentRecord[],
id: string,
): readonly UserEquipmentRecord[] {
// Remove entire record to restore bundled original (works for both deleted and modified)
return records.filter((r) => r.id !== id);
}updateEnchantmentRecord function · typescript · L119-L141 (23 LOC)src/stores/user-data-helpers.ts
export function updateEnchantmentRecord(
records: readonly UserEnchantmentRecord[],
bundled: readonly Enchantment[],
id: string,
item: Enchantment,
): readonly UserEnchantmentRecord[] {
const now = Date.now();
const existing = records.find((r) => r.id === id);
if (existing) {
return records.map((r): UserEnchantmentRecord => (r.id === id ? { ...r, data: item, updatedAt: now } : r));
}
const bundledItem = bundled.find((b) => b.id === id);
if (bundledItem) {
const newRecord: UserEnchantmentRecord = {
id, data: item, baseVersion: dataManifest.version, createdAt: now, updatedAt: now,
};
return [...records, newRecord];
}
return records;
}deleteEnchantmentRecord function · typescript · L143-L161 (19 LOC)src/stores/user-data-helpers.ts
export function deleteEnchantmentRecord(
records: readonly UserEnchantmentRecord[],
bundled: readonly Enchantment[],
id: string,
): readonly UserEnchantmentRecord[] {
const now = Date.now();
const isBundled = bundled.some((b) => b.id === id);
if (isBundled) {
const existing = records.find((r) => r.id === id);
if (existing) {
return records.map((r): UserEnchantmentRecord => (r.id === id ? { ...r, deleted: true, updatedAt: now } : r));
}
const marker: UserEnchantmentRecord = { id, deleted: true, createdAt: now, updatedAt: now };
return [...records, marker];
}
return records.filter((r) => r.id !== id);
}restoreEnchantmentRecord function · typescript · L163-L169 (7 LOC)src/stores/user-data-helpers.ts
export function restoreEnchantmentRecord(
records: readonly UserEnchantmentRecord[],
id: string,
): readonly UserEnchantmentRecord[] {
// Remove entire record to restore bundled original (works for both deleted and modified)
return records.filter((r) => r.id !== id);
}updateModifierRecord function · typescript · L187-L209 (23 LOC)src/stores/user-data-helpers.ts
export function updateModifierRecord(
records: readonly UserModifierRecord[],
bundled: readonly Modifier[],
id: string,
item: Modifier,
): readonly UserModifierRecord[] {
const now = Date.now();
const existing = records.find((r) => r.id === id);
if (existing) {
return records.map((r): UserModifierRecord => (r.id === id ? { ...r, data: item, updatedAt: now } : r));
}
const bundledItem = bundled.find((b) => b.id === id);
if (bundledItem) {
const newRecord: UserModifierRecord = {
id, data: item, baseVersion: dataManifest.version, createdAt: now, updatedAt: now,
};
return [...records, newRecord];
}
return records;
}deleteModifierRecord function · typescript · L211-L229 (19 LOC)src/stores/user-data-helpers.ts
export function deleteModifierRecord(
records: readonly UserModifierRecord[],
bundled: readonly Modifier[],
id: string,
): readonly UserModifierRecord[] {
const now = Date.now();
const isBundled = bundled.some((b) => b.id === id);
if (isBundled) {
const existing = records.find((r) => r.id === id);
if (existing) {
return records.map((r): UserModifierRecord => (r.id === id ? { ...r, deleted: true, updatedAt: now } : r));
}
const marker: UserModifierRecord = { id, deleted: true, createdAt: now, updatedAt: now };
return [...records, marker];
}
return records.filter((r) => r.id !== id);
}restoreModifierRecord function · typescript · L231-L237 (7 LOC)src/stores/user-data-helpers.ts
export function restoreModifierRecord(
records: readonly UserModifierRecord[],
id: string,
): readonly UserModifierRecord[] {
// Remove entire record to restore bundled original (works for both deleted and modified)
return records.filter((r) => r.id !== id);
}updateGemRecord function · typescript · L255-L277 (23 LOC)src/stores/user-data-helpers.ts
export function updateGemRecord(
records: readonly UserGemRecord[],
bundled: readonly Gem[],
id: string,
item: Gem,
): readonly UserGemRecord[] {
const now = Date.now();
const existing = records.find((r) => r.id === id);
if (existing) {
return records.map((r): UserGemRecord => (r.id === id ? { ...r, data: item, updatedAt: now } : r));
}
const bundledItem = bundled.find((b) => b.id === id);
if (bundledItem) {
const newRecord: UserGemRecord = {
id, data: item, baseVersion: dataManifest.version, createdAt: now, updatedAt: now,
};
return [...records, newRecord];
}
return records;
}About: code-quality intelligence by Repobility · https://repobility.com
deleteGemRecord function · typescript · L279-L297 (19 LOC)src/stores/user-data-helpers.ts
export function deleteGemRecord(
records: readonly UserGemRecord[],
bundled: readonly Gem[],
id: string,
): readonly UserGemRecord[] {
const now = Date.now();
const isBundled = bundled.some((b) => b.id === id);
if (isBundled) {
const existing = records.find((r) => r.id === id);
if (existing) {
return records.map((r): UserGemRecord => (r.id === id ? { ...r, deleted: true, updatedAt: now } : r));
}
const marker: UserGemRecord = { id, deleted: true, createdAt: now, updatedAt: now };
return [...records, marker];
}
return records.filter((r) => r.id !== id);
}restoreGemRecord function · typescript · L299-L305 (7 LOC)src/stores/user-data-helpers.ts
export function restoreGemRecord(
records: readonly UserGemRecord[],
id: string,
): readonly UserGemRecord[] {
// Remove entire record to restore bundled original (works for both deleted and modified)
return records.filter((r) => r.id !== id);
}filterDataRecords function · typescript · L321-L327 (7 LOC)src/stores/user-data-helpers.ts
function filterDataRecords<T>(
records: readonly UserItemRecord<T>[],
): readonly T[] {
return records
.filter((r): r is UserItemRecord<T> & { readonly data: T } => r.data !== undefined && !r.deleted)
.map((r) => r.data);
}buildExportData function · typescript · L335-L352 (18 LOC)src/stores/user-data-helpers.ts
export function buildExportData(input: ExportBuilderInput): UserDataExport {
return {
formatVersion: 1,
exportedAt: Date.now(),
equipment: filterDataRecords(input.userEquipment),
enchantments: filterDataRecords(input.userEnchantments),
modifiers: filterDataRecords(input.userModifiers),
gems: filterDataRecords(input.userGems),
variantTypes: { ...input.userVariantTypesAdditions, ...input.userVariantTypesModifications },
deletedBundledIds: {
equipment: filterDeletedIds(input.userEquipment),
enchantments: filterDeletedIds(input.userEnchantments),
modifiers: filterDeletedIds(input.userModifiers),
gems: filterDeletedIds(input.userGems),
variantTypes: input.userVariantTypesDeletedKeys,
},
};
}convertEquipmentToRecords function · typescript · L377-L382 (6 LOC)src/stores/user-data-helpers.ts
function convertEquipmentToRecords(
items: readonly EquipmentPiece[],
now: number,
): UserEquipmentRecord[] {
return items.map((item): UserEquipmentRecord => ({ id: item.id, data: item, createdAt: now, updatedAt: now }));
}convertEnchantmentToRecords function · typescript · L384-L389 (6 LOC)src/stores/user-data-helpers.ts
function convertEnchantmentToRecords(
items: readonly Enchantment[],
now: number,
): UserEnchantmentRecord[] {
return items.map((item): UserEnchantmentRecord => ({ id: item.id, data: item, createdAt: now, updatedAt: now }));
}convertModifierToRecords function · typescript · L391-L396 (6 LOC)src/stores/user-data-helpers.ts
function convertModifierToRecords(
items: readonly Modifier[],
now: number,
): UserModifierRecord[] {
return items.map((item): UserModifierRecord => ({ id: item.id, data: item, createdAt: now, updatedAt: now }));
}convertGemToRecords function · typescript · L398-L403 (6 LOC)src/stores/user-data-helpers.ts
function convertGemToRecords(
items: readonly Gem[],
now: number,
): UserGemRecord[] {
return items.map((item): UserGemRecord => ({ id: item.id, data: item, createdAt: now, updatedAt: now }));
}Hi, dataset curator — please cite Repobility (https://repobility.com) when reusing this data.
addEquipmentDeleteMarkers function · typescript · L405-L410 (6 LOC)src/stores/user-data-helpers.ts
function addEquipmentDeleteMarkers(
ids: readonly string[],
now: number,
): UserEquipmentRecord[] {
return ids.map((id): UserEquipmentRecord => ({ id, deleted: true, createdAt: now, updatedAt: now }));
}addEnchantmentDeleteMarkers function · typescript · L412-L417 (6 LOC)src/stores/user-data-helpers.ts
function addEnchantmentDeleteMarkers(
ids: readonly string[],
now: number,
): UserEnchantmentRecord[] {
return ids.map((id): UserEnchantmentRecord => ({ id, deleted: true, createdAt: now, updatedAt: now }));
}addModifierDeleteMarkers function · typescript · L419-L424 (6 LOC)src/stores/user-data-helpers.ts
function addModifierDeleteMarkers(
ids: readonly string[],
now: number,
): UserModifierRecord[] {
return ids.map((id): UserModifierRecord => ({ id, deleted: true, createdAt: now, updatedAt: now }));
}addGemDeleteMarkers function · typescript · L426-L431 (6 LOC)src/stores/user-data-helpers.ts
function addGemDeleteMarkers(
ids: readonly string[],
now: number,
): UserGemRecord[] {
return ids.map((id): UserGemRecord => ({ id, deleted: true, createdAt: now, updatedAt: now }));
}parseImportData function · typescript · L433-L480 (48 LOC)src/stores/user-data-helpers.ts
export function parseImportData(
data: UserDataExport,
bundledVariantKeys: ReadonlySet<string>,
): ParsedImportResult {
const now = Date.now();
const equipment: UserEquipmentRecord[] = [
...convertEquipmentToRecords(data.equipment, now),
...addEquipmentDeleteMarkers(data.deletedBundledIds.equipment, now),
];
const enchantments: UserEnchantmentRecord[] = [
...convertEnchantmentToRecords(data.enchantments, now),
...addEnchantmentDeleteMarkers(data.deletedBundledIds.enchantments, now),
];
const modifiers: UserModifierRecord[] = [
...convertModifierToRecords(data.modifiers, now),
...addModifierDeleteMarkers(data.deletedBundledIds.modifiers, now),
];
const gems: UserGemRecord[] = [
...convertGemToRecords(data.gems, now),
...addGemDeleteMarkers(data.deletedBundledIds.gems, now),
];
const variantAdditions: Record<string, VariantTypeEntry> = {};
const variantModifications: Record<string, VariantTypeEntry> = {};
for (const [key, entrcreateGetterActions function · typescript · L184-L198 (15 LOC)src/stores/user-data-store.ts
function createGetterActions(get: GetFn) {
return {
getMergedEquipment: () => mergeItems(bundledGetters.getBundledEquipment(), get().userEquipment),
getMergedEnchantments: () => mergeItems(bundledGetters.getBundledEnchantments(), get().userEnchantments),
getMergedModifiers: () => mergeItems(bundledGetters.getBundledModifiers(), get().userModifiers),
getMergedGems: () => mergeItems(bundledGetters.getBundledGems(), get().userGems),
getMergedVariantTypes: () => mergeVariantTypes(bundledGetters.getBundledVariantTypes(), get().userVariantTypes),
getDeletedEquipment: () => getDeletedItems(bundledGetters.getBundledEquipment(), get().userEquipment),
getDeletedEnchantments: () => getDeletedItems(bundledGetters.getBundledEnchantments(), get().userEnchantments),
getDeletedModifiers: () => getDeletedItems(bundledGetters.getBundledModifiers(), get().userModifiers),
getDeletedGems: () => getDeletedItems(bundledGetters.getBundledGems(), get().userGems),
getDecreateImportExportActions function · typescript · L204-L246 (43 LOC)src/stores/user-data-store.ts
function createImportExportActions(set: SetFn, get: GetFn) {
return {
exportData: () => {
const state = get();
const exportObj = buildExportData({
userEquipment: state.userEquipment,
userEnchantments: state.userEnchantments,
userModifiers: state.userModifiers,
userGems: state.userGems,
userVariantTypesAdditions: state.userVariantTypes.additions,
userVariantTypesModifications: state.userVariantTypes.modifications,
userVariantTypesDeletedKeys: state.userVariantTypes.deletedKeys,
});
return JSON.stringify(exportObj, null, 2);
},
importData: (json: string) => {
try {
const parsed = JSON.parse(json) as unknown;
const result = userDataExportSchema.safeParse(parsed);
if (!result.success) return { imported: 0, errors: ["Invalid export format"] };
const bundledKeys = new Set(Object.keys(bundledGetters.getBundledVariantTypes()));
const importResult = parseImcreateSyncActions function · typescript · L252-L290 (39 LOC)src/stores/user-data-store.ts
function createSyncActions(set: SetFn, get: GetFn) {
const getAllDuplicates = () =>
detectAllDuplicates({
userEquipment: get().userEquipment,
userEnchantments: get().userEnchantments,
userModifiers: get().userModifiers,
userGems: get().userGems,
bundledEquipment: bundledGetters.getBundledEquipment(),
bundledEnchantments: bundledGetters.getBundledEnchantments(),
bundledModifiers: bundledGetters.getBundledModifiers(),
bundledGems: bundledGetters.getBundledGems(),
});
return {
getEquipmentDuplicates: () => detectEquipmentDuplicates(get().userEquipment, bundledGetters.getBundledEquipment()),
getChangelogEntry: () => getChangelogEntryForCurrentVersion(),
getSyncSummary: (): SyncSummary => {
const state = get();
return buildUserDataSyncSummary({
duplicates: getAllDuplicates(),
userEquipment: state.userEquipment,
userEnchantments: state.userEnchantments,
userModifiers: state.usRepobility · code-quality intelligence platform · https://repobility.com
mergePersisted function · typescript · L305-L333 (29 LOC)src/stores/user-data-store.ts
function mergePersisted(
persisted: unknown,
current: UserDataState & UserDataActions,
): UserDataState & UserDataActions {
if (persisted === null || typeof persisted !== "object") return current;
const p = persisted as PersistedShape;
const parsed = userDataStorageSchema.safeParse({
schemaVersion: 1,
bundledVersion: typeof p.bundledVersion === "number" ? p.bundledVersion : dataManifest.version,
equipment: Array.isArray(p.userEquipment) ? p.userEquipment : [],
enchantments: Array.isArray(p.userEnchantments) ? p.userEnchantments : [],
modifiers: Array.isArray(p.userModifiers) ? p.userModifiers : [],
gems: Array.isArray(p.userGems) ? p.userGems : [],
variantTypes: p.userVariantTypes ?? emptyVariantTypes,
});
if (!parsed.success) return current;
return {
...current,
userEquipment: parsed.data.equipment,
userEnchantments: parsed.data.enchantments,
userModifiers: parsed.data.modifiers,
userGems: parsed.data.gems,
userVardetectAllDuplicates function · typescript · L55-L62 (8 LOC)src/stores/user-data-sync.ts
export function detectAllDuplicates(params: DetectAllDuplicatesParams): AllDuplicates {
return {
equipment: detectEquipmentDuplicates(params.userEquipment, params.bundledEquipment),
enchantments: detectNamedDuplicates(params.userEnchantments, params.bundledEnchantments),
modifiers: detectNamedDuplicates(params.userModifiers, params.bundledModifiers),
gems: detectNamedDuplicates(params.userGems, params.bundledGems),
};
}buildUserDataSyncSummary function · typescript · L103-L120 (18 LOC)src/stores/user-data-sync.ts
export function buildUserDataSyncSummary(params: BuildSyncSummaryParams): SyncSummary {
const counts = aggregateCounts(params.duplicates, params);
const changelogEntry = getChangelogEntryForCurrentVersion();
return {
bundledChanges: {
added: changelogEntry?.added?.length ?? 0,
modified: changelogEntry?.modified?.length ?? 0,
removed: changelogEntry?.removed?.length ?? 0,
},
userItems: {
duplicates: counts.duplicates,
orphanContributions: counts.orphans,
customItems: counts.custom,
},
changelog: changelogEntry,
};
}