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AS,WAAW,KAGnB,EACD,MAAM,IAAI,MAAM,0BAGpB,MAAM,KAAE,EAAO,GAAc,EAAQ,WAAW,MAAQ,KAAI,KAAE,EAAO,GAAc,EAAQ,WAAW,MAAQ,aAAiB,EAEzH,EAAM,UAEZ,EAAI,IAAI,EAAQ,KAAM,QAAQ,OAAO,EAAQ,OAAQ,IAErD,EAAI,IAAI,MAAM,CAAC,EAAK,KACZ,EAAI,KAAK,WAAW,EAAQ,MAC5B,EAAI,SAAS,GAGb,EAAI,SAAS,EAAQ,KACzB,IAGJ,MAAM,EAAS,EAAI,OAAO,EAAM,GAAM,IAAM,UAAU,UAAM,OAAQ,GAAQ,YAE7C,mBAAhB,UACD,EAAY,EAAK,IAE3B,MAAM,EAAM,UAAU,KAAQ,IAAO,EAAQ,OAC7C,QAAQ,IAAI,yCAAyC,MAAM,KAAK,MAE5D,EAAW,MACX,IAAI,EACZ,MAE4B,mBAAjB,UACD,EAAa,EAAK,GAEhC,KACJ,IAEJ,OAAO,QAAU","file":"/npm/vuepress-plugin-serve@2.0.4/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.19.2.\n * Original file: /npm/vuepress-plugin-serve@2.0.4/lib/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","var __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};\nconst { existsSync } = require('fs');\nconst { resolve } = require('path');\nconst express = require('express');\nconst chalk = require('chalk');\nconst opn = require('opn');\nconst ServePlugin = ({ commandName = 'serve', notFoundPath = '404.html', host: optionHost, port: optionPort, staticOptions, beforeServer, afterServer, }, context) => ({\n    name: 'vuepress-plugin-serve',\n    extendCli(cli) {\n        cli\n            .command(commandName, 'serve generated files')\n            .option('-b, --build', 'build project before serving')\n            .option('-p, --port <port>', 'use specified port (default: 8080)')\n            .option('-c, --cache [cache]', 'set the directory of cache')\n            .option('--dest <dest>', 'the output directory for build process')\n            .option('--no-cache', 'clean the cache before build')\n            .option('--host <host>', 'use specified host (default: 0.0.0.0)')\n            .option('--open', 'open browser when ready')\n            .allowUnknownOptions()\n            .action((cliOptions) => __awaiter(this, void 0, void 0, function* () {\n            // resolve the absolute path of not found file\n            notFoundPath = resolve(context.outDir, notFoundPath);\n            // build project first if there is no 404.html\n            let has404 = existsSync(notFoundPath);\n            // build project first if specified\n            if (cliOptions.build || !has404) {\n                process.env.NODE_ENV = 'production';\n                yield context.build();\n                has404 = existsSync(notFoundPath);\n            }\n            // ensure that a 404 file exists\n            if (!has404) {\n                throw new Error('No 404.html was found.');\n            }\n            // host and port priority: cli > options > siteConfig > default\n            const { port = optionPort || context.siteConfig.port || 8080, host = optionHost || context.siteConfig.host || 'localhost', } = cliOptions;\n            // express instance\n            const app = express();\n            // serve static files\n            app.use(context.base, express.static(context.outDir, staticOptions));\n            // fallback to base url\n            app.get(/.*/, (req, res) => {\n                if (req.path.startsWith(context.base)) {\n                    res.sendFile(notFoundPath);\n                }\n                else {\n                    res.redirect(context.base);\n                }\n            });\n            // create server\n            const server = app.listen(port, host, () => __awaiter(this, void 0, void 0, function* () {\n                // apply afterServer hook\n                if (typeof afterServer === 'function') {\n                    yield afterServer(app, server);\n                }\n                const url = `http://${host}:${port}${context.base}`;\n                console.log(`VuePress static files is listening at ${chalk.blue(url)}`);\n                // open browser when ready\n                if (cliOptions.open)\n                    opn(url);\n            }));\n            // apply beforeServer hook\n            if (typeof beforeServer === 'function') {\n                yield beforeServer(app, server);\n            }\n        }));\n    },\n});\nmodule.exports = ServePlugin;\n"]}