@bitrix24/b24jssdk
Version:
Bitrix24 REST API JavaScript SDK
71 lines (68 loc) • 1.88 kB
JavaScript
/**
* @package @bitrix24/b24jssdk
* @version 2.2.0
* @copyright (c) 2026 Bitrix24
* @license MIT
* @see https://github.com/bitrix24/b24jssdk
* @see https://bitrix24.github.io/b24jssdk/
*/
import { SdkError } from './core/sdk-error.mjs';
import { B24Frame } from './frame/b24.mjs';
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
let initPromise = null;
function parseFrameQueryParams() {
const queryParams = {
DOMAIN: null,
PROTOCOL: false,
APP_SID: null,
LANG: null
};
if (window.name) {
const [domain, protocol, appSid] = window.name.split("|");
queryParams.DOMAIN = domain;
queryParams.PROTOCOL = Number.parseInt(protocol ?? "0") === 1;
queryParams.APP_SID = appSid;
queryParams.LANG = null;
}
return queryParams;
}
__name(parseFrameQueryParams, "parseFrameQueryParams");
async function makeFrame(options) {
const queryParams = parseFrameQueryParams();
if (!queryParams.DOMAIN || !queryParams.APP_SID) {
throw new SdkError({
code: "JSSDK_CLIENT_SIDE_WARNING",
description: "Well done! Now paste this URL into the Bitrix24 app settings",
status: 500
});
}
const b24Frame = new B24Frame(queryParams, options);
try {
await b24Frame.init();
} catch (error) {
try {
b24Frame.destroy();
} catch {
}
throw error;
}
return b24Frame;
}
__name(makeFrame, "makeFrame");
async function initializeB24Frame(options) {
if (initPromise !== null) {
return initPromise;
}
const pending = makeFrame(options);
initPromise = pending;
pending.catch(() => {
if (initPromise === pending) {
initPromise = null;
}
});
return pending;
}
__name(initializeB24Frame, "initializeB24Frame");
export { initializeB24Frame };
//# sourceMappingURL=loader-b24frame.mjs.map