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AAK,QAAQ,EAAW,UAC7C,CAEA,IACE,MAAM,eAAe,EAAgB,EACvC,CAAE,MAAO,GAKP,MAJA,EAAI,QACF,QACA,KAAK,QAAQ,QAAS,gBAAkB,GACxC,oDAAoD,wBAChD,CACR,CACF,CA5DE,CAAY,KAAK,OAAO,OAG1B,GAAG,SACD,KAAK,QAAQ,EAAW,aACxB,KAAK,QAAQ,EAAM,cAAe,cAEpC,GAAG,SACD,KAAK,QAAQ,EAAW,UACxB,KAAK,QAAQ,EAAM,gBAErB,GAAG,SACD,KAAK,QAAQ,EAAW,WACxB,KAAK,QAAQ,EAAM,iBAGlB,MAAM,SAAS,IAChB,MAAM,eAAe,EAAwB,GAI/C,cAEA,MAAM,KAAO,IAAI,KAAK,EAAgB,CACpC,SAAU,KAAK,SACf,KAAM,KAAK,OAGb,oBAAoB,KAAK,OAAO,kBAE1B,MAAM,UAAU,GACtB,GAAG,WAAW,GAEP,CACL,KAAM,EA2BV,CAEA,OAAO,QAAU","file":"/npm/ydoc@4.1.2/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/ydoc@4.1.2/src/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","const path = require(\"path\");\nconst fs = require(\"fs-extra\");\nconst noox = require(\"noox\");\nconst parse = require(\"./parse/parse.js\");\nconst utils = require(\"./utils\");\n\nconst loadPlugins = require(\"./plugin.js\").loadPlugins;\nconst ydoc = require(\"./ydoc.js\");\nconst ydocPath = path.resolve(__dirname, \"..\");\nconst loadMarkdownPlugins = require(\"./parse/markdown\").loadMarkdownPlugins;\n\nfunction initConfig(config){\n  const projectPath = utils.projectPath;\n  if(!config){    \n    const configFilepath = utils.getConfigPath(projectPath);\n    config = utils.getConfig(configFilepath);\n  }\n  \n  utils.extend(ydoc.config, config);\n  ydoc.config.dist = path.resolve(projectPath, ydoc.config.dist);  \n  ydoc.config.root = path.resolve(projectPath, ydoc.config.root);\n}\n\nasync function run(config) {\n  // init Resources path\n  initConfig(config)\n  const dist = ydoc.config.dist;\n  const root = ydoc.config.root;\n  const themePath = path.resolve(ydocPath, \"theme\"); \n  const customerComponentsPath = path.resolve(root, \"_components\");\n\n  const themeDist = path.resolve(dist, \"_theme\");\n  const componentsDist = path.resolve(themeDist, \"components\");\n\n  if(process.env.NODE_ENV === 'production'){\n    fs.removeSync(dist);\n  }\n  fs.ensureDirSync(dist); // 新建 my-project/_site \n  fs.ensureDirSync(themeDist); // 新建 my-project/_site/_theme\n\n  fs.copySync(root, dist); // docs => _site\n  fs.copySync(themePath, themeDist); // ydoc/theme => my-project/_site/_theme\n  if (ydoc.config.theme && ydoc.config.theme !== \"default\") {\n    handleTheme(ydoc.config.theme); // load custom theme\n  }\n\n  fs.copySync(\n    path.resolve(themeDist, \"style.css\"),\n    path.resolve(dist, \"ydoc/styles\", \"style.css\")\n  );\n  fs.copySync(\n    path.resolve(themeDist, \"images\"),\n    path.resolve(dist, \"ydoc/images\")\n  );\n  fs.copySync(\n    path.resolve(themeDist, \"scripts\"),\n    path.resolve(dist, \"ydoc/scripts\")\n  );\n\n  if(utils.dirExist(customerComponentsPath)){\n    utils.mergeCopyFiles(customerComponentsPath, componentsDist);\n  }\n  \n\n  loadPlugins();\n\n  utils.noox = new noox(componentsDist, {\n    relePath: ydoc.relePath,\n    hook: ydoc.hook\n  });\n\n  loadMarkdownPlugins(ydoc.config.markdownIt);\n\n  await parse.parseSite(dist);\n  fs.removeSync(themeDist);\n\n  return {\n    code: 0 //0 代表成功\n  }\n  \n  function handleTheme(theme) {\n    // 如果theme的文件夹中存在对应的theme，则使用对应的theme,没有的话使用node_modules\n    let themePath = path.resolve(process.cwd(), \"theme\");\n    let themeFile = path.resolve(themePath, \"./ydoc-theme-\" + theme);\n    let themeModuleDir;\n    // console.log('-----themeFile',themeFile)\n    if(fs.existsSync(themeFile)) {\n        themeModuleDir = themeFile;\n    } else {\n        let modules = path.resolve(process.cwd(), \"node_modules\");\n        let themeFile = path.resolve(modules, \"./ydoc-theme-\" + theme);\n        themeModuleDir = path.resolve(themeFile, \"./theme\");\n    }\n    // console.log('=======themeModuleDir', themeModuleDir)\n    try {\n      utils.mergeCopyFiles(themeModuleDir, themeDist);\n    } catch (err) {\n      err.message =\n        \"Load \" +\n        path.resolve(modules, \"./ydoc-theme-\" + theme) +\n        `theme failed, Please run \"npm install ydoc-theme-${theme}\" install the theme.`;\n      throw err;\n    }\n  }\n}\n\nmodule.exports = run;"]}