Files
JiboSDK/lib/jibo-sdk-pulsar.js
2026-03-22 04:37:35 +02:00

53 lines
1.5 KiB
JavaScript

"use strict";
// Pulsar/Electron no longer supports the legacy gating/login flow that the
// bundled Jibo SDK package uses to delay command registration.
//
// The bundle's gating module checks localStorage for this key, and only
// registers all commands if it is set to "true".
const LEGACY_GATING_KEY = "cmajghqmadhnadjcjhamajdhda";
const bundled = require("./jibo-sdk");
function registerPulsarUriOpeners() {
try {
if (typeof atom === "undefined" || !atom.workspace || typeof atom.workspace.addOpener !== "function") return;
atom.workspace.addOpener((uri) => {
if (uri === "atom://jibo-cheat-sheet") {
const CheatSheetTab = require("./cheat-sheet/cheat-sheat-tab");
return new CheatSheetTab();
}
if (uri === "atom://atom-react-styleguide") {
const StyleguideEditor = require("./atom-react/styleguide/styleguide-editor");
return new StyleguideEditor();
}
return undefined;
});
} catch (_) {
// Best-effort only.
}
}
function forceLegacyLoginFlag() {
try {
if (typeof globalThis !== "undefined" && globalThis.localStorage) {
globalThis.localStorage.setItem(LEGACY_GATING_KEY, "true");
}
} catch (_) {
// Best-effort only.
}
}
if (bundled && typeof bundled.activate === "function") {
const originalActivate = bundled.activate.bind(bundled);
bundled.activate = function activate(state) {
forceLegacyLoginFlag();
const result = originalActivate(state);
registerPulsarUriOpeners();
return result;
};
}
module.exports = bundled;