UNPKG

@revues/code-compiler

Version:

A code compiler for compile huya miniapp

1,760 lines (1,682 loc) 567 kB
/*! * @revues/code-compiler * (c) 2024-2025 Alex * Released under the MIT License. */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var fs = require('fs-extra'); var path = require('path'); var crypto = require('crypto'); var minimatch = require('minimatch'); var javascriptObfuscator = require('javascript-obfuscator'); var lodash = require('lodash'); var perf_hooks = require('perf_hooks'); require('get-proxy'); var realRequest = require('request'); var jsonschema = require('jsonschema'); var parser = require('@babel/parser'); var traverse$1 = require('@babel/traverse'); var sourceMap = require('source-map'); var codeFrame = require('@babel/code-frame'); var acorn = require('acorn'); var glob = require('glob'); var rimraf = require('rimraf'); var rpt = require('read-package-tree'); var htmlparser2 = require('htmlparser2'); var os = require('os'); var core = require('@babel/core'); var fs$1 = require('fs'); var WokerThreads = require('worker_threads'); var child_process = require('child_process'); var UglifyJS = require('uglify-js'); var helperModuleImports = require('@babel/helper-module-imports'); var autoprefixer = require('autoprefixer'); var postcss = require('postcss'); var cluster = require('cluster'); var EventEmitter$1 = require('eventemitter3'); var transformModulesCommonjsPlugin = require('@babel/plugin-transform-modules-commonjs'); var DefinePlugin = require('babel-plugin-transform-define'); var less = require('less'); var sass = require('sass'); var TransformTSPlugin = require('@babel/plugin-transform-typescript'); var postcssColorHexAlpha = require('postcss-color-hex-alpha'); var valueParser = require('postcss-value-parser'); var analyse = require('@revues/code-analyzer'); var convert = require('convert-source-map'); var archiver = require('archiver'); var terser = require('terser'); var PresetEnv = require('@babel/preset-env'); var types = require('@babel/types'); var wxmlTranspiler = require('@revues/wxml-transpiler'); var flatted = require('flatted'); var wxssTranspiler = require('@revues/wxss-transpiler'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); var path__default = /*#__PURE__*/_interopDefaultLegacy(path); var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto); var minimatch__default = /*#__PURE__*/_interopDefaultLegacy(minimatch); var lodash__default = /*#__PURE__*/_interopDefaultLegacy(lodash); var realRequest__default = /*#__PURE__*/_interopDefaultLegacy(realRequest); var parser__default = /*#__PURE__*/_interopDefaultLegacy(parser); var traverse__default = /*#__PURE__*/_interopDefaultLegacy(traverse$1); var codeFrame__default = /*#__PURE__*/_interopDefaultLegacy(codeFrame); var acorn__default = /*#__PURE__*/_interopDefaultLegacy(acorn); var rimraf__default = /*#__PURE__*/_interopDefaultLegacy(rimraf); var rpt__default = /*#__PURE__*/_interopDefaultLegacy(rpt); var fs__default$1 = /*#__PURE__*/_interopDefaultLegacy(fs$1); var WokerThreads__default = /*#__PURE__*/_interopDefaultLegacy(WokerThreads); var UglifyJS__default = /*#__PURE__*/_interopDefaultLegacy(UglifyJS); var autoprefixer__default = /*#__PURE__*/_interopDefaultLegacy(autoprefixer); var postcss__default = /*#__PURE__*/_interopDefaultLegacy(postcss); var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter$1); var transformModulesCommonjsPlugin__default = /*#__PURE__*/_interopDefaultLegacy(transformModulesCommonjsPlugin); var DefinePlugin__default = /*#__PURE__*/_interopDefaultLegacy(DefinePlugin); var less__default = /*#__PURE__*/_interopDefaultLegacy(less); var sass__default = /*#__PURE__*/_interopDefaultLegacy(sass); var TransformTSPlugin__default = /*#__PURE__*/_interopDefaultLegacy(TransformTSPlugin); var postcssColorHexAlpha__default = /*#__PURE__*/_interopDefaultLegacy(postcssColorHexAlpha); var valueParser__default = /*#__PURE__*/_interopDefaultLegacy(valueParser); var analyse__default = /*#__PURE__*/_interopDefaultLegacy(analyse); var convert__default = /*#__PURE__*/_interopDefaultLegacy(convert); var archiver__default = /*#__PURE__*/_interopDefaultLegacy(archiver); var PresetEnv__default = /*#__PURE__*/_interopDefaultLegacy(PresetEnv); var types__default = /*#__PURE__*/_interopDefaultLegacy(types); var flatted__default = /*#__PURE__*/_interopDefaultLegacy(flatted); // 抖音小程序 // 默认配置,默认支持 hy, wx, 上述配置配置会额外添加于此 const Default_DSL = { alias: [], wxml: ["wxml", "hyml"], wxss: ["wxss", "hyss"], wxs: ["wxs", "hys"], prefix: ["wx", "hy"], js: ['ts'], // 这个特殊的平台配置 将被 remove finClipConf: ["FinClipConf.js", "FinChatConf.js"], }; const BasicCodeExts = ['js', 'wxml', 'wxss', 'json', 'wxs', 'ts']; const GameBasicCodeExts = ['js']; const FileType = { JSON: 'json', WXML: 'wxml', WXSS: 'wxss', WXS: 'wxs', JS: 'js' }; const AstType = { Babel: 'Babel', Acorn: 'Acorn' }; var COMPILE_SOURCES; (function (COMPILE_SOURCES) { COMPILE_SOURCES["wx"] = "wx"; COMPILE_SOURCES["tt"] = "tt"; COMPILE_SOURCES["ali"] = "ali"; COMPILE_SOURCES["hy"] = "hy"; })(COMPILE_SOURCES || (COMPILE_SOURCES = {})); const BUNDLE_TYPE$1 = { miniProgram: 'miniProgram', lowEnergy: 'lowEnergy' }; const BABEL_TRANS_JS_ERR = 10032; const UGLIFY_JS_ERR = 10033; const POST_WXSS_ERR = 10037; const MINIFY_WXML_ERR = 10038; const GAME_PLUGIN_LIB_MD5_NOT_MATCH = 10081; const PLUGIN_JSON_FILE_NOT_FOUND = 10091; const PLUGIN_JSON_CONTENT_ERR = 10092; const FILE_NOT_FOUND = 10005; const JSON_PARSE_ERR = 10006; const FILE_NOT_UTF8$1 = 10031; const JSON_CONTENT_ERR = 10009; const GET_SIGNATURE_RAND_STRING_ERR = 20001; const GENERATE_LOCAL_SIGNATURE_ERR = 20002; const CODE_PROTECT_TRANSLATE_FILENAME = 20004; const MINI_PROGRAM_MAIN_PACKAGE_ROOT = '__APP__'; const MINI_GAME_MAIN_PACKAGE_ROOT = '__GAME__'; const DefaultProjectAttr = { platform: !1, appType: 0, isSandbox: !1, released: !1, setting: { MaxCodeSize: 2, MaxSubpackageSubCodeSize: 2, MaxSubpackageFullCodeSize: 12, NavigateMiniprogramLimit: 10, MaxSubPackageLimit: 100, MinTabbarCount: 2, MaxTabbarCount: 5, MaxTabbarIconSize: 40 } }; var COMPILE_TYPE; (function (COMPILE_TYPE) { COMPILE_TYPE["miniProgram"] = "miniProgram"; COMPILE_TYPE["miniProgramPlugin"] = "miniProgramPlugin"; COMPILE_TYPE["miniGame"] = "miniGame"; COMPILE_TYPE["miniGamePlugin"] = "miniGamePlugin"; })(COMPILE_TYPE || (COMPILE_TYPE = {})); const TABBAR_ICON_WHITE_LIST = ['.png', '.jpg', '.jpeg']; const jsonVariablePropertyWhiteList = { windowPropertWhiteList: [ 'navigationBarBackgroundColor', 'navigationBarTextStyle', 'backgroundColor', 'backgroundTextStyle', 'backgroundColorTop', 'backgroundColorBottom', 'backgroundColorContent' ], tabBarPropertyWhiteList: [ 'color', 'selectedColor', 'backgroundColor', 'borderStyle' ], tabbarListItemPropertyWhiteList: ['iconPath', 'selectedIconPath'] }; const extendedLibMap = { kbone: { packages: ['miniprogram-element', 'miniprogram-render'] }, weui: { packages: ['weui-miniprogram'] } }; const store = {}; function performanceMark(key, end) { (end ? (console.timeEnd(key), (store[key] = Date.now() - store[key]), 'total time' === key && console.log(store)) : ((store[key] = Date.now()), console.time(key))); } const old = '0.0.2'; function getCompilerVersion() { let current = old; try { current = '1.0.35'; } catch (e) {} return current } function normalizePath$1(filePath = '') { const format = path__default["default"].posix.normalize(filePath.replace(/\\/g, '/')); const hasSlash = (!filePath.startsWith('//') && !filePath.startsWith('\\\\')) || format.startsWith('//'); return hasSlash ? format : '/' + format } function addSlashSuffix(subPath, suffix, filePath = false) { return filePath ? subPath.endsWith(suffix) ? subPath.slice(0, subPath.length - 1) : subPath : subPath.endsWith(suffix) ? subPath : subPath + suffix } function addSlashPrefix(subPath, prefix, filePath = false) { return filePath ? subPath.startsWith(prefix) ? subPath.slice(1) : subPath : subPath.startsWith(prefix) ? subPath : prefix + subPath } function createFilePathMatchFnBySameRules() { let lastRules = null, cache = Object.create(null); return function filePathMatchBySameRule(filePath, rules) { if (rules.length < 1) return false if (lastRules === rules) { if (void 0 !== cache[filePath]) return cache[filePath] } else { lastRules = rules; cache = Object.create(null); } const formatedPath = filePath.replace(/\\/g, '/').toLowerCase(); if (!formatedPath) return false const subPath = formatedPath.slice(formatedPath.lastIndexOf('/') + 1); let result = false; for (const match of rules) { if (!match || !match.type || !match.value) continue const value = match.value.toLowerCase(); if ('prefix' === match.type) result = subPath.startsWith(value); else if ('suffix' === match.type) result = subPath.endsWith(value); else if ('folder' === match.type) result = addSlashPrefix(formatedPath, '/').startsWith( addSlashSuffix(addSlashPrefix(value, '/'), '/') ); else if ('file' === match.type) result = addSlashPrefix(formatedPath, '/') === addSlashPrefix(value, '/'); else if ('glob' === match.type) try { result = minimatch__default["default"](formatedPath, value) || minimatch__default["default"](addSlashPrefix(formatedPath, '/'), value); } catch (e) { result = false; } else if ('regexp' === match.type) try { result = new RegExp(value, 'igm').test(formatedPath) || new RegExp(value, 'igm').test(addSlashPrefix(formatedPath, '/')); } catch (e) { result = false; } if (result) break } cache[filePath] = result; return result } } const isFileIgnored = createFilePathMatchFnBySameRules(); const isFileIncluded = createFilePathMatchFnBySameRules(); function generateMD5(e) { const t = crypto__default["default"].createHash('md5'); return t.update(e), t.digest('hex') } const bufferToUtf8String = (e) => { const t = e.toString(); if (0 === Buffer.compare(Buffer.from(t, 'utf8'), e)) return t }; function leading(e, t, s = !1) { return s ? e.startsWith(t) ? e.slice(1) : e : e.startsWith(t) ? e : t + e } function getType(e) { return Object.prototype.toString .call(e) .toLowerCase() .split(' ')[1] .replace(']', '') } const formatJSONParseErr = (e) => { const t = e.data || ''; try { u.parse(t); } catch (s) { try { const r = `Expecting ${s.expected}, got ${s.token}`, n = (function (e, t, s, r) { return (s = s > 0 ? s : 1), `${r}\n${(0, a.default)(e, t, s)}` })(t, s.line, s.loc.first_column, r); return `${e.filePath}\n${n}` } catch (e) {} } return `${e.filePath}\n${e.error}` }; function isHexColor$1(e) { return ( /^#[a-f\d]{3}$/i.test(e) || /^#[a-f\d]{4}$/i.test(e) || /^#[a-f\d]{6}$/i.test(e) || /^#[a-f\d]{8}$/i.test(e) ) } function formatSourceMap(e) { if (e) { if ('string' === getType(e)) return e try { return JSON.stringify(e) } catch (e) {} } } function ensureAbsPath(source, context) { return path__default["default"].isAbsolute(source) ? source : path__default["default"].join(context, source) } // 子进程 const cpprocessEnv = process.env.cpprocessEnv; const processEnv = 'childprocess' === cpprocessEnv || 'workerthread' === cpprocessEnv || 'workerprocess' === cpprocessEnv ? cpprocessEnv : 'main'; // 宿主 const env = process.env; const hostEnv = (env && env.isDevtools) || (process.__nwjs && 'wechatwebdevtools' === nw.App.manifest.appname) ? 'devtools' : 'ci'; const blenderProcess = "1" === process.env.blenderProcess; const babelHelperApiConf = { applyDecoratedDescriptor: [], arrayLikeToArray: [], arrayWithHoles: [], arrayWithoutHoles: ['arrayLikeToArray'], assertThisInitialized: [], AsyncGenerator: ['AwaitValue'], asyncGeneratorDelegate: [], asyncIterator: [], asyncToGenerator: [], awaitAsyncGenerator: ['AwaitValue'], AwaitValue: [], classCallCheck: [], classNameTDZError: [], classPrivateFieldDestructureSet: [], classPrivateFieldGet: [], classPrivateFieldLooseBase: [], classPrivateFieldLooseKey: [], classPrivateFieldSet: [], classPrivateMethodGet: [], classPrivateMethodSet: [], classStaticPrivateFieldSpecGet: [], classStaticPrivateFieldSpecSet: [], classStaticPrivateMethodGet: [], classStaticPrivateMethodSet: [], construct: ['setPrototypeOf', 'isNativeReflectConstruct'], createClass: [], createForOfIteratorHelper: ['unsupportedIterableToArray'], createForOfIteratorHelperLoose: ['unsupportedIterableToArray'], createSuper: [ 'getPrototypeOf', 'isNativeReflectConstruct', 'possibleConstructorReturn' ], decorate: ['toArray', 'toPropertyKey'], defaults: [], defineEnumerableProperties: [], defineProperty: [ 'toPropertyKey' ], extends: [], get: ['superPropBase'], getPrototypeOf: [], inherits: ['setPrototypeOf'], inheritsLoose: [], initializerDefineProperty: [], initializerWarningHelper: [], instanceof: [], interopRequireDefault: [], interopRequireWildcard: ['typeof'], isNativeFunction: [], isNativeReflectConstruct: [], iterableToArray: [], iterableToArrayLimit: [], iterableToArrayLimitLoose: [], jsx: [], maybeArrayLike: ['arrayLikeToArray'], newArrowCheck: [], nonIterableRest: [], nonIterableSpread: [], objectDestructuringEmpty: [], objectSpread: ['defineProperty'], objectSpread2: ['defineProperty'], objectWithoutProperties: ['objectWithoutPropertiesLoose'], objectWithoutPropertiesLoose: [], possibleConstructorReturn: ['typeof', 'assertThisInitialized'], readOnlyError: [], set: ['superPropBase', 'defineProperty'], setPrototypeOf: [], skipFirstGeneratorNext: [], slicedToArray: [ 'arrayWithHoles', 'iterableToArrayLimit', 'unsupportedIterableToArray', 'nonIterableRest' ], slicedToArrayLoose: [ 'arrayWithHoles', 'iterableToArrayLimitLoose', 'unsupportedIterableToArray', 'nonIterableRest' ], superPropBase: ['getPrototypeOf'], taggedTemplateLiteral: [], taggedTemplateLiteralLoose: [], tdz: [], temporalRef: ['temporalUndefined', 'tdz'], temporalUndefined: [], toArray: [ 'arrayWithHoles', 'iterableToArray', 'unsupportedIterableToArray', 'nonIterableRest' ], toConsumableArray: [ 'arrayWithoutHoles', 'iterableToArray', 'unsupportedIterableToArray', 'nonIterableSpread' ], toPrimitive: ['typeof'], toPropertyKey: ['typeof', 'toPrimitive'], typeof: [], unsupportedIterableToArray: ['arrayLikeToArray'], wrapAsyncGenerator: ['AsyncGenerator'], wrapNativeSuper: [ 'getPrototypeOf', 'setPrototypeOf', 'isNativeFunction', 'construct' ], wrapRegExp: [ 'typeof', 'wrapNativeSuper', 'getPrototypeOf', 'possibleConstructorReturn', 'inherits' ], regeneratorRuntime: [ 'typeof' ], Objectentries: [], Objectvalues: [], Arrayincludes: [], regenerator: [ 'regeneratorRuntime' ], callSuper: [ 'getPrototypeOf', 'isNativeReflectConstruct', 'possibleConstructorReturn' ] }; async function appendBabelHelpers(e, t, s, r) { const o = getHelperDeps(Array.from(e), s), a = Object.keys(o).map(async e => { try { const o = await getHelperContent(e, s), a = normalizePath$1( path__default["default"].posix.join(t, /\.js$/.test(e) ? '' + e : e + '.js') ); r[a] || (r[a] = o); } catch (e) { if ('ENOENT' !== e.code && 'EEXIST' !== e.code) throw e } }); return Promise.all(a) } function getHelperDeps(helperNames, prefix) { const moduleInfo = {}; function collectHelperDeps(graph) { while (graph.length) { const helperName = graph.shift() || '', scope = helperName.substr(0, helperName.indexOf(prefix) + prefix.length), helperFileName = helperName.replace(scope + '/helpers/', ''); if (babelHelperApiConf[helperFileName]) { babelHelperApiConf[helperFileName].forEach(dep => { const fullDep = `${scope}/helpers/${dep}`; if (!moduleInfo[fullDep]) { moduleInfo[fullDep] = true; graph.push(fullDep); } }); } moduleInfo[helperName] = true; } } collectHelperDeps(helperNames); // 收集 generator runtime deps if (moduleInfo[prefix + '/regenerator']) { collectHelperDeps([prefix + '/helpers/' + 'regeneratorRuntime']); } return moduleInfo } function isIgnore(e, t) { const s = e || [], r = t.split(path__default["default"].sep).join('/'); for (const e of s) { if (t === e) return !0 if ( !/^[./\\]+/.test(e) && /.+\/\*$/.test(e) && -1 !== r.indexOf(e.substr(0, e.length - 1)) ) return !0 } return !1 } function getHelperContent(e, t) { const s = e.substr(0, e.indexOf(t) + t.length), o = e.replace(s, 'babel_runtime'), a = normalizePath$1(path__default["default"].join(__dirname, ('../' ) + 'vendor/', o + '.js')); return fs__default["default"].readFile(a, 'utf8') } function collectBabelHelpers(e) { const t = {}; return ( e.replace( /require\("(@babel\/runtime\/[^"]+)"\)/gi, (e, s) => ((t[s] = !0), e) ), t ) } function replaceBabelHelpers(e, t, s, r) { t || (t = {}); // 按照commonjs相对路径规范引入模块 const n = new Set(), i = s .split('/') .map((e, t) => (0 === t ? '' : '../')) .join(''); return { transformCode: e.replace( /require\("(@babel\/runtime\/[^"]+)"\)/gi, (e, s) => { const o = s .replace(/@babel\/runtime\/(helpers\/)?/, '') .replace(/\.js$/, ''), a = s.replace('@babel/runtime', r), c = Object.prototype.hasOwnProperty.call(babelHelperApiConf, o); return !t[s] && c ? (n.add(a), `require("${i + a}")`) : e } ), helpers: Array.from(n) } } function getDefaultPlugins() { const e = [ [require.resolve('@babel/plugin-proposal-function-bind'), 0], // proposal-function-bind [require.resolve('@babel/plugin-proposal-export-default-from'), 0], // proposal-export-default-from [ require.resolve('@babel/plugin-proposal-pipeline-operator'), { proposal: 'minimal' } ], // proposal-pipeline-operator [require.resolve('@babel/plugin-proposal-do-expressions'), 0], // proposal-do-expressions [require.resolve('@babel/plugin-proposal-decorators'), { legacy: !0 }], // proposal-decorators [require.resolve('@babel/plugin-proposal-function-sent'), 0], // proposal-function-sent [require.resolve('@babel/plugin-proposal-throw-expressions'), 0], // proposal-throw-expressions [require.resolve('@babel/plugin-proposal-class-properties'), { loose: !0 }], // proposal-class-properties [require.resolve('@babel/plugin-proposal-private-methods'), { loose: !0 }] // proposal-private-methods ]; return new Map(e) } function getCustomPlugins(extra = []) { const base = getDefaultPlugins(); const result = []; for (const [pluginName, options] of base) 0 === options ? result.push(pluginName) : result.push([pluginName, options]); return result } const base = 'https://servicewechat.com'; const GET_RAND_STRING = base + '/wxa/ci/getrandstr'; const TRANSLATE_FILENAME = base + '/wxa/ci/translate_filename'; class FormatableString { constructor(v) { this.v = v; } format(...args) { const first = args[0]; let tamplateStr = this.v; if ('[object Array]' === Object.prototype.toString.call(first)) { first.forEach(e => { tamplateStr = tamplateStr.replace('%s', e); }); } else { args.forEach(e => { tamplateStr = tamplateStr.replace('%s', e); }); } return tamplateStr } } const template$2 = { GENERATE_LOCAL_SIGNATURE_FAIL: '生成本地签名失败。通常是key文件编码或者内容有误。错误详情: %s', PARAM_ERROR: '方法:"%s" 缺少参数:"%s"', SHOULD_NOT_BE_EMPTY: '%s 不能为空', JSON_CONTENT_SHOULD_BE: '%s 字段需为 %s', SHOULD_AT_LEAST_ONE_ITEM: '%s 需至少存在一项', SHOULD_MATCH: '%s 需与 %s 匹配', SHOULD_EQUAL: '%s 需等于 %s', EXT_SHOULD_BE_ERROR: '%s 的拓展名需为 "%s"', OR: '或', CORRESPONDING_FILE_NOT_FOUND: '未找到 %s 对应的 %s 文件', JSON_SHOULD_NOT_START_WITH: "%s 不应该以 '%s' 开头", JSON_SHOULD_NOT_CONTAIN: '%s 不应该包含 %s', NOT_FOUND: '%s 未找到', NOT_FOUND_IN_ROOT_DIR: '在项目根目录未找到 %s ', MINIPROGRAM_APP_JSON_NOT_FOUND: '根据 project.config.json 中 miniprogramRoot 指定的小程序目录 %s,%s 未找到', PLUGIN_JSON_NOT_FOUND: '根据 project.config.json 中 pluginRoot 指定的小程序本地开发插件目录 %s,%s 未找到', PLUGIN_PATH_SAME_WITH_MINIPROGRAM: 'project.config.json 中 pluginRoot 指定的小程序本地开发插件目录 %s,与小程序目录 %s 相同,请修改为不同目录', FILE_NOT_FOUND: '未找到 %s 文件,或者文件读取失败', JSON_PARSE_ERROR: '%s 文件解析错误', ENTRANCE_NOT_FOUND: '未找到入口页面\napp.json 中定义的 pages : %s', JSON_PAGE_FILE_NOT_EXISTS: '未找到 %s 中的定义的 %s "%s" 对应的 %s 文件', SHOULD_NOT_IN: '%s 不应该在 %s 中', JSON_CUSTOM_COMPILE_PATH_NOT_EXISTS_TITLE: 'app.json 或自定义编译条件错误', JSON_CUSTOM_COMPILE_PATH_NOT_EXISTS: 'app.json 中未定义自定义编译中指定的启动页面 %s', JSON_ENTRY_PAGE_PATH_NOT_FOUND: '未在 %s 中找到 %s 定义的入口页面', JSON_TABBAR_AT_LEAST: '["tabBar"]["list"] 需至少包含 %s 项', JSON_TABBAR_AT_MOST: '["tabBar"]["list"] 不能超过 %s 项', JSON_TABBAR_PATH_EMPTY: '["tabBar"]["list"][%s]["pagePath"] 不能为空', JSON_TABBAR_PATH_SAME_WITH_OTHER: '["tabBar"]["list"][%s]["pagePath"] 和 ["tabBar"]["list"][%s]["pagePath"] 相同', JSON_TABBAR_ICON_MAX_SIZE: '["tabBar"]["list"][%s]["%s"] 大小超过 %skb', JSON_TABBAR_ICON_EXT: '["tabBar"]["list"][%s]["%s"] 文件格式错误,仅支持 %s 格式', JSON_CONTENT_SHOULD_NOT_BE: '%s 不能为 %s', JSON_RESOLVE_ALIAS_ILLEGAL: 'resolveAlias 配置中 %s 或 %s 不合法,包含连续的 "//"', JSON_RESOLVE_ALIAS_INCLUDE_STAR: 'resolveAlias 配置中 %s 或 %s 需要用 "/*" 结尾', APP_JSON_SHOULD_SET_LAZYCODELOADING: '%s 中 "renderer" 设置为 "skyline",需在 app.json 添加 "lazyCodeLoading": "requiredComponents"', APP_JSON_CONTENT_ERROR: 'miniprogram_npm 目录下的 %s 包与扩展库 %s 发生冲突,请移除 %s 包或者删除 `useExtendedLib.%s` 配置', PAGE_JSON_SHOULD_SET_DISABLESCROLL_TRUE: '根据页面或 app.json 的配置,%s 页面 "renderer" 为 "skyline",需在页面配置中添加 "disableScroll": true', PAGE_JSON_SHOULD_SET_NAVIGATIONSTYLE_CUSTOM: '根据页面或 app.json 的配置,%s 页面 "renderer" 为 "skyline",需在页面配置中添加 "navigationStyle": custom', CONTENT_EXIST: '%s 已经存在', JSON_CONTENT_EXISTED: '%s 已经存在', JSON_CONTENT_NOT_FOUND: '%s 不存在', LACK_OF_FILE: '缺少文件 %s', JSON_PAGES_REPEAT: '%s 在 %s 中重复', JSON_CONTENT_REPEAT: '%s 不能同时在 %s 中声明', EXT_JSON_INVALID: '%s 不是 3rdMiniProgramAppid, ext.json 无法生效;查看文档: "%s"', GAME_EXT_JSON_INVALID: '%s 不是 3rdMiniGameAppid, ext.json 无法生效;"%s"', EXT_APPID_SHOULD_NOT_BE_EMPTY: 'extAppid 不能为空', FILE_NOT_UTF8: '%s 文件不是 UTF-8 格式', INVALID: '无效的 %s', DIRECTORY: '目录', EXCEED_LIMIT: '%s 超过限制 %s', PLEASE_CHOOSE_PLUGIN_MODE: '如果正在开发插件,请选择插件模式', TRIPLE_NUMBER_DOT: '数字.数字.数字', PAGE_PATH: '页面路径', PLUGINS_SAME_ALIAS: '%s 和 %s 的别名相同', SAME_ITEM: '%s 和 %s 的 "%s" 相同', ALREADY_EXISTS: '已存在', SAME_KEY_PAGE_PUBLICCOMPONENTS: '["pages"] 与 ["publicComponents"] 不能存在相同的 key: %s', GAME_DEV_PLUGIN_SHOULD_NOT_USE_LOCAL_PATH: '开发版插件 %s 不能使用 %s 指定本地路径', GAME_PLUGIN_SIGNATURE_MD5_NOT_MATCH_CONTENT: '插件文件 "%s" 的 MD5: "%s" 与其 signature.json 所给定的值: "%s" 不匹配, 因此编译过程已经中断。\n这表示此文件的内容可能已经被修改。\n恢复此文件的原始内容可能可以解决此问题并移除此警告。\n\n要了解更多,可以参考文档。\n', FILE: '文件', PROCESSING: '处理中: %s', DONE: '完成: %s', UPLOAD: '上传', SUCCESS: '成功', PROJECT_TYPE_ERROR: 'project.type 是 %s, 但 appid(%s) 是 %s', MINI_PROGRAM: '小程序', MINI_GAME: '小游戏', NOT_ALLOWED_REQUIRE_VAR: '不允许require变量', NOT_ALLOWED_REQUIRE_ASSIGN: '不允许将require函数赋值给其他变量', NOT_FOUND_NPM_ENTRY: '未找到npm包入口文件', NOT_FOUND_NODE_MODULES: '没有找到可以构建的 NPM 包,请确认需要参与构建的 npm 都在 `miniprogramRoot` 目录内,或配置 project.config.json 的 packNpmManually 和 packNpmRelationList 进行构建', JSON_ENTRANCE_DECLARE_PATH_ERR: '["entranceDeclare"]["locationMessage"]["path"] "%s" 需在 pages 数组或分包 pages 数组中', JSON_ENTRANCE_DECLARE_PATH_EMPTY: '["entranceDeclare"]["locationMessage"]["path"] 不能为空', COULD_NOT_USE_CODE_PROTECT: '无法使用代码保护功能', SUMMER_COMPILING_MODULE: '编译 %s', SUMMER_COMPILE_JSON: '编译 JSON 文件', SUMMER_OPTIMIZE_CODE: '优化代码', SUMMER_PACK_FILES: '打包资源文件', SUMMER_COMPRESS_PACK: '压缩代码包', SUMMER_SEAL_PACK: '封装代码包', SUMMER_APPEND_BABEL_HELPERS: '追加 babel helper 文件', SUMMER_COMPILE_PAGE_JSON: '编译 %s 个页面json文件', SUMMER_COMPILE_PLUGIN_PAGE_JSON: '编译插件 %s 个页面json文件', SUMMER_COMPILE: '编译 %s', SUMMER_COMPILE_MINIPROGRAM: '编译打包小程序', SUMMER_COMPILE_PLUGIN: '编译打包插件', SUMMER_COMPILE_ENABLE_LAZYLOAD: '开启了依赖注入,请将基础库至少升级到 3.0.38', }; const tipTemplateConfig$1 = {}; for (const [key, v] of Object.entries(template$2)) tipTemplateConfig$1[key] = new FormatableString(v); var log = { info: console.info, log: console.log, warn: console.warn, error: console.error, debug: (...e) => {}, }; class CodeError extends Error { constructor(e, code) { super(e); log.error(e, code); this.code = code; } } const AbortEvent$1 = 'abort'; class InterruptibleTask { then(onResolve, onReject) { return this._promise.then(onResolve, onReject) } catch(onReject) { return this._promise.catch(onReject) } abort() { this._aborted || (this._aborted = !0); } constructor(...opts) { this._aborted = false; this._args = opts; this._promise = this.run(...opts); } } class RequestTask extends InterruptibleTask { static async formateQuery(e) { const t = Object.assign({}, e), { needRandom: r } = t; delete t.needRandom; const n = (t.url || '').split('?'), o = n[0], i = []; return ( -1 !== r && i.push('_r=' + Math.random()), n[1] && i.push(n[1]), (t.url = `${o}?${i.join('&')}`), t ) } abort() { this._aborted || ((this._aborted = !0), this._realRequest && 'function' == typeof this._realRequest.abort && this._realRequest.abort()); } async request() { if (this._aborted) throw AbortEvent$1 const t = await e.formateQuery(this._opt); return ( e.requestProxy && (t.proxy = e.requestProxy), new Promise((e, r) => { (this._realRequest = realRequest__default["default"](t, (t, n, o) => { t ? r(t) : e({ resp: n, body: o }); })), this._realRequest.on('abort', () => { r(AbortEvent$1); }); }) ) } async run(e) { return (this._opt = Object.assign({}, e)), await this.request() } constructor(e) { super(e), (this._alreadyRefresh = !1), this._promise.catch(e => { log.error(`${this._opt.url} ${e}`); }); } } function request(e) { return new RequestTask(e) } function setCiProxy(e) { (RequestTask.requestProxy = e), log.info('miniprogram-ci is using proxy: ' + e); } RequestTask.requestProxy = ''; function jsonParse(e) { try { return JSON.parse(e) } catch (t) { throw ( (log.info('jsonParse error, input string:'), log.info(e), t) ) } } function jsonRespParse(e, t = '') { try { return JSON.parse(e) } catch (e) { throw ( (log.info( `CGI[${t}] response parse error, response body: ${e}` ), e) ) } } function nextTick(cb, arg1, arg2, arg3) { if ('function' != typeof cb) throw new TypeError('"callback" argument must be a function') const argsLength = arguments.length; switch (argsLength) { case 0: case 1: return process.nextTick(cb) case 2: return process.nextTick(function() { cb.call(null, arg1); }) case 3: return process.nextTick(function() { cb.call(null, arg1, arg2); }) case 4: return process.nextTick(function() { cb.call(null, arg1, arg2, arg3); }) default: const calledArgs = new Array(argsLength - 1).fill(0).map((n, i) => arguments[i + 1]); return process.nextTick(function() { cb.apply(null, calledArgs); }) } } // 这个模块这样功能是把 raw data 转换为 reactive data,目的是为了追踪数据的 mutation,从而做一些事件(effect)。 // 时间关系,这些细节变量就不翻译了 const n$2 = {}, i = Object.assign, s$1 = Object.prototype.hasOwnProperty, a$3 = (e, t) => s$1.call(e, t), c$2 = Array.isArray, u$2 = e => '[object Map]' === g$3(e), l$3 = e => 'string' == typeof e, f$4 = e => 'symbol' == typeof e, h$1 = e => null !== e && 'object' == typeof e, d$4 = Object.prototype.toString, g$3 = e => d$4.call(e), m$3 = e => g$3(e).slice(8, -1), y$2 = e => l$3(e) && 'NaN' !== e && '-' !== e[0] && '' + parseInt(e, 10) === e, O = ((e, t) => e !== t && (e == e || t == t)); const w = new WeakMap(), E = []; let j; const ITERATE_KEY = Symbol(''), C = Symbol(''); function effect(e, t = n$2) { (function(e) { return e && !0 === e._isEffect })(e) && (e = e.raw); const r = (function(e, t) { const r = function() { if (!r.active) return t.scheduler ? void 0 : e() if (!E.includes(r)) { x$1(r); try { return enableTracking(), E.push(r), (j = r), e() } finally { E.pop(), resetTracking(), (j = E[E.length - 1]); } } }; return ( (r.id = F$1++), (r.allowRecurse = !!t.allowRecurse), (r._isEffect = !0), (r.active = !0), (r.raw = e), (r.deps = []), (r.options = t), r ) })(e, t); return t.lazy || r(), r } let F$1 = 0; function x$1(e) { const { deps: t } = e; if (t.length) { for (let r = 0; r < t.length; r++) t[r].delete(e); t.length = 0; } } let L$1 = !0; const A$1 = []; function pauseTracking() { A$1.push(L$1), (L$1 = !1); } function enableTracking() { A$1.push(L$1), (L$1 = !0); } function resetTracking() { const e = A$1.pop(); L$1 = void 0 === e || e; } function track(e, t, r) { if (!L$1 || void 0 === j) return let n = w.get(e); n || w.set(e, (n = new Map())); let o = n.get(r); o || n.set(r, (o = new Set())), o.has(j) || (o.add(j), j.deps.push(o)); } function trigger(e, t, r, n, o, i) { const s = w.get(e); if (!s) return const a = new Set(), p = e => { e && e.forEach(e => { (e !== j || e.allowRecurse) && a.add(e); }); }; if ('clear' === t) s.forEach(p); else if ('length' === r && c$2(e)) s.forEach((e, t) => { ('length' === t || t >= n) && p(e); }); else switch ((void 0 !== r && p(s.get(r)), t)) { case 'add': c$2(e) ? y$2(r) && p(s.get('length')) : (p(s.get(ITERATE_KEY)), u$2(e) && p(s.get(C))); break case 'delete': c$2(e) || (p(s.get(ITERATE_KEY)), u$2(e) && p(s.get(C))); break case 'set': u$2(e) && p(s.get(ITERATE_KEY)); } a.forEach(e => { e.options.scheduler ? e.options.scheduler(e) : e(); }); } const U = new Set( Object.getOwnPropertyNames(Symbol) .map(e => Symbol[e]) .filter(f$4) ), $ = W(), q = W(!1, !0), G = W(!0), J = W(!0, !0), H = {}; function W(e = !1, t = !1) { return function(r, n, o) { if ('__v_isReactive' === n) return !e if ('__v_isReadonly' === n) return e if ('__v_raw' === n && o === (e ? _e : ve).get(r)) return r const i = c$2(r); if (!e && i && a$3(H, n)) return Reflect.get(H, n, o) const s = Reflect.get(r, n, o); if (f$4(n) ? U.has(n) : '__proto__' === n || '__v_isRef' === n) return s if ((e || track(r, 0, n), t)) return s if (isRef(s)) { return !i || !y$2(n) ? s.value : s } return h$1(s) ? (e ? readonly(s) : reactive(s)) : s } } ['includes', 'indexOf', 'lastIndexOf'].forEach(e => { const t = Array.prototype[e]; H[e] = function(...e) { const r = toRaw(this); for (let e = 0, t = this.length; e < t; e++) track(r, 0, e + ''); const n = t.apply(r, e); return -1 === n || !1 === n ? t.apply(r, e.map(toRaw)) : n }; }), ['push', 'pop', 'shift', 'unshift', 'splice'].forEach(e => { const t = Array.prototype[e]; H[e] = function(...e) { pauseTracking(); const r = t.apply(this, e); return resetTracking(), r }; }); function z(e = !1) { return function(t, r, n, o) { const i = t[r]; if (!e && ((n = toRaw(n)), !c$2(t) && isRef(i) && !isRef(n))) return (i.value = n), !0 const s = c$2(t) && y$2(r) ? Number(r) < t.length : a$3(t, r), u = Reflect.set(t, r, n, o); return ( t === toRaw(o) && (s ? O(n, i) && trigger(t, 'set', r, n) : trigger(t, 'add', r, n)), u ) } } const Y = { get: $, set: z(), deleteProperty: function(e, t) { const r = a$3(e, t), n = (e[t], Reflect.deleteProperty(e, t)); return n && r && trigger(e, 'delete', t, void 0), n }, has: function(e, t) { const r = Reflect.has(e, t); return (f$4(t) && U.has(t)) || track(e, 0, t), r }, ownKeys: function(e) { return track(e, 0, c$2(e) ? 'length' : ITERATE_KEY), Reflect.ownKeys(e) } }, V = { get: G, set: (e, t) => !0, deleteProperty: (e, t) => !0 }; i({}, Y, { get: q, set: z(!0) }); i({}, V, { get: J }); const Z = e => (h$1(e) ? reactive(e) : e), Q = e => (h$1(e) ? readonly(e) : e), ee = e => e, te = e => Reflect.getPrototypeOf(e); function re(e, t, r = !1, n = !1) { const o = toRaw((e = e.__v_raw)), i = toRaw(t); t !== i && !r && track(o, 0, t), !r && track(o, 0, i); const { has: s } = te(o), a = r ? Q : n ? ee : Z; return s.call(o, t) ? a(e.get(t)) : s.call(o, i) ? a(e.get(i)) : void 0 } function ne(e, t = !1) { const r = this.__v_raw, n = toRaw(r), o = toRaw(e); return ( e !== o && !t && track(n, 0, e), !t && track(n, 0, o), e === o ? r.has(e) : r.has(e) || r.has(o) ) } function oe(e, t = !1) { return ( (e = e.__v_raw), !t && track(toRaw(e), 0, ITERATE_KEY), Reflect.get(e, 'size', e) ) } function ie(e) { e = toRaw(e); const t = toRaw(this), r = te(t).has.call(t, e); return t.add(e), r || trigger(t, 'add', e, e), this } function se(e, t) { t = toRaw(t); const r = toRaw(this), { has: n, get: o } = te(r); let i = n.call(r, e); i || ((e = toRaw(e)), (i = n.call(r, e))); const s = o.call(r, e); return ( r.set(e, t), i ? O(t, s) && trigger(r, 'set', e, t) : trigger(r, 'add', e, t), this ) } function ae(e) { const t = toRaw(this), { has: r, get: n } = te(t); let o = r.call(t, e); o || ((e = toRaw(e)), (o = r.call(t, e))); n && n.call(t, e); const i = t.delete(e); return o && trigger(t, 'delete', e, void 0), i } function ce() { const e = toRaw(this), t = 0 !== e.size, r = e.clear(); return t && trigger(e, 'clear', void 0, void 0), r } function ue(e, t) { return function(r, n) { const o = this, i = o.__v_raw, s = toRaw(i), a = e ? Q : t ? ee : Z; return ( !e && track(s, 0, ITERATE_KEY), i.forEach((e, t) => r.call(n, a(e), a(t), o)) ) } } function pe(e, t, r) { return function(...n) { const o = this.__v_raw, i = toRaw(o), s = u$2(i), a = 'entries' === e || (e === Symbol.iterator && s), c = 'keys' === e && s, p = o[e](...n), l = t ? Q : r ? ee : Z; return ( !t && track(i, 0, c ? C : ITERATE_KEY), { next() { const { value: e, done: t } = p.next(); return t ? { value: e, done: t } : { value: a ? [l(e[0]), l(e[1])] : l(e), done: t } }, [Symbol.iterator]() { return this } } ) } } function le(e) { return function(...t) { return 'delete' !== e && this } } const fe = { get(e) { return re(this, e) }, get size() { return oe(this) }, has: ne, add: ie, set: se, delete: ae, clear: ce, forEach: ue(!1, !1) }, he = { get(e) { return re(this, e, !1, !0) }, get size() { return oe(this) }, has: ne, add: ie, set: se, delete: ae, clear: ce, forEach: ue(!1, !0) }, de = { get(e) { return re(this, e, !0) }, get size() { return oe(this, !0) }, has(e) { return ne.call(this, e, !0) }, add: le('add'), set: le('set'), delete: le('delete'), clear: le('clear'), forEach: ue(!0, !1) }; function ge(e, t) { const r = t ? he : e ? de : fe; return (t, n, o) => '__v_isReactive' === n ? !e : '__v_isReadonly' === n ? e : '__v_raw' === n ? t : Reflect.get(a$3(r, n) && n in t ? r : t, n, o) } ['keys', 'values', 'entries', Symbol.iterator].forEach(e => { (fe[e] = pe(e, !1, !1)), (de[e] = pe(e, !0, !1)), (he[e] = pe(e, !1, !0)); }); const me = { get: ge(!1, !1) }, be = { get: ge(!0, !1) }; const ve = new WeakMap(), _e = new WeakMap(); function reactive(e) { return e && e.__v_isReadonly ? e : Ee(e, !1, Y, me) } function readonly(e) { return Ee(e, !0, V, be) } function Ee(e, t, r, n) { if (!h$1(e)) return e if (e.__v_raw && (!t || !e.__v_isReactive)) return e const o = t ? _e : ve, i = o.get(e); if (i) return i const s = (a = e).__v_skip || !Object.isExtensible(a) ? 0 : (function(e) { switch (e) { case 'Object': case 'Array': return 1 case 'Map': case 'Set': case 'WeakMap': case 'WeakSet': return 2 default: return 0 } })(m$3(a)); var a; if (0 === s) return e const c = new Proxy(e, 2 === s ? n : r); return o.set(e, c), c } function toRaw(e) { return (e && toRaw(e.__v_raw)) || e } const Fe = e => (h$1(e) ? reactive(e) : e); function isRef(e) { return Boolean(e && !0 === e.__v_isRef) } function ref(e) { return Ie(e) } class De { constructor(e, t = !1) { (this._rawValue = e), (this._shallow = t), (this.__v_isRef = !0), (this._value = t ? e : Fe(e)); } get value() { return track(toRaw(this), 0, 'value'), this._value } set value(e) { O(toRaw(e), this._rawValue) && ((this._rawValue = e), (this._value = this._shallow ? e : Fe(e)), trigger(toRaw(this), 'set', 'value', e)); } } function Ie(e, t = !1) { return isRef(e) ? e : new De(e, t) } let d$3 = !1; const g$2 = new Set(), m$2 = Promise.resolve(); function toReadOnly(v) { return v && 'object' == typeof v ? readonly(v) : v } class ReactiveJSONCompiler { release() {} registerOrGet(e, t, ...r) { let o = this.jsonComputeds.get(e); if (!o) { (o = ref(void 0)), this.jsonComputeds.set(e, o); const i = effect( () => { try { const e = t.call(null, this.project, ...r); if (!lodash__default["default"].isEqual(e, o.value)) { o.value = toReadOnly(e); } } catch (e) { o.value = e instanceof Error ? e : new Error(e.toString()); } }, { scheduler() { var e; i && i.active && ((e = i), g$2.add(e), d$3 || ((d$3 = !0), m$2.then(() => { try { const e = Array.from(g$2); g$2.clear(), (d$3 = !1), e.forEach(e => { e(); }); } finally { } }))); } } ); } const { value: i } = o; if (i instanceof Error) throw i return i } static setOriginGetPageJSON(e) { this.originGetPageJSON = e; } static setOriginCheckPageJSON(e) { this.originCheckPageJSON = e; } getPageJSON(t, r) { let n = this.pageComputeds.get(r.pagePath); n || ((n = { checked: ref(void 0), compiled: ref(void 0) }), this.pageComputeds.set(r.pagePath, n)); const o = n[t]; if (void 0 === o.value) { let n = null; n = effect( () => { try { r.pagePath; const n = 'compiled' === t ? ReactiveJSONCompiler.originGetPageJSON(this.project, r) : ReactiveJSONCompiler.originCheckPageJSON(this.project, r) ;(o.value = toReadOnly(n)), r.pagePath; } catch (e) { (o.value = e instanceof Error ? e : new Error(e.toString())), r.pagePath; } }, { scheduler() { if (n && n.active) { nextTick(n); } } } ); } const a = o.value; if (a instanceof Error) throw a return a } constructor(project) { (this.pageComputeds = new Map()), (this.jsonComputeds = new Map()), (this.project = project); } } class ReactiveProject { release() { this.resetFileChangeListener(); } async attr() { return this.attrSync() } getFileList(e, t) { return this.project.getFileList(e, t) } getFilesAndDirs() { return this.project.getFilesAndDirs() } getExtAppid() { return this.project.getExtAppid() } updateFiles() { throw new Error('Method updateFiles not implemented.') } async updateProject() { this.appidBox.value !== this.project.appid && (this.appidBox.value = this.project.appid), this.typeBox.value !== this.project.type && (this.typeBox.value = this.project.type), this.miniprogramRootBox.value !== this.project.miniprogramRoot && (this.miniprogramRootBox.value = this.project.miniprogramRoot), this.pluginRootBox.value !== this.project.pluginRoot && (this.pluginRootBox.value = this.project.pluginRoot); const e = await this.project.attr(); return ( (function(e, t) { return ( 'object' == typeof e && 'object' == typeof t && !(!e || !t) && e.platform === t.platform && e.appType === t.appType && e.gameApp === t.gameApp && e.isSandbox === t.isSandbox && e.released === t.released && e.setting.MaxCodeSize === t.setting.MaxCodeSize && e.setting.MaxSubpackageSubCodeSize === t.setting.MaxSubpackageSubCodeSize && e.setting.MaxSubpackageFullCodeSize === t.setting.MaxSubpackageFullCodeSize && e.setting.NavigateMiniprogramLimit === t.setting.NavigateMiniprogramLimit && e.setting.MaxSubPackageLimit === t.setting.MaxSubPackageLimit && e.setting.MinTabbarCount === t.setting.MinTabbarCount && e.setting.MaxTabbarCount === t.setting.MaxTabbarCount && e.setting.MaxTabbarIconSize === t.setting.MaxTabbarIconSize ) })(e, this.attrBox.value) || (this.attrBox.value = e), new Promise(e => { setTimeout(e, 0); }) ) } onFileChange(e, t) { if ('change' === e) { const e = this.fileBoxs.get(t); if (e) { const r = this.project.getFile('', t) ;(e.value && 0 === r.compare(e.value)) || (e.value = r); } } else if ('unlink' === e) { const e = this.fileBoxs.get(t); e && (this.fileBoxs.delete(t), (e.value = void 0)); const r = this.statBoxs.get(t); if (r) { const e = this.project.stat('', t); lodash__default["default"].isEqual(e, r.value) || (r.value = e); } } else if ('unlinkDir' === e) { const e = t + '/'; let r = Array.from(this.fileBoxs.keys()); for (const t of r) if (0 === t.indexOf(e)) { const e = this.fileBoxs.get(t); this.fileBoxs.delete(t), (e.value = void 0); } r = Array.from(this.statBoxs.keys()); for (const t of r) if (0 === t.indexOf(e)) { const e = this.statBoxs.get(t); void 0 !== e.value && (this.statBoxs.delete(t), (e.value = void 0)); } } else if ('add' === e || 'addDir' === e) { const e = this.statBoxs.get(t); if (e) { const r = this.project.stat('', t); lodash__default["default"].isEqual(r, e.value) || (e.value = r); } } } getFile(e, t) { const r = this.getTargetPath(e, t), n = this.fileBoxs.get(r); if (n) return n.value const o = ref(this.project.getFile(e, t)); return this.fileBoxs.set(r, o), o.value } stat(e, t) { const r = this.getTargetPath(e, t), n = this.statBoxs.get(r); if (n) return n.value const o = ref(this.project.stat(e, t)); return this.statBoxs.set(r, o), o.value } attrSync() { return this.attrBox.value } get appid() { return this.appidBox.value } get type() { return this.typeBox.value } get nameMappingFromDevtools() { return this.project.nameMappingFromDevtools } get projectPath() { return this.project.projectPath } get privateKey() { return this.project.privateKey } get miniprogramRoot() { return this.miniprogramRootBox.value } set miniprogramRoot(e) { (this.miniprogramRootBox.value = e), (this.project.miniprogramRoot = e); } get pluginRoot() { return this.pluginRootBox.value } set pluginRoot(e) { (this.pluginRootBox.value = e), (this.project.pluginRoot = e); } getTargetPath(e, t) { return normalizePath$1(path__default["default"].posix.join(e, t)) .replace(/\/$/, '') .replace(/^\//, '') } constructor(e) { if ( ((this.fileBoxs = new Map()), (this.statBoxs = new Map()), (this.resetFileChangeListener = () => {}), (this.project = e), e.onFileChange) ) { const t = e.onFileChange ;(e.onFileChange = (r, n) => { t.call(e, r, n), this.onFileChange(r, n); }), (this.resetFileChangeListener = () => { e.onFileChange = t; }); } (this.miniprogramRootBox = ref(e.miniprogramRoot)), (this.pluginRootBox = ref(e.pluginRoot)), (this.appidBox = ref(e.appid)), (this.typeBox = ref(e.type)), (this.attrBox = ref(DefaultProjectAttr)); } } const projectMap = new Map(); function tryToGetReactiveProject(project) { let rproject = projectMap.get(project.projectPath); if (rproject == null) { rproject = new ReactiveProject(project); projectMap.set(project.projectPath, rproject); } return rproject } const compilerMap = new Map(); function tryToGetReactiveJSONCompiler(project) { let compiler = compilerMap.get(project.projectPath); if (compiler == null) { compiler = new ReactiveJSONCompiler(project); compilerMap.set(project.projectPath, compiler); } return compiler } function wrapCompileJSONFunc(e, t) { return function(project, ...args) { const isReactProjectInstance = project instanceof ReactiveProject; if (!isReactProjectInstance) { project = tryToGetReactiveProject(project); } return tryToGetReactiveJSONCompiler(project).registerOrGet(e, t, ...args) } } function cleanReactiveCache() { projectMap.forEach(e => { e.release(); }); projectMap.clear(); compilerMap.forEach(e => { e.release(); }); compilerMap.clear(); } const CACHE_KEY = { PROJECT_CONFIG: 'project.config', RAW_APP_JSON: 'raw|app.json', APP_JSON: 'app.json', APP_EXT_JSON: 'app.ext.json', EXT_JSON: 'ext.json', PAGE_JSON: 'page.json', COMPILED_APP_JSON: 'compiled.app.json', COMPILED_PAGE_JSON: 'compiled.page.json', GAME_JSON: 'game.json', PLUGIN_JSON: 'plugin.json', SITE_MAP_JSON: 'sitemap.json', THEME_JSON: 'theme.json', PLUGIN_THEME_JSON: 'plugin|theme.json', APP_JSON_THEME_LOCATION: 'app.json.themeLocation', APP_JSON_USING_COMPONENTS: 'app.json.usingComponents' }; function replaceTheKey(e, t) { return ( !!e && (Object.keys(e).forEach((r) => { const n = t[r]; if (n) { let t = e[r]; 'YES' === t ? (t = !0) : 'NO' === t && (t = !1), (e[n] = t), delete e[r]; } }), e) ) } var appConfigForAli = { pages: { url: { original: 'https://docs.alipay.com/mini/framework/page-json', target: 'https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/page.html', }, type: 7, status: 0, desc: '设置页面路径', }, window: { name: '用于对小程序进行全局配置,设置页面文件的路径、窗口表现、网络超时时间、多 tab 等', url: { original: 'https://docs.alipay.com/mini/framework/app-json', target: 'https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#window', }, desc: 'window 用于设置小程序的状态栏、导航条、标题、窗口背景色等。', status: 1, props: { defaultTitle: { type: 1, status: 0, desc: '页面默认标题', msg: 'navigationBarTitleText', }, pullRefresh: { type: 1, status: 0, desc: '是否允许下拉刷新。默认NO', msg: 'enablePullDownRefresh', }, allowsBounceVertical: { type: 0, status: 2, desc: '是否允许向下拉拽。默认 YES', msg: '暂不支持', }, transparentTitle: { type: 0, status: 2, desc: '导航栏透明设置。默认 none', msg: '暂不支持', }, titlePenetrate: { type: 0, status: 2, desc: '是否允许导航栏点击穿透。默认 NO', msg: '暂不支持', }, showTitle