@intlayer/chokidar
Version:
Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.
56 lines • 2.39 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 checkDictionaryChanges_exports = {};
__export(checkDictionaryChanges_exports, {
checkDictionaryChanges: () => checkDictionaryChanges
});
module.exports = __toCommonJS(checkDictionaryChanges_exports);
var import_api = require("@intlayer/api");
var import_buildIntlayerDictionary = require('./transpiler/declaration_file_to_dictionary/intlayer_dictionary/buildIntlayerDictionary.cjs');
var import_config = require("@intlayer/config");
const writeDictionary = async (dictionary) => {
(0, import_config.appLogger)(`Writing dictionary ${dictionary.key}`);
await (0, import_buildIntlayerDictionary.buildIntlayerDictionary)([dictionary]);
};
const checkDictionaryChanges = async () => {
const configuration = (0, import_config.getConfiguration)();
const { editor } = configuration;
if (!editor.hotReload) return;
if (!editor.clientId) return;
if (!editor.clientSecret) return;
const eventSource = new import_api.IntlayerEventListener(configuration);
try {
await eventSource.initialize().then(() => {
(0, import_config.appLogger)("Connected to Intlayer. Hot reload enabled");
});
} catch (error) {
(0, import_config.appLogger)("Error initializing IntlayerEventListener:", {
level: "error"
});
}
eventSource.onDictionaryAdded = writeDictionary;
eventSource.onDictionaryChange = writeDictionary;
eventSource.onDictionaryDeleted = writeDictionary;
return eventSource;
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
checkDictionaryChanges
});
//# sourceMappingURL=checkDictionaryChanges.cjs.map