UNPKG

openblox

Version:

Roblox API Wrapper For Both Classic And OpenCloud APIs.

23 lines (22 loc) 2.69 kB
import type { Identifier } from "typeforge"; import type { DeepLinkAppsFlyerFormat, DeepLinkRobloxProtocolFormat, DeepLinkRobloxUrlFormat } from "./deepLinkHelpers.types"; type AnyDeepLink = DeepLinkAppsFlyerFormat<Identifier, boolean> | DeepLinkRobloxProtocolFormat<Identifier, boolean> | DeepLinkRobloxUrlFormat<Identifier, boolean>; type ExtractDataFromDeepLink<DeepLink extends unknown> = (DeepLink extends `${string}placeId=${infer PlaceId}&${string}` ? [[PlaceId], [true]] : DeepLink extends `${string}placeId=${infer PlaceId}` ? [[PlaceId], [false]] : DeepLink extends `ro.blox.com/Ebh5?af_dp=roblox%3A%2F%2FplaceId%3D${infer PlaceIdA}%26launchData%3D${string}&af_web_dp=https%3A%2F%2Fwww.roblox.com%2Fgames%2Fstart%3FplaceId%3D${infer PlaceIdB}%26launchData%3D${string}` ? [[PlaceIdA, PlaceIdB], [true, true]] : DeepLink extends `ro.blox.com/Ebh5?af_dp=roblox%3A%2F%2FplaceId%3D${infer PlaceIdA}&af_web_dp=https%3A%2F%2Fwww.roblox.com%2Fgames%2Fstart%3FplaceId%3D${infer PlaceIdB}%26launchData%3D${string}` ? [[PlaceIdA, PlaceIdB], [false, true]] : DeepLink extends `ro.blox.com/Ebh5?af_dp=roblox%3A%2F%2FplaceId%3D${infer PlaceIdA}%26launchData%3D${string}&af_web_dp=https%3A%2F%2Fwww.roblox.com%2Fgames%2Fstart%3FplaceId%3D${infer PlaceIdB}` ? [[PlaceIdA, PlaceIdB], [true, false]] : DeepLink extends `ro.blox.com/Ebh5?af_dp=roblox%3A%2F%2FplaceId%3D${infer PlaceIdA}&af_web_dp=https%3A%2F%2Fwww.roblox.com%2Fgames%2Fstart%3FplaceId%3D${infer PlaceIdB}` ? [[PlaceIdA, PlaceIdB], [false, false]] : never); type DeepLinkParseReturns<DeepLink extends any, PlaceId, LaunchData extends boolean[]> = (DeepLink extends AnyDeepLink ? PlaceId extends string[] ? PlaceId["length"] extends 2 ? [ { placeId: PlaceId[0]; launchData: LaunchData[0] extends true ? string | Record<any, any> : null; }, { placeId: PlaceId[1]; launchData: LaunchData[1] extends true ? string | Record<any, any> : null; } ] : [{ placeId: PlaceId[0]; launchData: LaunchData[0] extends true ? string | Record<any, any> : null; }] : never : { placeIds: `${number}`[]; launchData: null | string | Record<any, any>; }[]); export declare const deepLinkParse: <DeepLink extends string, ExtractedData extends DeepLink extends AnyDeepLink ? ExtractDataFromDeepLink<"🔒__PRIVATE_SELF" extends keyof DeepLink ? DeepLink["🔒__PRIVATE_SELF"] : DeepLink> : never, PlaceIds_1 extends ExtractedData extends [infer PlaceIds, boolean[]] ? PlaceIds : never, LaunchData extends ExtractedData extends [string[], infer HasLaunchData] ? HasLaunchData : never>(deepLink: DeepLink, decodeBase64?: boolean) => DeepLinkParseReturns<DeepLink, PlaceIds_1, LaunchData>; export {};