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,KAG/B,EAAI,gBAAgB,qBAAqB,eAC1B,EAAS,MAAO,KAG/B,EAAI,gBAAgB,qBAAqB,eAC1B,EAAS,MAAO,KAG/B,EAAI,gBAAgB,qBAAqB,eAC1B,EAAS,MAAO,KAG/B,EAAI,gBAAgB,mBAAmB,eACxB,EAAW,KAG1B,EAAI,gBAAgB,yBAAyB,UAC3C,EAAK,MAAO,EACZ,MAAM,EAAW,UAGjB,OAFA,EAAa,GACb,EAAmB,SACN,EAAI,QAAQ,IAAI,QAAS,EAAI,IAE5C,EAAI,gBAAgB,yBAAyB,eAC9B,EAAS,UAAW,IAClC,EAGH,OAAO,QAAQ,aAAe","file":"/npm/@llblumire/vue-cli-plugin-cordova@2.1.5/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@llblumire/vue-cli-plugin-cordova@2.1.5/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 spawn = require('cross-spawn')\r\nconst { info, error } = require('@vue/cli-shared-utils')\r\nconst fs = require('fs')\r\nconst portfinder = require('portfinder')\r\nconst address = require('address')\r\nconst defaults = require('./defaults')\r\nconst defaultServe = require('./default-serve')\r\n\r\nconst defaultModes = {\r\n  'cordova-serve-electron': 'development',\r\n  'cordova-build-electron': 'production',\r\n  'cordova-serve-android': 'development',\r\n  'cordova-build-android': 'production',\r\n  'cordova-serve-ios': 'development',\r\n  'cordova-build-ios': 'production',\r\n  'cordova-serve-browser': 'development',\r\n  'cordova-build-browser': 'production',\r\n  'cordova-serve-osx': 'development',\r\n  'cordova-build-osx': 'production'\r\n}\r\n\r\nmodule.exports = (api, options) => {\r\n  const cordovaPath = options.pluginOptions.cordovaPath || defaults.cordovaPath\r\n  const srcCordovaPath = api.resolve(cordovaPath)\r\n\r\n  const getPlatformPath = platform => {\r\n    return api.resolve(`${cordovaPath}/platforms/${platform}`)\r\n  }\r\n\r\n  const getPlatformPathWWW = platform => {\r\n    return api.resolve(`${cordovaPath}/platforms/${platform}/platform_www`)\r\n  }\r\n\r\n  const getCordovaPathConfig = () => {\r\n    return api.resolve(`${cordovaPath}/config.xml`)\r\n  }\r\n\r\n  const cordovaRun = platform => {\r\n    // cordova run platform\r\n    info(`executing \"cordova run ${platform}\" in folder ${srcCordovaPath}`)\r\n    return spawn.sync('cordova', [\r\n      'run',\r\n      platform\r\n    ], {\r\n      cwd: srcCordovaPath,\r\n      env: process.env,\r\n      stdio: 'inherit', // pipe to console\r\n      encoding: 'utf-8'\r\n    })\r\n  }\r\n\r\n  const cordovaPrepare = () => {\r\n    // cordova run platform\r\n    info(`executing \"cordova prepare in folder ${srcCordovaPath}`)\r\n    return spawn.sync('cordova', [\r\n      'prepare'\r\n    ], {\r\n      cwd: srcCordovaPath,\r\n      env: process.env,\r\n      stdio: 'inherit', // pipe to console\r\n      encoding: 'utf-8'\r\n    })\r\n  }\r\n\r\n  const cordovaBuild = (platform, release = true) => {\r\n    // cordova run platform\r\n    const cordovaMode = release ? '--release' : '--debug'\r\n    info(`executing \"cordova build ${platform} ${cordovaMode}\" in folder ${srcCordovaPath}`)\r\n    return spawn.sync('cordova', [\r\n      'build',\r\n      platform,\r\n      cordovaMode\r\n    ], {\r\n      cwd: srcCordovaPath,\r\n      env: process.env,\r\n      stdio: 'inherit', // pipe to console\r\n      encoding: 'utf-8'\r\n    })\r\n  }\r\n\r\n  const cordovaClean = () => {\r\n    // cordova clean\r\n    info(`executing \"cordova clean\" in folder ${srcCordovaPath}`)\r\n    return spawn.sync('cordova', [\r\n      'clean'\r\n    ], {\r\n      cwd: srcCordovaPath,\r\n      env: process.env,\r\n      stdio: 'inherit', // pipe to console\r\n      encoding: 'utf-8'\r\n    })\r\n  }\r\n\r\n  const cordovaJSMiddleware = platform => {\r\n    return (req, res, next) => {\r\n      if (req.url !== '/') {\r\n        const filePath = getPlatformPathWWW(platform) + req.url\r\n        try {\r\n          if (fs.existsSync(filePath)) {\r\n            const fileContent = fs.readFileSync(filePath, 'utf-8')\r\n            res.send(fileContent)\r\n            return\r\n          }\r\n        } catch (err) {\r\n        }\r\n      }\r\n      next()\r\n    }\r\n  }\r\n\r\n  const cordovaContent = (resetNavigation, url) => {\r\n    const cordovaConfigPath = getCordovaPathConfig()\r\n    let cordovaConfig = fs.readFileSync(cordovaConfigPath, 'utf-8')\r\n    let lines = cordovaConfig.split(/\\r?\\n/g).reverse()\r\n    const regexContent = /\\s+<content/\r\n    const contentIndex = lines.findIndex(line => line.match(regexContent))\r\n    const allowNavigation = `<allow-navigation href=\"${url}\" />`\r\n    if (contentIndex >= 0) {\r\n      if (resetNavigation) {\r\n        lines[contentIndex] = `    <content src=\"index.html\" />`\r\n        lines = lines.filter(line => !line.includes(allowNavigation))\r\n      } else {\r\n        lines[contentIndex] = `    <content src=\"${url}\" />`\r\n        lines.splice(contentIndex, 0, allowNavigation)\r\n      }\r\n    }\r\n\r\n    cordovaConfig = lines.reverse().join('\\n')\r\n    fs.writeFileSync(cordovaConfigPath, cordovaConfig)\r\n  }\r\n\r\n  const runServe = async (platform, args) => {\r\n    const availablePlatforms = []\r\n    const platforms = defaults.platforms\r\n\r\n    platforms.forEach(platform => {\r\n      const platformPath = getPlatformPath(platform)\r\n      if (fs.existsSync(platformPath)) {\r\n        availablePlatforms.push(platform)\r\n      }\r\n    })\r\n\r\n    if (availablePlatforms.includes(platform)) {\r\n      // add cordova.js, define process.env.CORDOVA_PLATFORM\r\n      chainWebPack(platform)\r\n      // Add js middleware\r\n      configureDevServer(platform)\r\n\r\n      const projectDevServerOptions = options.devServer || {}\r\n      // resolve server options\r\n      const open = false // browser does not need to be opened\r\n      const https = options.devServer.https || false // check devServer.options for user defined https setting\r\n      const protocol = https ? 'https' : 'http'\r\n      const host = args.host || process.env.HOST || projectDevServerOptions.host || defaultServe.host\r\n      let port = args.port || process.env.PORT || projectDevServerOptions.port || defaultServe.port\r\n      portfinder.basePort = port\r\n      port = await portfinder.getPortPromise()\r\n      const publicArg = args.public || projectDevServerOptions.public\r\n      const defaultPublicURL = `${protocol}://${address.ip()}:${port}`\r\n      const rawPublicUrl = publicArg || defaultPublicURL\r\n      const publicUrl = rawPublicUrl\r\n        ? /^[a-zA-Z]+:\\/\\//.test(rawPublicUrl)\r\n          ? rawPublicUrl\r\n          : `${protocol}://${rawPublicUrl}`\r\n        : null\r\n\r\n      const serveArgs = {\r\n        open,\r\n        host,\r\n        port,\r\n        https,\r\n        public: publicArg\r\n      }\r\n      // npm run serve\r\n      const server = await api.service.run('serve', serveArgs)\r\n\r\n      // on kill, reset cordova config.xml\r\n      const signals = ['SIGINT', 'SIGTERM']\r\n      signals.forEach(signal => {\r\n        process.on(signal, () => {\r\n          cordovaContent(true, publicUrl)\r\n        })\r\n      })\r\n\r\n      // set content url to devServer\r\n      info(`updating cordova config.xml content to ${publicUrl}`)\r\n      cordovaContent(false, publicUrl)\r\n\r\n      cordovaClean()\r\n\r\n      cordovaRun(platform)\r\n\r\n      return server\r\n    } else {\r\n      if (availablePlatforms.length === 0) {\r\n        error(`No platforms installed in '${srcCordovaPath}', please execute \"cordova platform add ${platform}\" in ${srcCordovaPath}`)\r\n      } else {\r\n        error(`Missing platform '${platform}', please execute \"cordova platform add ${platform}\" in ${srcCordovaPath}`)\r\n      }\r\n    }\r\n  }\r\n\r\n  const runBuild = async (platform, args) => {\r\n    // add cordova.js, define process.env.CORDOVA_PLATFORM\r\n    chainWebPack(platform)\r\n    // set build output folder\r\n    args.dest = cordovaPath + '/www'\r\n    // build\r\n    await api.service.run('build', args)\r\n    // cordova clean\r\n    await cordovaClean()\r\n    // cordova build --release (if you want a build debug build, use cordovaBuild(platform, false)\r\n    await cordovaBuild(platform)\r\n  }\r\n\r\n  const runPrepare = async (args) => {\r\n    // add cordova.js, define process.env.CORDOVA_PLATFORM\r\n    chainWebPack(null)\r\n    // set build output folder\r\n    args.dest = cordovaPath + '/www'\r\n    // build\r\n    await api.service.run('build', args)\r\n\r\n    // cordova prepare\r\n    await cordovaPrepare()\r\n  }\r\n\r\n  const configureDevServer = platform => {\r\n    api.configureDevServer(app => {\r\n      // /cordova.js should resolve to platform cordova.js\r\n      app.use(cordovaJSMiddleware(platform))\r\n    })\r\n  }\r\n\r\n  const chainWebPack = platform => {\r\n    api.chainWebpack(webpackConfig => {\r\n      // add cordova.js to index.html\r\n      webpackConfig.plugin('cordova')\r\n                .use(require('html-webpack-include-assets-plugin'), [{\r\n                  assets: 'cordova.js',\r\n                  append: false,\r\n                  publicPath: false\r\n                }])\r\n\r\n      // process.env.CORDOVA_PLATFORM = platform\r\n      if (platform !== null) {\r\n        webpackConfig.plugin('define')\r\n                  .tap(args => {\r\n                    const { 'process.env': env, ...rest } = args[0]\r\n                    return [{\r\n                      'process.env': Object.assign(\r\n                        {},\r\n                        env,\r\n                        {\r\n                          CORDOVA_PLATFORM: '\\'' + platform + '\\''\r\n                        }\r\n                      ),\r\n                      ...rest\r\n                    }]\r\n                  })\r\n      }\r\n\r\n    })\r\n  }\r\n\r\n  api.registerCommand('cordova-serve-electron', async args => {\r\n    return await runServe('electron', args)\r\n  })\r\n\r\n  api.registerCommand('cordova-build-electron', async args => {\r\n    return await runBuild('electron', args)\r\n  })\r\n\r\n  api.registerCommand('cordova-serve-android', async args => {\r\n    return await runServe('android', args)\r\n  })\r\n\r\n  api.registerCommand('cordova-build-android', async args => {\r\n    return await runBuild('android', args)\r\n  })\r\n\r\n  api.registerCommand('cordova-serve-ios', async args => {\r\n    return await runServe('ios', args)\r\n  })\r\n\r\n  api.registerCommand('cordova-build-ios', async args => {\r\n    return await runBuild('ios', args)\r\n  })\r\n\r\n  api.registerCommand('cordova-serve-osx', async args => {\r\n    return await runServe('osx', args)\r\n  })\r\n\r\n  api.registerCommand('cordova-build-osx', async args => {\r\n    return await runBuild('osx', args)\r\n  })\r\n\r\n  api.registerCommand('cordova-prepare', async args => {\r\n    return await runPrepare(args)\r\n  })\r\n\r\n  api.registerCommand('cordova-serve-browser', async args => {\r\n    args.open = true\r\n    const platform = 'browser'\r\n    chainWebPack(platform)\r\n    configureDevServer(platform)\r\n    return await api.service.run('serve', args)\r\n  })\r\n  api.registerCommand('cordova-build-browser', async args => {\r\n    return await runBuild('browser', args)\r\n  })\r\n}\r\n\r\nmodule.exports.defaultModes = defaultModes\r\n"]}