1.0.2 • Published 8 months ago

@rbxts/api-dump-fetcher v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Api-dump-fetcher

Fully types MaximumADHD Api-Dump (mostly for plugins)

NPM

Start

#bun
bun add @rbxts/api-dump-fetcher

#npm
npm i @rbxts/api-dump-fetcher

Saves api-dump in the plugin and auto updates it.

interface IGetApiDumpOptions {
	/**doesnt save in the plugin
	 * @default false */
	DontSave?: boolean;
	/**name of the plugin.SetSetting where compressed api dump is going to be saved
	 * @default API_DUMP*/
	SaveName?: string;
	/**name of the plugin.SetSetting where version of the api dump is going to be saved
	 * @default API_DUMP_VERSION*/
	VersionSaveName?: string;
}

export function LoadApiDump(plugin?: Plugin, options?: IGetApiDumpOptions): Promise<void>;
export function GetApiDump(): Promise<ApiDumpTypes.IAPIDump>;

Example usage:

Extracting all classes with propeties that are of type Color3

import { ApiDumpConstants, GetApiDump, LoadApiDump } from "@rbxts/api-dump-fetcher";

LoadApiDump(plugin); //has to be executed once from the .client.ts or .server.ts

const api_dump = GetApiDump().expect();

const class_properties_map = new Map<string, string[]>();

api_dump.Classes.forEach((value) =>
	value.Members.forEach((member) => {
		if (member.MemberType !== ApiDumpConstants.EMemberMemberType.Property) return;
		if (member.ValueType?.Category !== ApiDumpConstants.EMemberValueTypeCategory.DataType) return;
		if (member.ValueType.Name !== ApiDumpConstants.EMemberValueTypeCategoryDataTypeName.Color3)
			return;
		const properties_list =
			class_properties_map.get(value.Name) ??
			class_properties_map.set(value.Name, []).get(value.Name)!;
		properties_list.push(member.Name);
	}),
);

for (const [classname] of class_properties_map) {
	let superclass = classname;
	while (superclass !== ApiDumpConstants.ROOT_SUPER_CLASS) {
		superclass = api_dump.Classes.find((value) => value.Name === superclass)!.Superclass;
		const properties = class_properties_map.get(superclass);
		if (properties === undefined) continue;
		for (const property_name of class_properties_map.get(superclass)!) {
			class_properties_map.get(classname)!.push(property_name);
		}
	}
}

print(class_properties_map);
1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago