UNPKG

@redocly/theme

Version:

Shared UI components lib

23 lines 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getCodeWalkthroughFileText = getCodeWalkthroughFileText; const match_code_walkthrough_conditions_1 = require("./match-code-walkthrough-conditions"); const replace_inputs_with_value_1 = require("./replace-inputs-with-value"); function getCodeWalkthroughFileText(file, state, inputsState) { var _a; const contentChunks = (_a = file === null || file === void 0 ? void 0 : file.content.flatMap((node) => getChunkText(node, state, inputsState))) !== null && _a !== void 0 ? _a : []; return contentChunks.join('\n'); } function getChunkText(node, state, inputsState) { if (typeof node === 'string') { const replacedNode = (0, replace_inputs_with_value_1.replaceInputsWithValue)(node, inputsState); return [replacedNode]; } else { if (!(0, match_code_walkthrough_conditions_1.matchCodeWalkthroughConditions)(node.condition || {}, state)) { return []; } return node.children.flatMap((child) => getChunkText(child, state, inputsState)); } } //# sourceMappingURL=get-code-walkthrough-file-text.js.map