@intlayer/cli 8.1.2 → 8.1.3-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/IntlayerEventListener.cjs +1 -186
- package/dist/cjs/IntlayerEventListener.cjs.map +1 -1
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
- package/dist/cjs/_virtual/_utils_asset.cjs +2 -98
- package/dist/cjs/auth/login.cjs +2 -85
- package/dist/cjs/auth/login.cjs.map +1 -1
- package/dist/cjs/build.cjs +1 -27
- package/dist/cjs/build.cjs.map +1 -1
- package/dist/cjs/ci.cjs +1 -73
- package/dist/cjs/ci.cjs.map +1 -1
- package/dist/cjs/cli.cjs +1 -476
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/config.cjs +1 -12
- package/dist/cjs/config.cjs.map +1 -1
- package/dist/cjs/editor.cjs +1 -50
- package/dist/cjs/editor.cjs.map +1 -1
- package/dist/cjs/extract.cjs +1 -96
- package/dist/cjs/extract.cjs.map +1 -1
- package/dist/cjs/fill/deepMergeContent.cjs +1 -27
- package/dist/cjs/fill/deepMergeContent.cjs.map +1 -1
- package/dist/cjs/fill/fill.cjs +1 -78
- package/dist/cjs/fill/fill.cjs.map +1 -1
- package/dist/cjs/fill/formatAutoFilledFilePath.cjs +1 -29
- package/dist/cjs/fill/formatAutoFilledFilePath.cjs.map +1 -1
- package/dist/cjs/fill/formatFillData.cjs +1 -50
- package/dist/cjs/fill/formatFillData.cjs.map +1 -1
- package/dist/cjs/fill/getAvailableLocalesInDictionary.cjs +1 -26
- package/dist/cjs/fill/getAvailableLocalesInDictionary.cjs.map +1 -1
- package/dist/cjs/fill/getFilterMissingContentPerLocale.cjs +1 -50
- package/dist/cjs/fill/getFilterMissingContentPerLocale.cjs.map +1 -1
- package/dist/cjs/fill/index.cjs +1 -6
- package/dist/cjs/fill/listTranslationsTasks.cjs +1 -70
- package/dist/cjs/fill/listTranslationsTasks.cjs.map +1 -1
- package/dist/cjs/fill/mergeChunks.cjs +1 -28
- package/dist/cjs/fill/mergeChunks.cjs.map +1 -1
- package/dist/cjs/fill/translateDictionary.cjs +1 -205
- package/dist/cjs/fill/translateDictionary.cjs.map +1 -1
- package/dist/cjs/fill/writeFill.cjs +1 -54
- package/dist/cjs/fill/writeFill.cjs.map +1 -1
- package/dist/cjs/getTargetDictionary.cjs +1 -36
- package/dist/cjs/getTargetDictionary.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -39
- package/dist/cjs/init.cjs +1 -322
- package/dist/cjs/init.cjs.map +1 -1
- package/dist/cjs/listContentDeclaration.cjs +1 -41
- package/dist/cjs/listContentDeclaration.cjs.map +1 -1
- package/dist/cjs/listProjects.cjs +1 -28
- package/dist/cjs/listProjects.cjs.map +1 -1
- package/dist/cjs/liveSync.cjs +8 -151
- package/dist/cjs/liveSync.cjs.map +1 -1
- package/dist/cjs/pull.cjs +1 -146
- package/dist/cjs/pull.cjs.map +1 -1
- package/dist/cjs/push/pullLog.cjs +3 -102
- package/dist/cjs/push/pullLog.cjs.map +1 -1
- package/dist/cjs/push/push.cjs +1 -206
- package/dist/cjs/push/push.cjs.map +1 -1
- package/dist/cjs/pushConfig.cjs +1 -19
- package/dist/cjs/pushConfig.cjs.map +1 -1
- package/dist/cjs/pushLog.cjs +3 -84
- package/dist/cjs/pushLog.cjs.map +1 -1
- package/dist/cjs/reviewDoc/reviewDoc.cjs +1 -68
- package/dist/cjs/reviewDoc/reviewDoc.cjs.map +1 -1
- package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs +1 -94
- package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs.map +1 -1
- package/dist/cjs/searchDoc.cjs +1 -38
- package/dist/cjs/searchDoc.cjs.map +1 -1
- package/dist/cjs/test/index.cjs +1 -7
- package/dist/cjs/test/listMissingTranslations.cjs +1 -49
- package/dist/cjs/test/listMissingTranslations.cjs.map +1 -1
- package/dist/cjs/test/test.cjs +1 -53
- package/dist/cjs/test/test.cjs.map +1 -1
- package/dist/cjs/translateDoc/index.cjs +1 -9
- package/dist/cjs/translateDoc/translateDoc.cjs +1 -74
- package/dist/cjs/translateDoc/translateDoc.cjs.map +1 -1
- package/dist/cjs/translateDoc/translateFile.cjs +2 -103
- package/dist/cjs/translateDoc/translateFile.cjs.map +1 -1
- package/dist/cjs/translateDoc/validation.cjs +5 -49
- package/dist/cjs/translateDoc/validation.cjs.map +1 -1
- package/dist/cjs/translation-alignment/alignBlocks.cjs +1 -67
- package/dist/cjs/translation-alignment/alignBlocks.cjs.map +1 -1
- package/dist/cjs/translation-alignment/computeSimilarity.cjs +1 -25
- package/dist/cjs/translation-alignment/computeSimilarity.cjs.map +1 -1
- package/dist/cjs/translation-alignment/fingerprintBlock.cjs +1 -23
- package/dist/cjs/translation-alignment/fingerprintBlock.cjs.map +1 -1
- package/dist/cjs/translation-alignment/index.cjs +1 -22
- package/dist/cjs/translation-alignment/mapChangedLinesToBlocks.cjs +1 -18
- package/dist/cjs/translation-alignment/mapChangedLinesToBlocks.cjs.map +1 -1
- package/dist/cjs/translation-alignment/normalizeBlock.cjs +1 -22
- package/dist/cjs/translation-alignment/normalizeBlock.cjs.map +1 -1
- package/dist/cjs/translation-alignment/pipeline.cjs +1 -37
- package/dist/cjs/translation-alignment/pipeline.cjs.map +1 -1
- package/dist/cjs/translation-alignment/planActions.cjs +1 -46
- package/dist/cjs/translation-alignment/planActions.cjs.map +1 -1
- package/dist/cjs/translation-alignment/rebuildDocument.cjs +2 -49
- package/dist/cjs/translation-alignment/rebuildDocument.cjs.map +1 -1
- package/dist/cjs/translation-alignment/segmentDocument.cjs +5 -66
- package/dist/cjs/translation-alignment/segmentDocument.cjs.map +1 -1
- package/dist/cjs/utils/calculateChunks.cjs +2 -89
- package/dist/cjs/utils/calculateChunks.cjs.map +1 -1
- package/dist/cjs/utils/checkAccess.cjs +1 -81
- package/dist/cjs/utils/checkAccess.cjs.map +1 -1
- package/dist/cjs/utils/checkConfigConsistency.cjs +1 -16
- package/dist/cjs/utils/checkConfigConsistency.cjs.map +1 -1
- package/dist/cjs/utils/checkFileModifiedRange.cjs +1 -81
- package/dist/cjs/utils/checkFileModifiedRange.cjs.map +1 -1
- package/dist/cjs/utils/checkLastUpdateTime.cjs +1 -19
- package/dist/cjs/utils/checkLastUpdateTime.cjs.map +1 -1
- package/dist/cjs/utils/chunkInference.cjs +1 -45
- package/dist/cjs/utils/chunkInference.cjs.map +1 -1
- package/dist/cjs/utils/fixChunkStartEndChars.cjs +3 -27
- package/dist/cjs/utils/fixChunkStartEndChars.cjs.map +1 -1
- package/dist/cjs/utils/formatTimeDiff.cjs +1 -20
- package/dist/cjs/utils/formatTimeDiff.cjs.map +1 -1
- package/dist/cjs/utils/getIsFileUpdatedRecently.cjs +1 -16
- package/dist/cjs/utils/getIsFileUpdatedRecently.cjs.map +1 -1
- package/dist/cjs/utils/getOutputFilePath.cjs +1 -74
- package/dist/cjs/utils/getOutputFilePath.cjs.map +1 -1
- package/dist/cjs/utils/getParentPackageJSON.cjs +1 -20
- package/dist/cjs/utils/getParentPackageJSON.cjs.map +1 -1
- package/dist/cjs/utils/listSpecialChars.cjs +2 -54
- package/dist/cjs/utils/listSpecialChars.cjs.map +1 -1
- package/dist/cjs/utils/mapChunksBetweenFiles.cjs +1 -102
- package/dist/cjs/utils/mapChunksBetweenFiles.cjs.map +1 -1
- package/dist/cjs/utils/openBrowser.cjs +1 -19
- package/dist/cjs/utils/openBrowser.cjs.map +1 -1
- package/dist/cjs/utils/reorderParagraphs.cjs +3 -91
- package/dist/cjs/utils/reorderParagraphs.cjs.map +1 -1
- package/dist/cjs/utils/setupAI.cjs +1 -64
- package/dist/cjs/utils/setupAI.cjs.map +1 -1
- package/dist/cjs/watch.cjs +1 -43
- package/dist/cjs/watch.cjs.map +1 -1
- package/dist/esm/IntlayerEventListener.mjs +1 -183
- package/dist/esm/IntlayerEventListener.mjs.map +1 -1
- package/dist/esm/_virtual/_rolldown/runtime.mjs +1 -8
- package/dist/esm/_virtual/_utils_asset.mjs +2 -97
- package/dist/esm/auth/login.mjs +2 -82
- package/dist/esm/auth/login.mjs.map +1 -1
- package/dist/esm/build.mjs +1 -25
- package/dist/esm/build.mjs.map +1 -1
- package/dist/esm/ci.mjs +1 -71
- package/dist/esm/ci.mjs.map +1 -1
- package/dist/esm/cli.mjs +1 -473
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/config.mjs +1 -10
- package/dist/esm/config.mjs.map +1 -1
- package/dist/esm/editor.mjs +1 -49
- package/dist/esm/editor.mjs.map +1 -1
- package/dist/esm/extract.mjs +1 -93
- package/dist/esm/extract.mjs.map +1 -1
- package/dist/esm/fill/deepMergeContent.mjs +1 -25
- package/dist/esm/fill/deepMergeContent.mjs.map +1 -1
- package/dist/esm/fill/fill.mjs +1 -76
- package/dist/esm/fill/fill.mjs.map +1 -1
- package/dist/esm/fill/formatAutoFilledFilePath.mjs +1 -27
- package/dist/esm/fill/formatAutoFilledFilePath.mjs.map +1 -1
- package/dist/esm/fill/formatFillData.mjs +1 -49
- package/dist/esm/fill/formatFillData.mjs.map +1 -1
- package/dist/esm/fill/getAvailableLocalesInDictionary.mjs +1 -24
- package/dist/esm/fill/getAvailableLocalesInDictionary.mjs.map +1 -1
- package/dist/esm/fill/getFilterMissingContentPerLocale.mjs +1 -48
- package/dist/esm/fill/getFilterMissingContentPerLocale.mjs.map +1 -1
- package/dist/esm/fill/index.mjs +1 -4
- package/dist/esm/fill/listTranslationsTasks.mjs +1 -68
- package/dist/esm/fill/listTranslationsTasks.mjs.map +1 -1
- package/dist/esm/fill/mergeChunks.mjs +1 -26
- package/dist/esm/fill/mergeChunks.mjs.map +1 -1
- package/dist/esm/fill/translateDictionary.mjs +1 -203
- package/dist/esm/fill/translateDictionary.mjs.map +1 -1
- package/dist/esm/fill/writeFill.mjs +1 -52
- package/dist/esm/fill/writeFill.mjs.map +1 -1
- package/dist/esm/getTargetDictionary.mjs +1 -33
- package/dist/esm/getTargetDictionary.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -18
- package/dist/esm/init.mjs +1 -317
- package/dist/esm/init.mjs.map +1 -1
- package/dist/esm/listContentDeclaration.mjs +1 -38
- package/dist/esm/listContentDeclaration.mjs.map +1 -1
- package/dist/esm/listProjects.mjs +1 -26
- package/dist/esm/listProjects.mjs.map +1 -1
- package/dist/esm/liveSync.mjs +8 -148
- package/dist/esm/liveSync.mjs.map +1 -1
- package/dist/esm/pull.mjs +1 -144
- package/dist/esm/pull.mjs.map +1 -1
- package/dist/esm/push/pullLog.mjs +3 -100
- package/dist/esm/push/pullLog.mjs.map +1 -1
- package/dist/esm/push/push.mjs +1 -203
- package/dist/esm/push/push.mjs.map +1 -1
- package/dist/esm/pushConfig.mjs +1 -17
- package/dist/esm/pushConfig.mjs.map +1 -1
- package/dist/esm/pushLog.mjs +3 -82
- package/dist/esm/pushLog.mjs.map +1 -1
- package/dist/esm/reviewDoc/reviewDoc.mjs +1 -65
- package/dist/esm/reviewDoc/reviewDoc.mjs.map +1 -1
- package/dist/esm/reviewDoc/reviewDocBlockAware.mjs +1 -92
- package/dist/esm/reviewDoc/reviewDocBlockAware.mjs.map +1 -1
- package/dist/esm/searchDoc.mjs +1 -36
- package/dist/esm/searchDoc.mjs.map +1 -1
- package/dist/esm/test/index.mjs +1 -4
- package/dist/esm/test/listMissingTranslations.mjs +1 -46
- package/dist/esm/test/listMissingTranslations.mjs.map +1 -1
- package/dist/esm/test/test.mjs +1 -51
- package/dist/esm/test/test.mjs.map +1 -1
- package/dist/esm/translateDoc/index.mjs +1 -5
- package/dist/esm/translateDoc/translateDoc.mjs +1 -71
- package/dist/esm/translateDoc/translateDoc.mjs.map +1 -1
- package/dist/esm/translateDoc/translateFile.mjs +2 -101
- package/dist/esm/translateDoc/translateFile.mjs.map +1 -1
- package/dist/esm/translateDoc/validation.mjs +5 -46
- package/dist/esm/translateDoc/validation.mjs.map +1 -1
- package/dist/esm/translation-alignment/alignBlocks.mjs +1 -66
- package/dist/esm/translation-alignment/alignBlocks.mjs.map +1 -1
- package/dist/esm/translation-alignment/computeSimilarity.mjs +1 -22
- package/dist/esm/translation-alignment/computeSimilarity.mjs.map +1 -1
- package/dist/esm/translation-alignment/fingerprintBlock.mjs +1 -20
- package/dist/esm/translation-alignment/fingerprintBlock.mjs.map +1 -1
- package/dist/esm/translation-alignment/index.mjs +1 -11
- package/dist/esm/translation-alignment/mapChangedLinesToBlocks.mjs +1 -16
- package/dist/esm/translation-alignment/mapChangedLinesToBlocks.mjs.map +1 -1
- package/dist/esm/translation-alignment/normalizeBlock.mjs +1 -20
- package/dist/esm/translation-alignment/normalizeBlock.mjs.map +1 -1
- package/dist/esm/translation-alignment/pipeline.mjs +1 -35
- package/dist/esm/translation-alignment/pipeline.mjs.map +1 -1
- package/dist/esm/translation-alignment/planActions.mjs +1 -44
- package/dist/esm/translation-alignment/planActions.mjs.map +1 -1
- package/dist/esm/translation-alignment/rebuildDocument.mjs +2 -46
- package/dist/esm/translation-alignment/rebuildDocument.mjs.map +1 -1
- package/dist/esm/translation-alignment/segmentDocument.mjs +5 -64
- package/dist/esm/translation-alignment/segmentDocument.mjs.map +1 -1
- package/dist/esm/utils/calculateChunks.mjs +2 -87
- package/dist/esm/utils/calculateChunks.mjs.map +1 -1
- package/dist/esm/utils/checkAccess.mjs +1 -78
- package/dist/esm/utils/checkAccess.mjs.map +1 -1
- package/dist/esm/utils/checkConfigConsistency.mjs +1 -14
- package/dist/esm/utils/checkConfigConsistency.mjs.map +1 -1
- package/dist/esm/utils/checkFileModifiedRange.mjs +1 -80
- package/dist/esm/utils/checkFileModifiedRange.mjs.map +1 -1
- package/dist/esm/utils/checkLastUpdateTime.mjs +1 -17
- package/dist/esm/utils/checkLastUpdateTime.mjs.map +1 -1
- package/dist/esm/utils/chunkInference.mjs +1 -43
- package/dist/esm/utils/chunkInference.mjs.map +1 -1
- package/dist/esm/utils/fixChunkStartEndChars.mjs +3 -25
- package/dist/esm/utils/fixChunkStartEndChars.mjs.map +1 -1
- package/dist/esm/utils/formatTimeDiff.mjs +1 -18
- package/dist/esm/utils/formatTimeDiff.mjs.map +1 -1
- package/dist/esm/utils/getIsFileUpdatedRecently.mjs +1 -14
- package/dist/esm/utils/getIsFileUpdatedRecently.mjs.map +1 -1
- package/dist/esm/utils/getOutputFilePath.mjs +1 -72
- package/dist/esm/utils/getOutputFilePath.mjs.map +1 -1
- package/dist/esm/utils/getParentPackageJSON.mjs +1 -18
- package/dist/esm/utils/getParentPackageJSON.mjs.map +1 -1
- package/dist/esm/utils/listSpecialChars.mjs +2 -52
- package/dist/esm/utils/listSpecialChars.mjs.map +1 -1
- package/dist/esm/utils/mapChunksBetweenFiles.mjs +1 -100
- package/dist/esm/utils/mapChunksBetweenFiles.mjs.map +1 -1
- package/dist/esm/utils/openBrowser.mjs +1 -17
- package/dist/esm/utils/openBrowser.mjs.map +1 -1
- package/dist/esm/utils/reorderParagraphs.mjs +3 -90
- package/dist/esm/utils/reorderParagraphs.mjs.map +1 -1
- package/dist/esm/utils/setupAI.mjs +1 -62
- package/dist/esm/utils/setupAI.mjs.map +1 -1
- package/dist/esm/watch.mjs +1 -41
- package/dist/esm/watch.mjs.map +1 -1
- package/dist/types/auth/login.d.ts +1 -1
- package/dist/types/auth/login.d.ts.map +1 -1
- package/dist/types/build.d.ts +1 -1
- package/dist/types/build.d.ts.map +1 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/extract.d.ts +1 -1
- package/dist/types/extract.d.ts.map +1 -1
- package/dist/types/fill/fill.d.ts +1 -1
- package/dist/types/fill/fill.d.ts.map +1 -1
- package/dist/types/fill/translateDictionary.d.ts +2 -2
- package/dist/types/fill/translateDictionary.d.ts.map +1 -1
- package/dist/types/fill/writeFill.d.ts.map +1 -1
- package/dist/types/getTargetDictionary.d.ts +2 -2
- package/dist/types/index.d.ts +4 -1
- package/dist/types/listContentDeclaration.d.ts +1 -1
- package/dist/types/listContentDeclaration.d.ts.map +1 -1
- package/dist/types/liveSync.d.ts +1 -1
- package/dist/types/pull.d.ts +1 -1
- package/dist/types/pull.d.ts.map +1 -1
- package/dist/types/push/pullLog.d.ts +1 -1
- package/dist/types/push/pullLog.d.ts.map +1 -1
- package/dist/types/push/push.d.ts +2 -2
- package/dist/types/pushConfig.d.ts +1 -1
- package/dist/types/reviewDoc/reviewDoc.d.ts +2 -2
- package/dist/types/reviewDoc/reviewDoc.d.ts.map +1 -1
- package/dist/types/reviewDoc/reviewDocBlockAware.d.ts +1 -1
- package/dist/types/reviewDoc/reviewDocBlockAware.d.ts.map +1 -1
- package/dist/types/searchDoc.d.ts +1 -1
- package/dist/types/searchDoc.d.ts.map +1 -1
- package/dist/types/test/listMissingTranslations.d.ts +1 -1
- package/dist/types/test/test.d.ts +1 -1
- package/dist/types/test/test.d.ts.map +1 -1
- package/dist/types/translateDoc/translateDoc.d.ts.map +1 -1
- package/dist/types/translateDoc/types.d.ts +2 -2
- package/dist/types/translateDoc/validation.d.ts +1 -1
- package/dist/types/utils/checkAccess.d.ts.map +1 -1
- package/dist/types/watch.d.ts +1 -1
- package/dist/types/watch.d.ts.map +1 -1
- package/package.json +11 -11
|
@@ -1,187 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let _intlayer_api = require("@intlayer/api");
|
|
4
|
-
let _intlayer_config_built = require("@intlayer/config/built");
|
|
5
|
-
_intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
|
|
6
|
-
let _intlayer_config_client = require("@intlayer/config/client");
|
|
7
|
-
let eventsource = require("eventsource");
|
|
8
|
-
|
|
9
|
-
//#region src/IntlayerEventListener.ts
|
|
10
|
-
/**
|
|
11
|
-
* IntlayerEventListener class to listen for dictionary changes via SSE (Server-Sent Events).
|
|
12
|
-
*
|
|
13
|
-
* Usage example:
|
|
14
|
-
*
|
|
15
|
-
* import { buildIntlayerDictionary } from './transpiler/declaration_file_to_dictionary/intlayer_dictionary';
|
|
16
|
-
* import { IntlayerEventListener } from '@intlayer/api';
|
|
17
|
-
*
|
|
18
|
-
* export const checkDictionaryChanges = async () => {
|
|
19
|
-
* // Instantiate the listener
|
|
20
|
-
* const eventListener = new IntlayerEventListener();
|
|
21
|
-
*
|
|
22
|
-
* // Set up your callbacks
|
|
23
|
-
* eventListener.onDictionaryChange = async (dictionary) => {
|
|
24
|
-
* await buildIntlayerDictionary(dictionary);
|
|
25
|
-
* };
|
|
26
|
-
*
|
|
27
|
-
* // Initialize the listener
|
|
28
|
-
* await eventListener.initialize();
|
|
29
|
-
*
|
|
30
|
-
* // Optionally, clean up later when you’re done
|
|
31
|
-
* // eventListener.cleanup();
|
|
32
|
-
* };
|
|
33
|
-
*/
|
|
34
|
-
var IntlayerEventListener = class {
|
|
35
|
-
appLogger = (0, _intlayer_config_client.getAppLogger)(_intlayer_config_built.default);
|
|
36
|
-
eventSource = null;
|
|
37
|
-
reconnectAttempts = 0;
|
|
38
|
-
maxReconnectAttempts = 5;
|
|
39
|
-
reconnectDelay = 1e3;
|
|
40
|
-
isManuallyDisconnected = false;
|
|
41
|
-
reconnectTimeout = null;
|
|
42
|
-
/**
|
|
43
|
-
* Callback triggered when a Dictionary is ADDED.
|
|
44
|
-
*/
|
|
45
|
-
onDictionaryAdded;
|
|
46
|
-
/**
|
|
47
|
-
* Callback triggered when a Dictionary is UPDATED.
|
|
48
|
-
*/
|
|
49
|
-
onDictionaryChange;
|
|
50
|
-
/**
|
|
51
|
-
* Callback triggered when a Dictionary is DELETED.
|
|
52
|
-
*/
|
|
53
|
-
onDictionaryDeleted;
|
|
54
|
-
/**
|
|
55
|
-
* Callback triggered when connection is established or re-established.
|
|
56
|
-
*/
|
|
57
|
-
onConnectionOpen;
|
|
58
|
-
/**
|
|
59
|
-
* Callback triggered when connection encounters an error.
|
|
60
|
-
*/
|
|
61
|
-
onConnectionError;
|
|
62
|
-
constructor(intlayerConfig = _intlayer_config_built.default) {
|
|
63
|
-
this.intlayerConfig = intlayerConfig;
|
|
64
|
-
this.appLogger = (0, _intlayer_config_client.getAppLogger)(this.intlayerConfig);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Initializes the EventSource connection using the given intlayerConfig
|
|
68
|
-
* (or the default config if none was provided).
|
|
69
|
-
*/
|
|
70
|
-
async initialize() {
|
|
71
|
-
this.isManuallyDisconnected = false;
|
|
72
|
-
await this.connect();
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Establishes the EventSource connection with automatic reconnection support.
|
|
76
|
-
*/
|
|
77
|
-
async connect() {
|
|
78
|
-
try {
|
|
79
|
-
const backendURL = this.intlayerConfig.editor.backendURL;
|
|
80
|
-
const accessToken = await (0, _intlayer_api.getIntlayerAPIProxy)(void 0, this.intlayerConfig).oAuth.getOAuth2AccessToken();
|
|
81
|
-
if (!accessToken) throw new Error("Failed to retrieve access token");
|
|
82
|
-
const API_ROUTE = `${backendURL}/api/event-listener`;
|
|
83
|
-
if (this.eventSource) this.eventSource.close();
|
|
84
|
-
this.eventSource = new eventsource.EventSource(API_ROUTE, { fetch: (input, init) => fetch(input, {
|
|
85
|
-
...init,
|
|
86
|
-
headers: {
|
|
87
|
-
...init?.headers ?? {},
|
|
88
|
-
Authorization: `Bearer ${accessToken.data?.accessToken}`
|
|
89
|
-
}
|
|
90
|
-
}) });
|
|
91
|
-
this.eventSource.onopen = () => {
|
|
92
|
-
this.reconnectAttempts = 0;
|
|
93
|
-
this.reconnectDelay = 1e3;
|
|
94
|
-
this.onConnectionOpen?.();
|
|
95
|
-
};
|
|
96
|
-
this.eventSource.onmessage = (event) => this.handleMessage(event);
|
|
97
|
-
this.eventSource.onerror = (event) => this.handleError(event);
|
|
98
|
-
} catch (_error) {
|
|
99
|
-
this.appLogger("Failed to establish EventSource connection:", { level: "error" });
|
|
100
|
-
this.scheduleReconnect();
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Cleans up (closes) the EventSource connection.
|
|
105
|
-
*/
|
|
106
|
-
cleanup() {
|
|
107
|
-
this.isManuallyDisconnected = true;
|
|
108
|
-
if (this.reconnectTimeout) {
|
|
109
|
-
clearTimeout(this.reconnectTimeout);
|
|
110
|
-
this.reconnectTimeout = null;
|
|
111
|
-
}
|
|
112
|
-
if (this.eventSource) {
|
|
113
|
-
this.eventSource.close();
|
|
114
|
-
this.eventSource = null;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Schedules a reconnection attempt with exponential backoff.
|
|
119
|
-
*/
|
|
120
|
-
scheduleReconnect() {
|
|
121
|
-
if (this.isManuallyDisconnected || this.reconnectAttempts >= this.maxReconnectAttempts) {
|
|
122
|
-
if (this.reconnectAttempts >= this.maxReconnectAttempts) this.appLogger([`Max reconnection attempts (${this.maxReconnectAttempts}) reached. Giving up.`], { level: "error" });
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
this.reconnectAttempts++;
|
|
126
|
-
const delay = this.reconnectDelay * 2 ** (this.reconnectAttempts - 1);
|
|
127
|
-
this.appLogger(`Scheduling reconnection attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts} in ${delay}ms`);
|
|
128
|
-
this.reconnectTimeout = setTimeout(async () => {
|
|
129
|
-
if (!this.isManuallyDisconnected) await this.connect();
|
|
130
|
-
}, delay);
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Handles incoming SSE messages, parses the event data,
|
|
134
|
-
* and invokes the appropriate callback.
|
|
135
|
-
*/
|
|
136
|
-
async handleMessage(event) {
|
|
137
|
-
try {
|
|
138
|
-
const { data } = event;
|
|
139
|
-
const dataJSON = JSON.parse(data);
|
|
140
|
-
for (const dataEl of dataJSON) switch (dataEl.object) {
|
|
141
|
-
case "DICTIONARY":
|
|
142
|
-
switch (dataEl.status) {
|
|
143
|
-
case "ADDED":
|
|
144
|
-
await this.onDictionaryAdded?.(dataEl.data);
|
|
145
|
-
break;
|
|
146
|
-
case "UPDATED":
|
|
147
|
-
await this.onDictionaryChange?.(dataEl.data);
|
|
148
|
-
break;
|
|
149
|
-
case "DELETED":
|
|
150
|
-
await this.onDictionaryDeleted?.(dataEl.data);
|
|
151
|
-
break;
|
|
152
|
-
default:
|
|
153
|
-
this.appLogger(["Unhandled dictionary status:", dataEl.status], { level: "error" });
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
break;
|
|
157
|
-
default:
|
|
158
|
-
this.appLogger(["Unknown object type:", dataEl.object], { level: "error" });
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
} catch (error) {
|
|
162
|
-
this.appLogger(["Error processing dictionary update:", error], { level: "error" });
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Handles any SSE errors and attempts reconnection if appropriate.
|
|
167
|
-
*/
|
|
168
|
-
handleError(event) {
|
|
169
|
-
const errorEvent = event;
|
|
170
|
-
this.appLogger(["EventSource error:", {
|
|
171
|
-
type: errorEvent.type,
|
|
172
|
-
message: errorEvent.message,
|
|
173
|
-
code: errorEvent.code,
|
|
174
|
-
readyState: this.eventSource?.readyState,
|
|
175
|
-
url: this.eventSource?.url
|
|
176
|
-
}], { level: "error" });
|
|
177
|
-
this.onConnectionError?.(event);
|
|
178
|
-
if (errorEvent.type === "error" && (errorEvent.message?.includes("terminated") || errorEvent.message?.includes("closed") || this.eventSource?.readyState === eventsource.EventSource.CLOSED) && !this.isManuallyDisconnected) {
|
|
179
|
-
this.appLogger("Connection was terminated by server, attempting to reconnect...");
|
|
180
|
-
this.scheduleReconnect();
|
|
181
|
-
} else this.cleanup();
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
//#endregion
|
|
186
|
-
exports.IntlayerEventListener = IntlayerEventListener;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./_virtual/_rolldown/runtime.cjs`);let t=require(`@intlayer/api`),n=require(`@intlayer/config/built`);n=e.__toESM(n);let r=require(`@intlayer/config/client`),i=require(`eventsource`);var a=class{appLogger=(0,r.getAppLogger)(n.default);eventSource=null;reconnectAttempts=0;maxReconnectAttempts=5;reconnectDelay=1e3;isManuallyDisconnected=!1;reconnectTimeout=null;onDictionaryAdded;onDictionaryChange;onDictionaryDeleted;onConnectionOpen;onConnectionError;constructor(e=n.default){this.intlayerConfig=e,this.appLogger=(0,r.getAppLogger)(this.intlayerConfig)}async initialize(){this.isManuallyDisconnected=!1,await this.connect()}async connect(){try{let e=this.intlayerConfig.editor.backendURL,n=await(0,t.getIntlayerAPIProxy)(void 0,this.intlayerConfig).oAuth.getOAuth2AccessToken();if(!n)throw Error(`Failed to retrieve access token`);let r=`${e}/api/event-listener`;this.eventSource&&this.eventSource.close(),this.eventSource=new i.EventSource(r,{fetch:(e,t)=>fetch(e,{...t,headers:{...t?.headers??{},Authorization:`Bearer ${n.data?.accessToken}`}})}),this.eventSource.onopen=()=>{this.reconnectAttempts=0,this.reconnectDelay=1e3,this.onConnectionOpen?.()},this.eventSource.onmessage=e=>this.handleMessage(e),this.eventSource.onerror=e=>this.handleError(e)}catch{this.appLogger(`Failed to establish EventSource connection:`,{level:`error`}),this.scheduleReconnect()}}cleanup(){this.isManuallyDisconnected=!0,this.reconnectTimeout&&=(clearTimeout(this.reconnectTimeout),null),this.eventSource&&=(this.eventSource.close(),null)}scheduleReconnect(){if(this.isManuallyDisconnected||this.reconnectAttempts>=this.maxReconnectAttempts){this.reconnectAttempts>=this.maxReconnectAttempts&&this.appLogger([`Max reconnection attempts (${this.maxReconnectAttempts}) reached. Giving up.`],{level:`error`});return}this.reconnectAttempts++;let e=this.reconnectDelay*2**(this.reconnectAttempts-1);this.appLogger(`Scheduling reconnection attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts} in ${e}ms`),this.reconnectTimeout=setTimeout(async()=>{this.isManuallyDisconnected||await this.connect()},e)}async handleMessage(e){try{let{data:t}=e,n=JSON.parse(t);for(let e of n)switch(e.object){case`DICTIONARY`:switch(e.status){case`ADDED`:await this.onDictionaryAdded?.(e.data);break;case`UPDATED`:await this.onDictionaryChange?.(e.data);break;case`DELETED`:await this.onDictionaryDeleted?.(e.data);break;default:this.appLogger([`Unhandled dictionary status:`,e.status],{level:`error`});break}break;default:this.appLogger([`Unknown object type:`,e.object],{level:`error`});break}}catch(e){this.appLogger([`Error processing dictionary update:`,e],{level:`error`})}}handleError(e){let t=e;this.appLogger([`EventSource error:`,{type:t.type,message:t.message,code:t.code,readyState:this.eventSource?.readyState,url:this.eventSource?.url}],{level:`error`}),this.onConnectionError?.(e),t.type===`error`&&(t.message?.includes(`terminated`)||t.message?.includes(`closed`)||this.eventSource?.readyState===i.EventSource.CLOSED)&&!this.isManuallyDisconnected?(this.appLogger(`Connection was terminated by server, attempting to reconnect...`),this.scheduleReconnect()):this.cleanup()}};exports.IntlayerEventListener=a;
|
|
187
2
|
//# sourceMappingURL=IntlayerEventListener.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerEventListener.cjs","names":["configuration","EventSource"],"sources":["../../src/IntlayerEventListener.ts"],"sourcesContent":["import { getIntlayerAPIProxy } from '@intlayer/api';\n// @ts-ignore: @intlayer/backend is not built yet\nimport type { DictionaryAPI, MessageEventData } from '@intlayer/backend';\nimport configuration from '@intlayer/config/built';\nimport { getAppLogger } from '@intlayer/config/client';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { EventSource } from 'eventsource';\n\nexport type IntlayerMessageEvent = MessageEvent;\n\n/**\n * IntlayerEventListener class to listen for dictionary changes via SSE (Server-Sent Events).\n *\n * Usage example:\n *\n * import { buildIntlayerDictionary } from './transpiler/declaration_file_to_dictionary/intlayer_dictionary';\n * import { IntlayerEventListener } from '@intlayer/api';\n *\n * export const checkDictionaryChanges = async () => {\n * // Instantiate the listener\n * const eventListener = new IntlayerEventListener();\n *\n * // Set up your callbacks\n * eventListener.onDictionaryChange = async (dictionary) => {\n * await buildIntlayerDictionary(dictionary);\n * };\n *\n * // Initialize the listener\n * await eventListener.initialize();\n *\n * // Optionally, clean up later when you’re done\n * // eventListener.cleanup();\n * };\n */\nexport class IntlayerEventListener {\n private appLogger = getAppLogger(configuration);\n\n private eventSource: EventSource | null = null;\n private reconnectAttempts = 0;\n private maxReconnectAttempts = 5;\n private reconnectDelay = 1000; // Start with 1 second\n private isManuallyDisconnected = false;\n private reconnectTimeout: NodeJS.Timeout | null = null;\n\n /**\n * Callback triggered when a Dictionary is ADDED.\n */\n public onDictionaryAdded?: (dictionary: DictionaryAPI) => any;\n\n /**\n * Callback triggered when a Dictionary is UPDATED.\n */\n public onDictionaryChange?: (dictionary: DictionaryAPI) => any;\n\n /**\n * Callback triggered when a Dictionary is DELETED.\n */\n public onDictionaryDeleted?: (dictionary: DictionaryAPI) => any;\n\n /**\n * Callback triggered when connection is established or re-established.\n */\n public onConnectionOpen?: () => any;\n\n /**\n * Callback triggered when connection encounters an error.\n */\n public onConnectionError?: (error: Event) => any;\n\n constructor(private intlayerConfig: IntlayerConfig = configuration) {\n this.appLogger = getAppLogger(this.intlayerConfig);\n }\n\n /**\n * Initializes the EventSource connection using the given intlayerConfig\n * (or the default config if none was provided).\n */\n public async initialize(): Promise<void> {\n this.isManuallyDisconnected = false;\n await this.connect();\n }\n\n /**\n * Establishes the EventSource connection with automatic reconnection support.\n */\n private async connect(): Promise<void> {\n try {\n const backendURL = this.intlayerConfig.editor.backendURL;\n\n // Retrieve the access token via proxy\n const accessToken = await getIntlayerAPIProxy(\n undefined,\n this.intlayerConfig\n ).oAuth.getOAuth2AccessToken();\n\n if (!accessToken) {\n throw new Error('Failed to retrieve access token');\n }\n\n const API_ROUTE = `${backendURL}/api/event-listener`;\n\n // Close existing connection if any\n if (this.eventSource) {\n this.eventSource.close();\n }\n\n this.eventSource = new EventSource(API_ROUTE, {\n fetch: (input, init) =>\n fetch(input, {\n ...init,\n headers: {\n ...(init?.headers ?? {}),\n Authorization: `Bearer ${accessToken.data?.accessToken}`,\n },\n }),\n });\n\n this.eventSource.onopen = () => {\n this.reconnectAttempts = 0;\n this.reconnectDelay = 1000; // Reset delay\n this.onConnectionOpen?.();\n };\n\n this.eventSource.onmessage = (event) => this.handleMessage(event);\n this.eventSource.onerror = (event) => this.handleError(event);\n } catch (_error) {\n this.appLogger('Failed to establish EventSource connection:', {\n level: 'error',\n });\n this.scheduleReconnect();\n }\n }\n\n /**\n * Cleans up (closes) the EventSource connection.\n */\n public cleanup(): void {\n this.isManuallyDisconnected = true;\n\n if (this.reconnectTimeout) {\n clearTimeout(this.reconnectTimeout);\n this.reconnectTimeout = null;\n }\n\n if (this.eventSource) {\n this.eventSource.close();\n this.eventSource = null;\n }\n }\n\n /**\n * Schedules a reconnection attempt with exponential backoff.\n */\n private scheduleReconnect(): void {\n if (\n this.isManuallyDisconnected ||\n this.reconnectAttempts >= this.maxReconnectAttempts\n ) {\n if (this.reconnectAttempts >= this.maxReconnectAttempts) {\n this.appLogger(\n [\n `Max reconnection attempts (${this.maxReconnectAttempts}) reached. Giving up.`,\n ],\n {\n level: 'error',\n }\n );\n }\n return;\n }\n\n this.reconnectAttempts++;\n const delay = this.reconnectDelay * 2 ** (this.reconnectAttempts - 1); // Exponential backoff\n\n this.appLogger(\n `Scheduling reconnection attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts} in ${delay}ms`\n );\n\n this.reconnectTimeout = setTimeout(async () => {\n if (!this.isManuallyDisconnected) {\n await this.connect();\n }\n }, delay);\n }\n\n /**\n * Handles incoming SSE messages, parses the event data,\n * and invokes the appropriate callback.\n */\n private async handleMessage(event: IntlayerMessageEvent): Promise<void> {\n try {\n const { data } = event;\n\n const dataJSON: MessageEventData[] = JSON.parse(data);\n\n for (const dataEl of dataJSON) {\n switch (dataEl.object) {\n case 'DICTIONARY':\n switch (dataEl.status) {\n case 'ADDED':\n await this.onDictionaryAdded?.(dataEl.data);\n break;\n case 'UPDATED':\n await this.onDictionaryChange?.(dataEl.data);\n break;\n case 'DELETED':\n await this.onDictionaryDeleted?.(dataEl.data);\n break;\n default:\n this.appLogger(\n ['Unhandled dictionary status:', dataEl.status],\n {\n level: 'error',\n }\n );\n break;\n }\n break;\n default:\n this.appLogger(['Unknown object type:', dataEl.object], {\n level: 'error',\n });\n break;\n }\n }\n } catch (error) {\n this.appLogger(['Error processing dictionary update:', error], {\n level: 'error',\n });\n }\n }\n\n /**\n * Handles any SSE errors and attempts reconnection if appropriate.\n */\n private handleError(event: Event): void {\n const errorEvent = event as any;\n\n // Log detailed error information\n this.appLogger(\n [\n 'EventSource error:',\n {\n type: errorEvent.type,\n message: errorEvent.message,\n code: errorEvent.code,\n readyState: this.eventSource?.readyState,\n url: this.eventSource?.url,\n },\n ],\n {\n level: 'error',\n }\n );\n\n // Notify error callback\n this.onConnectionError?.(event);\n\n // Check if this is a connection close error\n const isConnectionClosed =\n errorEvent.type === 'error' &&\n (errorEvent.message?.includes('terminated') ||\n errorEvent.message?.includes('closed') ||\n this.eventSource?.readyState === EventSource.CLOSED);\n\n if (isConnectionClosed && !this.isManuallyDisconnected) {\n this.appLogger(\n 'Connection was terminated by server, attempting to reconnect...'\n );\n this.scheduleReconnect();\n } else {\n // For other types of errors, close the connection\n this.cleanup();\n }\n }\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"IntlayerEventListener.cjs","names":["configuration","EventSource"],"sources":["../../src/IntlayerEventListener.ts"],"sourcesContent":["import { getIntlayerAPIProxy } from '@intlayer/api';\n// @ts-ignore: @intlayer/backend is not built yet\nimport type { DictionaryAPI, MessageEventData } from '@intlayer/backend';\nimport configuration from '@intlayer/config/built';\nimport { getAppLogger } from '@intlayer/config/client';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport { EventSource } from 'eventsource';\n\nexport type IntlayerMessageEvent = MessageEvent;\n\n/**\n * IntlayerEventListener class to listen for dictionary changes via SSE (Server-Sent Events).\n *\n * Usage example:\n *\n * import { buildIntlayerDictionary } from './transpiler/declaration_file_to_dictionary/intlayer_dictionary';\n * import { IntlayerEventListener } from '@intlayer/api';\n *\n * export const checkDictionaryChanges = async () => {\n * // Instantiate the listener\n * const eventListener = new IntlayerEventListener();\n *\n * // Set up your callbacks\n * eventListener.onDictionaryChange = async (dictionary) => {\n * await buildIntlayerDictionary(dictionary);\n * };\n *\n * // Initialize the listener\n * await eventListener.initialize();\n *\n * // Optionally, clean up later when you’re done\n * // eventListener.cleanup();\n * };\n */\nexport class IntlayerEventListener {\n private appLogger = getAppLogger(configuration);\n\n private eventSource: EventSource | null = null;\n private reconnectAttempts = 0;\n private maxReconnectAttempts = 5;\n private reconnectDelay = 1000; // Start with 1 second\n private isManuallyDisconnected = false;\n private reconnectTimeout: NodeJS.Timeout | null = null;\n\n /**\n * Callback triggered when a Dictionary is ADDED.\n */\n public onDictionaryAdded?: (dictionary: DictionaryAPI) => any;\n\n /**\n * Callback triggered when a Dictionary is UPDATED.\n */\n public onDictionaryChange?: (dictionary: DictionaryAPI) => any;\n\n /**\n * Callback triggered when a Dictionary is DELETED.\n */\n public onDictionaryDeleted?: (dictionary: DictionaryAPI) => any;\n\n /**\n * Callback triggered when connection is established or re-established.\n */\n public onConnectionOpen?: () => any;\n\n /**\n * Callback triggered when connection encounters an error.\n */\n public onConnectionError?: (error: Event) => any;\n\n constructor(private intlayerConfig: IntlayerConfig = configuration) {\n this.appLogger = getAppLogger(this.intlayerConfig);\n }\n\n /**\n * Initializes the EventSource connection using the given intlayerConfig\n * (or the default config if none was provided).\n */\n public async initialize(): Promise<void> {\n this.isManuallyDisconnected = false;\n await this.connect();\n }\n\n /**\n * Establishes the EventSource connection with automatic reconnection support.\n */\n private async connect(): Promise<void> {\n try {\n const backendURL = this.intlayerConfig.editor.backendURL;\n\n // Retrieve the access token via proxy\n const accessToken = await getIntlayerAPIProxy(\n undefined,\n this.intlayerConfig\n ).oAuth.getOAuth2AccessToken();\n\n if (!accessToken) {\n throw new Error('Failed to retrieve access token');\n }\n\n const API_ROUTE = `${backendURL}/api/event-listener`;\n\n // Close existing connection if any\n if (this.eventSource) {\n this.eventSource.close();\n }\n\n this.eventSource = new EventSource(API_ROUTE, {\n fetch: (input, init) =>\n fetch(input, {\n ...init,\n headers: {\n ...(init?.headers ?? {}),\n Authorization: `Bearer ${accessToken.data?.accessToken}`,\n },\n }),\n });\n\n this.eventSource.onopen = () => {\n this.reconnectAttempts = 0;\n this.reconnectDelay = 1000; // Reset delay\n this.onConnectionOpen?.();\n };\n\n this.eventSource.onmessage = (event) => this.handleMessage(event);\n this.eventSource.onerror = (event) => this.handleError(event);\n } catch (_error) {\n this.appLogger('Failed to establish EventSource connection:', {\n level: 'error',\n });\n this.scheduleReconnect();\n }\n }\n\n /**\n * Cleans up (closes) the EventSource connection.\n */\n public cleanup(): void {\n this.isManuallyDisconnected = true;\n\n if (this.reconnectTimeout) {\n clearTimeout(this.reconnectTimeout);\n this.reconnectTimeout = null;\n }\n\n if (this.eventSource) {\n this.eventSource.close();\n this.eventSource = null;\n }\n }\n\n /**\n * Schedules a reconnection attempt with exponential backoff.\n */\n private scheduleReconnect(): void {\n if (\n this.isManuallyDisconnected ||\n this.reconnectAttempts >= this.maxReconnectAttempts\n ) {\n if (this.reconnectAttempts >= this.maxReconnectAttempts) {\n this.appLogger(\n [\n `Max reconnection attempts (${this.maxReconnectAttempts}) reached. Giving up.`,\n ],\n {\n level: 'error',\n }\n );\n }\n return;\n }\n\n this.reconnectAttempts++;\n const delay = this.reconnectDelay * 2 ** (this.reconnectAttempts - 1); // Exponential backoff\n\n this.appLogger(\n `Scheduling reconnection attempt ${this.reconnectAttempts}/${this.maxReconnectAttempts} in ${delay}ms`\n );\n\n this.reconnectTimeout = setTimeout(async () => {\n if (!this.isManuallyDisconnected) {\n await this.connect();\n }\n }, delay);\n }\n\n /**\n * Handles incoming SSE messages, parses the event data,\n * and invokes the appropriate callback.\n */\n private async handleMessage(event: IntlayerMessageEvent): Promise<void> {\n try {\n const { data } = event;\n\n const dataJSON: MessageEventData[] = JSON.parse(data);\n\n for (const dataEl of dataJSON) {\n switch (dataEl.object) {\n case 'DICTIONARY':\n switch (dataEl.status) {\n case 'ADDED':\n await this.onDictionaryAdded?.(dataEl.data);\n break;\n case 'UPDATED':\n await this.onDictionaryChange?.(dataEl.data);\n break;\n case 'DELETED':\n await this.onDictionaryDeleted?.(dataEl.data);\n break;\n default:\n this.appLogger(\n ['Unhandled dictionary status:', dataEl.status],\n {\n level: 'error',\n }\n );\n break;\n }\n break;\n default:\n this.appLogger(['Unknown object type:', dataEl.object], {\n level: 'error',\n });\n break;\n }\n }\n } catch (error) {\n this.appLogger(['Error processing dictionary update:', error], {\n level: 'error',\n });\n }\n }\n\n /**\n * Handles any SSE errors and attempts reconnection if appropriate.\n */\n private handleError(event: Event): void {\n const errorEvent = event as any;\n\n // Log detailed error information\n this.appLogger(\n [\n 'EventSource error:',\n {\n type: errorEvent.type,\n message: errorEvent.message,\n code: errorEvent.code,\n readyState: this.eventSource?.readyState,\n url: this.eventSource?.url,\n },\n ],\n {\n level: 'error',\n }\n );\n\n // Notify error callback\n this.onConnectionError?.(event);\n\n // Check if this is a connection close error\n const isConnectionClosed =\n errorEvent.type === 'error' &&\n (errorEvent.message?.includes('terminated') ||\n errorEvent.message?.includes('closed') ||\n this.eventSource?.readyState === EventSource.CLOSED);\n\n if (isConnectionClosed && !this.isManuallyDisconnected) {\n this.appLogger(\n 'Connection was terminated by server, attempting to reconnect...'\n );\n this.scheduleReconnect();\n } else {\n // For other types of errors, close the connection\n this.cleanup();\n }\n }\n}\n"],"mappings":"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"}
|
|
@@ -1,29 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
-
__defProp(to, key, {
|
|
14
|
-
get: ((k) => from[k]).bind(null, key),
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
-
value: mod,
|
|
24
|
-
enumerable: true
|
|
25
|
-
}) : target, mod));
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
|
|
29
|
-
exports.__toESM = __toESM;
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
|
|
@@ -1,98 +1,2 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
let node_url = require("node:url");
|
|
4
|
-
let node_fs = require("node:fs");
|
|
5
|
-
|
|
6
|
-
//#region \0utils:asset
|
|
7
|
-
const hereDirname = () => {
|
|
8
|
-
try {
|
|
9
|
-
return (0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
10
|
-
} catch {
|
|
11
|
-
return typeof __dirname !== "undefined" ? __dirname : process.cwd();
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
const findDistRoot = (startDir) => {
|
|
15
|
-
let dir = startDir;
|
|
16
|
-
for (let i = 0; i < 12; i++) {
|
|
17
|
-
if ((0, node_path.basename)(dir) === "dist") return dir;
|
|
18
|
-
const parent = (0, node_path.resolve)(dir, "..");
|
|
19
|
-
if (parent === dir) break;
|
|
20
|
-
dir = parent;
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
};
|
|
24
|
-
const normalizeFrameFile = (file) => {
|
|
25
|
-
if (!file) return null;
|
|
26
|
-
try {
|
|
27
|
-
if (file.startsWith("file://")) return (0, node_url.fileURLToPath)(file);
|
|
28
|
-
} catch {}
|
|
29
|
-
return file;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Returns the directory of the *caller* module that invoked readAsset.
|
|
33
|
-
* Prefers non-virtual frames; falls back to the first real frame.
|
|
34
|
-
*/
|
|
35
|
-
const getCallerDir = () => {
|
|
36
|
-
const prev = Error.prepareStackTrace;
|
|
37
|
-
try {
|
|
38
|
-
Error.prepareStackTrace = (_, structured) => structured;
|
|
39
|
-
const err = /* @__PURE__ */ new Error();
|
|
40
|
-
Error.captureStackTrace(err, getCallerDir);
|
|
41
|
-
/** @type {import('node:vm').CallSite[]} */
|
|
42
|
-
const frames = err.stack || [];
|
|
43
|
-
const isVirtualPath = (p) => p.includes(`${node_path.sep}_virtual${node_path.sep}`) || p.includes("/_virtual/");
|
|
44
|
-
for (const frame of frames) {
|
|
45
|
-
const file = normalizeFrameFile(typeof frame.getFileName === "function" ? frame.getFileName() : null);
|
|
46
|
-
if (!file) continue;
|
|
47
|
-
if (file.includes("node:internal") || file.includes(`${node_path.sep}internal${node_path.sep}modules${node_path.sep}`)) continue;
|
|
48
|
-
if (!isVirtualPath(file)) return (0, node_path.dirname)(file);
|
|
49
|
-
}
|
|
50
|
-
for (const frame of frames) {
|
|
51
|
-
const file = normalizeFrameFile(typeof frame.getFileName === "function" ? frame.getFileName() : null);
|
|
52
|
-
if (file) return (0, node_path.dirname)(file);
|
|
53
|
-
}
|
|
54
|
-
} catch {} finally {
|
|
55
|
-
Error.prepareStackTrace = prev;
|
|
56
|
-
}
|
|
57
|
-
return hereDirname();
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Read an asset copied from src/** to dist/assets/**.
|
|
61
|
-
* - './' or '../' is resolved relative to the *caller module's* emitted directory.
|
|
62
|
-
* - otherwise, treat as src-relative.
|
|
63
|
-
*
|
|
64
|
-
* @param {string} relPath - e.g. './PROMPT.md' or 'utils/AI/askDocQuestion/embeddings/<fileKey>.json'
|
|
65
|
-
* @param {BufferEncoding} [encoding='utf8']
|
|
66
|
-
*/
|
|
67
|
-
const readAsset = (relPath, encoding = "utf8") => {
|
|
68
|
-
const here = hereDirname();
|
|
69
|
-
const distRoot = findDistRoot(here) ?? (0, node_path.resolve)(here, "..", "..", "dist");
|
|
70
|
-
const assetsRoot = (0, node_path.join)(distRoot, "assets");
|
|
71
|
-
const tried = [];
|
|
72
|
-
/**
|
|
73
|
-
* Transform dist/(esm|cjs)/... and _virtual/ prefix to clean subpath (Windows-safe)
|
|
74
|
-
*/
|
|
75
|
-
const callerSubpath = (0, node_path.relative)(distRoot, getCallerDir()).split("\\").join("/").replace(/^(?:dist\/)?(?:esm|cjs)\//, "").replace(/^_virtual\//, "");
|
|
76
|
-
if (relPath.startsWith("./") || relPath.startsWith("../")) {
|
|
77
|
-
const fromCallerAbs = (0, node_path.resolve)(assetsRoot, callerSubpath, relPath);
|
|
78
|
-
tried.push(fromCallerAbs);
|
|
79
|
-
if ((0, node_fs.existsSync)(fromCallerAbs)) return (0, node_fs.readFileSync)(fromCallerAbs, encoding);
|
|
80
|
-
}
|
|
81
|
-
const directPath = (0, node_path.join)(assetsRoot, relPath);
|
|
82
|
-
tried.push(directPath);
|
|
83
|
-
if ((0, node_fs.existsSync)(directPath)) return (0, node_fs.readFileSync)(directPath, encoding);
|
|
84
|
-
if (callerSubpath) {
|
|
85
|
-
const nested = (0, node_path.join)(assetsRoot, callerSubpath, relPath);
|
|
86
|
-
tried.push(nested);
|
|
87
|
-
if ((0, node_fs.existsSync)(nested)) return (0, node_fs.readFileSync)(nested, encoding);
|
|
88
|
-
}
|
|
89
|
-
const msg = [
|
|
90
|
-
"readAsset: file not found.",
|
|
91
|
-
"Searched:",
|
|
92
|
-
...tried.map((p) => `- ${p}`)
|
|
93
|
-
].join("\n");
|
|
94
|
-
throw new Error(msg);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
//#endregion
|
|
98
|
-
exports.readAsset = readAsset;
|
|
1
|
+
require(`./_rolldown/runtime.cjs`);let e=require(`node:path`),t=require(`node:url`),n=require(`node:fs`);const r=()=>{try{return(0,e.dirname)((0,t.fileURLToPath)(require(`url`).pathToFileURL(__filename).href))}catch{return typeof __dirname<`u`?__dirname:process.cwd()}},i=t=>{let n=t;for(let t=0;t<12;t++){if((0,e.basename)(n)===`dist`)return n;let t=(0,e.resolve)(n,`..`);if(t===n)break;n=t}return null},a=e=>{if(!e)return null;try{if(e.startsWith(`file://`))return(0,t.fileURLToPath)(e)}catch{}return e},o=()=>{let t=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let t=Error();Error.captureStackTrace(t,o);let n=t.stack||[],r=t=>t.includes(`${e.sep}_virtual${e.sep}`)||t.includes(`/_virtual/`);for(let t of n){let n=a(typeof t.getFileName==`function`?t.getFileName():null);if(n&&!(n.includes(`node:internal`)||n.includes(`${e.sep}internal${e.sep}modules${e.sep}`))&&!r(n))return(0,e.dirname)(n)}for(let t of n){let n=a(typeof t.getFileName==`function`?t.getFileName():null);if(n)return(0,e.dirname)(n)}}catch{}finally{Error.prepareStackTrace=t}return r()},s=(t,a=`utf8`)=>{let s=r(),c=i(s)??(0,e.resolve)(s,`..`,`..`,`dist`),l=(0,e.join)(c,`assets`),u=[],d=(0,e.relative)(c,o()).split(`\\`).join(`/`).replace(/^(?:dist\/)?(?:esm|cjs)\//,``).replace(/^_virtual\//,``);if(t.startsWith(`./`)||t.startsWith(`../`)){let r=(0,e.resolve)(l,d,t);if(u.push(r),(0,n.existsSync)(r))return(0,n.readFileSync)(r,a)}let f=(0,e.join)(l,t);if(u.push(f),(0,n.existsSync)(f))return(0,n.readFileSync)(f,a);if(d){let r=(0,e.join)(l,d,t);if(u.push(r),(0,n.existsSync)(r))return(0,n.readFileSync)(r,a)}let p=[`readAsset: file not found.`,`Searched:`,...u.map(e=>`- ${e}`)].join(`
|
|
2
|
+
`);throw Error(p)};exports.readAsset=s;
|
package/dist/cjs/auth/login.cjs
CHANGED
|
@@ -1,60 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_utils_openBrowser = require('../utils/openBrowser.cjs');
|
|
4
|
-
let _intlayer_config = require("@intlayer/config");
|
|
5
|
-
let node_url = require("node:url");
|
|
6
|
-
let node_http = require("node:http");
|
|
7
|
-
node_http = require_runtime.__toESM(node_http);
|
|
8
|
-
|
|
9
|
-
//#region src/auth/login.ts
|
|
10
|
-
const login = async (options) => {
|
|
11
|
-
const configuration = (0, _intlayer_config.getConfiguration)(options.configOptions);
|
|
12
|
-
const logger = (0, _intlayer_config.getAppLogger)(configuration);
|
|
13
|
-
const cmsUrl = options.cmsUrl ?? configuration.editor.cmsURL;
|
|
14
|
-
return new Promise((resolve) => {
|
|
15
|
-
const server = node_http.default.createServer((req, res) => {
|
|
16
|
-
const url = new node_url.URL(req.url ?? "", `http://${req.headers.host}`);
|
|
17
|
-
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
18
|
-
res.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS");
|
|
19
|
-
res.setHeader("Access-Control-Allow-Headers", "Content-Type");
|
|
20
|
-
if (req.method === "OPTIONS") {
|
|
21
|
-
res.writeHead(204);
|
|
22
|
-
res.end();
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if (url.pathname === "/callback") {
|
|
26
|
-
const clientId = url.searchParams.get("clientId");
|
|
27
|
-
const clientSecret = url.searchParams.get("clientSecret");
|
|
28
|
-
if (clientId && clientSecret) {
|
|
29
|
-
logger("");
|
|
30
|
-
logger("Log in successful. Client ID and Client Secret received.");
|
|
31
|
-
logger("");
|
|
32
|
-
logger([
|
|
33
|
-
"1. Insert the Client ID and Client Secret in your",
|
|
34
|
-
(0, _intlayer_config.colorizePath)(".env"),
|
|
35
|
-
"file:"
|
|
36
|
-
]);
|
|
37
|
-
logger((0, _intlayer_config.colorize)("--------------------------------", _intlayer_config.ANSIColors.GREY_DARK));
|
|
38
|
-
logger([(0, _intlayer_config.colorize)("INTLAYER_CLIENT_ID=", _intlayer_config.ANSIColors.GREY_LIGHT), (0, _intlayer_config.colorize)(clientId, _intlayer_config.ANSIColors.BLUE)].join(""));
|
|
39
|
-
logger([(0, _intlayer_config.colorize)("INTLAYER_CLIENT_SECRET=", _intlayer_config.ANSIColors.GREY_LIGHT), (0, _intlayer_config.colorize)(clientSecret, _intlayer_config.ANSIColors.BLUE)].join(""));
|
|
40
|
-
logger((0, _intlayer_config.colorize)("--------------------------------", _intlayer_config.ANSIColors.GREY_DARK));
|
|
41
|
-
logger("");
|
|
42
|
-
logger("2. Insert in your Intlayer configuration file:");
|
|
43
|
-
logger((0, _intlayer_config.colorize)("--------------------------------", _intlayer_config.ANSIColors.GREY_DARK));
|
|
44
|
-
[
|
|
45
|
-
`${_intlayer_config.ANSIColors.GREY_LIGHT}{`,
|
|
46
|
-
` editor: {`,
|
|
47
|
-
` cmsURL: '${(0, _intlayer_config.colorizePath)(cmsUrl, void 0, _intlayer_config.ANSIColors.GREY_LIGHT)}',`,
|
|
48
|
-
` clientId: '${(0, _intlayer_config.colorize)("process.env.INTLAYER_CLIENT_ID", _intlayer_config.ANSIColors.BLUE, _intlayer_config.ANSIColors.GREY_LIGHT)}',`,
|
|
49
|
-
` clientSecret: '${(0, _intlayer_config.colorize)("process.env.INTLAYER_CLIENT_SECRET", _intlayer_config.ANSIColors.BLUE, _intlayer_config.ANSIColors.GREY_LIGHT)}',`,
|
|
50
|
-
` },`,
|
|
51
|
-
`}`
|
|
52
|
-
].forEach((line) => {
|
|
53
|
-
logger(line);
|
|
54
|
-
});
|
|
55
|
-
logger((0, _intlayer_config.colorize)("--------------------------------", _intlayer_config.ANSIColors.GREY_DARK));
|
|
56
|
-
res.writeHead(200, { "Content-Type": "text/html" });
|
|
57
|
-
res.end(`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../utils/openBrowser.cjs`);let n=require(`@intlayer/config/node`),r=require(`@intlayer/config/logger`),i=require(`node:url`),a=require(`node:http`);a=e.__toESM(a);const o=async e=>{let o=(0,n.getConfiguration)(e.configOptions),s=(0,r.getAppLogger)(o),c=e.cmsUrl??o.editor.cmsURL;return new Promise(e=>{let n=a.default.createServer((t,a)=>{let o=new i.URL(t.url??``,`http://${t.headers.host}`);if(a.setHeader(`Access-Control-Allow-Origin`,`*`),a.setHeader(`Access-Control-Allow-Methods`,`GET, OPTIONS`),a.setHeader(`Access-Control-Allow-Headers`,`Content-Type`),t.method===`OPTIONS`){a.writeHead(204),a.end();return}if(o.pathname===`/callback`){let t=o.searchParams.get(`clientId`),i=o.searchParams.get(`clientSecret`);t&&i?(s(``),s(`Log in successful. Client ID and Client Secret received.`),s(``),s([`1. Insert the Client ID and Client Secret in your`,(0,r.colorizePath)(`.env`),`file:`]),s((0,r.colorize)(`--------------------------------`,r.ANSIColors.GREY_DARK)),s([(0,r.colorize)(`INTLAYER_CLIENT_ID=`,r.ANSIColors.GREY_LIGHT),(0,r.colorize)(t,r.ANSIColors.BLUE)].join(``)),s([(0,r.colorize)(`INTLAYER_CLIENT_SECRET=`,r.ANSIColors.GREY_LIGHT),(0,r.colorize)(i,r.ANSIColors.BLUE)].join(``)),s((0,r.colorize)(`--------------------------------`,r.ANSIColors.GREY_DARK)),s(``),s(`2. Insert in your Intlayer configuration file:`),s((0,r.colorize)(`--------------------------------`,r.ANSIColors.GREY_DARK)),[`${r.ANSIColors.GREY_LIGHT}{`,` editor: {`,` cmsURL: '${(0,r.colorizePath)(c,void 0,r.ANSIColors.GREY_LIGHT)}',`,` clientId: '${(0,r.colorize)(`process.env.INTLAYER_CLIENT_ID`,r.ANSIColors.BLUE,r.ANSIColors.GREY_LIGHT)}',`,` clientSecret: '${(0,r.colorize)(`process.env.INTLAYER_CLIENT_SECRET`,r.ANSIColors.BLUE,r.ANSIColors.GREY_LIGHT)}',`,` },`,`}`].forEach(e=>{s(e)}),s((0,r.colorize)(`--------------------------------`,r.ANSIColors.GREY_DARK)),a.writeHead(200,{"Content-Type":`text/html`}),a.end(`
|
|
58
2
|
<!DOCTYPE html>
|
|
59
3
|
<html lang="en" data-theme="dark">
|
|
60
4
|
<head>
|
|
@@ -126,32 +70,5 @@ const login = async (options) => {
|
|
|
126
70
|
<\/script>
|
|
127
71
|
</body>
|
|
128
72
|
</html>
|
|
129
|
-
`);
|
|
130
|
-
server.close(() => {
|
|
131
|
-
resolve();
|
|
132
|
-
process.exit(0);
|
|
133
|
-
});
|
|
134
|
-
} else {
|
|
135
|
-
res.writeHead(400, { "Content-Type": "text/plain" });
|
|
136
|
-
res.end("Missing parameters");
|
|
137
|
-
}
|
|
138
|
-
} else {
|
|
139
|
-
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
140
|
-
res.end("Not found");
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
server.listen(0, () => {
|
|
144
|
-
const address = server.address();
|
|
145
|
-
const port = typeof address === "object" && address ? address.port : 0;
|
|
146
|
-
const state = Math.random().toString(36).substring(7);
|
|
147
|
-
const loginUrl = `${cmsUrl ?? process.env.INTLAYER_SITE_URL ?? "http://localhost:3000"}/en/auth/cli-login?port=${port}&state=${state}`;
|
|
148
|
-
logger("Opening browser for login...");
|
|
149
|
-
logger(`If browser does not open, visit: ${(0, _intlayer_config.colorizePath)(loginUrl)}`);
|
|
150
|
-
require_utils_openBrowser.openBrowser(loginUrl);
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
//#endregion
|
|
156
|
-
exports.login = login;
|
|
73
|
+
`),n.close(()=>{e(),process.exit(0)})):(a.writeHead(400,{"Content-Type":`text/plain`}),a.end(`Missing parameters`))}else a.writeHead(404,{"Content-Type":`text/plain`}),a.end(`Not found`)});n.listen(0,()=>{let e=n.address(),i=typeof e==`object`&&e?e.port:0,a=Math.random().toString(36).substring(7),o=`${c??process.env.INTLAYER_SITE_URL??`http://localhost:3000`}/en/auth/cli-login?port=${i}&state=${a}`;s(`Opening browser for login...`),s(`If browser does not open, visit: ${(0,r.colorizePath)(o)}`),t.openBrowser(o)})})};exports.login=o;
|
|
157
74
|
//# sourceMappingURL=login.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.cjs","names":["http","URL","ANSIColors"],"sources":["../../../src/auth/login.ts"],"sourcesContent":["import http from 'node:http';\nimport { URL } from 'node:url';\nimport
|
|
1
|
+
{"version":3,"file":"login.cjs","names":["http","URL","ANSIColors"],"sources":["../../../src/auth/login.ts"],"sourcesContent":["import http from 'node:http';\nimport { URL } from 'node:url';\nimport {\n ANSIColors,\n colorize,\n colorizePath,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { openBrowser } from '../utils/openBrowser';\n\ntype LoginOptions = {\n cmsUrl?: string;\n configOptions?: GetConfigurationOptions;\n};\n\nexport const login = async (options: LoginOptions) => {\n const configuration = getConfiguration(options.configOptions);\n const logger = getAppLogger(configuration);\n\n const cmsUrl = options.cmsUrl ?? configuration.editor.cmsURL;\n\n return new Promise<void>((resolve) => {\n const server = http.createServer((req, res) => {\n const url = new URL(req.url ?? '', `http://${req.headers.host}`);\n\n // Set CORS headers\n res.setHeader('Access-Control-Allow-Origin', '*');\n res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS');\n res.setHeader('Access-Control-Allow-Headers', 'Content-Type');\n\n if (req.method === 'OPTIONS') {\n res.writeHead(204);\n res.end();\n return;\n }\n\n if (url.pathname === '/callback') {\n const clientId = url.searchParams.get('clientId');\n const clientSecret = url.searchParams.get('clientSecret');\n\n if (clientId && clientSecret) {\n logger('');\n logger('Log in successful. Client ID and Client Secret received.');\n\n logger('');\n logger([\n '1. Insert the Client ID and Client Secret in your',\n colorizePath('.env'),\n 'file:',\n ]);\n logger(\n colorize('--------------------------------', ANSIColors.GREY_DARK)\n );\n logger(\n [\n colorize('INTLAYER_CLIENT_ID=', ANSIColors.GREY_LIGHT),\n colorize(clientId, ANSIColors.BLUE),\n ].join('')\n );\n logger(\n [\n colorize('INTLAYER_CLIENT_SECRET=', ANSIColors.GREY_LIGHT),\n colorize(clientSecret, ANSIColors.BLUE),\n ].join('')\n );\n logger(\n colorize('--------------------------------', ANSIColors.GREY_DARK)\n );\n logger('');\n logger('2. Insert in your Intlayer configuration file:');\n logger(\n colorize('--------------------------------', ANSIColors.GREY_DARK)\n );\n [\n `${ANSIColors.GREY_LIGHT}{`,\n ` editor: {`,\n ` cmsURL: '${colorizePath(cmsUrl, undefined, ANSIColors.GREY_LIGHT)}',`,\n ` clientId: '${colorize('process.env.INTLAYER_CLIENT_ID', ANSIColors.BLUE, ANSIColors.GREY_LIGHT)}',`,\n ` clientSecret: '${colorize('process.env.INTLAYER_CLIENT_SECRET', ANSIColors.BLUE, ANSIColors.GREY_LIGHT)}',`,\n ` },`,\n `}`,\n ].forEach((line) => {\n logger(line);\n });\n logger(\n colorize('--------------------------------', ANSIColors.GREY_DARK)\n );\n\n res.writeHead(200, { 'Content-Type': 'text/html' });\n res.end(`\n <!DOCTYPE html>\n <html lang=\"en\" data-theme=\"dark\">\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>Intlayer CLI Login</title>\n <style>\n :root {\n --color-background: rgba(23, 23, 23);\n --color-card: rgba(39, 39, 39);\n --color-text: rgba(255, 245, 237);\n --color-neutral: rgba(93, 93, 93);\n --font-sans: \"Inter\", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\n }\n \n * {\n box-sizing: border-box;\n }\n \n body {\n font-family: var(--font-sans);\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100vh;\n margin: 0;\n padding: 1rem;\n background-color: var(--color-background);\n color: var(--color-text);\n }\n \n .container {\n text-align: center;\n padding: 2rem;\n border-radius: 1rem;\n background-color: var(--color-card);\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n max-width: 400px;\n width: 100%;\n }\n \n h1 {\n margin: 0 0 1rem 0;\n font-size: 1.5rem;\n font-weight: 700;\n color: var(--color-text);\n }\n \n p {\n color: var(--color-neutral);\n margin: 0 0 1.5rem 0;\n line-height: 1.5;\n }\n </style>\n </head>\n <body>\n <div class=\"container\">\n <h1>Login Successful</h1>\n <p>You have successfully logged in to Intlayer CLI. You can now close this tab and return to your terminal.</p>\n </div>\n <script>\n // Attempt to close the window\n window.close();\n \n // Fallback: if window.close() doesn't work, show a message\n setTimeout(() => {\n window.close();\n }, 1000);\n </script>\n </body>\n </html>\n `);\n\n server.close(() => {\n resolve();\n process.exit(0);\n });\n } else {\n res.writeHead(400, { 'Content-Type': 'text/plain' });\n res.end('Missing parameters');\n }\n } else {\n res.writeHead(404, { 'Content-Type': 'text/plain' });\n res.end('Not found');\n }\n });\n\n server.listen(0, () => {\n const address = server.address();\n const port = typeof address === 'object' && address ? address.port : 0;\n const state = Math.random().toString(36).substring(7);\n\n const websiteUrl =\n cmsUrl ?? process.env.INTLAYER_SITE_URL ?? 'http://localhost:3000';\n const loginUrl = `${websiteUrl}/en/auth/cli-login?port=${port}&state=${state}`;\n\n logger('Opening browser for login...');\n logger(`If browser does not open, visit: ${colorizePath(loginUrl)}`);\n\n openBrowser(loginUrl);\n });\n });\n};\n"],"mappings":"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"}
|
package/dist/cjs/build.cjs
CHANGED
|
@@ -1,28 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let _intlayer_chokidar = require("@intlayer/chokidar");
|
|
4
|
-
let _intlayer_config = require("@intlayer/config");
|
|
5
|
-
|
|
6
|
-
//#region src/build.ts
|
|
7
|
-
/**
|
|
8
|
-
* Get locales dictionaries .content.{json|ts|tsx|js|jsx|mjs|cjs} and build the JSON dictionaries in the .intlayer directory.
|
|
9
|
-
* Watch mode available to get the change in the .content.{json|ts|tsx|js|jsx|mjs|cjs}
|
|
10
|
-
*/
|
|
11
|
-
const build = async (options) => {
|
|
12
|
-
const config = (0, _intlayer_config.getConfiguration)(options?.configOptions);
|
|
13
|
-
let parallelProcess = null;
|
|
14
|
-
if (options?.with) {
|
|
15
|
-
parallelProcess = (0, _intlayer_chokidar.runParallel)(options.with);
|
|
16
|
-
parallelProcess.result.catch(() => {});
|
|
17
|
-
}
|
|
18
|
-
await (0, _intlayer_chokidar.buildAndWatchIntlayer)({
|
|
19
|
-
persistent: options?.watch ?? false,
|
|
20
|
-
skipPrepare: options?.skipPrepare ?? false,
|
|
21
|
-
configuration: config
|
|
22
|
-
});
|
|
23
|
-
if (!options?.watch && parallelProcess) parallelProcess.kill();
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
exports.build = build;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/chokidar/utils`),t=require(`@intlayer/chokidar/watcher`),n=require(`@intlayer/config/node`);const r=async r=>{let i=(0,n.getConfiguration)(r?.configOptions),a=null;r?.with&&(a=(0,e.runParallel)(r.with),a.result.catch(()=>{})),await(0,t.buildAndWatchIntlayer)({persistent:r?.watch??!1,skipPrepare:r?.skipPrepare??!1,configuration:i}),!r?.watch&&a&&a.kill()};exports.build=r;
|
|
28
2
|
//# sourceMappingURL=build.cjs.map
|
package/dist/cjs/build.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.cjs","names":[],"sources":["../../src/build.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"build.cjs","names":[],"sources":["../../src/build.ts"],"sourcesContent":["import { type ParallelHandle, runParallel } from '@intlayer/chokidar/utils';\nimport { buildAndWatchIntlayer } from '@intlayer/chokidar/watcher';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\n\ntype BuildOptions = {\n watch?: boolean;\n skipPrepare?: boolean;\n with?: string | string[];\n configOptions?: GetConfigurationOptions;\n};\n\n/**\n * Get locales dictionaries .content.{json|ts|tsx|js|jsx|mjs|cjs} and build the JSON dictionaries in the .intlayer directory.\n * Watch mode available to get the change in the .content.{json|ts|tsx|js|jsx|mjs|cjs}\n */\nexport const build = async (options?: BuildOptions) => {\n const config = getConfiguration(options?.configOptions);\n let parallelProcess: ParallelHandle | null = null;\n\n if (options?.with) {\n parallelProcess = runParallel(options.with);\n // Handle the promise to avoid unhandled rejection\n parallelProcess.result.catch(() => {\n // Parallel process failed or was terminated\n });\n }\n\n await buildAndWatchIntlayer({\n persistent: options?.watch ?? false,\n skipPrepare: options?.skipPrepare ?? false,\n configuration: config,\n });\n\n if (!options?.watch && parallelProcess) {\n parallelProcess.kill();\n }\n};\n"],"mappings":"oOAkBA,MAAa,EAAQ,KAAO,IAA2B,CACrD,IAAM,GAAA,EAAA,EAAA,kBAA0B,GAAS,cAAc,CACnD,EAAyC,KAEzC,GAAS,OACX,GAAA,EAAA,EAAA,aAA8B,EAAQ,KAAK,CAE3C,EAAgB,OAAO,UAAY,GAEjC,EAGJ,MAAA,EAAA,EAAA,uBAA4B,CAC1B,WAAY,GAAS,OAAS,GAC9B,YAAa,GAAS,aAAe,GACrC,cAAe,EAChB,CAAC,CAEE,CAAC,GAAS,OAAS,GACrB,EAAgB,MAAM"}
|