@intlayer/cli 8.4.4 → 8.4.6
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 +186 -1
- package/dist/cjs/IntlayerEventListener.cjs.map +1 -1
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/cjs/_virtual/_utils_asset.cjs +98 -0
- package/dist/cjs/auth/login.cjs +90 -2
- package/dist/cjs/auth/login.cjs.map +1 -1
- package/dist/cjs/build.cjs +30 -1
- package/dist/cjs/build.cjs.map +1 -1
- package/dist/cjs/ci.cjs +76 -1
- package/dist/cjs/ci.cjs.map +1 -1
- package/dist/cjs/cli.cjs +485 -1
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/config.cjs +15 -1
- package/dist/cjs/config.cjs.map +1 -1
- package/dist/cjs/editor.cjs +50 -1
- package/dist/cjs/editor.cjs.map +1 -1
- package/dist/cjs/extract.cjs +108 -1
- package/dist/cjs/extract.cjs.map +1 -1
- package/dist/cjs/fill/deepMergeContent.cjs +27 -1
- package/dist/cjs/fill/deepMergeContent.cjs.map +1 -1
- package/dist/cjs/fill/fill.cjs +89 -1
- package/dist/cjs/fill/fill.cjs.map +1 -1
- package/dist/cjs/fill/formatAutoFilledFilePath.cjs +32 -1
- package/dist/cjs/fill/formatAutoFilledFilePath.cjs.map +1 -1
- package/dist/cjs/fill/formatFillData.cjs +91 -1
- package/dist/cjs/fill/formatFillData.cjs.map +1 -1
- package/dist/cjs/fill/getAvailableLocalesInDictionary.cjs +26 -1
- package/dist/cjs/fill/getAvailableLocalesInDictionary.cjs.map +1 -1
- package/dist/cjs/fill/getFilterMissingContentPerLocale.cjs +51 -1
- package/dist/cjs/fill/getFilterMissingContentPerLocale.cjs.map +1 -1
- package/dist/cjs/fill/index.cjs +6 -1
- package/dist/cjs/fill/listTranslationsTasks.cjs +72 -1
- package/dist/cjs/fill/listTranslationsTasks.cjs.map +1 -1
- package/dist/cjs/fill/translateDictionary.cjs +241 -1
- package/dist/cjs/fill/translateDictionary.cjs.map +1 -1
- package/dist/cjs/fill/writeFill.cjs +53 -1
- package/dist/cjs/fill/writeFill.cjs.map +1 -1
- package/dist/cjs/getTargetDictionary.cjs +36 -1
- package/dist/cjs/getTargetDictionary.cjs.map +1 -1
- package/dist/cjs/index.cjs +44 -1
- package/dist/cjs/init.cjs +22 -1
- package/dist/cjs/init.cjs.map +1 -1
- package/dist/cjs/initMCP.cjs +69 -1
- package/dist/cjs/initMCP.cjs.map +1 -1
- package/dist/cjs/initSkills.cjs +93 -1
- package/dist/cjs/initSkills.cjs.map +1 -1
- package/dist/cjs/listContentDeclaration.cjs +42 -1
- package/dist/cjs/listContentDeclaration.cjs.map +1 -1
- package/dist/cjs/listProjects.cjs +28 -1
- package/dist/cjs/listProjects.cjs.map +1 -1
- package/dist/cjs/liveSync.cjs +153 -8
- package/dist/cjs/liveSync.cjs.map +1 -1
- package/dist/cjs/pull.cjs +153 -1
- package/dist/cjs/pull.cjs.map +1 -1
- package/dist/cjs/push/pullLog.cjs +105 -3
- package/dist/cjs/push/pullLog.cjs.map +1 -1
- package/dist/cjs/push/push.cjs +212 -1
- package/dist/cjs/push/push.cjs.map +1 -1
- package/dist/cjs/pushConfig.cjs +22 -1
- package/dist/cjs/pushConfig.cjs.map +1 -1
- package/dist/cjs/pushLog.cjs +86 -3
- package/dist/cjs/pushLog.cjs.map +1 -1
- package/dist/cjs/reviewDoc/reviewDoc.cjs +73 -1
- package/dist/cjs/reviewDoc/reviewDoc.cjs.map +1 -1
- package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs +98 -1
- package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs.map +1 -1
- package/dist/cjs/searchDoc.cjs +41 -1
- package/dist/cjs/searchDoc.cjs.map +1 -1
- package/dist/cjs/test/index.cjs +7 -1
- package/dist/cjs/test/listMissingTranslations.cjs +66 -1
- package/dist/cjs/test/listMissingTranslations.cjs.map +1 -1
- package/dist/cjs/test/test.cjs +56 -1
- package/dist/cjs/test/test.cjs.map +1 -1
- package/dist/cjs/translateDoc/index.cjs +9 -1
- package/dist/cjs/translateDoc/translateDoc.cjs +79 -1
- package/dist/cjs/translateDoc/translateDoc.cjs.map +1 -1
- package/dist/cjs/translateDoc/translateFile.cjs +106 -2
- package/dist/cjs/translateDoc/translateFile.cjs.map +1 -1
- package/dist/cjs/translateDoc/validation.cjs +49 -5
- package/dist/cjs/translateDoc/validation.cjs.map +1 -1
- package/dist/cjs/translation-alignment/alignBlocks.cjs +67 -1
- package/dist/cjs/translation-alignment/alignBlocks.cjs.map +1 -1
- package/dist/cjs/translation-alignment/computeSimilarity.cjs +25 -1
- package/dist/cjs/translation-alignment/computeSimilarity.cjs.map +1 -1
- package/dist/cjs/translation-alignment/fingerprintBlock.cjs +23 -1
- package/dist/cjs/translation-alignment/fingerprintBlock.cjs.map +1 -1
- package/dist/cjs/translation-alignment/index.cjs +22 -1
- package/dist/cjs/translation-alignment/mapChangedLinesToBlocks.cjs +18 -1
- package/dist/cjs/translation-alignment/mapChangedLinesToBlocks.cjs.map +1 -1
- package/dist/cjs/translation-alignment/normalizeBlock.cjs +22 -1
- package/dist/cjs/translation-alignment/normalizeBlock.cjs.map +1 -1
- package/dist/cjs/translation-alignment/pipeline.cjs +37 -1
- package/dist/cjs/translation-alignment/pipeline.cjs.map +1 -1
- package/dist/cjs/translation-alignment/planActions.cjs +46 -1
- package/dist/cjs/translation-alignment/planActions.cjs.map +1 -1
- package/dist/cjs/translation-alignment/rebuildDocument.cjs +49 -2
- package/dist/cjs/translation-alignment/rebuildDocument.cjs.map +1 -1
- package/dist/cjs/translation-alignment/segmentDocument.cjs +66 -5
- package/dist/cjs/translation-alignment/segmentDocument.cjs.map +1 -1
- package/dist/cjs/utils/calculateChunks.cjs +89 -2
- package/dist/cjs/utils/calculateChunks.cjs.map +1 -1
- package/dist/cjs/utils/checkAccess.cjs +83 -1
- package/dist/cjs/utils/checkAccess.cjs.map +1 -1
- package/dist/cjs/utils/checkConfigConsistency.cjs +16 -1
- package/dist/cjs/utils/checkConfigConsistency.cjs.map +1 -1
- package/dist/cjs/utils/checkFileModifiedRange.cjs +81 -1
- package/dist/cjs/utils/checkFileModifiedRange.cjs.map +1 -1
- package/dist/cjs/utils/checkLastUpdateTime.cjs +19 -1
- package/dist/cjs/utils/checkLastUpdateTime.cjs.map +1 -1
- package/dist/cjs/utils/chunkInference.cjs +45 -1
- package/dist/cjs/utils/chunkInference.cjs.map +1 -1
- package/dist/cjs/utils/fixChunkStartEndChars.cjs +27 -3
- package/dist/cjs/utils/fixChunkStartEndChars.cjs.map +1 -1
- package/dist/cjs/utils/formatTimeDiff.cjs +20 -1
- package/dist/cjs/utils/formatTimeDiff.cjs.map +1 -1
- package/dist/cjs/utils/getIsFileUpdatedRecently.cjs +16 -1
- package/dist/cjs/utils/getIsFileUpdatedRecently.cjs.map +1 -1
- package/dist/cjs/utils/getOutputFilePath.cjs +108 -1
- package/dist/cjs/utils/getOutputFilePath.cjs.map +1 -1
- package/dist/cjs/utils/getParentPackageJSON.cjs +20 -1
- package/dist/cjs/utils/getParentPackageJSON.cjs.map +1 -1
- package/dist/cjs/utils/listSpecialChars.cjs +54 -2
- package/dist/cjs/utils/listSpecialChars.cjs.map +1 -1
- package/dist/cjs/utils/mapChunksBetweenFiles.cjs +102 -1
- package/dist/cjs/utils/mapChunksBetweenFiles.cjs.map +1 -1
- package/dist/cjs/utils/openBrowser.cjs +19 -1
- package/dist/cjs/utils/openBrowser.cjs.map +1 -1
- package/dist/cjs/utils/reorderParagraphs.cjs +91 -3
- package/dist/cjs/utils/reorderParagraphs.cjs.map +1 -1
- package/dist/cjs/utils/setupAI.cjs +66 -1
- package/dist/cjs/utils/setupAI.cjs.map +1 -1
- package/dist/cjs/watch.cjs +47 -1
- package/dist/cjs/watch.cjs.map +1 -1
- package/dist/esm/IntlayerEventListener.mjs +183 -1
- package/dist/esm/IntlayerEventListener.mjs.map +1 -1
- package/dist/esm/_virtual/_rolldown/runtime.mjs +8 -0
- package/dist/esm/_virtual/_utils_asset.mjs +97 -0
- package/dist/esm/auth/login.mjs +86 -2
- package/dist/esm/auth/login.mjs.map +1 -1
- package/dist/esm/build.mjs +28 -1
- package/dist/esm/build.mjs.map +1 -1
- package/dist/esm/ci.mjs +74 -1
- package/dist/esm/ci.mjs.map +1 -1
- package/dist/esm/cli.mjs +482 -1
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/config.mjs +13 -1
- package/dist/esm/config.mjs.map +1 -1
- package/dist/esm/editor.mjs +50 -1
- package/dist/esm/editor.mjs.map +1 -0
- package/dist/esm/extract.mjs +104 -1
- package/dist/esm/extract.mjs.map +1 -1
- package/dist/esm/fill/deepMergeContent.mjs +25 -1
- package/dist/esm/fill/deepMergeContent.mjs.map +1 -1
- package/dist/esm/fill/fill.mjs +86 -1
- package/dist/esm/fill/fill.mjs.map +1 -1
- package/dist/esm/fill/formatAutoFilledFilePath.mjs +30 -1
- package/dist/esm/fill/formatAutoFilledFilePath.mjs.map +1 -1
- package/dist/esm/fill/formatFillData.mjs +89 -1
- package/dist/esm/fill/formatFillData.mjs.map +1 -1
- package/dist/esm/fill/getAvailableLocalesInDictionary.mjs +24 -1
- package/dist/esm/fill/getAvailableLocalesInDictionary.mjs.map +1 -1
- package/dist/esm/fill/getFilterMissingContentPerLocale.mjs +49 -1
- package/dist/esm/fill/getFilterMissingContentPerLocale.mjs.map +1 -1
- package/dist/esm/fill/index.mjs +4 -1
- package/dist/esm/fill/listTranslationsTasks.mjs +69 -1
- package/dist/esm/fill/listTranslationsTasks.mjs.map +1 -1
- package/dist/esm/fill/translateDictionary.mjs +238 -1
- package/dist/esm/fill/translateDictionary.mjs.map +1 -1
- package/dist/esm/fill/writeFill.mjs +51 -1
- package/dist/esm/fill/writeFill.mjs.map +1 -1
- package/dist/esm/getTargetDictionary.mjs +33 -1
- package/dist/esm/getTargetDictionary.mjs.map +1 -1
- package/dist/esm/index.mjs +20 -1
- package/dist/esm/init.mjs +19 -1
- package/dist/esm/init.mjs.map +1 -1
- package/dist/esm/initMCP.mjs +65 -1
- package/dist/esm/initMCP.mjs.map +1 -1
- package/dist/esm/initSkills.mjs +87 -1
- package/dist/esm/initSkills.mjs.map +1 -1
- package/dist/esm/listContentDeclaration.mjs +39 -1
- package/dist/esm/listContentDeclaration.mjs.map +1 -1
- package/dist/esm/listProjects.mjs +26 -1
- package/dist/esm/listProjects.mjs.map +1 -1
- package/dist/esm/liveSync.mjs +150 -8
- package/dist/esm/liveSync.mjs.map +1 -1
- package/dist/esm/pull.mjs +150 -1
- package/dist/esm/pull.mjs.map +1 -1
- package/dist/esm/push/pullLog.mjs +102 -3
- package/dist/esm/push/pullLog.mjs.map +1 -1
- package/dist/esm/push/push.mjs +208 -1
- package/dist/esm/push/push.mjs.map +1 -1
- package/dist/esm/pushConfig.mjs +20 -1
- package/dist/esm/pushConfig.mjs.map +1 -1
- package/dist/esm/pushLog.mjs +83 -3
- package/dist/esm/pushLog.mjs.map +1 -1
- package/dist/esm/reviewDoc/reviewDoc.mjs +69 -1
- package/dist/esm/reviewDoc/reviewDoc.mjs.map +1 -1
- package/dist/esm/reviewDoc/reviewDocBlockAware.mjs +95 -1
- package/dist/esm/reviewDoc/reviewDocBlockAware.mjs.map +1 -1
- package/dist/esm/searchDoc.mjs +39 -1
- package/dist/esm/searchDoc.mjs.map +1 -1
- package/dist/esm/test/index.mjs +4 -1
- package/dist/esm/test/listMissingTranslations.mjs +63 -1
- package/dist/esm/test/listMissingTranslations.mjs.map +1 -1
- package/dist/esm/test/test.mjs +53 -1
- package/dist/esm/test/test.mjs.map +1 -1
- package/dist/esm/translateDoc/index.mjs +5 -1
- package/dist/esm/translateDoc/translateDoc.mjs +75 -1
- package/dist/esm/translateDoc/translateDoc.mjs.map +1 -1
- package/dist/esm/translateDoc/translateFile.mjs +103 -2
- package/dist/esm/translateDoc/translateFile.mjs.map +1 -1
- package/dist/esm/translateDoc/validation.mjs +46 -5
- package/dist/esm/translateDoc/validation.mjs.map +1 -1
- package/dist/esm/translation-alignment/alignBlocks.mjs +66 -1
- package/dist/esm/translation-alignment/alignBlocks.mjs.map +1 -1
- package/dist/esm/translation-alignment/computeSimilarity.mjs +22 -1
- package/dist/esm/translation-alignment/computeSimilarity.mjs.map +1 -1
- package/dist/esm/translation-alignment/fingerprintBlock.mjs +20 -1
- package/dist/esm/translation-alignment/fingerprintBlock.mjs.map +1 -1
- package/dist/esm/translation-alignment/index.mjs +11 -1
- package/dist/esm/translation-alignment/mapChangedLinesToBlocks.mjs +16 -1
- package/dist/esm/translation-alignment/mapChangedLinesToBlocks.mjs.map +1 -1
- package/dist/esm/translation-alignment/normalizeBlock.mjs +20 -1
- package/dist/esm/translation-alignment/normalizeBlock.mjs.map +1 -1
- package/dist/esm/translation-alignment/pipeline.mjs +35 -1
- package/dist/esm/translation-alignment/pipeline.mjs.map +1 -1
- package/dist/esm/translation-alignment/planActions.mjs +44 -1
- package/dist/esm/translation-alignment/planActions.mjs.map +1 -1
- package/dist/esm/translation-alignment/rebuildDocument.mjs +46 -2
- package/dist/esm/translation-alignment/rebuildDocument.mjs.map +1 -1
- package/dist/esm/translation-alignment/segmentDocument.mjs +64 -5
- package/dist/esm/translation-alignment/segmentDocument.mjs.map +1 -1
- package/dist/esm/utils/calculateChunks.mjs +87 -2
- package/dist/esm/utils/calculateChunks.mjs.map +1 -1
- package/dist/esm/utils/checkAccess.mjs +79 -1
- package/dist/esm/utils/checkAccess.mjs.map +1 -1
- package/dist/esm/utils/checkConfigConsistency.mjs +14 -1
- package/dist/esm/utils/checkConfigConsistency.mjs.map +1 -1
- package/dist/esm/utils/checkFileModifiedRange.mjs +80 -1
- package/dist/esm/utils/checkFileModifiedRange.mjs.map +1 -1
- package/dist/esm/utils/checkLastUpdateTime.mjs +17 -1
- package/dist/esm/utils/checkLastUpdateTime.mjs.map +1 -1
- package/dist/esm/utils/chunkInference.mjs +43 -1
- package/dist/esm/utils/chunkInference.mjs.map +1 -1
- package/dist/esm/utils/fixChunkStartEndChars.mjs +25 -3
- package/dist/esm/utils/fixChunkStartEndChars.mjs.map +1 -1
- package/dist/esm/utils/formatTimeDiff.mjs +18 -1
- package/dist/esm/utils/formatTimeDiff.mjs.map +1 -1
- package/dist/esm/utils/getIsFileUpdatedRecently.mjs +14 -1
- package/dist/esm/utils/getIsFileUpdatedRecently.mjs.map +1 -1
- package/dist/esm/utils/getOutputFilePath.mjs +104 -1
- package/dist/esm/utils/getOutputFilePath.mjs.map +1 -1
- package/dist/esm/utils/getParentPackageJSON.mjs +18 -1
- package/dist/esm/utils/getParentPackageJSON.mjs.map +1 -1
- package/dist/esm/utils/listSpecialChars.mjs +52 -2
- package/dist/esm/utils/listSpecialChars.mjs.map +1 -1
- package/dist/esm/utils/mapChunksBetweenFiles.mjs +100 -1
- package/dist/esm/utils/mapChunksBetweenFiles.mjs.map +1 -1
- package/dist/esm/utils/openBrowser.mjs +17 -1
- package/dist/esm/utils/openBrowser.mjs.map +1 -1
- package/dist/esm/utils/reorderParagraphs.mjs +90 -3
- package/dist/esm/utils/reorderParagraphs.mjs.map +1 -1
- package/dist/esm/utils/setupAI.mjs +63 -1
- package/dist/esm/utils/setupAI.mjs.map +1 -1
- package/dist/esm/watch.mjs +45 -1
- package/dist/esm/watch.mjs.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/formatFillData.d.ts.map +1 -1
- package/dist/types/fill/translateDictionary.d.ts +1 -1
- package/dist/types/getTargetDictionary.d.ts +19 -2
- package/dist/types/getTargetDictionary.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/reviewDoc/reviewDocBlockAware.d.ts +1 -1
- package/dist/types/test/index.d.ts +2 -2
- package/dist/types/test/listMissingTranslations.d.ts +28 -2
- package/dist/types/test/listMissingTranslations.d.ts.map +1 -0
- package/dist/types/test/test.d.ts +11 -2
- package/dist/types/test/test.d.ts.map +1 -0
- package/dist/types/translateDoc/index.d.ts +1 -1
- package/dist/types/translateDoc/translateDoc.d.ts +1 -1
- package/dist/types/translateDoc/translateFile.d.ts +1 -1
- package/dist/types/translateDoc/types.d.ts +48 -2
- package/dist/types/translateDoc/types.d.ts.map +1 -0
- package/dist/types/utils/chunkInference.d.ts +1 -1
- package/dist/types/utils/getOutputFilePath.d.ts +18 -1
- package/dist/types/utils/getOutputFilePath.d.ts.map +1 -1
- package/dist/types/utils/setupAI.d.ts +21 -2
- package/dist/types/utils/setupAI.d.ts.map +1 -0
- package/package.json +12 -12
- package/dist/cjs/_utils_asset-ghp_Cjwk.cjs +0 -2
- package/dist/cjs/chunk-Bmb41Sf3.cjs +0 -1
- package/dist/esm/_utils_asset-B187VPMw.mjs +0 -2
- package/dist/esm/editor-D8BGlLzF.mjs +0 -2
- package/dist/esm/editor-D8BGlLzF.mjs.map +0 -1
- package/dist/types/getTargetDictionary-RBSRtaQj.d.ts +0 -19
- package/dist/types/getTargetDictionary-RBSRtaQj.d.ts.map +0 -1
- package/dist/types/listMissingTranslations-DxKw7nqI.d.ts +0 -28
- package/dist/types/listMissingTranslations-DxKw7nqI.d.ts.map +0 -1
- package/dist/types/setupAI-Bosjx7ah.d.ts +0 -21
- package/dist/types/setupAI-Bosjx7ah.d.ts.map +0 -1
- package/dist/types/test-DUTiJR5_.d.ts +0 -11
- package/dist/types/test-DUTiJR5_.d.ts.map +0 -1
- package/dist/types/types-BKvc3FmV.d.ts +0 -48
- package/dist/types/types-BKvc3FmV.d.ts.map +0 -1
package/dist/cjs/init.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.cjs","names":[],"sources":["../../src/init.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { initIntlayer } from '@intlayer/chokidar/cli';\n\nexport const findProjectRoot = (startDir: string) => {\n let currentDir = startDir;\n\n while (currentDir !== resolve(currentDir, '..')) {\n if (existsSync(join(currentDir, 'package.json'))) {\n return currentDir;\n }\n currentDir = resolve(currentDir, '..');\n }\n\n // If no package.json is found, return the start directory.\n // The initIntlayer function will handle the missing package.json error.\n return startDir;\n};\n\nexport const init = async (projectRoot?: string) => {\n const root = projectRoot\n ? findProjectRoot(resolve(projectRoot))\n : findProjectRoot(process.cwd());\n\n await initIntlayer(root);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.cjs","names":[],"sources":["../../src/init.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { initIntlayer } from '@intlayer/chokidar/cli';\n\nexport const findProjectRoot = (startDir: string) => {\n let currentDir = startDir;\n\n while (currentDir !== resolve(currentDir, '..')) {\n if (existsSync(join(currentDir, 'package.json'))) {\n return currentDir;\n }\n currentDir = resolve(currentDir, '..');\n }\n\n // If no package.json is found, return the start directory.\n // The initIntlayer function will handle the missing package.json error.\n return startDir;\n};\n\nexport const init = async (projectRoot?: string) => {\n const root = projectRoot\n ? findProjectRoot(resolve(projectRoot))\n : findProjectRoot(process.cwd());\n\n await initIntlayer(root);\n};\n"],"mappings":";;;;;;;AAIA,MAAa,mBAAmB,aAAqB;CACnD,IAAI,aAAa;AAEjB,QAAO,sCAAuB,YAAY,KAAK,EAAE;AAC/C,kDAAoB,YAAY,eAAe,CAAC,CAC9C,QAAO;AAET,sCAAqB,YAAY,KAAK;;AAKxC,QAAO;;AAGT,MAAa,OAAO,OAAO,gBAAyB;AAKlD,gDAJa,cACT,uCAAwB,YAAY,CAAC,GACrC,gBAAgB,QAAQ,KAAK,CAAC,CAEV"}
|
package/dist/cjs/initMCP.cjs
CHANGED
|
@@ -1,2 +1,70 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_init = require('./init.cjs');
|
|
4
|
+
const require_initSkills = require('./initSkills.cjs');
|
|
5
|
+
let node_path = require("node:path");
|
|
6
|
+
let _intlayer_chokidar_cli = require("@intlayer/chokidar/cli");
|
|
7
|
+
let enquirer = require("enquirer");
|
|
8
|
+
enquirer = require_runtime.__toESM(enquirer);
|
|
9
|
+
let _clack_prompts = require("@clack/prompts");
|
|
10
|
+
_clack_prompts = require_runtime.__toESM(_clack_prompts);
|
|
11
|
+
|
|
12
|
+
//#region src/initMCP.ts
|
|
13
|
+
const initMCP = async (projectRoot) => {
|
|
14
|
+
const root = require_init.findProjectRoot(projectRoot ? (0, node_path.resolve)(projectRoot) : process.cwd());
|
|
15
|
+
_clack_prompts.intro("Initializing Intlayer MCP Server");
|
|
16
|
+
const detectedPlatform = require_initSkills.getDetectedPlatform();
|
|
17
|
+
let platform;
|
|
18
|
+
try {
|
|
19
|
+
platform = (await enquirer.default.prompt({
|
|
20
|
+
type: "autocomplete",
|
|
21
|
+
name: "platforms",
|
|
22
|
+
message: "Which platform are you using? (Type to search)",
|
|
23
|
+
multiple: false,
|
|
24
|
+
initial: detectedPlatform ? _intlayer_chokidar_cli.PLATFORMS.indexOf(detectedPlatform) : void 0,
|
|
25
|
+
choices: require_initSkills.PLATFORM_OPTIONS.map((opt) => ({
|
|
26
|
+
name: opt.value,
|
|
27
|
+
message: opt.label,
|
|
28
|
+
hint: opt.hint
|
|
29
|
+
}))
|
|
30
|
+
})).platforms;
|
|
31
|
+
} catch {
|
|
32
|
+
_clack_prompts.cancel("Operation cancelled.");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (!platform) {
|
|
36
|
+
_clack_prompts.cancel("Operation cancelled. No platform selected.");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const transport = await _clack_prompts.select({
|
|
40
|
+
message: "Which transport method do you want to use?",
|
|
41
|
+
options: [{
|
|
42
|
+
value: "stdio",
|
|
43
|
+
label: "Local server (stdio)",
|
|
44
|
+
hint: "Recommended. Integrates all features including CLI tools."
|
|
45
|
+
}, {
|
|
46
|
+
value: "sse",
|
|
47
|
+
label: "Remote server (SSE)",
|
|
48
|
+
hint: "Hosted by Intlayer. Documentation only."
|
|
49
|
+
}]
|
|
50
|
+
});
|
|
51
|
+
if (_clack_prompts.isCancel(transport) || !transport) {
|
|
52
|
+
_clack_prompts.cancel("Operation cancelled.");
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const s = _clack_prompts.spinner();
|
|
56
|
+
s.start("Configuring MCP Server...");
|
|
57
|
+
try {
|
|
58
|
+
const result = await (0, _intlayer_chokidar_cli.installMCP)(root, platform, transport);
|
|
59
|
+
s.stop("MCP Server configured successfully");
|
|
60
|
+
_clack_prompts.note(result, "Success");
|
|
61
|
+
} catch (error) {
|
|
62
|
+
s.stop("Failed to configure MCP Server");
|
|
63
|
+
_clack_prompts.log.error(error instanceof Error ? error.message : String(error));
|
|
64
|
+
}
|
|
65
|
+
_clack_prompts.outro("Intlayer MCP Server initialization complete");
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
exports.initMCP = initMCP;
|
|
2
70
|
//# sourceMappingURL=initMCP.cjs.map
|
package/dist/cjs/initMCP.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initMCP.cjs","names":["findProjectRoot","getDetectedPlatform","PLATFORMS","PLATFORM_OPTIONS","p"],"sources":["../../src/initMCP.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport * as p from '@clack/prompts';\nimport {\n installMCP,\n type MCPTransport,\n PLATFORMS,\n} from '@intlayer/chokidar/cli';\nimport enquirer from 'enquirer';\nimport { findProjectRoot } from './init';\nimport { getDetectedPlatform, PLATFORM_OPTIONS } from './initSkills';\n\nexport const initMCP = async (projectRoot?: string) => {\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n\n p.intro('Initializing Intlayer MCP Server');\n\n const detectedPlatform = getDetectedPlatform();\n\n let platform: any;\n try {\n const response = await enquirer.prompt<{ platforms: any }>({\n type: 'autocomplete',\n name: 'platforms',\n message: 'Which platform are you using? (Type to search)',\n multiple: false,\n initial: detectedPlatform\n ? PLATFORMS.indexOf(detectedPlatform)\n : undefined,\n choices: PLATFORM_OPTIONS.map((opt) => ({\n name: opt.value,\n message: opt.label,\n hint: opt.hint,\n })),\n });\n platform = response.platforms;\n } catch {\n p.cancel('Operation cancelled.');\n return;\n }\n\n if (!platform) {\n p.cancel('Operation cancelled. No platform selected.');\n return;\n }\n\n const transport = (await p.select({\n message: 'Which transport method do you want to use?',\n options: [\n {\n value: 'stdio',\n label: 'Local server (stdio)',\n hint: 'Recommended. Integrates all features including CLI tools.',\n },\n {\n value: 'sse',\n label: 'Remote server (SSE)',\n hint: 'Hosted by Intlayer. Documentation only.',\n },\n ],\n })) as MCPTransport;\n\n if (p.isCancel(transport) || !transport) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const s = p.spinner();\n s.start('Configuring MCP Server...');\n\n try {\n const result = await installMCP(root, platform, transport);\n\n s.stop('MCP Server configured successfully');\n\n p.note(result, 'Success');\n } catch (error) {\n s.stop('Failed to configure MCP Server');\n p.log.error(error instanceof Error ? error.message : String(error));\n }\n\n p.outro('Intlayer MCP Server initialization complete');\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"initMCP.cjs","names":["findProjectRoot","getDetectedPlatform","PLATFORMS","PLATFORM_OPTIONS","p"],"sources":["../../src/initMCP.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport * as p from '@clack/prompts';\nimport {\n installMCP,\n type MCPTransport,\n PLATFORMS,\n} from '@intlayer/chokidar/cli';\nimport enquirer from 'enquirer';\nimport { findProjectRoot } from './init';\nimport { getDetectedPlatform, PLATFORM_OPTIONS } from './initSkills';\n\nexport const initMCP = async (projectRoot?: string) => {\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n\n p.intro('Initializing Intlayer MCP Server');\n\n const detectedPlatform = getDetectedPlatform();\n\n let platform: any;\n try {\n const response = await enquirer.prompt<{ platforms: any }>({\n type: 'autocomplete',\n name: 'platforms',\n message: 'Which platform are you using? (Type to search)',\n multiple: false,\n initial: detectedPlatform\n ? PLATFORMS.indexOf(detectedPlatform)\n : undefined,\n choices: PLATFORM_OPTIONS.map((opt) => ({\n name: opt.value,\n message: opt.label,\n hint: opt.hint,\n })),\n });\n platform = response.platforms;\n } catch {\n p.cancel('Operation cancelled.');\n return;\n }\n\n if (!platform) {\n p.cancel('Operation cancelled. No platform selected.');\n return;\n }\n\n const transport = (await p.select({\n message: 'Which transport method do you want to use?',\n options: [\n {\n value: 'stdio',\n label: 'Local server (stdio)',\n hint: 'Recommended. Integrates all features including CLI tools.',\n },\n {\n value: 'sse',\n label: 'Remote server (SSE)',\n hint: 'Hosted by Intlayer. Documentation only.',\n },\n ],\n })) as MCPTransport;\n\n if (p.isCancel(transport) || !transport) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const s = p.spinner();\n s.start('Configuring MCP Server...');\n\n try {\n const result = await installMCP(root, platform, transport);\n\n s.stop('MCP Server configured successfully');\n\n p.note(result, 'Success');\n } catch (error) {\n s.stop('Failed to configure MCP Server');\n p.log.error(error instanceof Error ? error.message : String(error));\n }\n\n p.outro('Intlayer MCP Server initialization complete');\n};\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,UAAU,OAAO,gBAAyB;CACrD,MAAM,OAAOA,6BACX,qCAAsB,YAAY,GAAG,QAAQ,KAAK,CACnD;AAED,gBAAE,MAAM,mCAAmC;CAE3C,MAAM,mBAAmBC,wCAAqB;CAE9C,IAAI;AACJ,KAAI;AAeF,cAdiB,MAAM,iBAAS,OAA2B;GACzD,MAAM;GACN,MAAM;GACN,SAAS;GACT,UAAU;GACV,SAAS,mBACLC,iCAAU,QAAQ,iBAAiB,GACnC;GACJ,SAASC,oCAAiB,KAAK,SAAS;IACtC,MAAM,IAAI;IACV,SAAS,IAAI;IACb,MAAM,IAAI;IACX,EAAE;GACJ,CAAC,EACkB;SACd;AACN,iBAAE,OAAO,uBAAuB;AAChC;;AAGF,KAAI,CAAC,UAAU;AACb,iBAAE,OAAO,6CAA6C;AACtD;;CAGF,MAAM,YAAa,MAAMC,eAAE,OAAO;EAChC,SAAS;EACT,SAAS,CACP;GACE,OAAO;GACP,OAAO;GACP,MAAM;GACP,EACD;GACE,OAAO;GACP,OAAO;GACP,MAAM;GACP,CACF;EACF,CAAC;AAEF,KAAIA,eAAE,SAAS,UAAU,IAAI,CAAC,WAAW;AACvC,iBAAE,OAAO,uBAAuB;AAChC;;CAGF,MAAM,IAAIA,eAAE,SAAS;AACrB,GAAE,MAAM,4BAA4B;AAEpC,KAAI;EACF,MAAM,SAAS,6CAAiB,MAAM,UAAU,UAAU;AAE1D,IAAE,KAAK,qCAAqC;AAE5C,iBAAE,KAAK,QAAQ,UAAU;UAClB,OAAO;AACd,IAAE,KAAK,iCAAiC;AACxC,iBAAE,IAAI,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,CAAC;;AAGrE,gBAAE,MAAM,8CAA8C"}
|
package/dist/cjs/initSkills.cjs
CHANGED
|
@@ -1,2 +1,94 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_init = require('./init.cjs');
|
|
4
|
+
let node_fs = require("node:fs");
|
|
5
|
+
let node_path = require("node:path");
|
|
6
|
+
let _intlayer_chokidar_cli = require("@intlayer/chokidar/cli");
|
|
7
|
+
let enquirer = require("enquirer");
|
|
8
|
+
enquirer = require_runtime.__toESM(enquirer);
|
|
9
|
+
let _clack_prompts = require("@clack/prompts");
|
|
10
|
+
_clack_prompts = require_runtime.__toESM(_clack_prompts);
|
|
11
|
+
|
|
12
|
+
//#region src/initSkills.ts
|
|
13
|
+
const PLATFORM_CHECKS = _intlayer_chokidar_cli.PLATFORMS.filter((platform) => _intlayer_chokidar_cli.PLATFORMS_METADATA[platform].check).map((platform) => ({
|
|
14
|
+
check: _intlayer_chokidar_cli.PLATFORMS_METADATA[platform].check ?? (() => false),
|
|
15
|
+
platform
|
|
16
|
+
}));
|
|
17
|
+
const PLATFORM_OPTIONS = _intlayer_chokidar_cli.PLATFORMS.map((platform) => ({
|
|
18
|
+
value: platform,
|
|
19
|
+
label: _intlayer_chokidar_cli.PLATFORMS_METADATA[platform].label,
|
|
20
|
+
hint: `(${_intlayer_chokidar_cli.PLATFORMS_METADATA[platform].dir})`
|
|
21
|
+
}));
|
|
22
|
+
const getDetectedPlatform = () => PLATFORM_CHECKS.find(({ check }) => check())?.platform;
|
|
23
|
+
const getDependencies = (root) => {
|
|
24
|
+
try {
|
|
25
|
+
const packageJsonPath = (0, node_path.join)(root, "package.json");
|
|
26
|
+
if (!(0, node_fs.existsSync)(packageJsonPath)) return {};
|
|
27
|
+
const { dependencies = {}, devDependencies = {} } = JSON.parse((0, node_fs.readFileSync)(packageJsonPath, "utf-8"));
|
|
28
|
+
return {
|
|
29
|
+
...dependencies,
|
|
30
|
+
...devDependencies
|
|
31
|
+
};
|
|
32
|
+
} catch {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const initSkills = async (projectRoot) => {
|
|
37
|
+
const root = require_init.findProjectRoot(projectRoot ? (0, node_path.resolve)(projectRoot) : process.cwd());
|
|
38
|
+
_clack_prompts.intro("Initializing Intlayer skills");
|
|
39
|
+
const detectedPlatform = getDetectedPlatform();
|
|
40
|
+
let platform;
|
|
41
|
+
try {
|
|
42
|
+
platform = (await enquirer.default.prompt({
|
|
43
|
+
type: "autocomplete",
|
|
44
|
+
name: "platforms",
|
|
45
|
+
message: "Which platforms are you using? (Type to search)",
|
|
46
|
+
multiple: false,
|
|
47
|
+
initial: detectedPlatform ? _intlayer_chokidar_cli.PLATFORMS.indexOf(detectedPlatform) : void 0,
|
|
48
|
+
choices: PLATFORM_OPTIONS.map((opt) => ({
|
|
49
|
+
name: opt.value,
|
|
50
|
+
message: opt.label,
|
|
51
|
+
hint: opt.hint
|
|
52
|
+
}))
|
|
53
|
+
})).platforms;
|
|
54
|
+
} catch {
|
|
55
|
+
_clack_prompts.cancel("Operation cancelled.");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (!platform) {
|
|
59
|
+
_clack_prompts.log.warn("No platform selected. Nothing to install.");
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const initialValues = (0, _intlayer_chokidar_cli.getInitialSkills)(getDependencies(root));
|
|
63
|
+
const selectedSkills = await _clack_prompts.multiselect({
|
|
64
|
+
message: "Select the documentation skills to provide to your AI:",
|
|
65
|
+
initialValues,
|
|
66
|
+
options: _intlayer_chokidar_cli.SKILLS.map((skill) => ({
|
|
67
|
+
value: skill,
|
|
68
|
+
label: skill,
|
|
69
|
+
hint: _intlayer_chokidar_cli.SKILLS_METADATA[skill]
|
|
70
|
+
})),
|
|
71
|
+
required: false
|
|
72
|
+
});
|
|
73
|
+
if (_clack_prompts.isCancel(selectedSkills) || !selectedSkills || selectedSkills.length === 0) {
|
|
74
|
+
_clack_prompts.cancel("Operation cancelled. No skills selected.");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const s = _clack_prompts.spinner();
|
|
78
|
+
s.start("Installing skills...");
|
|
79
|
+
try {
|
|
80
|
+
const result = await (0, _intlayer_chokidar_cli.installSkills)(root, platform, selectedSkills);
|
|
81
|
+
s.stop("Skills installed successfully");
|
|
82
|
+
_clack_prompts.note(result, "Success");
|
|
83
|
+
} catch (error) {
|
|
84
|
+
s.stop("Failed to install skills");
|
|
85
|
+
_clack_prompts.log.error(error instanceof Error ? error.message : String(error));
|
|
86
|
+
}
|
|
87
|
+
_clack_prompts.outro("Intlayer skills initialization complete");
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
exports.PLATFORM_OPTIONS = PLATFORM_OPTIONS;
|
|
92
|
+
exports.getDetectedPlatform = getDetectedPlatform;
|
|
93
|
+
exports.initSkills = initSkills;
|
|
2
94
|
//# sourceMappingURL=initSkills.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initSkills.cjs","names":["PLATFORMS","PLATFORMS_METADATA","findProjectRoot","p","SKILLS","SKILLS_METADATA"],"sources":["../../src/initSkills.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport * as p from '@clack/prompts';\nimport {\n getInitialSkills,\n installSkills,\n PLATFORMS,\n PLATFORMS_METADATA,\n type Platform,\n SKILLS,\n SKILLS_METADATA,\n} from '@intlayer/chokidar/cli';\nimport enquirer from 'enquirer';\nimport { findProjectRoot } from './init';\n\nconst PLATFORM_CHECKS: Array<{ check: () => boolean; platform: Platform }> =\n PLATFORMS.filter((platform) => PLATFORMS_METADATA[platform].check).map(\n (platform) => ({\n check: PLATFORMS_METADATA[platform].check ?? (() => false),\n platform,\n })\n );\n\nexport const PLATFORM_OPTIONS: Array<{\n value: Platform;\n label: string;\n hint: string;\n}> = PLATFORMS.map((platform) => ({\n value: platform,\n label: PLATFORMS_METADATA[platform].label,\n hint: `(${PLATFORMS_METADATA[platform].dir})`,\n}));\n\nexport const getDetectedPlatform = (): Platform | undefined =>\n PLATFORM_CHECKS.find(({ check }) => check())?.platform;\n\nconst getDependencies = (root: string): Record<string, string> => {\n try {\n const packageJsonPath = join(root, 'package.json');\n if (!existsSync(packageJsonPath)) return {};\n\n const { dependencies = {}, devDependencies = {} } = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8')\n );\n return { ...dependencies, ...devDependencies };\n } catch {\n return {};\n }\n};\n\nexport const initSkills = async (projectRoot?: string) => {\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n\n p.intro('Initializing Intlayer skills');\n\n const detectedPlatform = getDetectedPlatform();\n\n let platform: Platform;\n try {\n const response = await enquirer.prompt<{ platforms: Platform }>({\n type: 'autocomplete',\n name: 'platforms',\n message: 'Which platforms are you using? (Type to search)',\n multiple: false,\n initial: detectedPlatform\n ? PLATFORMS.indexOf(detectedPlatform)\n : undefined,\n choices: PLATFORM_OPTIONS.map((opt) => ({\n name: opt.value,\n message: opt.label,\n hint: opt.hint,\n })),\n });\n platform = response.platforms;\n } catch {\n p.cancel('Operation cancelled.');\n return;\n }\n\n if (!platform) {\n p.log.warn('No platform selected. Nothing to install.');\n return;\n }\n\n const dependencies = getDependencies(root);\n const initialValues = getInitialSkills(dependencies);\n\n const selectedSkills = await p.multiselect({\n message: 'Select the documentation skills to provide to your AI:',\n initialValues,\n options: SKILLS.map((skill) => ({\n value: skill,\n label: skill,\n hint: SKILLS_METADATA[skill],\n })),\n required: false,\n });\n\n if (\n p.isCancel(selectedSkills) ||\n !selectedSkills ||\n (selectedSkills as string[]).length === 0\n ) {\n p.cancel('Operation cancelled. No skills selected.');\n return;\n }\n\n const s = p.spinner();\n s.start('Installing skills...');\n\n try {\n const result = await installSkills(root, platform, selectedSkills);\n\n s.stop('Skills installed successfully');\n\n p.note(result, 'Success');\n } catch (error) {\n s.stop('Failed to install skills');\n p.log.error(error instanceof Error ? error.message : String(error));\n }\n\n p.outro('Intlayer skills initialization complete');\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"initSkills.cjs","names":["PLATFORMS","PLATFORMS_METADATA","findProjectRoot","p","SKILLS","SKILLS_METADATA"],"sources":["../../src/initSkills.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport * as p from '@clack/prompts';\nimport {\n getInitialSkills,\n installSkills,\n PLATFORMS,\n PLATFORMS_METADATA,\n type Platform,\n SKILLS,\n SKILLS_METADATA,\n} from '@intlayer/chokidar/cli';\nimport enquirer from 'enquirer';\nimport { findProjectRoot } from './init';\n\nconst PLATFORM_CHECKS: Array<{ check: () => boolean; platform: Platform }> =\n PLATFORMS.filter((platform) => PLATFORMS_METADATA[platform].check).map(\n (platform) => ({\n check: PLATFORMS_METADATA[platform].check ?? (() => false),\n platform,\n })\n );\n\nexport const PLATFORM_OPTIONS: Array<{\n value: Platform;\n label: string;\n hint: string;\n}> = PLATFORMS.map((platform) => ({\n value: platform,\n label: PLATFORMS_METADATA[platform].label,\n hint: `(${PLATFORMS_METADATA[platform].dir})`,\n}));\n\nexport const getDetectedPlatform = (): Platform | undefined =>\n PLATFORM_CHECKS.find(({ check }) => check())?.platform;\n\nconst getDependencies = (root: string): Record<string, string> => {\n try {\n const packageJsonPath = join(root, 'package.json');\n if (!existsSync(packageJsonPath)) return {};\n\n const { dependencies = {}, devDependencies = {} } = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8')\n );\n return { ...dependencies, ...devDependencies };\n } catch {\n return {};\n }\n};\n\nexport const initSkills = async (projectRoot?: string) => {\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n\n p.intro('Initializing Intlayer skills');\n\n const detectedPlatform = getDetectedPlatform();\n\n let platform: Platform;\n try {\n const response = await enquirer.prompt<{ platforms: Platform }>({\n type: 'autocomplete',\n name: 'platforms',\n message: 'Which platforms are you using? (Type to search)',\n multiple: false,\n initial: detectedPlatform\n ? PLATFORMS.indexOf(detectedPlatform)\n : undefined,\n choices: PLATFORM_OPTIONS.map((opt) => ({\n name: opt.value,\n message: opt.label,\n hint: opt.hint,\n })),\n });\n platform = response.platforms;\n } catch {\n p.cancel('Operation cancelled.');\n return;\n }\n\n if (!platform) {\n p.log.warn('No platform selected. Nothing to install.');\n return;\n }\n\n const dependencies = getDependencies(root);\n const initialValues = getInitialSkills(dependencies);\n\n const selectedSkills = await p.multiselect({\n message: 'Select the documentation skills to provide to your AI:',\n initialValues,\n options: SKILLS.map((skill) => ({\n value: skill,\n label: skill,\n hint: SKILLS_METADATA[skill],\n })),\n required: false,\n });\n\n if (\n p.isCancel(selectedSkills) ||\n !selectedSkills ||\n (selectedSkills as string[]).length === 0\n ) {\n p.cancel('Operation cancelled. No skills selected.');\n return;\n }\n\n const s = p.spinner();\n s.start('Installing skills...');\n\n try {\n const result = await installSkills(root, platform, selectedSkills);\n\n s.stop('Skills installed successfully');\n\n p.note(result, 'Success');\n } catch (error) {\n s.stop('Failed to install skills');\n p.log.error(error instanceof Error ? error.message : String(error));\n }\n\n p.outro('Intlayer skills initialization complete');\n};\n"],"mappings":";;;;;;;;;;;;AAeA,MAAM,kBACJA,iCAAU,QAAQ,aAAaC,0CAAmB,UAAU,MAAM,CAAC,KAChE,cAAc;CACb,OAAOA,0CAAmB,UAAU,gBAAgB;CACpD;CACD,EACF;AAEH,MAAa,mBAIRD,iCAAU,KAAK,cAAc;CAChC,OAAO;CACP,OAAOC,0CAAmB,UAAU;CACpC,MAAM,IAAIA,0CAAmB,UAAU,IAAI;CAC5C,EAAE;AAEH,MAAa,4BACX,gBAAgB,MAAM,EAAE,YAAY,OAAO,CAAC,EAAE;AAEhD,MAAM,mBAAmB,SAAyC;AAChE,KAAI;EACF,MAAM,sCAAuB,MAAM,eAAe;AAClD,MAAI,yBAAY,gBAAgB,CAAE,QAAO,EAAE;EAE3C,MAAM,EAAE,eAAe,EAAE,EAAE,kBAAkB,EAAE,KAAK,KAAK,gCAC1C,iBAAiB,QAAQ,CACvC;AACD,SAAO;GAAE,GAAG;GAAc,GAAG;GAAiB;SACxC;AACN,SAAO,EAAE;;;AAIb,MAAa,aAAa,OAAO,gBAAyB;CACxD,MAAM,OAAOC,6BACX,qCAAsB,YAAY,GAAG,QAAQ,KAAK,CACnD;AAED,gBAAE,MAAM,+BAA+B;CAEvC,MAAM,mBAAmB,qBAAqB;CAE9C,IAAI;AACJ,KAAI;AAeF,cAdiB,MAAM,iBAAS,OAAgC;GAC9D,MAAM;GACN,MAAM;GACN,SAAS;GACT,UAAU;GACV,SAAS,mBACLF,iCAAU,QAAQ,iBAAiB,GACnC;GACJ,SAAS,iBAAiB,KAAK,SAAS;IACtC,MAAM,IAAI;IACV,SAAS,IAAI;IACb,MAAM,IAAI;IACX,EAAE;GACJ,CAAC,EACkB;SACd;AACN,iBAAE,OAAO,uBAAuB;AAChC;;AAGF,KAAI,CAAC,UAAU;AACb,iBAAE,IAAI,KAAK,4CAA4C;AACvD;;CAIF,MAAM,6DADe,gBAAgB,KAAK,CACU;CAEpD,MAAM,iBAAiB,MAAMG,eAAE,YAAY;EACzC,SAAS;EACT;EACA,SAASC,8BAAO,KAAK,WAAW;GAC9B,OAAO;GACP,OAAO;GACP,MAAMC,uCAAgB;GACvB,EAAE;EACH,UAAU;EACX,CAAC;AAEF,KACEF,eAAE,SAAS,eAAe,IAC1B,CAAC,kBACA,eAA4B,WAAW,GACxC;AACA,iBAAE,OAAO,2CAA2C;AACpD;;CAGF,MAAM,IAAIA,eAAE,SAAS;AACrB,GAAE,MAAM,uBAAuB;AAE/B,KAAI;EACF,MAAM,SAAS,gDAAoB,MAAM,UAAU,eAAe;AAElE,IAAE,KAAK,gCAAgC;AAEvC,iBAAE,KAAK,QAAQ,UAAU;UAClB,OAAO;AACd,IAAE,KAAK,2BAA2B;AAClC,iBAAE,IAAI,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,CAAC;;AAGrE,gBAAE,MAAM,0CAA0C"}
|
|
@@ -1,2 +1,43 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let node_path = require("node:path");
|
|
4
|
+
let _intlayer_chokidar_utils = require("@intlayer/chokidar/utils");
|
|
5
|
+
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
6
|
+
let _intlayer_config_node = require("@intlayer/config/node");
|
|
7
|
+
let _intlayer_unmerged_dictionaries_entry = require("@intlayer/unmerged-dictionaries-entry");
|
|
8
|
+
|
|
9
|
+
//#region src/listContentDeclaration.ts
|
|
10
|
+
const listContentDeclarationRows = (options) => {
|
|
11
|
+
const config = (0, _intlayer_config_node.getConfiguration)(options?.configOptions);
|
|
12
|
+
const unmergedDictionariesRecord = (0, _intlayer_unmerged_dictionaries_entry.getUnmergedDictionaries)(config);
|
|
13
|
+
return Object.values(unmergedDictionariesRecord).flat().map((dictionary) => ({
|
|
14
|
+
key: dictionary.key ?? "",
|
|
15
|
+
path: options?.absolute ? dictionary.filePath ?? "Remote" : (0, node_path.relative)(config.system.baseDir, dictionary.filePath ?? "Remote")
|
|
16
|
+
}));
|
|
17
|
+
};
|
|
18
|
+
const listContentDeclaration = (options) => {
|
|
19
|
+
const rows = listContentDeclarationRows(options);
|
|
20
|
+
if (options?.json) {
|
|
21
|
+
console.log(JSON.stringify(rows));
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const appLogger = (0, _intlayer_config_logger.getAppLogger)((0, _intlayer_config_node.getConfiguration)(options?.configOptions));
|
|
25
|
+
const lines = rows.map((row) => [
|
|
26
|
+
(0, _intlayer_config_logger.colon)(` - ${(0, _intlayer_config_logger.colorizeKey)(row.key)}`, {
|
|
27
|
+
colSize: rows.map((row) => row.key.length),
|
|
28
|
+
maxSize: 60
|
|
29
|
+
}),
|
|
30
|
+
" - ",
|
|
31
|
+
(0, _intlayer_chokidar_utils.formatPath)(row.path)
|
|
32
|
+
].join(""));
|
|
33
|
+
appLogger(`Content declaration files:`);
|
|
34
|
+
lines.forEach((line) => {
|
|
35
|
+
appLogger(line, { level: "info" });
|
|
36
|
+
});
|
|
37
|
+
appLogger(`Total content declaration files: ${(0, _intlayer_config_logger.colorizeNumber)(rows.length)}`);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
exports.listContentDeclaration = listContentDeclaration;
|
|
42
|
+
exports.listContentDeclarationRows = listContentDeclarationRows;
|
|
2
43
|
//# sourceMappingURL=listContentDeclaration.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listContentDeclaration.cjs","names":[],"sources":["../../src/listContentDeclaration.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport { formatPath } from '@intlayer/chokidar/utils';\nimport {\n colon,\n colorizeKey,\n colorizeNumber,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\n\ntype ListContentDeclarationOptions = {\n configOptions?: GetConfigurationOptions;\n json?: boolean;\n absolute?: boolean;\n};\n\nexport const listContentDeclarationRows = (\n options?: ListContentDeclarationOptions\n) => {\n const config = getConfiguration(options?.configOptions);\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(config);\n\n const rows = Object.values(unmergedDictionariesRecord)\n .flat()\n .map((dictionary) => ({\n key: dictionary.key ?? '',\n path: options?.absolute\n ? (dictionary.filePath ?? 'Remote')\n : relative(config.system.baseDir, dictionary.filePath ?? 'Remote'),\n }));\n return rows;\n};\n\nexport const listContentDeclaration = (\n options?: ListContentDeclarationOptions\n) => {\n const rows = listContentDeclarationRows(options);\n\n if (options?.json) {\n console.log(JSON.stringify(rows));\n return;\n }\n\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config);\n\n const lines = rows.map((row) =>\n [\n colon(` - ${colorizeKey(row.key)}`, {\n colSize: rows.map((row) => row.key.length),\n maxSize: 60,\n }),\n ' - ',\n formatPath(row.path),\n ].join('')\n );\n\n appLogger(`Content declaration files:`);\n\n lines.forEach((line) => {\n appLogger(line, {\n level: 'info',\n });\n });\n\n appLogger(`Total content declaration files: ${colorizeNumber(rows.length)}`);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"listContentDeclaration.cjs","names":[],"sources":["../../src/listContentDeclaration.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport { formatPath } from '@intlayer/chokidar/utils';\nimport {\n colon,\n colorizeKey,\n colorizeNumber,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\n\ntype ListContentDeclarationOptions = {\n configOptions?: GetConfigurationOptions;\n json?: boolean;\n absolute?: boolean;\n};\n\nexport const listContentDeclarationRows = (\n options?: ListContentDeclarationOptions\n) => {\n const config = getConfiguration(options?.configOptions);\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(config);\n\n const rows = Object.values(unmergedDictionariesRecord)\n .flat()\n .map((dictionary) => ({\n key: dictionary.key ?? '',\n path: options?.absolute\n ? (dictionary.filePath ?? 'Remote')\n : relative(config.system.baseDir, dictionary.filePath ?? 'Remote'),\n }));\n return rows;\n};\n\nexport const listContentDeclaration = (\n options?: ListContentDeclarationOptions\n) => {\n const rows = listContentDeclarationRows(options);\n\n if (options?.json) {\n console.log(JSON.stringify(rows));\n return;\n }\n\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config);\n\n const lines = rows.map((row) =>\n [\n colon(` - ${colorizeKey(row.key)}`, {\n colSize: rows.map((row) => row.key.length),\n maxSize: 60,\n }),\n ' - ',\n formatPath(row.path),\n ].join('')\n );\n\n appLogger(`Content declaration files:`);\n\n lines.forEach((line) => {\n appLogger(line, {\n level: 'info',\n });\n });\n\n appLogger(`Total content declaration files: ${colorizeNumber(rows.length)}`);\n};\n"],"mappings":";;;;;;;;;AAoBA,MAAa,8BACX,YACG;CACH,MAAM,qDAA0B,SAAS,cAAc;CAEvD,MAAM,gGAAqD,OAAO;AAUlE,QARa,OAAO,OAAO,2BAA2B,CACnD,MAAM,CACN,KAAK,gBAAgB;EACpB,KAAK,WAAW,OAAO;EACvB,MAAM,SAAS,WACV,WAAW,YAAY,mCACf,OAAO,OAAO,SAAS,WAAW,YAAY,SAAS;EACrE,EAAE;;AAIP,MAAa,0BACX,YACG;CACH,MAAM,OAAO,2BAA2B,QAAQ;AAEhD,KAAI,SAAS,MAAM;AACjB,UAAQ,IAAI,KAAK,UAAU,KAAK,CAAC;AACjC;;CAIF,MAAM,kGAD0B,SAAS,cAAc,CACjB;CAEtC,MAAM,QAAQ,KAAK,KAAK,QACtB;qCACQ,+CAAkB,IAAI,IAAI,IAAI;GAClC,SAAS,KAAK,KAAK,QAAQ,IAAI,IAAI,OAAO;GAC1C,SAAS;GACV,CAAC;EACF;2CACW,IAAI,KAAK;EACrB,CAAC,KAAK,GAAG,CACX;AAED,WAAU,6BAA6B;AAEvC,OAAM,SAAS,SAAS;AACtB,YAAU,MAAM,EACd,OAAO,QACR,CAAC;GACF;AAEF,WAAU,gFAAmD,KAAK,OAAO,GAAG"}
|
|
@@ -1,2 +1,29 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let node_path = require("node:path");
|
|
4
|
+
let _intlayer_chokidar_cli = require("@intlayer/chokidar/cli");
|
|
5
|
+
|
|
6
|
+
//#region src/listProjects.ts
|
|
7
|
+
const listProjectsCommand = async (options) => {
|
|
8
|
+
const { searchDir, projectsPath } = await (0, _intlayer_chokidar_cli.listProjects)(options);
|
|
9
|
+
const projectsRelativePath = projectsPath.map((projectPath) => options?.absolute ? projectPath : (0, node_path.relative)(searchDir, projectPath)).map((projectPath) => projectPath === "" ? "." : projectPath);
|
|
10
|
+
if (options?.json) {
|
|
11
|
+
console.dir(projectsRelativePath, {
|
|
12
|
+
depth: null,
|
|
13
|
+
arrayLimit: null
|
|
14
|
+
});
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (projectsPath.length === 0) {
|
|
18
|
+
console.log("No Intlayer projects found.");
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
console.log(`Found ${projectsPath.length} Intlayer project(s):\n`);
|
|
22
|
+
projectsPath.forEach((project) => {
|
|
23
|
+
console.log(` - ${project}`);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
exports.listProjectsCommand = listProjectsCommand;
|
|
2
29
|
//# sourceMappingURL=listProjects.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listProjects.cjs","names":[],"sources":["../../src/listProjects.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport { type ListProjectsOptions, listProjects } from '@intlayer/chokidar/cli';\n\nexport type ListProjectsCommandOptions = ListProjectsOptions & {\n json?: boolean;\n absolute?: boolean;\n};\n\nexport const listProjectsCommand = async (\n options?: ListProjectsCommandOptions\n) => {\n const { searchDir, projectsPath } = await listProjects(options);\n\n const projectsRelativePath = projectsPath\n .map((projectPath) =>\n options?.absolute ? projectPath : relative(searchDir, projectPath)\n )\n .map((projectPath) => (projectPath === '' ? '.' : projectPath));\n\n if (options?.json) {\n console.dir(projectsRelativePath, { depth: null, arrayLimit: null });\n return;\n }\n\n if (projectsPath.length === 0) {\n console.log('No Intlayer projects found.');\n return;\n }\n\n console.log(`Found ${projectsPath.length} Intlayer project(s):\\n`);\n projectsPath.forEach((project) => {\n console.log(` - ${project}`);\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"listProjects.cjs","names":[],"sources":["../../src/listProjects.ts"],"sourcesContent":["import { relative } from 'node:path';\nimport { type ListProjectsOptions, listProjects } from '@intlayer/chokidar/cli';\n\nexport type ListProjectsCommandOptions = ListProjectsOptions & {\n json?: boolean;\n absolute?: boolean;\n};\n\nexport const listProjectsCommand = async (\n options?: ListProjectsCommandOptions\n) => {\n const { searchDir, projectsPath } = await listProjects(options);\n\n const projectsRelativePath = projectsPath\n .map((projectPath) =>\n options?.absolute ? projectPath : relative(searchDir, projectPath)\n )\n .map((projectPath) => (projectPath === '' ? '.' : projectPath));\n\n if (options?.json) {\n console.dir(projectsRelativePath, { depth: null, arrayLimit: null });\n return;\n }\n\n if (projectsPath.length === 0) {\n console.log('No Intlayer projects found.');\n return;\n }\n\n console.log(`Found ${projectsPath.length} Intlayer project(s):\\n`);\n projectsPath.forEach((project) => {\n console.log(` - ${project}`);\n });\n};\n"],"mappings":";;;;;;AAQA,MAAa,sBAAsB,OACjC,YACG;CACH,MAAM,EAAE,WAAW,iBAAiB,+CAAmB,QAAQ;CAE/D,MAAM,uBAAuB,aAC1B,KAAK,gBACJ,SAAS,WAAW,sCAAuB,WAAW,YAAY,CACnE,CACA,KAAK,gBAAiB,gBAAgB,KAAK,MAAM,YAAa;AAEjE,KAAI,SAAS,MAAM;AACjB,UAAQ,IAAI,sBAAsB;GAAE,OAAO;GAAM,YAAY;GAAM,CAAC;AACpE;;AAGF,KAAI,aAAa,WAAW,GAAG;AAC7B,UAAQ,IAAI,8BAA8B;AAC1C;;AAGF,SAAQ,IAAI,SAAS,aAAa,OAAO,yBAAyB;AAClE,cAAa,SAAS,YAAY;AAChC,UAAQ,IAAI,OAAO,UAAU;GAC7B"}
|
package/dist/cjs/liveSync.cjs
CHANGED
|
@@ -1,10 +1,155 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_IntlayerEventListener = require('./IntlayerEventListener.cjs');
|
|
4
|
+
let _intlayer_chokidar_build = require("@intlayer/chokidar/build");
|
|
5
|
+
let _intlayer_chokidar_utils = require("@intlayer/chokidar/utils");
|
|
6
|
+
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
7
|
+
let _intlayer_config_node = require("@intlayer/config/node");
|
|
8
|
+
let _intlayer_unmerged_dictionaries_entry = require("@intlayer/unmerged-dictionaries-entry");
|
|
9
|
+
let node_http = require("node:http");
|
|
10
|
+
let _intlayer_config_package_json = require("@intlayer/config/package.json");
|
|
11
|
+
_intlayer_config_package_json = require_runtime.__toESM(_intlayer_config_package_json);
|
|
12
|
+
let _intlayer_core_plugins = require("@intlayer/core/plugins");
|
|
13
|
+
let _intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
|
|
14
|
+
|
|
15
|
+
//#region src/liveSync.ts
|
|
16
|
+
const writeDictionary = async (dictionary, configuration) => {
|
|
17
|
+
(0, _intlayer_config_logger.getAppLogger)(configuration)(`Writing dictionary ${dictionary.key}`);
|
|
18
|
+
await (0, _intlayer_chokidar_build.buildDictionary)([dictionary], configuration);
|
|
19
|
+
};
|
|
20
|
+
const liveSync = async (options) => {
|
|
21
|
+
const configuration = (0, _intlayer_config_node.getConfiguration)(options?.configOptions);
|
|
22
|
+
const appLogger = (0, _intlayer_config_logger.getAppLogger)(configuration);
|
|
23
|
+
const { liveSyncPort, liveSyncURL } = configuration.editor;
|
|
24
|
+
let parallelProcess = null;
|
|
25
|
+
let eventListener = null;
|
|
26
|
+
if (options?.with) {
|
|
27
|
+
parallelProcess = (0, _intlayer_chokidar_utils.runParallel)(options.with);
|
|
28
|
+
parallelProcess.result.catch(() => {});
|
|
29
|
+
}
|
|
30
|
+
if (configuration.editor.liveSync && configuration.editor.backendURL && configuration.editor.clientId && configuration.editor.clientSecret) {
|
|
31
|
+
eventListener = new require_IntlayerEventListener.IntlayerEventListener(configuration);
|
|
32
|
+
eventListener.onConnectionOpen = () => {
|
|
33
|
+
appLogger("Live sync connection established");
|
|
34
|
+
};
|
|
35
|
+
eventListener.onConnectionError = (error) => {
|
|
36
|
+
const errorEvent = error;
|
|
37
|
+
appLogger(`Live sync connection error: ${errorEvent.message ?? "Unknown error"}`, { level: "warn" });
|
|
38
|
+
if (errorEvent.message?.includes("terminated") || errorEvent.message?.includes("closed")) appLogger("Server connection was terminated, automatic reconnection will be attempted...", { level: "info" });
|
|
39
|
+
};
|
|
40
|
+
eventListener.onDictionaryAdded = (dictionary) => writeDictionary(dictionary, configuration);
|
|
41
|
+
eventListener.onDictionaryChange = (dictionary) => writeDictionary(dictionary, configuration);
|
|
42
|
+
eventListener.onDictionaryDeleted = (dictionary) => writeDictionary(dictionary, configuration);
|
|
43
|
+
try {
|
|
44
|
+
await eventListener.initialize();
|
|
45
|
+
} catch (error) {
|
|
46
|
+
appLogger("Failed to initialize IntlayerEventListener:", { level: "error" });
|
|
47
|
+
appLogger(`Error: ${error instanceof Error ? error.message : String(error)}`, { level: "error" });
|
|
48
|
+
}
|
|
49
|
+
} else if (!configuration.editor.liveSync) appLogger("Hot reload is disabled. Please enable it in the configuration (editor.liveSync).");
|
|
50
|
+
else if (!configuration.editor.clientId || !configuration.editor.clientSecret) appLogger("Missing client credentials for hot reload. Please configure clientId and clientSecret");
|
|
51
|
+
const server = (0, node_http.createServer)(async (req, res) => {
|
|
52
|
+
if (req.method === "OPTIONS") {
|
|
53
|
+
res.writeHead(200, {
|
|
54
|
+
"Access-Control-Allow-Origin": "*",
|
|
55
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
|
|
56
|
+
"Access-Control-Allow-Headers": "Content-Type, Authorization"
|
|
57
|
+
});
|
|
58
|
+
res.end();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (req.url?.startsWith("/dictionaries")) {
|
|
62
|
+
res.writeHead(200, {
|
|
63
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
64
|
+
"Cache-Control": "no-store",
|
|
65
|
+
"Access-Control-Allow-Origin": "*",
|
|
66
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
|
|
67
|
+
"Access-Control-Allow-Headers": "Content-Type, Authorization"
|
|
68
|
+
});
|
|
69
|
+
const dictionaries = (0, _intlayer_dictionaries_entry.getDictionaries)(configuration);
|
|
70
|
+
if (req.url.startsWith("/dictionaries/")) {
|
|
71
|
+
const [key, locale] = decodeURIComponent(req.url).slice(14).split("/");
|
|
72
|
+
const dictionary = dictionaries[key] ?? null;
|
|
73
|
+
if (locale) {
|
|
74
|
+
const sourceLocaleContent = (0, _intlayer_core_plugins.getLocalizedContent)(dictionary.content, locale, {
|
|
75
|
+
dictionaryKey: key,
|
|
76
|
+
keyPath: []
|
|
77
|
+
});
|
|
78
|
+
res.end(JSON.stringify(sourceLocaleContent));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
res.end(JSON.stringify(dictionary));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
res.end(JSON.stringify(dictionaries));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (req.url?.startsWith("/unmerged_dictionaries")) {
|
|
88
|
+
res.writeHead(200, {
|
|
89
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
90
|
+
"Cache-Control": "no-store",
|
|
91
|
+
"Access-Control-Allow-Origin": "*",
|
|
92
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
|
|
93
|
+
"Access-Control-Allow-Headers": "Content-Type, Authorization"
|
|
94
|
+
});
|
|
95
|
+
const unmergedDictionaries = (0, _intlayer_unmerged_dictionaries_entry.getUnmergedDictionaries)(configuration);
|
|
96
|
+
if (req.url.startsWith("/unmerged_dictionaries/")) {
|
|
97
|
+
const one = unmergedDictionaries[decodeURIComponent(req.url.slice(23))] ?? null;
|
|
98
|
+
res.end(JSON.stringify(one));
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
res.end(JSON.stringify(unmergedDictionaries));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (req.url === "/configuration") {
|
|
105
|
+
res.writeHead(200, {
|
|
106
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
107
|
+
"Cache-Control": "no-store",
|
|
108
|
+
"Access-Control-Allow-Origin": "*",
|
|
109
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
|
|
110
|
+
"Access-Control-Allow-Headers": "Content-Type, Authorization"
|
|
111
|
+
});
|
|
112
|
+
res.end(JSON.stringify(configuration));
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (req.url === "/health") {
|
|
116
|
+
res.writeHead(200, { "Content-Type": "application/json; charset=utf-8" });
|
|
117
|
+
res.end(JSON.stringify({ status: "ok" }));
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
res.end("Not found");
|
|
121
|
+
});
|
|
122
|
+
const getLiveSyncParam = () => {
|
|
123
|
+
if (!configuration.editor.liveSync) return "\x1B[31m✗ Disabled\x1B[0m";
|
|
124
|
+
return "\x1B[32m✓ Enabled\x1B[0m";
|
|
125
|
+
};
|
|
126
|
+
server.listen(liveSyncPort, () => {
|
|
127
|
+
console.log(`
|
|
128
|
+
\x1b[1;90mINTLAYER v${_intlayer_config_package_json.default.version}\x1b[0m
|
|
3
129
|
|
|
4
|
-
Live server running at: \x1b[90m${
|
|
5
|
-
- Backend URL: \x1b[90m${
|
|
6
|
-
- Live sync: ${
|
|
7
|
-
- Parallel process: ${
|
|
8
|
-
- Access key: ${
|
|
9
|
-
`)
|
|
130
|
+
Live server running at: \x1b[90m${liveSyncURL}\x1b[0m
|
|
131
|
+
- Backend URL: \x1b[90m${configuration.editor.backendURL ?? "-"}\x1b[0m
|
|
132
|
+
- Live sync: ${getLiveSyncParam()}
|
|
133
|
+
- Parallel process: ${options?.with ? `\x1b[90m${Array.isArray(options.with) ? options.with.join(" ") : options.with}\x1b[0m` : "-"}
|
|
134
|
+
- Access key: ${configuration.editor.clientId ?? "-"}
|
|
135
|
+
`);
|
|
136
|
+
});
|
|
137
|
+
const cleanup = () => {
|
|
138
|
+
if (eventListener) {
|
|
139
|
+
appLogger("Closing SSE connection...");
|
|
140
|
+
eventListener.cleanup();
|
|
141
|
+
}
|
|
142
|
+
if (parallelProcess) parallelProcess.kill();
|
|
143
|
+
server.close(() => {
|
|
144
|
+
appLogger("Live sync server stopped");
|
|
145
|
+
process.exit(0);
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
process.on("SIGINT", cleanup);
|
|
149
|
+
process.on("SIGTERM", cleanup);
|
|
150
|
+
process.on("exit", cleanup);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
//#endregion
|
|
154
|
+
exports.liveSync = liveSync;
|
|
10
155
|
//# sourceMappingURL=liveSync.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liveSync.cjs","names":["IntlayerEventListener","packageJson"],"sources":["../../src/liveSync.ts"],"sourcesContent":["import { createServer } from 'node:http';\n// @ts-ignore: @intlayer/backend is not built yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { buildDictionary } from '@intlayer/chokidar/build';\nimport { type ParallelHandle, runParallel } from '@intlayer/chokidar/utils';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport { getLocalizedContent } from '@intlayer/core/plugins';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { IntlayerEventListener } from './IntlayerEventListener';\n\ntype LiveSyncOptions = {\n with?: string | string[];\n configOptions?: GetConfigurationOptions;\n};\n\nconst writeDictionary = async (\n dictionary: DictionaryAPI,\n configuration: IntlayerConfig\n) => {\n const appLogger = getAppLogger(configuration);\n appLogger(`Writing dictionary ${dictionary.key}`);\n await buildDictionary([dictionary], configuration);\n};\n\nexport const liveSync = async (options?: LiveSyncOptions) => {\n const configuration = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(configuration);\n\n const { liveSyncPort, liveSyncURL } = configuration.editor;\n\n let parallelProcess: ParallelHandle | null = null;\n let eventListener: IntlayerEventListener | null = null;\n let _isHotReloadConnected = false;\n let _connectionStatus = 'disconnected'; // 'connected', 'connecting', 'reconnecting', 'disconnected', 'error'\n\n // Start the parallel process if provided\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 // Initialize the event listener for hot reload if configured\n if (\n configuration.editor.liveSync &&\n configuration.editor.backendURL &&\n configuration.editor.clientId &&\n configuration.editor.clientSecret\n ) {\n eventListener = new IntlayerEventListener(configuration);\n _connectionStatus = 'connecting';\n\n // Set up connection callbacks\n eventListener.onConnectionOpen = () => {\n _connectionStatus = 'connected';\n _isHotReloadConnected = true;\n appLogger('Live sync connection established');\n };\n\n eventListener.onConnectionError = (error) => {\n _connectionStatus = 'error';\n _isHotReloadConnected = false;\n const errorEvent = error as any;\n appLogger(\n `Live sync connection error: ${errorEvent.message ?? 'Unknown error'}`,\n {\n level: 'warn',\n }\n );\n\n // If this is a \"terminated: other side closed\" error, it's likely a server restart\n if (\n errorEvent.message?.includes('terminated') ||\n errorEvent.message?.includes('closed')\n ) {\n appLogger(\n 'Server connection was terminated, automatic reconnection will be attempted...',\n {\n level: 'info',\n }\n );\n _connectionStatus = 'reconnecting';\n }\n };\n\n // Set up dictionary change callbacks\n eventListener.onDictionaryAdded = (dictionary) =>\n writeDictionary(dictionary, configuration);\n eventListener.onDictionaryChange = (dictionary) =>\n writeDictionary(dictionary, configuration);\n eventListener.onDictionaryDeleted = (dictionary) =>\n writeDictionary(dictionary, configuration);\n\n try {\n await eventListener.initialize();\n } catch (error) {\n _connectionStatus = 'error';\n _isHotReloadConnected = false;\n appLogger('Failed to initialize IntlayerEventListener:', {\n level: 'error',\n });\n appLogger(\n `Error: ${error instanceof Error ? error.message : String(error)}`,\n {\n level: 'error',\n }\n );\n }\n } else if (!configuration.editor.liveSync) {\n appLogger(\n 'Hot reload is disabled. Please enable it in the configuration (editor.liveSync).'\n );\n } else if (\n !configuration.editor.clientId ||\n !configuration.editor.clientSecret\n ) {\n appLogger(\n 'Missing client credentials for hot reload. Please configure clientId and clientSecret'\n );\n }\n\n const server = createServer(async (req, res) => {\n // Handle CORS preflight requests\n if (req.method === 'OPTIONS') {\n res.writeHead(200, {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',\n 'Access-Control-Allow-Headers': 'Content-Type, Authorization',\n });\n\n res.end();\n return;\n }\n\n if (req.url?.startsWith('/dictionaries')) {\n res.writeHead(200, {\n 'Content-Type': 'application/json; charset=utf-8',\n 'Cache-Control': 'no-store',\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',\n 'Access-Control-Allow-Headers': 'Content-Type, Authorization',\n });\n const dictionaries = getDictionaries(configuration);\n\n const prefix = '/dictionaries/';\n if (req.url.startsWith(prefix)) {\n const [key, locale] = decodeURIComponent(req.url)\n .slice(prefix.length)\n .split('/');\n\n const dictionary = dictionaries[key] ?? null;\n\n if (locale) {\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const sourceLocaleContent = getLocalizedContent(\n dictionary.content,\n locale,\n {\n dictionaryKey: key,\n keyPath: [],\n }\n );\n\n res.end(JSON.stringify(sourceLocaleContent));\n return;\n }\n\n res.end(JSON.stringify(dictionary));\n return;\n }\n\n res.end(JSON.stringify(dictionaries));\n return;\n }\n\n if (req.url?.startsWith('/unmerged_dictionaries')) {\n res.writeHead(200, {\n 'Content-Type': 'application/json; charset=utf-8',\n 'Cache-Control': 'no-store',\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',\n 'Access-Control-Allow-Headers': 'Content-Type, Authorization',\n });\n const unmergedDictionaries = getUnmergedDictionaries(configuration);\n\n const prefix = '/unmerged_dictionaries/';\n if (req.url.startsWith(prefix)) {\n const key = decodeURIComponent(req.url.slice(prefix.length));\n const one = unmergedDictionaries[key] ?? null;\n\n res.end(JSON.stringify(one));\n return;\n }\n\n res.end(JSON.stringify(unmergedDictionaries));\n return;\n }\n\n if (req.url === '/configuration') {\n res.writeHead(200, {\n 'Content-Type': 'application/json; charset=utf-8',\n 'Cache-Control': 'no-store',\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',\n 'Access-Control-Allow-Headers': 'Content-Type, Authorization',\n });\n res.end(JSON.stringify(configuration));\n return;\n }\n\n if (req.url === '/health') {\n res.writeHead(200, {\n 'Content-Type': 'application/json; charset=utf-8',\n });\n res.end(JSON.stringify({ status: 'ok' }));\n return;\n }\n\n res.end('Not found');\n return;\n });\n\n const getLiveSyncParam = () => {\n if (!configuration.editor.liveSync) return '\\x1b[31m✗ Disabled\\x1b[0m';\n\n return '\\x1b[32m✓ Enabled\\x1b[0m';\n };\n server.listen(liveSyncPort, () => {\n console.log(`\n \\x1b[1;90mINTLAYER v${packageJson.version}\\x1b[0m\n \n Live server running at: \\x1b[90m${liveSyncURL}\\x1b[0m\n - Backend URL: \\x1b[90m${configuration.editor.backendURL ?? '-'}\\x1b[0m\n - Live sync: ${getLiveSyncParam()}\n - Parallel process: ${options?.with ? `\\x1b[90m${Array.isArray(options.with) ? options.with.join(' ') : options.with}\\x1b[0m` : '-'}\n - Access key: ${configuration.editor.clientId ?? '-'}\n `);\n });\n\n // Cleanup function to terminate child process and event listener when the main process exits\n const cleanup = () => {\n // Clean up event listener\n if (eventListener) {\n appLogger('Closing SSE connection...');\n eventListener.cleanup();\n }\n\n if (parallelProcess) {\n parallelProcess.kill();\n }\n\n server.close(() => {\n appLogger('Live sync server stopped');\n process.exit(0);\n });\n };\n\n // Handle process termination signals\n process.on('SIGINT', cleanup);\n process.on('SIGTERM', cleanup);\n process.on('exit', cleanup);\n};\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"liveSync.cjs","names":["IntlayerEventListener","packageJson"],"sources":["../../src/liveSync.ts"],"sourcesContent":["import { createServer } from 'node:http';\n// @ts-ignore: @intlayer/backend is not built yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { buildDictionary } from '@intlayer/chokidar/build';\nimport { type ParallelHandle, runParallel } from '@intlayer/chokidar/utils';\nimport { getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport packageJson from '@intlayer/config/package.json' with { type: 'json' };\nimport { getLocalizedContent } from '@intlayer/core/plugins';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { IntlayerEventListener } from './IntlayerEventListener';\n\ntype LiveSyncOptions = {\n with?: string | string[];\n configOptions?: GetConfigurationOptions;\n};\n\nconst writeDictionary = async (\n dictionary: DictionaryAPI,\n configuration: IntlayerConfig\n) => {\n const appLogger = getAppLogger(configuration);\n appLogger(`Writing dictionary ${dictionary.key}`);\n await buildDictionary([dictionary], configuration);\n};\n\nexport const liveSync = async (options?: LiveSyncOptions) => {\n const configuration = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(configuration);\n\n const { liveSyncPort, liveSyncURL } = configuration.editor;\n\n let parallelProcess: ParallelHandle | null = null;\n let eventListener: IntlayerEventListener | null = null;\n let _isHotReloadConnected = false;\n let _connectionStatus = 'disconnected'; // 'connected', 'connecting', 'reconnecting', 'disconnected', 'error'\n\n // Start the parallel process if provided\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 // Initialize the event listener for hot reload if configured\n if (\n configuration.editor.liveSync &&\n configuration.editor.backendURL &&\n configuration.editor.clientId &&\n configuration.editor.clientSecret\n ) {\n eventListener = new IntlayerEventListener(configuration);\n _connectionStatus = 'connecting';\n\n // Set up connection callbacks\n eventListener.onConnectionOpen = () => {\n _connectionStatus = 'connected';\n _isHotReloadConnected = true;\n appLogger('Live sync connection established');\n };\n\n eventListener.onConnectionError = (error) => {\n _connectionStatus = 'error';\n _isHotReloadConnected = false;\n const errorEvent = error as any;\n appLogger(\n `Live sync connection error: ${errorEvent.message ?? 'Unknown error'}`,\n {\n level: 'warn',\n }\n );\n\n // If this is a \"terminated: other side closed\" error, it's likely a server restart\n if (\n errorEvent.message?.includes('terminated') ||\n errorEvent.message?.includes('closed')\n ) {\n appLogger(\n 'Server connection was terminated, automatic reconnection will be attempted...',\n {\n level: 'info',\n }\n );\n _connectionStatus = 'reconnecting';\n }\n };\n\n // Set up dictionary change callbacks\n eventListener.onDictionaryAdded = (dictionary) =>\n writeDictionary(dictionary, configuration);\n eventListener.onDictionaryChange = (dictionary) =>\n writeDictionary(dictionary, configuration);\n eventListener.onDictionaryDeleted = (dictionary) =>\n writeDictionary(dictionary, configuration);\n\n try {\n await eventListener.initialize();\n } catch (error) {\n _connectionStatus = 'error';\n _isHotReloadConnected = false;\n appLogger('Failed to initialize IntlayerEventListener:', {\n level: 'error',\n });\n appLogger(\n `Error: ${error instanceof Error ? error.message : String(error)}`,\n {\n level: 'error',\n }\n );\n }\n } else if (!configuration.editor.liveSync) {\n appLogger(\n 'Hot reload is disabled. Please enable it in the configuration (editor.liveSync).'\n );\n } else if (\n !configuration.editor.clientId ||\n !configuration.editor.clientSecret\n ) {\n appLogger(\n 'Missing client credentials for hot reload. Please configure clientId and clientSecret'\n );\n }\n\n const server = createServer(async (req, res) => {\n // Handle CORS preflight requests\n if (req.method === 'OPTIONS') {\n res.writeHead(200, {\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',\n 'Access-Control-Allow-Headers': 'Content-Type, Authorization',\n });\n\n res.end();\n return;\n }\n\n if (req.url?.startsWith('/dictionaries')) {\n res.writeHead(200, {\n 'Content-Type': 'application/json; charset=utf-8',\n 'Cache-Control': 'no-store',\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',\n 'Access-Control-Allow-Headers': 'Content-Type, Authorization',\n });\n const dictionaries = getDictionaries(configuration);\n\n const prefix = '/dictionaries/';\n if (req.url.startsWith(prefix)) {\n const [key, locale] = decodeURIComponent(req.url)\n .slice(prefix.length)\n .split('/');\n\n const dictionary = dictionaries[key] ?? null;\n\n if (locale) {\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const sourceLocaleContent = getLocalizedContent(\n dictionary.content,\n locale,\n {\n dictionaryKey: key,\n keyPath: [],\n }\n );\n\n res.end(JSON.stringify(sourceLocaleContent));\n return;\n }\n\n res.end(JSON.stringify(dictionary));\n return;\n }\n\n res.end(JSON.stringify(dictionaries));\n return;\n }\n\n if (req.url?.startsWith('/unmerged_dictionaries')) {\n res.writeHead(200, {\n 'Content-Type': 'application/json; charset=utf-8',\n 'Cache-Control': 'no-store',\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',\n 'Access-Control-Allow-Headers': 'Content-Type, Authorization',\n });\n const unmergedDictionaries = getUnmergedDictionaries(configuration);\n\n const prefix = '/unmerged_dictionaries/';\n if (req.url.startsWith(prefix)) {\n const key = decodeURIComponent(req.url.slice(prefix.length));\n const one = unmergedDictionaries[key] ?? null;\n\n res.end(JSON.stringify(one));\n return;\n }\n\n res.end(JSON.stringify(unmergedDictionaries));\n return;\n }\n\n if (req.url === '/configuration') {\n res.writeHead(200, {\n 'Content-Type': 'application/json; charset=utf-8',\n 'Cache-Control': 'no-store',\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',\n 'Access-Control-Allow-Headers': 'Content-Type, Authorization',\n });\n res.end(JSON.stringify(configuration));\n return;\n }\n\n if (req.url === '/health') {\n res.writeHead(200, {\n 'Content-Type': 'application/json; charset=utf-8',\n });\n res.end(JSON.stringify({ status: 'ok' }));\n return;\n }\n\n res.end('Not found');\n return;\n });\n\n const getLiveSyncParam = () => {\n if (!configuration.editor.liveSync) return '\\x1b[31m✗ Disabled\\x1b[0m';\n\n return '\\x1b[32m✓ Enabled\\x1b[0m';\n };\n server.listen(liveSyncPort, () => {\n console.log(`\n \\x1b[1;90mINTLAYER v${packageJson.version}\\x1b[0m\n \n Live server running at: \\x1b[90m${liveSyncURL}\\x1b[0m\n - Backend URL: \\x1b[90m${configuration.editor.backendURL ?? '-'}\\x1b[0m\n - Live sync: ${getLiveSyncParam()}\n - Parallel process: ${options?.with ? `\\x1b[90m${Array.isArray(options.with) ? options.with.join(' ') : options.with}\\x1b[0m` : '-'}\n - Access key: ${configuration.editor.clientId ?? '-'}\n `);\n });\n\n // Cleanup function to terminate child process and event listener when the main process exits\n const cleanup = () => {\n // Clean up event listener\n if (eventListener) {\n appLogger('Closing SSE connection...');\n eventListener.cleanup();\n }\n\n if (parallelProcess) {\n parallelProcess.kill();\n }\n\n server.close(() => {\n appLogger('Live sync server stopped');\n process.exit(0);\n });\n };\n\n // Handle process termination signals\n process.on('SIGINT', cleanup);\n process.on('SIGTERM', cleanup);\n process.on('exit', cleanup);\n};\n"],"mappings":";;;;;;;;;;;;;;;AAsBA,MAAM,kBAAkB,OACtB,YACA,kBACG;AAEH,2CAD+B,cAAc,CACnC,sBAAsB,WAAW,MAAM;AACjD,qDAAsB,CAAC,WAAW,EAAE,cAAc;;AAGpD,MAAa,WAAW,OAAO,YAA8B;CAC3D,MAAM,4DAAiC,SAAS,cAAc;CAC9D,MAAM,sDAAyB,cAAc;CAE7C,MAAM,EAAE,cAAc,gBAAgB,cAAc;CAEpD,IAAI,kBAAyC;CAC7C,IAAI,gBAA8C;AAKlD,KAAI,SAAS,MAAM;AACjB,8DAA8B,QAAQ,KAAK;AAE3C,kBAAgB,OAAO,YAAY,GAEjC;;AAIJ,KACE,cAAc,OAAO,YACrB,cAAc,OAAO,cACrB,cAAc,OAAO,YACrB,cAAc,OAAO,cACrB;AACA,kBAAgB,IAAIA,oDAAsB,cAAc;AAIxD,gBAAc,yBAAyB;AAGrC,aAAU,mCAAmC;;AAG/C,gBAAc,qBAAqB,UAAU;GAG3C,MAAM,aAAa;AACnB,aACE,+BAA+B,WAAW,WAAW,mBACrD,EACE,OAAO,QACR,CACF;AAGD,OACE,WAAW,SAAS,SAAS,aAAa,IAC1C,WAAW,SAAS,SAAS,SAAS,CAEtC,WACE,iFACA,EACE,OAAO,QACR,CACF;;AAML,gBAAc,qBAAqB,eACjC,gBAAgB,YAAY,cAAc;AAC5C,gBAAc,sBAAsB,eAClC,gBAAgB,YAAY,cAAc;AAC5C,gBAAc,uBAAuB,eACnC,gBAAgB,YAAY,cAAc;AAE5C,MAAI;AACF,SAAM,cAAc,YAAY;WACzB,OAAO;AAGd,aAAU,+CAA+C,EACvD,OAAO,SACR,CAAC;AACF,aACE,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IAChE,EACE,OAAO,SACR,CACF;;YAEM,CAAC,cAAc,OAAO,SAC/B,WACE,mFACD;UAED,CAAC,cAAc,OAAO,YACtB,CAAC,cAAc,OAAO,aAEtB,WACE,wFACD;CAGH,MAAM,qCAAsB,OAAO,KAAK,QAAQ;AAE9C,MAAI,IAAI,WAAW,WAAW;AAC5B,OAAI,UAAU,KAAK;IACjB,+BAA+B;IAC/B,gCAAgC;IAChC,gCAAgC;IACjC,CAAC;AAEF,OAAI,KAAK;AACT;;AAGF,MAAI,IAAI,KAAK,WAAW,gBAAgB,EAAE;AACxC,OAAI,UAAU,KAAK;IACjB,gBAAgB;IAChB,iBAAiB;IACjB,+BAA+B;IAC/B,gCAAgC;IAChC,gCAAgC;IACjC,CAAC;GACF,MAAM,iEAA+B,cAAc;AAGnD,OAAI,IAAI,IAAI,WADG,iBACe,EAAE;IAC9B,MAAM,CAAC,KAAK,UAAU,mBAAmB,IAAI,IAAI,CAC9C,MAAM,GAAc,CACpB,MAAM,IAAI;IAEb,MAAM,aAAa,aAAa,QAAQ;AAExC,QAAI,QAAQ;KAEV,MAAM,sEACJ,WAAW,SACX,QACA;MACE,eAAe;MACf,SAAS,EAAE;MACZ,CACF;AAED,SAAI,IAAI,KAAK,UAAU,oBAAoB,CAAC;AAC5C;;AAGF,QAAI,IAAI,KAAK,UAAU,WAAW,CAAC;AACnC;;AAGF,OAAI,IAAI,KAAK,UAAU,aAAa,CAAC;AACrC;;AAGF,MAAI,IAAI,KAAK,WAAW,yBAAyB,EAAE;AACjD,OAAI,UAAU,KAAK;IACjB,gBAAgB;IAChB,iBAAiB;IACjB,+BAA+B;IAC/B,gCAAgC;IAChC,gCAAgC;IACjC,CAAC;GACF,MAAM,0FAA+C,cAAc;AAGnE,OAAI,IAAI,IAAI,WADG,0BACe,EAAE;IAE9B,MAAM,MAAM,qBADA,mBAAmB,IAAI,IAAI,MAAM,GAAc,CAAC,KACnB;AAEzC,QAAI,IAAI,KAAK,UAAU,IAAI,CAAC;AAC5B;;AAGF,OAAI,IAAI,KAAK,UAAU,qBAAqB,CAAC;AAC7C;;AAGF,MAAI,IAAI,QAAQ,kBAAkB;AAChC,OAAI,UAAU,KAAK;IACjB,gBAAgB;IAChB,iBAAiB;IACjB,+BAA+B;IAC/B,gCAAgC;IAChC,gCAAgC;IACjC,CAAC;AACF,OAAI,IAAI,KAAK,UAAU,cAAc,CAAC;AACtC;;AAGF,MAAI,IAAI,QAAQ,WAAW;AACzB,OAAI,UAAU,KAAK,EACjB,gBAAgB,mCACjB,CAAC;AACF,OAAI,IAAI,KAAK,UAAU,EAAE,QAAQ,MAAM,CAAC,CAAC;AACzC;;AAGF,MAAI,IAAI,YAAY;GAEpB;CAEF,MAAM,yBAAyB;AAC7B,MAAI,CAAC,cAAc,OAAO,SAAU,QAAO;AAE3C,SAAO;;AAET,QAAO,OAAO,oBAAoB;AAChC,UAAQ,IAAI;4BACYC,sCAAY,QAAQ;;iDAEC,YAAY;iDACZ,cAAc,OAAO,cAAc,IAAI;yCAC/C,kBAAkB,CAAC;yCACnB,SAAS,OAAO,WAAW,MAAM,QAAQ,QAAQ,KAAK,GAAG,QAAQ,KAAK,KAAK,IAAI,GAAG,QAAQ,KAAK,WAAW,IAAI;yCAC9G,cAAc,OAAO,YAAY,IAAI;QACtE;GACJ;CAGF,MAAM,gBAAgB;AAEpB,MAAI,eAAe;AACjB,aAAU,4BAA4B;AACtC,iBAAc,SAAS;;AAGzB,MAAI,gBACF,iBAAgB,MAAM;AAGxB,SAAO,YAAY;AACjB,aAAU,2BAA2B;AACrC,WAAQ,KAAK,EAAE;IACf;;AAIJ,SAAQ,GAAG,UAAU,QAAQ;AAC7B,SAAQ,GAAG,WAAW,QAAQ;AAC9B,SAAQ,GAAG,QAAQ,QAAQ"}
|