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oc-cli@0.13.21/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/redoc-cli@0.13.21/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","#!/usr/bin/env node\n\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.mimeTypes = void 0;\n/* tslint:disable:no-implicit-dependencies */\nconst react_1 = require(\"react\");\nconst server_1 = require(\"react-dom/server\");\nconst styled_components_1 = require(\"styled-components\");\nconst handlebars_1 = require(\"handlebars\");\nconst http_1 = require(\"http\");\nconst path_1 = require(\"path\");\nconst zlib = require(\"zlib\");\nconst boxen = require(\"boxen\");\n// @ts-ignore\nconst redoc_1 = require(\"redoc\");\nconst chokidar_1 = require(\"chokidar\");\nconst fs_1 = require(\"fs\");\nconst mkdirp = require(\"mkdirp\");\nconst YargsParser = require(\"yargs\");\n// eslint-disable-next-line import/no-extraneous-dependencies\nconst openapi_core_1 = require(\"@redocly/openapi-core\");\n// eslint-disable-next-line import/no-extraneous-dependencies\nconst openapi_core_2 = require(\"@redocly/openapi-core\");\nexports.mimeTypes = {\n    '.html': 'text/html',\n    '.js': 'text/javascript',\n    '.css': 'text/css',\n    '.json': 'application/json',\n    '.png': 'image/png',\n    '.jpg': 'image/jpg',\n    '.gif': 'image/gif',\n    '.svg': 'image/svg+xml',\n    '.wav': 'audio/wav',\n    '.mp4': 'video/mp4',\n    '.woff': 'application/font-woff',\n    '.ttf': 'application/font-ttf',\n    '.eot': 'application/vnd.ms-fontobject',\n    '.otf': 'application/font-otf',\n    '.wasm': 'application/wasm',\n};\nconst BUNDLES_DIR = path_1.dirname(require.resolve('redoc'));\nconst boxenOptions = {\n    title: 'DEPRECATED',\n    titleAlignment: 'center',\n    padding: 1,\n    margin: 1,\n    borderColor: 'red',\n};\nconst builderForBuildCommand = yargs => {\n    yargs.positional('spec', {\n        describe: 'path or URL to your spec',\n    });\n    yargs.option('o', {\n        describe: 'Output file',\n        alias: 'output',\n        type: 'string',\n        default: 'redoc-static.html',\n    });\n    yargs.options('title', {\n        describe: 'Page Title',\n        type: 'string',\n    });\n    yargs.options('disableGoogleFont', {\n        describe: 'Disable Google Font',\n        type: 'boolean',\n        default: false,\n    });\n    yargs.option('cdn', {\n        describe: 'Do not include ReDoc source code into html page, use link to CDN instead',\n        type: 'boolean',\n        default: false,\n    });\n    yargs.demandOption('spec');\n    return yargs;\n};\nconst handlerForBuildCommand = (argv) => __awaiter(void 0, void 0, void 0, function* () {\n    const config = {\n        ssr: true,\n        output: argv.o,\n        cdn: argv.cdn,\n        title: argv.title,\n        disableGoogleFont: argv.disableGoogleFont,\n        templateFileName: argv.template,\n        templateOptions: argv.templateOptions || {},\n        redocOptions: getObjectOrJSON(argv.options),\n    };\n    try {\n        yield bundle(argv.spec, config);\n    }\n    catch (e) {\n        handleError(e);\n    }\n});\nYargsParser.command('serve <spec>', 'start the server [deprecated]', yargs => {\n    yargs.positional('spec', {\n        describe: 'path or URL to your spec',\n    });\n    yargs.options('title', {\n        describe: 'Page Title',\n        type: 'string',\n    });\n    yargs.option('s', {\n        alias: 'ssr',\n        describe: 'Enable server-side rendering',\n        type: 'boolean',\n    });\n    yargs.option('h', {\n        alias: 'host',\n        type: 'string',\n        default: '127.0.0.1',\n    });\n    yargs.option('p', {\n        alias: 'port',\n        type: 'number',\n        default: 8080,\n    });\n    yargs.option('w', {\n        alias: 'watch',\n        type: 'boolean',\n    });\n    yargs.options('disable-google-font', {\n        describe: 'Disable Google Font',\n        type: 'boolean',\n        default: false,\n    });\n    yargs.demandOption('spec');\n    return yargs;\n}, (argv) => __awaiter(void 0, void 0, void 0, function* () {\n    const config = {\n        ssr: argv.ssr,\n        title: argv.title,\n        watch: argv.watch,\n        disableGoogleFont: argv.disableGoogleFont,\n        templateFileName: argv.template,\n        templateOptions: argv.templateOptions || {},\n        redocOptions: getObjectOrJSON(argv.options),\n    };\n    try {\n        yield serve(argv.host, argv.port, argv.spec, config);\n    }\n    catch (e) {\n        handleError(e);\n    }\n}), [\n    res => {\n        console.log(`\n        ${boxen('This package is deprecated.\\n\\nUse `npx @redocly/cli preview-docs <api>` instead.', boxenOptions)}`);\n        return res;\n    },\n], true)\n    .command('build <spec>', 'build definition into zero-dependency HTML-file [deprecated]', builderForBuildCommand, handlerForBuildCommand, [notifyDeprecation], true)\n    .command('bundle <spec>', 'bundle spec into zero-dependency HTML-file [deprecated]', builderForBuildCommand, handlerForBuildCommand, [notifyDeprecation], true)\n    .demandCommand()\n    .options('t', {\n    alias: 'template',\n    describe: 'Path to handlebars page template, see https://git.io/vh8fP for the example ',\n    type: 'string',\n})\n    .options('templateOptions', {\n    describe: 'Additional options that you want pass to template. Use dot notation, e.g. templateOptions.metaDescription',\n})\n    .options('options', {\n    describe: 'ReDoc options, use dot notation, e.g. options.nativeScrollbars',\n}).argv;\nfunction serve(host, port, pathToSpec, options = {}) {\n    return __awaiter(this, void 0, void 0, function* () {\n        let spec = yield redoc_1.loadAndBundleSpec(isURL(pathToSpec) ? pathToSpec : path_1.resolve(pathToSpec));\n        let pageHTML = yield getPageHTML(spec, pathToSpec, options);\n        const server = http_1.createServer((request, response) => {\n            console.time('GET ' + request.url);\n            if (request.url === '/redoc.standalone.js') {\n                respondWithGzip(fs_1.createReadStream(path_1.join(BUNDLES_DIR, 'redoc.standalone.js'), 'utf8'), request, response, {\n                    'Content-Type': 'application/javascript',\n                });\n            }\n            else if (request.url === '/') {\n                respondWithGzip(pageHTML, request, response, {\n                    'Content-Type': 'text/html',\n                });\n            }\n            else if (request.url === '/spec.json') {\n                const specStr = JSON.stringify(spec, null, 2);\n                respondWithGzip(specStr, request, response, {\n                    'Content-Type': 'application/json',\n                });\n            }\n            else {\n                try {\n                    const filePath = path_1.join(path_1.dirname(pathToSpec), request.url || '');\n                    const extname = String(path_1.extname(filePath)).toLowerCase();\n                    const contentType = exports.mimeTypes[extname] || 'application/octet-stream';\n                    respondWithGzip(fs_1.createReadStream(filePath), request, response, {\n                        'Content-Type': contentType,\n                    });\n                }\n                catch (e) {\n                    response.writeHead(404);\n                    response.write('Not found');\n                    response.end();\n                }\n            }\n            console.timeEnd('GET ' + request.url);\n        });\n        console.log();\n        server.listen(port, host, () => console.log(`Server started: http://${host}:${port}`));\n        if (options.watch && fs_1.existsSync(pathToSpec)) {\n            const pathToSpecDirectory = path_1.resolve(path_1.dirname(pathToSpec));\n            const watchOptions = {\n                ignored: [/(^|[\\/\\\\])\\../, /___jb_[a-z]+___$/],\n                ignoreInitial: true,\n            };\n            const watcher = chokidar_1.watch(pathToSpecDirectory, watchOptions);\n            const log = console.log.bind(console);\n            const handlePath = (_path) => __awaiter(this, void 0, void 0, function* () {\n                try {\n                    spec = yield redoc_1.loadAndBundleSpec(path_1.resolve(pathToSpec));\n                    pageHTML = yield getPageHTML(spec, pathToSpec, options);\n                    log('Updated successfully');\n                }\n                catch (e) {\n                    console.error('Error while updating: ', e.message);\n                }\n            });\n            watcher\n                .on('change', (path) => __awaiter(this, void 0, void 0, function* () {\n                log(`${path} changed, updating docs`);\n                handlePath(path);\n            }))\n                .on('add', (path) => __awaiter(this, void 0, void 0, function* () {\n                log(`File ${path} added, updating docs`);\n                handlePath(path);\n            }))\n                .on('addDir', path => {\n                log(`↗  Directory ${path} added. Files in here will trigger reload.`);\n            })\n                .on('error', error => console.error(`Watcher error: ${error}`))\n                .on('ready', () => log(`👀  Watching ${pathToSpecDirectory} for changes...`));\n        }\n    });\n}\nfunction bundle(pathToSpec, options = {}) {\n    return __awaiter(this, void 0, void 0, function* () {\n        const start = Date.now();\n        const spec = yield redoc_1.loadAndBundleSpec(isURL(pathToSpec) ? pathToSpec : path_1.resolve(pathToSpec));\n        const pageHTML = yield getPageHTML(spec, pathToSpec, Object.assign(Object.assign({}, options), { ssr: true }));\n        mkdirp.sync(path_1.dirname(options.output));\n        fs_1.writeFileSync(options.output, pageHTML);\n        const sizeInKiB = Math.ceil(Buffer.byteLength(pageHTML) / 1024);\n        const time = Date.now() - start;\n        console.log(`\\n🎉 bundled successfully in: ${options.output} (${sizeInKiB} KiB) [⏱ ${time / 1000}s]`);\n    });\n}\nfunction getPageHTML(spec, pathToSpec, { ssr, cdn, title, disableGoogleFont, templateFileName, templateOptions, redocOptions = {}, }) {\n    return __awaiter(this, void 0, void 0, function* () {\n        let html;\n        let css;\n        let state;\n        let redocStandaloneSrc;\n        if (ssr) {\n            console.log('Prerendering docs');\n            const specUrl = redocOptions.specUrl || (isURL(pathToSpec) ? pathToSpec : undefined);\n            const store = yield redoc_1.createStore(spec, specUrl, redocOptions);\n            const sheet = new styled_components_1.ServerStyleSheet();\n            // @ts-ignore\n            html = server_1.renderToString(sheet.collectStyles(react_1.createElement(redoc_1.Redoc, { store })));\n            css = sheet.getStyleTags();\n            state = yield store.toJS();\n            if (!cdn) {\n                redocStandaloneSrc = fs_1.readFileSync(path_1.join(BUNDLES_DIR, 'redoc.standalone.js'));\n            }\n        }\n        templateFileName = templateFileName ? templateFileName : path_1.join(__dirname, './template.hbs');\n        const template = handlebars_1.compile(fs_1.readFileSync(templateFileName).toString());\n        return template({\n            redocHTML: `\n    <div id=\"redoc\">${(ssr && html) || ''}</div>\n    <script>\n    ${(ssr && `const __redoc_state = ${sanitizeJSONString(JSON.stringify(state))};`) || ''}\n\n    var container = document.getElementById('redoc');\n    Redoc.${ssr\n                ? 'hydrate(__redoc_state, container)'\n                : `init(\"spec.json\", ${JSON.stringify(redocOptions)}, container)`};\n\n    </script>`,\n            redocHead: ssr\n                ? (cdn\n                    ? '<script src=\"https://unpkg.com/redoc@latest/bundles/redoc.standalone.js\"></script>'\n                    : `<script>${redocStandaloneSrc}</script>`) + css\n                : '<script src=\"redoc.standalone.js\"></script>',\n            title: title || spec.info.title || 'ReDoc documentation',\n            disableGoogleFont,\n            templateOptions,\n        });\n    });\n}\n// credits: https://stackoverflow.com/a/9238214/1749888\nfunction respondWithGzip(contents, request, response, headers = {}) {\n    let compressedStream;\n    const acceptEncoding = request.headers['accept-encoding'] || '';\n    if (acceptEncoding.match(/\\bdeflate\\b/)) {\n        response.writeHead(200, Object.assign(Object.assign({}, headers), { 'content-encoding': 'deflate' }));\n        compressedStream = zlib.createDeflate();\n    }\n    else if (acceptEncoding.match(/\\bgzip\\b/)) {\n        response.writeHead(200, Object.assign(Object.assign({}, headers), { 'content-encoding': 'gzip' }));\n        compressedStream = zlib.createGzip();\n    }\n    else {\n        response.writeHead(200, headers);\n        if (typeof contents === 'string') {\n            response.write(contents);\n            response.end();\n        }\n        else {\n            contents.pipe(response);\n        }\n        return;\n    }\n    if (typeof contents === 'string') {\n        compressedStream.write(contents);\n        compressedStream.pipe(response);\n        compressedStream.end();\n        return;\n    }\n    else {\n        contents.pipe(compressedStream).pipe(response);\n    }\n}\nfunction isURL(str) {\n    return /^(https?:)\\/\\//m.test(str);\n}\nfunction sanitizeJSONString(str) {\n    return escapeClosingScriptTag(escapeUnicode(str));\n}\n// see http://www.thespanner.co.uk/2011/07/25/the-json-specification-is-now-wrong/\nfunction escapeClosingScriptTag(str) {\n    return str.replace(/<\\/script>/g, '<\\\\/script>');\n}\n// see http://www.thespanner.co.uk/2011/07/25/the-json-specification-is-now-wrong/\nfunction escapeUnicode(str) {\n    return str.replace(/\\u2028|\\u2029/g, m => '\\\\u202' + (m === '\\u2028' ? '8' : '9'));\n}\nfunction handleError(error) {\n    console.error(error.stack);\n    process.exit(1);\n}\nfunction getObjectOrJSON(options) {\n    switch (typeof options) {\n        case 'object':\n            return options;\n        case 'string':\n            try {\n                if (fs_1.existsSync(options) && fs_1.lstatSync(options).isFile()) {\n                    return JSON.parse(fs_1.readFileSync(options, 'utf-8'));\n                }\n                else {\n                    return JSON.parse(options);\n                }\n            }\n            catch (e) {\n                console.log(`Encountered error:\\n\\n${options}\\n\\nis neither a file with a valid JSON object neither a stringified JSON object.`);\n                handleError(e);\n            }\n        default:\n            const configFile = openapi_core_1.findConfig();\n            if (configFile) {\n                console.log(`Found ${configFile} and using features.openapi options`);\n                try {\n                    const config = openapi_core_2.parseYaml(fs_1.readFileSync(configFile, 'utf-8'));\n                    return config['features.openapi'];\n                }\n                catch (e) {\n                    console.warn(`Found ${configFile} but failed to parse: ${e.message}`);\n                }\n            }\n            return {};\n    }\n}\nfunction notifyDeprecation(res) {\n    console.log(boxen('This package is deprecated.\\n\\nUse `npx @redocly/cli build-docs <api>` instead.', boxenOptions));\n    return res;\n}\n"]}