openblox
Version:
Roblox API Wrapper For Both Classic And OpenCloud APIs.
77 lines (76 loc) • 3.23 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var createDeepLink_exports = {};
__export(createDeepLink_exports, {
deepLinkCreate: () => deepLinkCreate
});
module.exports = __toCommonJS(createDeepLink_exports);
const toAppsFlyerFormat = (placeId, launchDataStr) => new DeepLinkString(
`ro.blox.com/Ebh5?af_dp=roblox%3A%2F%2FplaceId%3D${placeId}${launchDataStr ? `%26launchData%3D${launchDataStr}` : ""}&af_web_dp=https%3A%2F%2Fwww.roblox.com%2Fgames%2Fstart%3FplaceId%3D${placeId}${launchDataStr ? `%26launchData%3D${launchDataStr}` : ""}`,
placeId,
launchDataStr,
toAppsFlyerFormat
);
const toRobloxProtocolFormat = (placeId, launchDataStr) => new DeepLinkString(`roblox://placeId=${placeId}${launchDataStr ? `&launchData=${launchDataStr}` : ""}`, placeId, launchDataStr, toRobloxProtocolFormat);
const toRobloxUrlFormat = (placeId, launchDataStr) => new DeepLinkString(
`https://www.roblox.com/games/start?placeId=${placeId}${launchDataStr ? `&launchData=${launchDataStr}` : ""}`,
placeId,
launchDataStr,
toRobloxUrlFormat
);
const stringifyLaunchData = (launchData) => {
if (!launchData) return null;
if (typeof launchData === "string") return launchData.length == 0 ? null : encodeURIComponent(btoa(launchData));
if (launchData?.constructor === Object) return encodeURIComponent(btoa(JSON.stringify(launchData)));
return null;
};
class DeepLinkString extends String {
str;
placeId;
launchData;
reFormat;
constructor(str, placeId, launchData, reFormat) {
super(str);
this.str = str;
this.placeId = placeId;
this.launchData = launchData;
this.reFormat = reFormat;
}
setLaunchData(launchData) {
return this.reFormat(this.placeId, stringifyLaunchData(launchData));
}
toAppsFlyerFormat() {
return toAppsFlyerFormat(this.placeId, this.launchData);
}
toRobloxProtocolFormat() {
return toRobloxProtocolFormat(this.placeId, this.launchData);
}
toRobloxUrlFormat() {
return toRobloxUrlFormat(this.placeId, this.launchData);
}
}
const deepLinkCreate = ({ placeId, launchData, format }) => {
if (!format) format = "AppsFlyer";
const launchDataStr = stringifyLaunchData(launchData);
return format == "AppsFlyer" ? toAppsFlyerFormat(placeId, launchDataStr) : format == "RobloxProtocol" ? toRobloxProtocolFormat(placeId, launchDataStr) : toRobloxUrlFormat(placeId, launchDataStr);
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
deepLinkCreate
});
;