miniprogram-ci 2.1.32 → 2.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/README.md +2 -0
- package/dist/@types/ci/cloud/utils.d.ts +1 -1
- package/dist/@types/common/code-analyse/index.d.ts +16 -1
- package/dist/@types/config/config.d.ts +1 -1
- package/dist/@types/index.d.ts +2 -0
- package/dist/@types/modules/corecompiler/original/compile/game.d.ts +1 -1
- package/dist/@types/modules/corecompiler/original/compile/index.d.ts +1 -1
- package/dist/@types/modules/corecompiler/original/index.d.ts +1 -1
- package/dist/@types/modules/corecompiler/original/workerThread/childprocessManager.d.ts +1 -1
- package/dist/@types/modules/corecompiler/original/workerThread/config.d.ts +3 -0
- package/dist/@types/modules/corecompiler/original/workerThread/task/compilejs.d.ts +3 -0
- package/dist/@types/modules/corecompiler/original/workerThread/task/func.d.ts +4 -0
- package/dist/@types/modules/corecompiler/original/workerThread/workerManager.d.ts +8 -0
- package/dist/@types/modules/corecompiler/originalCompiler.d.ts +1 -1
- package/dist/@types/modules/corecompiler/summer/pipeManager/index.d.ts +6 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipeCPProject.d.ts +17 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipeContext.d.ts +10 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipeManager.d.ts +12 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipeWorker.d.ts +2 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/appservicePipe/index.d.ts +3 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/compileWxmlToGlassEaselPipe.d.ts +3 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/compileWxssPipe.d.ts +3 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/index.d.ts +2 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/pageInitSourcePipe/index.d.ts +4 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/pageframePipe/index.d.ts +3 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appdevserver/getAppService.d.ts +6 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appdevserver/getwxappcode.d.ts +9 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getjsfile.d.ts +12 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getmainpkgsortedjsfiles.d.ts +11 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getwxappcode.d.ts +8 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/common/apperrcode.config.d.ts +92 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/common/tools.d.ts +1 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/appconfig.d.ts +6 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/appjson.d.ts +3 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/customcomponent.d.ts +21 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/helper/theme.d.ts +40 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/pagejson.d.ts +3 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/project/wxappcodejson.d.ts +3 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/trans/transwxmltojs.d.ts +19 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/trans/transwxsstojs.d.ts +15 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/utils/web/processPath.d.ts +9 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/pipes/wccPipe.d.ts +3 -0
- package/dist/@types/modules/corecompiler/summer/pipeManager/types.d.ts +100 -0
- package/dist/@types/modules/corecompiler/summer/plugins/script_task/minify_script_task.d.ts +1 -1
- package/dist/@types/modules/corecompiler/summerCompiler.d.ts +10 -0
- package/dist/@types/modules/index.d.ts +1 -1
- package/dist/@types/modules/precompiler/conditioncompile/compiler/plant.d.ts +1 -1
- package/dist/@types/modules/precompiler/conditioncompile/index.d.ts +1 -1
- package/dist/@types/project/advance/precompileProject.d.ts +1 -1
- package/dist/@types/project/baseProject.d.ts +1 -0
- package/dist/@types/services/app/ci/appDirService.d.ts +6 -0
- package/dist/@types/services/common/getservice.d.ts +6 -3
- package/dist/@types/services/compilewxml/common/compilewxmlService.d.ts +2 -2
- package/dist/@types/services/compilewxml/node/compileglasseasel.d.ts +14 -0
- package/dist/@types/services/multiTaskManager/ci/multiTaskManager.d.ts +5 -0
- package/dist/@types/services/multiTaskManager/common/multiTaskManager.d.ts +5 -0
- package/dist/@types/services/multiTaskManager/electron/multiTaskManager.d.ts +5 -0
- package/dist/@types/services/multiTaskManager/webide/multiTaskManager.d.ts +5 -0
- package/dist/@types/services/nativeModule/ci/nativeModule.d.ts +3 -0
- package/dist/@types/services/nativeModule/common/nativeModule.d.ts +2 -2
- package/dist/@types/services/nativeModule/common/nativeModule.impl.d.ts +3 -2
- package/dist/@types/services/pluginFileReader/ci/pluginFileReader.d.ts +3 -0
- package/dist/@types/services/pluginFileReader/common/pluginFileReader.base.d.ts +9 -0
- package/dist/@types/services/pluginFileReader/common/pluginFileReader.d.ts +12 -0
- package/dist/@types/services/pluginFileReader/electron/pluginFileReader.d.ts +3 -0
- package/dist/@types/services/pluginFileReader/webide/pluginFileReader.d.ts +9 -0
- package/dist/@types/services/root/ci/rootService.d.ts +2 -0
- package/dist/@types/services/root/webide/root.d.ts +11 -0
- package/dist/@types/services/root/webide/rootService.d.ts +2 -0
- package/dist/@types/utils/colorutils.d.ts +4 -0
- package/dist/@types/utils/debug.d.ts +1 -0
- package/dist/@types/utils/error.d.ts +1 -1
- package/dist/@types/utils/fsagent.d.ts +4 -3
- package/dist/@types/utils/processBootstrap.d.ts +7 -0
- package/dist/@types/utils/subprocess/processManager.d.ts +1 -0
- package/dist/@types/utils/wxapkg/pack.d.ts +2 -2
- package/dist/ci/android-miniapp-toolkit/dist/index.js +1 -1
- package/dist/ci/build-apk.js +1 -1
- package/dist/ci/build-ipa.js +1 -1
- package/dist/ci/checkCodeQuality.js +1 -1
- package/dist/ci/cloud/cloudapi.js +1 -1
- package/dist/ci/cloud/createTimeTrigger.js +1 -1
- package/dist/ci/cloud/uploadContainer.js +1 -1
- package/dist/ci/cloud/uploadFile.js +1 -1
- package/dist/ci/cloud/uploadFunction.js +1 -1
- package/dist/ci/cloud/utils.js +1 -1
- package/dist/ci/code-analyse.js +1 -1
- package/dist/ci/cos-upload.js +1 -1
- package/dist/ci/gamepkg/apkplug.js +1 -1
- package/dist/ci/gamepkg/index.js +1 -1
- package/dist/ci/getCompiledResult.js +1 -1
- package/dist/ci/getDevSourceMap.js +1 -1
- package/dist/ci/getcompiler.js +1 -1
- package/dist/ci/miniapp/androidCloudBuild.js +1 -1
- package/dist/ci/miniapp/archive.js +1 -1
- package/dist/ci/miniapp/iosCloudBuild.js +1 -1
- package/dist/ci/miniapp/miniappPlugin.js +1 -1
- package/dist/ci/miniapp/sdkManager.js +1 -1
- package/dist/ci/miniapp/upload.js +1 -1
- package/dist/ci/miniapp-cloud-upload.js +1 -1
- package/dist/ci/preview.js +1 -1
- package/dist/ci/upload.js +1 -1
- package/dist/ci/utils/codeDenpendencyQualityChecker.js +1 -1
- package/dist/ci/utils/filterUnusedFile.js +1 -1
- package/dist/ci/utils/pack.js +1 -1
- package/dist/ci/utils/packfile.js +1 -1
- package/dist/ci/utils/terminalQrcode.js +1 -1
- package/dist/ci/utils/tools.js +1 -1
- package/dist/ci/utils/unpack.js +1 -1
- package/dist/ci/utils/wxvpkg/unpack/version0.js +1 -1
- package/dist/ci/utils/wxvpkg/unpack/version10.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/common/code-analyse/index.js +1 -1
- package/dist/config/config.js +1 -1
- package/dist/config/url.config.js +1 -1
- package/dist/index.js +1 -1
- package/dist/modules/corecompiler/baseCompiler.js +1 -1
- package/dist/modules/corecompiler/original/analyse/partial.js +1 -1
- package/dist/modules/corecompiler/original/compile/common.js +1 -1
- package/dist/modules/corecompiler/original/compile/game.js +1 -1
- package/dist/modules/corecompiler/original/compile/gamePlugin.js +1 -1
- package/dist/modules/corecompiler/original/compile/handler/js.js +1 -1
- package/dist/modules/corecompiler/original/compile/handler/mpjson.js +1 -1
- package/dist/modules/corecompiler/original/compile/handler/wxml.js +1 -1
- package/dist/modules/corecompiler/original/compile/handler/wxss.js +1 -1
- package/dist/modules/corecompiler/original/compile/miniprogram.js +1 -1
- package/dist/modules/corecompiler/original/compile/miniprogramPlugin.js +1 -1
- package/dist/modules/corecompiler/original/js/enhance.js +1 -1
- package/dist/modules/corecompiler/original/js/es6Transform.js +1 -1
- package/dist/modules/corecompiler/original/js/generateMap.js +1 -1
- package/dist/modules/corecompiler/original/js/minifyjs.js +1 -1
- package/dist/modules/corecompiler/original/js/minifyjsAfterWrap.js +1 -1
- package/dist/modules/corecompiler/original/js/workletCompile.js +1 -1
- package/dist/modules/corecompiler/original/json/app/appJSON.js +1 -1
- package/dist/modules/corecompiler/original/json/app/checkAppFields.js +1 -1
- package/dist/modules/corecompiler/original/json/app/extJSON.js +1 -1
- package/dist/modules/corecompiler/original/json/app/index.js +1 -1
- package/dist/modules/corecompiler/original/json/common.js +1 -1
- package/dist/modules/corecompiler/original/json/game.js +1 -1
- package/dist/modules/corecompiler/original/json/page/checkPageJSON.js +1 -1
- package/dist/modules/corecompiler/original/json/page/getPageJSON.js +1 -1
- package/dist/modules/corecompiler/original/json/plugin/plugin.js +1 -1
- package/dist/modules/corecompiler/original/json/plugin/pluginPage.js +1 -1
- package/dist/modules/corecompiler/original/json/projectconfig.js +1 -1
- package/dist/modules/corecompiler/original/json/reactiveCache.js +1 -1
- package/dist/modules/corecompiler/original/json/signaturejson.js +1 -1
- package/dist/modules/corecompiler/original/json/sitemap.js +1 -1
- package/dist/modules/corecompiler/original/json/theme.js +1 -1
- package/dist/modules/corecompiler/original/npm/filterdeps.js +1 -1
- package/dist/modules/corecompiler/original/npm/packnpm.js +1 -1
- package/dist/modules/corecompiler/original/protect/fileFlatter.js +1 -1
- package/dist/modules/corecompiler/original/protect/uglifyfilenames.js +1 -1
- package/dist/modules/corecompiler/original/utils/logger.js +1 -1
- package/dist/modules/corecompiler/original/validate/schemaValidate.js +1 -1
- package/dist/modules/corecompiler/original/validate/validate.js +1 -1
- package/dist/modules/corecompiler/original/workerThread/childprocess.js +1 -1
- package/dist/modules/corecompiler/original/workerThread/childprocessManager.js +1 -1
- package/dist/modules/corecompiler/original/workerThread/config.js +1 -1
- package/dist/modules/corecompiler/original/workerThread/fork.js +1 -1
- package/dist/modules/corecompiler/original/workerThread/index.js +1 -1
- package/dist/modules/corecompiler/original/workerThread/task/call_func.js +1 -1
- package/dist/modules/corecompiler/original/workerThread/task/compilejs.js +1 -1
- package/dist/modules/corecompiler/original/workerThread/task/compilewxss.js +1 -1
- package/dist/modules/corecompiler/original/workerThread/task/func.js +1 -1
- package/dist/modules/corecompiler/original/workerThread/task/index.js +1 -1
- package/dist/modules/corecompiler/original/workerThread/task/minifywxml.js +1 -1
- package/dist/modules/corecompiler/original/workerThread/worker.js +1 -1
- package/dist/modules/corecompiler/original/workerThread/workerManager.js +1 -1
- package/dist/modules/corecompiler/originalCompiler.js +1 -1
- package/dist/modules/corecompiler/processHandler.js +1 -1
- package/dist/modules/corecompiler/summer/graph/appconf.js +1 -1
- package/dist/modules/corecompiler/summer/graph/appgraph.js +1 -1
- package/dist/modules/corecompiler/summer/graph/basegraph.js +1 -1
- package/dist/modules/corecompiler/summer/graph/gameconf.js +1 -1
- package/dist/modules/corecompiler/summer/graph/gamegraph.js +1 -1
- package/dist/modules/corecompiler/summer/graph/gamepluginconf.js +1 -1
- package/dist/modules/corecompiler/summer/graph/gameplugingraph.js +1 -1
- package/dist/modules/corecompiler/summer/graph/pluginconf.js +1 -1
- package/dist/modules/corecompiler/summer/graph/plugingraph.js +1 -1
- package/dist/modules/corecompiler/summer/index.js +1 -1
- package/dist/modules/corecompiler/summer/initPlugin.js +1 -1
- package/dist/modules/corecompiler/summer/module.js +1 -1
- package/dist/modules/corecompiler/summer/persistCache.js +1 -1
- package/dist/modules/corecompiler/summer/pipeManager/index.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipeCPProject.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipeContext.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipeManager.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipeWorker.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/appservicePipe/index.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/compileWxmlToGlassEaselPipe.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/compileWxssPipe.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/index.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/pageInitSourcePipe/index.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/pageframePipe/index.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appdevserver/getAppService.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appdevserver/getwxappcode.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getjsfile.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getmainpkgsortedjsfiles.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/appservice/getwxappcode.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/common/apperrcode.config.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/common/tools.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/appconfig.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/appjson.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/customcomponent.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/helper/theme.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/pagejson.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/project/wxappcodejson.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/trans/transwxmltojs.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/trans/transwxsstojs.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/utils/web/processPath.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/pipes/wccPipe.js +1 -0
- package/dist/modules/corecompiler/summer/pipeManager/types.js +1 -0
- package/dist/modules/corecompiler/summer/pluginDriver.js +1 -1
- package/dist/modules/corecompiler/summer/pluginconfig.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/base/es6module.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/base/javascript.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/base/swc.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/base/wxss.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/enhance.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/filetask/script.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/less.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/minifywxml.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/sass.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/script_task/babel_script_task.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/script_task/load_script_task.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/script_task/minify_script_task.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/script_task/swc_task.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/terser.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/typescript.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/worklet.js +1 -1
- package/dist/modules/corecompiler/summer/resolver.js +1 -1
- package/dist/modules/corecompiler/summer/summer.js +1 -1
- package/dist/modules/corecompiler/summer/utils/async.js +1 -1
- package/dist/modules/corecompiler/summer/utils/inputsourcemap.js +1 -1
- package/dist/modules/corecompiler/summerCompiler.js +1 -1
- package/dist/modules/corecompiler/summerEntryProcess.js +1 -1
- package/dist/modules/createSummer.js +1 -1
- package/dist/modules/fullcompiler/app/app.js +1 -1
- package/dist/modules/fullcompiler/app/contactandlaunch/updateContactForSubpkg.js +1 -1
- package/dist/modules/fullcompiler/app/contactandlaunch/updatecontactandlaunch.js +1 -1
- package/dist/modules/index.js +1 -1
- package/dist/modules/nativecompiler/android/adb.js +1 -1
- package/dist/modules/nativecompiler/android/device.js +1 -1
- package/dist/modules/nativecompiler/android/index.js +1 -1
- package/dist/modules/nativecompiler/android/projectconfig.js +1 -1
- package/dist/modules/nativecompiler/index.js +1 -1
- package/dist/modules/nativecompiler/ios/buildCloud.js +1 -1
- package/dist/modules/nativecompiler/ios/device.js +1 -1
- package/dist/modules/nativecompiler/ios/index.js +1 -1
- package/dist/modules/nativecompiler/nativeEntryProcess.js +1 -1
- package/dist/modules/nativecompiler/processHandler.js +1 -1
- package/dist/modules/precompiler/conditioncompile/compiler/json.js +1 -1
- package/dist/modules/precompiler/conditioncompile/compiler/macro.js +1 -1
- package/dist/modules/precompiler/conditioncompile/index.js +1 -1
- package/dist/project/advance/precompileProject.js +1 -1
- package/dist/project/advance/reactiveProject.js +1 -1
- package/dist/project/baseProject.js +1 -1
- package/dist/project/ciProjectWithMockBuffer.js +1 -1
- package/dist/project/summerCPProject.js +1 -1
- package/dist/services/app/ci/appDirService.js +1 -0
- package/dist/services/common/getservice.js +1 -1
- package/dist/services/common/vsbase.js +1 -1
- package/dist/services/compilewxml/node/compileUtils.js +1 -1
- package/dist/services/compilewxml/node/compileglasseasel.js +1 -1
- package/dist/services/compilewxml/webide/pageFrameWasm/wcc/runWcc.js +1 -1
- package/dist/services/compilewxss/node/compileUtils.js +1 -1
- package/dist/services/compilewxss/webide/pageFrameWasm/wcsc/runWcsc.js +1 -1
- package/dist/services/multiTaskManager/ci/multiTaskManager.js +1 -0
- package/dist/services/multiTaskManager/common/multiTaskManager.js +1 -0
- package/dist/services/multiTaskManager/electron/multiTaskManager.js +1 -0
- package/dist/services/multiTaskManager/webide/multiTaskManager.js +1 -0
- package/dist/services/nativeModule/ci/nativeModule.js +1 -0
- package/dist/services/nativeModule/common/nativeModule.impl.js +1 -1
- package/dist/services/pluginFileReader/ci/pluginFileReader.js +1 -0
- package/dist/services/pluginFileReader/common/pluginFileReader.base.js +1 -0
- package/dist/services/pluginFileReader/common/pluginFileReader.js +1 -0
- package/dist/services/pluginFileReader/electron/pluginFileReader.js +1 -0
- package/dist/services/pluginFileReader/webide/pluginFileReader.js +1 -0
- package/dist/services/root/{node → ci}/root.js +1 -1
- package/dist/services/root/ci/rootService.js +1 -0
- package/dist/services/root/electron/root.js +1 -1
- package/dist/services/root/electron/rootService.js +1 -1
- package/dist/services/root/nw/root.js +1 -1
- package/dist/services/root/webide/root.js +1 -0
- package/dist/services/root/webide/rootService.js +1 -0
- package/dist/utils/asyncTask/index.js +1 -1
- package/dist/utils/babel_helper.js +1 -1
- package/dist/utils/babel_plugin_worklet.js +1 -1
- package/dist/utils/colorutils.js +1 -0
- package/dist/utils/common.js +1 -1
- package/dist/utils/cosUpload.js +1 -1
- package/dist/utils/cp.js +1 -1
- package/dist/utils/customError.js +1 -1
- package/dist/utils/debug.js +1 -1
- package/dist/utils/download.js +1 -1
- package/dist/utils/expression.js +1 -1
- package/dist/utils/fsagent.js +1 -1
- package/dist/utils/genTempFile.js +1 -1
- package/dist/utils/generateIpa.js +1 -1
- package/dist/utils/glob.js +1 -1
- package/dist/utils/hackrequire/wxvpkgreader.js +1 -1
- package/dist/utils/helper_util.js +1 -1
- package/dist/utils/jsonlint.js +1 -1
- package/dist/utils/locales/fomatable_string.js +1 -1
- package/dist/utils/locales/locales.js +1 -1
- package/dist/utils/log.js +1 -1
- package/dist/utils/messageHub.js +1 -1
- package/dist/utils/miniAppI18N.js +1 -1
- package/dist/utils/miniapp-builder.js +1 -1
- package/dist/utils/miniappJson.js +1 -1
- package/dist/utils/officialDonutPlugin.js +1 -1
- package/dist/utils/packOptionsHelper.js +1 -1
- package/dist/utils/processBootstrap.js +1 -0
- package/dist/utils/progressRecorder.js +1 -1
- package/dist/utils/request.js +1 -1
- package/dist/utils/singletontask.js +1 -1
- package/dist/utils/subprocess/entryProcess.js +1 -1
- package/dist/utils/subprocess/processManager.js +1 -1
- package/dist/utils/subprocess/processService.js +1 -1
- package/dist/utils/swc_helper.js +1 -1
- package/dist/utils/taskmanager.js +1 -1
- package/dist/utils/tools.js +1 -1
- package/dist/utils/usbProcess.js +1 -1
- package/dist/utils/waitable.js +1 -1
- package/dist/utils/web/common.js +1 -1
- package/dist/utils/white_ext_list.js +1 -1
- package/dist/utils/wxapkg/pack.js +1 -1
- package/dist/utils/wxvpkgreader/wxvpkg/reader/version0.js +1 -1
- package/dist/utils/wxvpkgreader/wxvpkg/reader/version10.js +1 -1
- package/dist/utils/wxvpkgreader/wxvpkg/unpack/version0.js +1 -1
- package/dist/utils/wxvpkgreader/wxvpkg/unpack/version10.js +1 -1
- package/dist/utils/wxvpkgreader/wxvpkgreader.js +1 -1
- package/dist/utils/zip.js +1 -1
- package/package.json +62 -3
- package/dist/@types/services/root/node/rootService.d.ts +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/darwin_arm64/wcc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/darwin_arm64/wcsc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/darwin_x64/wcc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/darwin_x64/wcsc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/node_16.1.0_darwin_arm64_release/wcc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/node_16.1.0_darwin_arm64_release/wcsc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/node_16.1.0_darwin_x64_release/wcc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/node_16.1.0_darwin_x64_release/wcsc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/win32_ia32/wcc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/win32_ia32/wcsc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/win32_x64/wcc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/build/win32_x64/wcsc.node +0 -0
- package/dist/modules/fullcompiler/trans/wcc/lib/addonVersion.js +0 -19
- package/dist/modules/fullcompiler/trans/wcc/lib/index.js +0 -4
- package/dist/modules/fullcompiler/trans/wcc/lib/util.js +0 -1134
- package/dist/modules/fullcompiler/trans/wcc/lib/wcc.js +0 -94
- package/dist/modules/fullcompiler/trans/wcc/lib/wcsc.js +0 -93
- package/dist/services/root/node/rootService.js +0 -1
- /package/dist/@types/services/root/{node → ci}/root.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkComponentPath=exports.getUseExtendLib=void 0,exports.checkJSONFormat=checkJSONFormat,exports.checkPagePathIsInSubPackage=checkPagePathIsInSubPackage,exports.checkPagePathIsInIndependentSubpackage=checkPagePathIsInIndependentSubpackage,exports.checkFilePathIsInIndependentSubpackage=checkFilePathIsInIndependentSubpackage,exports.getPageJSONVariableDecalearProperty=getPageJSONVariableDecalearProperty;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=require("lodash"),tools_1=require("../../../../utils/tools"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),common_1=require("../../../../utils/common"),config_1=require("../../../../config/config"),appJSON_1=require("./app/appJSON");function checkJSONFormat(e,t){let o={};e||(0,common_1.throwError)({filePath:t,msg:"Empty file is NOT a valid json file",code:config_1.JSON_PARSE_ERR});try{o=JSON.parse(e)}catch(o){const n=(0,tools_1.formatJSONParseErr)({filePath:t,data:e,error:o});(0,common_1.throwError)({filePath:t,msg:n,code:config_1.JSON_PARSE_ERR})}return o}function checkPagePathIsInSubPackage(e,t){const{subPackages:o,subpackages:n}=e;if(o||n)for(const e of o||n)if(t.startsWith(e.root))return e}function checkPagePathIsInIndependentSubpackage(e,t){const o=checkPagePathIsInSubPackage(e,t);if(o&&!0===o.independent)return o}function checkFilePathIsInIndependentSubpackage(e,t){const{subPackages:o}=e;if(o)for(const e of o)if(!0===e.independent){const o=e.root.replace(/^\//,"");if(t.startsWith(o))return o}}function checkNodeModulesFile2(e,t,o){var n,a;for(const i of o){const o
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkComponentPath=exports.getUseExtendLib=void 0,exports.checkJSONFormat=checkJSONFormat,exports.checkPagePathIsInSubPackage=checkPagePathIsInSubPackage,exports.checkPagePathIsInIndependentSubpackage=checkPagePathIsInIndependentSubpackage,exports.checkFilePathIsInIndependentSubpackage=checkFilePathIsInIndependentSubpackage,exports.getPageJSONVariableDecalearProperty=getPageJSONVariableDecalearProperty;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=require("lodash"),tools_1=require("../../../../utils/tools"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),common_1=require("../../../../utils/common"),config_1=require("../../../../config/config"),appJSON_1=require("./app/appJSON");function checkJSONFormat(e,t){let o={};e||(0,common_1.throwError)({filePath:t,msg:"Empty file is NOT a valid json file",code:config_1.JSON_PARSE_ERR});try{o=JSON.parse(e)}catch(o){const n=(0,tools_1.formatJSONParseErr)({filePath:t,data:e,error:o});(0,common_1.throwError)({filePath:t,msg:n,code:config_1.JSON_PARSE_ERR})}return o}function checkPagePathIsInSubPackage(e,t){const{subPackages:o,subpackages:n}=e;if(o||n)for(const e of o||n)if(t.startsWith(e.root))return e}function checkPagePathIsInIndependentSubpackage(e,t){const o=checkPagePathIsInSubPackage(e,t);if(o&&!0===o.independent)return o}function checkFilePathIsInIndependentSubpackage(e,t){const{subPackages:o}=e;if(o)for(const e of o)if(!0===e.independent){const o=e.root.replace(/^\//,"");if(t.startsWith(o))return o}}function checkNodeModulesFile2(e,t,o){var n,a;for(const i of o){const o=`${i}.json`,r=`${i}.wxml`;if((null===(n=e.stat(t,o))||void 0===n?void 0:n.isFile)&&(null===(a=e.stat(t,r))||void 0===a?void 0:a.isFile))return i}return""}function resolveComponentPath2(e,t,o,n){n=(0,tools_1.normalizePath)(n);const a=[path_1.default.posix.join(o,n),path_1.default.posix.join(o,n,"index")];let i=o.split(path_1.default.posix.sep);for(i=i.filter((e=>!!e));i.length;){const e=[path_1.default.posix.join(i.join(path_1.default.posix.sep),"miniprogram_npm",n),path_1.default.posix.join(i.join(path_1.default.posix.sep),"miniprogram_npm",n,"index")];a.push(...e),i.pop()}const r=[path_1.default.posix.join("miniprogram_npm",n),path_1.default.posix.join("miniprogram_npm",n,"index")];a.push(...r);const s=checkNodeModulesFile2(e,t,a);return s?{searchedPaths:a,requirePath:path_1.default.posix.relative(o,s)}:{searchedPaths:a,requirePath:""}}const innerCheckComponentPath=e=>{const{value:t,tips:o,project:n,root:a,relativePath:i}=e,r=`${o}: "${t}"`,s=path_1.default.posix.join(a,i);if(t.startsWith("plugin://")||t.startsWith("plugin-private://"))return t;const c=e=>n.stat(a,`${e}.json`)&&n.stat(a,`${e}.wxml`),p=(0,exports.getUseExtendLib)(n,i);if(t.startsWith("/")){if(p.length){const e=p.map((e=>`/miniprogram_npm/${e}`));let o=!1;for(const n of e)if(t.startsWith(n)){o=!0;break}if(o)return t}if(c(t))return t;if(c(`${t}/index`))return`${t}/index`;(0,common_1.throwError)({msg:locales_1.default.config.COMPONENT_NOT_FOUND.format(r,path_1.default.posix.join(n.projectPath,a,t)),filePath:s})}if(t.startsWith(".")){if(t.startsWith("../")){const e=t.replace(/^(\.\.\/)+/,"");if(c(`/${e}`))return t;if(c(`/${e}/index`))return`${t}/index`}if(c(path_1.default.posix.join(path_1.default.posix.dirname(i),`${t}`)))return t;if(c(path_1.default.posix.join(path_1.default.posix.dirname(i),`${t}/index`)))return`${t}/index`;(0,common_1.throwError)({msg:locales_1.default.config.COMPONENT_NOT_FOUND.format(r,path_1.default.posix.join(n.projectPath,a,path_1.default.posix.dirname(i),t)),filePath:s})}for(const e of p)if(t.startsWith(e))return"miniprogram-element"===e?`/miniprogram_npm/${e}/index`:t.replace(e,`/miniprogram_npm/${e}`);const l=resolveComponentPath2(n,a,path_1.default.posix.dirname(i),t);l.requirePath||(0,common_1.throwError)({msg:locales_1.default.config.COMPONENT_NOT_FOUND.format(r,l.searchedPaths.map((e=>path_1.default.posix.join(n.projectPath,a,e))).join("\n")),filePath:s});const d=l.requirePath||"";return d.startsWith(".")?d:`./${d}`},getUseExtendLib=(e,t)=>{var o;const n=(0,appJSON_1.getRawAppJSON)(e);let a=[];if("[object Object]"===Object.prototype.toString.call(n.useExtendedLib)){const e=Object.keys(config_1.extendedLibMap),t=Object.keys(n.useExtendedLib).filter((t=>!e.includes(t)));t.length&&(0,common_1.throwError)({msg:`${t.join(", ")} is not allowed in ["useExtendedLib"]`,filePath:"app.json"}),a=Object.keys(n.useExtendedLib||{}).filter((e=>n.useExtendedLib[e])).map((e=>config_1.extendedLibMap[e].packages)),a=(0,lodash_1.flattenDeep)(a)}const i=checkPagePathIsInSubPackage(n,t);if((null==i?void 0:i.useExtendedLib)&&"[object Object]"===Object.prototype.toString.call(i.useExtendedLib)){const e=Object.keys(config_1.extendedLibMap),t=Object.keys(i.useExtendedLib).filter((t=>!e.includes(t)));t.length&&(0,common_1.throwError)({msg:`${t.join(", ")} is not allowed in subPackages[${null===(o=n.subPackages)||void 0===o?void 0:o.indexOf(i)}]["useExtendedLib"]`,filePath:"app.json"});const r=Object.keys(i.useExtendedLib||{}).filter((e=>i.useExtendedLib[e])).map((e=>config_1.extendedLibMap[e].packages));a=(0,lodash_1.uniq)(a.concat((0,lodash_1.flattenDeep)(r)))}return a};exports.getUseExtendLib=getUseExtendLib;const checkComponentPath=e=>{const{project:t,root:o,relativePath:n,inputJSON:a}=e,{usingComponents:i,componentGenerics:r}=a;if(i)for(const e in i){const a=i[e]||"";i[e]=innerCheckComponentPath({tips:`["usingComponents"]["${e}"]`,value:a,project:t,root:o,relativePath:n})}if(r)for(const e in r){const a="object"==typeof r[e],i=a?r[e].default:r[e];if(!i||"string"!=typeof i)continue;const s=innerCheckComponentPath({tips:`["componentGenerics"]["${e}"]`,value:i,project:t,root:o,relativePath:n});a?r[e].default=s:r[e]=s}};function getPageJSONVariableDecalearProperty(e){const{windowPropertWhiteList:t}=config_1.jsonVariablePropertyWhiteList;let o=[];return"[object Object]"===Object.prototype.toString.call(e)&&(o=o.concat(Object.keys(e).filter((e=>t.includes(e))).map((t=>({property:`["${t}"]`,value:e[t]}))).filter((e=>e.value.startsWith("@"))))),o}exports.checkComponentPath=checkComponentPath;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),cache_1=require("../../../../utils/cache"),common_1=require("../../../../utils/common"),config_1=require("../../../../config/config"),tools_1=require("../../../../utils/tools"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),schemaValidate_1=require("../validate/schemaValidate"),signaturejson_1=tslib_1.__importDefault(require("../validate/signaturejson")),gamepluginjson_1=tslib_1.__importDefault(require("../validate/gamepluginjson")),projectconfig_1=require("./projectconfig"),common_2=require("./common"),reactiveCache_1=require("./reactiveCache");function isPluginMode(o){return o.type===config_1.COMPILE_TYPE.miniGamePlugin}function checkLocalPlugin(o,t){const{project:e,root:a,filePath:i}=o,r=t.path;let n=e.stat(a,r);n&&n.isDirectory||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t.tips+'["path"]',locales_1.default.config.DIRECTORY),filePath:i});const c=path_1.default.posix.join(r,"signature.json");n=e.stat(a,c);let s=(0,tools_1.normalizePath)(path_1.default.posix.join(a,c));n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t.tips+'["path"]',s),filePath:i,code:config_1.FILE_NOT_FOUND});let _=e.getFile(a,c),l=(0,common_1.checkUTF8)(_,s);const f=(0,common_2.checkJSONFormat)(l,s);try{signaturejson_1.default.check(f)}catch(o){(0,common_1.throwError)({msg:"signature.json"+o.message,filePath:s})}f.provider!==t.provider&&(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format('["provider"]',`"${t.provider}"`),filePath:s});for(let o=0;o<f.signature.length;o++){const t=f.signature[o];(0,common_1.checkPath)({value:t.path,tips:`["signature"][${o}]["path"]`,filePath:s});const i=path_1.default.posix.join(r,t.path);n=e.stat(a,i),n&&n.isFile||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["signature"][${o}]["path"]`,i),filePath:s,code:config_1.FILE_NOT_FOUND});const c=e.getFile(a,i),_=(0,tools_1.generateMD5)(c);_!==t.md5&&(0,common_1.throwError)({msg:locales_1.default.config.GAME_PLUGIN_SIGNATURE_MD5_NOT_MATCH_CONTENT.format(path_1.default.posix.join(r,t.path),_,t.md5),code:config_1.GAME_PLUGIN_LIB_MD5_NOT_MATCH,filePath:s})}const g=path_1.default.posix.join(r,"plugin.json");n=e.stat(a,g),s=(0,tools_1.normalizePath)(path_1.default.posix.join(a,g)),n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t.tips+'["path"]',s),code:config_1.FILE_NOT_FOUND,filePath:i}),_=e.getFile(a,g),l=(0,common_1.checkUTF8)(_,s);const u=(0,common_2.checkJSONFormat)(l,s);try{gamepluginjson_1.default.check(u)}catch(o){(0,common_1.throwError)({msg:"plugin.json"+o.message,filePath:s})}u.main&&((0,common_1.checkPath)({value:u.main,tips:'["main"]',filePath:s}),n=e.stat(a,path_1.default.posix.join(r,u.main)),n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["main"]',""+u.main),filePath:s,code:config_1.FILE_NOT_FOUND}))}function checkPluginPath(o,t){const{subPackages:e}=t,a=[],i=(o,t,e)=>{const{plugins:i}=o;if(i)for(const o in i){if(!i.hasOwnProperty(o))continue;const r=i[o];r&&r.path&&a.push({alias:o,version:r.version||"",provider:r.provider||"",tips:`${e}["plugins"]["${o}"]`,path:(0,tools_1.normalizePath)(path_1.default.posix.join(t,r.path))})}};if(i(t,"",""),e)for(let o=0;o<e.length;o++){const t=e[o];i(t,t.root||"",`["subPackages"][${o}]`)}if(!(a.length<=0))for(const t of a)checkLocalPlugin(o,t)}function checkPlugins(o,t){const{project:e,filePath:a}=o,i=[],r=t.plugins||{};function n(o,t){const{appid:r}=e,n=isPluginMode(e),c=(0,projectconfig_1.getProjectConfigJSON)(e),s=(null==c?void 0:c.pluginAppid)||r;if(n||"dev"!==o.version)if(n&&"dev"===o.version&&o.provider!==s)i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["provider"]',s));else if("dev"!==o.version||"string"!=typeof o.path){if("dev"===o.version||"latest"===o.version||/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test(o.version)||/^dev-[A-Za-z0-9]+$/.test(o.version))return o.path&&(0,common_1.checkPath)({value:o.path,tips:t+'["path"]',filePath:a}),!0;i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["version"]',locales_1.default.config.TRIPLE_NUMBER_DOT))}else i.push(locales_1.default.config.GAME_DEV_PLUGIN_SHOULD_NOT_USE_LOCAL_PATH.format(t,t+'["path"]'));else i.push(`${locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(t+'["version"]',"dev")}\n${locales_1.default.config.PLEASE_CHOOSE_PLUGIN_MODE}`)}const c={},s={};for(const o in r){if(!r.hasOwnProperty(o))continue;const t=r[o];n(t,`["plugins"]["${o}"]`)&&(c[t.provider]?i.push(locales_1.default.config.SAME_ITEM.format(`["plugins"]["${o}"]`,c[t.provider].tips,"provider")):c[t.provider]=s[o]={provider:t.provider,version:t.version,alias:o,path:t.path||"",tips:`["plugins"]["${o}"]`})}const _=t.subPackages||t.subpackages;if(Array.isArray(_))for(let o=0,t=_.length;o<t;o++){const t=_[o];if(!t.plugins)continue;const e=`["subPackages"][${o}]["plugins"]`;for(const o in t.plugins){const a=t.plugins[o],r=`${e}["${o}"]`;n(a,r)&&(c[a.provider]?i.push(locales_1.default.config.SAME_ITEM.format(r,c[a.provider].tips,"provider")):s[o]?i.push(locales_1.default.config.PLUGINS_SAME_ALIAS.format(r,s[o].tips)):c[a.provider]=s[o]={provider:a.provider,version:a.version,alias:o,path:a.path||"",tips:r})}}i.length>0&&(0,common_1.throwError)({msg:i.join("\n"),filePath:a})}function checkSubpackages(o,t){const{root:e,project:a,filePath:i}=o,r=[];let n='["subPackages"]';if(t.subpackages&&(n='["subpackages"]',t.subPackages=t.subpackages,delete t.subpackages),t.subPackages){const o=a.attrSync(),{setting:c}=o;t.subPackages.length>c.MaxSubPackageLimit&&(0,common_1.throwError)({msg:locales_1.default.config.EXCEED_LIMIT.format([n,c.MaxSubPackageLimit]),filePath:i});const s={},_={};for(let o=0,i=t.subPackages.length;o<i;o++){const i=t.subPackages[o];if(i.name){if(i.name===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["name"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(i.name===config_1.MINI_GAME_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["name"]`,config_1.MINI_GAME_MAIN_PACKAGE_ROOT));continue}s[i.name]&&r.push(locales_1.default.config.SAME_ITEM.format(`${n}[${o}]`,s[i.name],"name")),s[i.name]=`${n}[${o}]`}if(i.root===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(i.root===config_1.MINI_GAME_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_GAME_MAIN_PACKAGE_ROOT));continue}if(i.root===config_1.MINI_GAME_WORKERS_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_GAME_WORKERS_PACKAGE_ROOT));continue}if(i.root==="/"+config_1.MINI_GAME_WORKERS_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,"/"+config_1.MINI_GAME_WORKERS_PACKAGE_ROOT));continue}if(i.root.startsWith(".")){r.push(locales_1.default.config.JSON_SHOULD_NOT_START_WITH.format(`${n}[${o}]["root"]`,"."));continue}if(i.root.startsWith("__wx__")){r.push(locales_1.default.config.JSON_SHOULD_NOT_START_WITH.format(`${n}[${o}]["root"]`,"__wx__"));continue}i.root.startsWith("/")||(i.root=(0,tools_1.normalizePath)("/"+i.root)),i.root.endsWith(".js")?i.root=(0,tools_1.normalizePath)(i.root):i.root=(0,tools_1.normalizePath)(i.root+"/"),_[i.root]&&r.push(locales_1.default.config.SAME_ITEM.format(`${n}[${o}]`,_[i.root],"root")),_[i.root]=`${n}[${o}]`;const c=a.stat(e,i.root);if(c){if(c.isDirectory){i.root.endsWith("/")||(i.root+="/");const t=path_1.default.posix.join(i.root,"./game.js"),c=a.stat(e,t);c&&c.isFile||r.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`${n}[${o}]["root"]`,t))}}else r.push(locales_1.default.config.JSON_CONTENT_NOT_FOUND.format(`${n}[${o}]["root"]`))}}r.length>0&&(0,common_1.throwError)({msg:r.join("\n"),filePath:i})}function checkLoadingImageUrl(o,t){const{project:e,root:a,filePath:i}=o,{loadingImageInfo:r}=t;if(!r)return;(0,common_1.checkPath)({tips:'["loadingImageInfo"]["path"]',value:r.path,filePath:i});const n=e.stat(a,r.path);n&&n.isFile||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_NOT_FOUND.format(`["loadingImageInfo"]["path"]: "${r.path}"`),filePath:i}),r.progressBarColor&&!(0,tools_1.isHexColor)(r.progressBarColor)&&(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`["loadingImageInfo"]["progressBarColor"]: "${r.progressBarColor}"`,"HexColor"),filePath:i})}function checkWorkers(o,t){const{project:e,root:a,filePath:i}=o,{workers:r}=t;if(void 0===r)return;const n=(0,tools_1.getWorkersPath)(r);(0,common_1.checkPath)({tips:'["workers"]',value:n,filePath:i});const c=e.stat(a,n);c&&!c.isFile||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["workers"]',locales_1.default.config.DIRECTORY]),filePath:i})}function checkOpenDataContext(o,t){const{project:e,root:a,filePath:i}=o,{openDataContext:r}=t;if(void 0===r)return;(0,common_1.checkPath)({value:r,tips:'["openDataContext"]',filePath:i});const n=e.stat(a,r);n&&n.isDirectory||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["openDataContext"]',locales_1.default.config.DIRECTORY]),filePath:i});const c=path_1.default.posix.join(r,"./index.js"),s=e.stat(a,c);s&&s.isFile||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["openDataContext"]',c),filePath:i}),t.openDataContext=(0,tools_1.normalizePath)(r+"/")}function checkGameJSON(o){const{project:t,root:e,filePath:a}=o;t.stat(e,"game.json")||(0,common_1.throwError)({msg:locales_1.default.config.FILE_NOT_FOUND.format(path_1.default.posix.join(a)),filePath:a,code:config_1.FILE_NOT_FOUND});const i=t.getFile(e,"game.json"),r=(0,common_2.checkJSONFormat)((0,common_1.checkUTF8)(i,a),a),n=(0,schemaValidate_1.schemaValidate)("game",r);return n.warning&&(r.__warning__=locales_1.default.config.INVALID.format(n.warning)),(0,schemaValidate_1.transValidateResult)(a,n),checkOpenDataContext(o,r),checkPlugins(o,r),checkSubpackages(o,r),checkPluginPath(o,r),checkLoadingImageUrl(o,r),checkWorkers(o,r),r}const getGameJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.GAME_JSON,o=>{const t=(0,projectconfig_1.getProjectConfigJSON)(o).miniprogramRoot||"";return checkGameJSON({project:o,root:t,filePath:(0,tools_1.normalizePath)(path_1.default.posix.join(t,"game.json"))})});exports.default=getGameJSON;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),cache_1=require("../../../../utils/cache"),common_1=require("../../../../utils/common"),config_1=require("../../../../config/config"),tools_1=require("../../../../utils/tools"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),schemaValidate_1=require("../validate/schemaValidate"),signaturejson_1=tslib_1.__importDefault(require("../validate/signaturejson")),gamepluginjson_1=tslib_1.__importDefault(require("../validate/gamepluginjson")),projectconfig_1=require("./projectconfig"),common_2=require("./common"),reactiveCache_1=require("./reactiveCache");function isPluginMode(o){return o.type===config_1.COMPILE_TYPE.miniGamePlugin}function checkLocalPlugin(o,t){const{project:e,root:a,filePath:i}=o,r=t.path;let n=e.stat(a,r);n&&n.isDirectory||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`${t.tips}["path"]`,locales_1.default.config.DIRECTORY),filePath:i});const c=path_1.default.posix.join(r,"signature.json");n=e.stat(a,c);let s=(0,tools_1.normalizePath)(path_1.default.posix.join(a,c));n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`${t.tips}["path"]`,s),filePath:i,code:config_1.FILE_NOT_FOUND});let _=e.getFile(a,c),l=(0,common_1.checkUTF8)(_,s);const f=(0,common_2.checkJSONFormat)(l,s);try{signaturejson_1.default.check(f)}catch(o){(0,common_1.throwError)({msg:`signature.json${o.message}`,filePath:s})}f.provider!==t.provider&&(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format('["provider"]',`"${t.provider}"`),filePath:s});for(let o=0;o<f.signature.length;o++){const t=f.signature[o];(0,common_1.checkPath)({value:t.path,tips:`["signature"][${o}]["path"]`,filePath:s});const i=path_1.default.posix.join(r,t.path);n=e.stat(a,i),n&&n.isFile||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["signature"][${o}]["path"]`,i),filePath:s,code:config_1.FILE_NOT_FOUND});const c=e.getFile(a,i),_=(0,tools_1.generateMD5)(c);_!==t.md5&&(0,common_1.throwError)({msg:locales_1.default.config.GAME_PLUGIN_SIGNATURE_MD5_NOT_MATCH_CONTENT.format(path_1.default.posix.join(r,t.path),_,t.md5),code:config_1.GAME_PLUGIN_LIB_MD5_NOT_MATCH,filePath:s})}const u=path_1.default.posix.join(r,"plugin.json");n=e.stat(a,u),s=(0,tools_1.normalizePath)(path_1.default.posix.join(a,u)),n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`${t.tips}["path"]`,s),code:config_1.FILE_NOT_FOUND,filePath:i}),_=e.getFile(a,u),l=(0,common_1.checkUTF8)(_,s);const g=(0,common_2.checkJSONFormat)(l,s);try{gamepluginjson_1.default.check(g)}catch(o){(0,common_1.throwError)({msg:`plugin.json${o.message}`,filePath:s})}g.main&&((0,common_1.checkPath)({value:g.main,tips:'["main"]',filePath:s}),n=e.stat(a,path_1.default.posix.join(r,g.main)),n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["main"]',`${g.main}`),filePath:s,code:config_1.FILE_NOT_FOUND}))}function checkPluginPath(o,t){const{subPackages:e}=t,a=[],i=(o,t,e)=>{const{plugins:i}=o;if(i)for(const o in i){if(!i.hasOwnProperty(o))continue;const r=i[o];r&&r.path&&a.push({alias:o,version:r.version||"",provider:r.provider||"",tips:`${e}["plugins"]["${o}"]`,path:(0,tools_1.normalizePath)(path_1.default.posix.join(t,r.path))})}};if(i(t,"",""),e)for(let o=0;o<e.length;o++){const t=e[o];i(t,t.root||"",`["subPackages"][${o}]`)}if(!(a.length<=0))for(const t of a)checkLocalPlugin(o,t)}function checkPlugins(o,t){const{project:e,filePath:a}=o,i=[],r=t.plugins||{};function n(o,t){const{appid:r}=e,n=isPluginMode(e),c=(0,projectconfig_1.getProjectConfigJSON)(e),s=(null==c?void 0:c.pluginAppid)||r;if(n||"dev"!==o.version)if(n&&"dev"===o.version&&o.provider!==s)i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`${t}["provider"]`,s));else if("dev"!==o.version||"string"!=typeof o.path){if("dev"===o.version||"latest"===o.version||/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test(o.version)||/^dev-[A-Za-z0-9]+$/.test(o.version))return o.path&&(0,common_1.checkPath)({value:o.path,tips:`${t}["path"]`,filePath:a}),!0;i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`${t}["version"]`,locales_1.default.config.TRIPLE_NUMBER_DOT))}else i.push(locales_1.default.config.GAME_DEV_PLUGIN_SHOULD_NOT_USE_LOCAL_PATH.format(t,`${t}["path"]`));else i.push(`${locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${t}["version"]`,"dev")}\n${locales_1.default.config.PLEASE_CHOOSE_PLUGIN_MODE}`)}const c={},s={};for(const o in r){if(!r.hasOwnProperty(o))continue;const t=r[o];n(t,`["plugins"]["${o}"]`)&&(c[t.provider]?i.push(locales_1.default.config.SAME_ITEM.format(`["plugins"]["${o}"]`,c[t.provider].tips,"provider")):c[t.provider]=s[o]={provider:t.provider,version:t.version,alias:o,path:t.path||"",tips:`["plugins"]["${o}"]`})}const _=t.subPackages||t.subpackages;if(Array.isArray(_))for(let o=0,t=_.length;o<t;o++){const t=_[o];if(!t.plugins)continue;const e=`["subPackages"][${o}]["plugins"]`;for(const o in t.plugins){const a=t.plugins[o],r=`${e}["${o}"]`;n(a,r)&&(c[a.provider]?i.push(locales_1.default.config.SAME_ITEM.format(r,c[a.provider].tips,"provider")):s[o]?i.push(locales_1.default.config.PLUGINS_SAME_ALIAS.format(r,s[o].tips)):c[a.provider]=s[o]={provider:a.provider,version:a.version,alias:o,path:a.path||"",tips:r})}}i.length>0&&(0,common_1.throwError)({msg:i.join("\n"),filePath:a})}function checkSubpackages(o,t){const{root:e,project:a,filePath:i}=o,r=[];let n='["subPackages"]';if(t.subpackages&&(n='["subpackages"]',t.subPackages=t.subpackages,delete t.subpackages),t.subPackages){const o=a.attrSync(),{setting:c}=o;t.subPackages.length>c.MaxSubPackageLimit&&(0,common_1.throwError)({msg:locales_1.default.config.EXCEED_LIMIT.format([n,c.MaxSubPackageLimit]),filePath:i});const s={},_={};for(let o=0,i=t.subPackages.length;o<i;o++){const i=t.subPackages[o];if(i.name){if(i.name===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["name"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(i.name===config_1.MINI_GAME_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["name"]`,config_1.MINI_GAME_MAIN_PACKAGE_ROOT));continue}s[i.name]&&r.push(locales_1.default.config.SAME_ITEM.format(`${n}[${o}]`,s[i.name],"name")),s[i.name]=`${n}[${o}]`}if(i.root===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(i.root===config_1.MINI_GAME_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_GAME_MAIN_PACKAGE_ROOT));continue}if(i.root===config_1.MINI_GAME_WORKERS_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_GAME_WORKERS_PACKAGE_ROOT));continue}if(i.root===`/${config_1.MINI_GAME_WORKERS_PACKAGE_ROOT}`){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,`/${config_1.MINI_GAME_WORKERS_PACKAGE_ROOT}`));continue}if(i.root.startsWith(".")){r.push(locales_1.default.config.JSON_SHOULD_NOT_START_WITH.format(`${n}[${o}]["root"]`,"."));continue}if(i.root.startsWith("__wx__")){r.push(locales_1.default.config.JSON_SHOULD_NOT_START_WITH.format(`${n}[${o}]["root"]`,"__wx__"));continue}i.root.startsWith("/")||(i.root=(0,tools_1.normalizePath)(`/${i.root}`)),i.root.endsWith(".js")?i.root=(0,tools_1.normalizePath)(i.root):i.root=(0,tools_1.normalizePath)(`${i.root}/`),_[i.root]&&r.push(locales_1.default.config.SAME_ITEM.format(`${n}[${o}]`,_[i.root],"root")),_[i.root]=`${n}[${o}]`;const c=a.stat(e,i.root);if(c){if(c.isDirectory){i.root.endsWith("/")||(i.root+="/");const t=path_1.default.posix.join(i.root,"./game.js"),c=a.stat(e,t);c&&c.isFile||r.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`${n}[${o}]["root"]`,t))}}else r.push(locales_1.default.config.JSON_CONTENT_NOT_FOUND.format(`${n}[${o}]["root"]`))}}r.length>0&&(0,common_1.throwError)({msg:r.join("\n"),filePath:i})}function checkLoadingImageUrl(o,t){const{project:e,root:a,filePath:i}=o,{loadingImageInfo:r}=t;if(!r)return;(0,common_1.checkPath)({tips:'["loadingImageInfo"]["path"]',value:r.path,filePath:i});const n=e.stat(a,r.path);n&&n.isFile||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_NOT_FOUND.format(`["loadingImageInfo"]["path"]: "${r.path}"`),filePath:i}),r.progressBarColor&&!(0,tools_1.isHexColor)(r.progressBarColor)&&(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`["loadingImageInfo"]["progressBarColor"]: "${r.progressBarColor}"`,"HexColor"),filePath:i})}function checkWorkers(o,t){const{project:e,root:a,filePath:i}=o,{workers:r}=t;if(void 0===r)return;const n=(0,tools_1.getWorkersPath)(r);(0,common_1.checkPath)({tips:'["workers"]',value:n,filePath:i});const c=e.stat(a,n);c&&!c.isFile||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["workers"]',locales_1.default.config.DIRECTORY]),filePath:i})}function checkOpenDataContext(o,t){const{project:e,root:a,filePath:i}=o,{openDataContext:r}=t;if(void 0===r)return;(0,common_1.checkPath)({value:r,tips:'["openDataContext"]',filePath:i});const n=e.stat(a,r);n&&n.isDirectory||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["openDataContext"]',locales_1.default.config.DIRECTORY]),filePath:i});const c=path_1.default.posix.join(r,"./index.js"),s=e.stat(a,c);s&&s.isFile||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["openDataContext"]',c),filePath:i}),t.openDataContext=(0,tools_1.normalizePath)(`${r}/`)}function checkGameJSON(o){const{project:t,root:e,filePath:a}=o,i="game.json";t.stat(e,i)||(0,common_1.throwError)({msg:locales_1.default.config.FILE_NOT_FOUND.format(path_1.default.posix.join(a)),filePath:a,code:config_1.FILE_NOT_FOUND});const r=t.getFile(e,i),n=(0,common_2.checkJSONFormat)((0,common_1.checkUTF8)(r,a),a),c=(0,schemaValidate_1.schemaValidate)("game",n);return c.warning&&(n.__warning__=locales_1.default.config.INVALID.format(c.warning)),(0,schemaValidate_1.transValidateResult)(a,c),checkOpenDataContext(o,n),checkPlugins(o,n),checkSubpackages(o,n),checkPluginPath(o,n),checkLoadingImageUrl(o,n),checkWorkers(o,n),n}const getGameJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.GAME_JSON,(o=>{const t=(0,projectconfig_1.getProjectConfigJSON)(o).miniprogramRoot||"";return checkGameJSON({project:o,root:t,filePath:(0,tools_1.normalizePath)(path_1.default.posix.join(t,"game.json"))})}));exports.default=getGameJSON;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkPageJSON=checkPageJSON;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),common_1=require("../common"),schemaValidate_1=require("../../validate/schemaValidate"),tools_1=require("../../../../../utils/tools"),common_2=require("../../../../../utils/common"),theme_1=require("../theme"),checkHexColor=e=>{const{inputJSON:a,mode:o,pagePath:t,themeLocation:r}=e;let i
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.checkPageJSON=checkPageJSON;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),common_1=require("../common"),schemaValidate_1=require("../../validate/schemaValidate"),tools_1=require("../../../../../utils/tools"),common_2=require("../../../../../utils/common"),theme_1=require("../theme"),checkHexColor=e=>{const{inputJSON:a,mode:o,pagePath:t,themeLocation:r}=e;let i=`${t}.json`;if(a){r&&(i=`${t}.json or ${r}["${o}"]`);const{navigationBarBackgroundColor:e,backgroundColor:l}=a;void 0===e||(0,tools_1.isHexColor)(e)||(0,common_2.throwError)({msg:`["navigationBarBackgroundColor"]: "${e}" is not hexColor`,filePath:i}),void 0===l||(0,tools_1.isHexColor)(l)||(0,common_2.throwError)({msg:`["backgroundColor"]: "${l}" is not hexColor`,filePath:i})}};function checkPageJSON(e,a){const{pagePath:o,miniprogramRoot:t=""}=a,r=(0,tools_1.normalizePath)(path_1.default.posix.join(t,`${o}.json`));if(!e.stat("",r))return{};const i=e.getFile("",r),l=(0,common_1.checkJSONFormat)((0,common_2.checkUTF8)(i,r),r),n=(0,theme_1.getThemeLocation)(e);if(!n){const e=(0,common_1.getPageJSONVariableDecalearProperty)(l);e.length&&(0,common_2.throwError)({msg:`["themeLocation"] is required because:\n${e.map((e=>`"${e.value}" as variable was declared at ${r}:${e.property}`)).join("\n")}`,filePath:r})}let c={light:{},dark:{}};n&&(c=(0,theme_1.checkThemeJSON)(e,{themeLocation:n}));const m=(0,theme_1.mergeThemeJSONToPageJSON)(c,l,r),s=(0,schemaValidate_1.schemaValidate)("page",m.pageJSONLight),h=(0,schemaValidate_1.schemaValidate)("page",m.pageJSONDark),g=(0,common_1.getPageJSONVariableDecalearProperty)(m.pageJSONLight);g.length&&(0,common_2.throwError)({msg:g.map((e=>`"${e.value}" as variable was declared at ${r}:${e.property}, but not found at ${n}["light"]`)).join("\n"),filePath:r});const _=(0,common_1.getPageJSONVariableDecalearProperty)(m.pageJSONDark);return _.length&&(0,common_2.throwError)({msg:_.map((e=>`"${e.value}" as variable was declared at ${r}:${e.property}, but not found at ${n}["dark"]`)).join("\n"),filePath:r}),s.warning&&(l.__warning__=locales_1.default.config.INVALID.format(s.warning)),n&&h.warning&&(l.__warning__=locales_1.default.config.INVALID.format(h.warning)),(0,schemaValidate_1.transValidateResult)(n?`${r} or ${n}["light"]`:r,s),n&&(0,schemaValidate_1.transValidateResult)(`${r} or ${n}["dark"]`,h),checkHexColor({inputJSON:m.pageJSONLight,mode:"light",themeLocation:n||"",filePath:r,pagePath:o}),checkHexColor({inputJSON:m.pageJSONDark,mode:"dark",themeLocation:n||"",filePath:r,pagePath:o}),l}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.originGetPageJSON=originGetPageJSON,exports.getPageJSON=getPageJSON,exports.getPageJSONWithDisableSpreading=getPageJSONWithDisableSpreading;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=require("lodash"),extJSON_1=require("../app/extJSON"),app_1=require("../app"),tools_1=require("../../../../../utils/tools"),common_1=require("../common"),common_2=require("../../../../../utils/common"),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),reactiveCache_1=require("../reactiveCache"),checkPageJSON_1=require("./checkPageJSON"),spreadUsingComponent=e=>{const{project:o,pagePath:t,inputJSON:n}=e;if(t.includes("miniprogram_npm"))return;const a=(0,app_1.getAppJSON)(o);if((0,common_1.checkPagePathIsInIndependentSubpackage)(a,t))return;if(a.componentPlaceholder){n.componentPlaceholder=n.componentPlaceholder||{};for(const e in a.componentPlaceholder)n.componentPlaceholder[e]=n.componentPlaceholder[e]||a.componentPlaceholder[e]}const i=Object.assign({},a.usingComponents);if(0!==Object.keys(i).length){n.usingComponents||(n.usingComponents={});for(const e in i){if(n.usingComponents[e])continue;const o=i[e]||"";if(o.startsWith("/")||o.startsWith("plugin://")){n.usingComponents[e]=o;continue}const a=(0,tools_1.normalizePath)(path_1.default.posix.relative(path_1.default.posix.dirname(t),o));n.usingComponents[e]=a.startsWith(".")?a
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.originGetPageJSON=originGetPageJSON,exports.getPageJSON=getPageJSON,exports.getPageJSONWithDisableSpreading=getPageJSONWithDisableSpreading;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=require("lodash"),extJSON_1=require("../app/extJSON"),app_1=require("../app"),tools_1=require("../../../../../utils/tools"),common_1=require("../common"),common_2=require("../../../../../utils/common"),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),reactiveCache_1=require("../reactiveCache"),checkPageJSON_1=require("./checkPageJSON"),spreadUsingComponent=e=>{const{project:o,pagePath:t,inputJSON:n}=e;if(t.includes("miniprogram_npm"))return;const a=(0,app_1.getAppJSON)(o);if((0,common_1.checkPagePathIsInIndependentSubpackage)(a,t))return;if(a.componentPlaceholder){n.componentPlaceholder=n.componentPlaceholder||{};for(const e in a.componentPlaceholder)n.componentPlaceholder[e]=n.componentPlaceholder[e]||a.componentPlaceholder[e]}const i=Object.assign({},a.usingComponents);if(0!==Object.keys(i).length){n.usingComponents||(n.usingComponents={});for(const e in i){if(n.usingComponents[e])continue;const o=i[e]||"";if(o.startsWith("/")||o.startsWith("plugin://")){n.usingComponents[e]=o;continue}const a=(0,tools_1.normalizePath)(path_1.default.posix.relative(path_1.default.posix.dirname(t),o));n.usingComponents[e]=a.startsWith(".")?a:`./${a}`}}},mergeExtJSON=e=>{var o;const{project:t,inputJSON:n,pagePath:a}=e,i=(0,extJSON_1.getExtJSON)(t);(null===(o=null==i?void 0:i.extPages)||void 0===o?void 0:o[a])&&Object.assign(n,i.extPages[a])},checkComponentPath=e=>{const{project:o,miniprogramRoot:t,pagePath:n,inputJSON:a}=e;(0,common_1.checkComponentPath)({project:o,root:t,relativePath:`${n}.json`,inputJSON:a})},checkComponentGenerics=e=>{const{pagePath:o,inputJSON:t}=e,n=`${o}.json`;if(!t.componentGenerics)return;const a=[];for(const e in t.componentGenerics){const o=t.componentGenerics[e],n=(0,tools_1.getType)(o);"boolean"===n||"object"===n?"object"===n&&"string"!==(0,tools_1.getType)(o.default)&&a.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`["componentGenerics"]["${e}"]["default"]`,"string"])):a.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([`["componentGenerics"]["${e}"]`,"boolean/object"]))}a.length>0&&(0,common_2.throwError)({msg:a.join("\n"),filePath:n})};function checkRenderer(e){var o,t;const{filePath:n,inputJSON:a}=e,{renderer:i}=a,r=(0,app_1.getAppJSON)(e.project);if((0,common_2.getAllPages)(r).includes(e.pagePath)&&("skyline"===i&&"requiredComponents"!==r.lazyCodeLoading&&(0,common_2.throwError)({msg:locales_1.default.config.APP_JSON_SHOULD_SET_LAZYCODELOADING.format(n),filePath:n}),"skyline"===i||"skyline"===r.renderer&&void 0===i)){"default"===a.navigationStyle&&(0,common_2.throwError)({msg:locales_1.default.config.PAGE_JSON_SHOULD_SET_NAVIGATIONSTYLE_CUSTOM.format(n),filePath:n});!(a.navigationStyle?"custom"===a.navigationStyle:"custom"===(null===(o=r.window)||void 0===o?void 0:o.navigationStyle))&&(a.navigationBarTitleText||a.navigationBarTextStyle||a.navigationBarBackgroundColor)&&(0,common_2.throwError)({msg:locales_1.default.config.PAGE_JSON_SHOULD_SET_NAVIGATIONSTYLE_CUSTOM.format(n),filePath:n}),a.disableScroll=null===(t=a.disableScroll)||void 0===t||t,a.navigationStyle="custom"}}function checkComponentFramework(e){const{filePath:o,inputJSON:t}=e,{renderer:n,componentFramework:a}=t,i=(0,app_1.getAppJSON)(e.project);if(!(0,common_2.getAllPages)(i).includes(e.pagePath))return;const r="skyline"===n||"skyline"===i.renderer&&void 0===n,c="glass-easel"===a||"glass-easel"===i.componentFramework&&void 0===a;r&&(c||(0,common_2.throwError)({msg:locales_1.default.config.JSON_SHOULD_SET_COMPONENTFRAMEWORK_SKYLINE.format(o),filePath:o}))}const compilePageJSON=(e,o=!1)=>{mergeExtJSON(e),checkComponentGenerics(e),checkComponentPath(e),o||spreadUsingComponent(e),checkRenderer(e),checkComponentFramework(e)};function originGetPageJSON(e,o){const{pagePath:t,miniprogramRoot:n=""}=o,a=(0,tools_1.normalizePath)(path_1.default.posix.join(n,`${t}.json`)),i=(0,reactiveCache_1.tryToGetReactiveJSONCompiler)(e),r=(0,lodash_1.cloneDeep)(i.getPageJSON("checked",o));return compilePageJSON({project:e,miniprogramRoot:n,inputJSON:r,filePath:a,pagePath:t}),r.usingComponents||(r.usingComponents={}),r}async function getPageJSON(e,o){const t=(0,reactiveCache_1.tryToGetReactiveProject)(e);return(0,reactiveCache_1.tryToGetReactiveJSONCompiler)(t).getPageJSON("compiled",o)}function getPageJSONWithDisableSpreading(e,o){const t=(0,reactiveCache_1.tryToGetReactiveProject)(e),n=(0,reactiveCache_1.tryToGetReactiveJSONCompiler)(t),{pagePath:a,miniprogramRoot:i=""}=o,r=(0,tools_1.normalizePath)(path_1.default.posix.join(i,`${a}.json`)),c=(0,lodash_1.cloneDeep)(n.getPageJSON("checked",o));return compilePageJSON({project:t,miniprogramRoot:i,inputJSON:c,filePath:r,pagePath:a},!0),c.usingComponents||(c.usingComponents={}),c}reactiveCache_1.ReactiveJSONCompiler.setOriginCheckPageJSON(checkPageJSON_1.checkPageJSON),reactiveCache_1.ReactiveJSONCompiler.setOriginGetPageJSON(originGetPageJSON);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getGameLocalPluginJSON=exports.getDevPluginJSON=void 0,exports.checkComponentPath=checkComponentPath,exports.checkWorkers=checkWorkers;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),projectconfig_1=require("../projectconfig"),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),common_1=require("../common"),config_1=require("../../../../../config/config"),schemaValidate_1=require("../../validate/schemaValidate"),tools_1=require("../../../../../utils/tools"),cache_1=require("../../../../../utils/cache"),common_2=require("../../../../../utils/common"),reactiveCache_1=require("../reactiveCache");function checkComponentPath(o,e){const{project:t,root:c,filePath:i}=o;void 0!==e.usingComponents&&(0,common_1.checkComponentPath)({project:t,root:c,relativePath:path_1.default.posix.relative(c,i),inputJSON:e})}function checkPublicComponentsAndPages(o,e){const{project:t,root:c,filePath:i}=o,{publicComponents:n,pages:a}=e,r={};if(n){const o=[];for(const a in n){const n=e.publicComponents[a];(0,common_2.checkPath)({value:n,tips:`["publicComponents"]["${a}"]`,filePath:i,code:config_1.PLUGIN_JSON_CONTENT_ERR});let l=t.stat(c
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getGameLocalPluginJSON=exports.getDevPluginJSON=void 0,exports.checkComponentPath=checkComponentPath,exports.checkWorkers=checkWorkers;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),projectconfig_1=require("../projectconfig"),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),common_1=require("../common"),config_1=require("../../../../../config/config"),schemaValidate_1=require("../../validate/schemaValidate"),tools_1=require("../../../../../utils/tools"),cache_1=require("../../../../../utils/cache"),common_2=require("../../../../../utils/common"),reactiveCache_1=require("../reactiveCache");function checkComponentPath(o,e){const{project:t,root:c,filePath:i}=o;void 0!==e.usingComponents&&(0,common_1.checkComponentPath)({project:t,root:c,relativePath:path_1.default.posix.relative(c,i),inputJSON:e})}function checkPublicComponentsAndPages(o,e){const{project:t,root:c,filePath:i}=o,{publicComponents:n,pages:a}=e,r={};if(n){const o=[];for(const a in n){const n=e.publicComponents[a];(0,common_2.checkPath)({value:n,tips:`["publicComponents"]["${a}"]`,filePath:i,code:config_1.PLUGIN_JSON_CONTENT_ERR});let l=t.stat(c,`${n}.wxml`);l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["publicComponents"]["${n}"]`,`${n}.wxml`)),l=t.stat(c,`${n}.js`),l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["publicComponents"]["${n}"]`,`${n}.js`)),l=t.stat(c,`${n}.json`),l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["publicComponents"]["${n}"]`,`${n}.json`)),r[a]=!0}o.length>0&&(0,common_2.throwError)({msg:o.join("\n"),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i})}if(a){const o=[];for(const e in a){const n=a[e];(0,common_2.checkPath)({value:n,tips:`["pages"]["${e}"]`,filePath:i,code:config_1.PLUGIN_JSON_CONTENT_ERR});let l=t.stat(c,`${n}.wxml`);l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["pages"]["${n}"]`,`${n}.wxml`)),l=t.stat(c,`${n}.js`),l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["pages"]["${n}"]`,`${n}.js`)),l=t.stat(c,`${n}.json`),l&&!l.isDirectory||o.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["pages"]["${n}"]`,`${n}.json`)),r[e]&&o.push(locales_1.default.config.SAME_KEY_PAGE_PUBLICCOMPONENTS.format(`"${e}"`)),r[e]=!0}o.length>0&&(0,common_2.throwError)({msg:o.join("\n"),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i})}}function checkWorkers(o,e){const{project:t,root:c,filePath:i}=o,{workers:n}=e;if(void 0===n)return;const a='["workers"]';""===n&&(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(a,locales_1.default.config.DIRECTORY),filePath:i}),(0,common_2.checkPath)({value:n,tips:a,filePath:i});const r=t.stat(c,n);r&&r.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([a,locales_1.default.config.DIRECTORY]),filePath:i}),e.workers=(0,tools_1.normalizePath)(`${n}/`)}function checkMain(o,e){const{project:t,root:c,filePath:i}=o,{main:n}=e;if(void 0===n)return;""===n&&(0,common_2.throwError)({msg:locales_1.default.config.SHOULD_NOT_BE_EMPTY.format('["main"]'),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i}),(0,common_2.checkPath)({value:n,tips:'["main"]',filePath:i,code:config_1.PLUGIN_JSON_CONTENT_ERR});const a=t.stat(c,n);a&&!a.isDirectory||(0,common_2.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["main"]',n),code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i})}function isKindOfGamePlugin(o){return o.type===config_1.COMPILE_TYPE.miniGamePlugin}function checkPluginJSON(o){const{root:e="",project:t}=o,c="plugin.json",i=path_1.default.posix.join(e,c);t.stat(e,c)||(0,common_2.throwError)({msg:locales_1.default.config.PLUGIN_JSON_NOT_FOUND.format(e,c),code:config_1.PLUGIN_JSON_FILE_NOT_FOUND,filePath:i});const n=t.getFile(e,c),a=(0,common_1.checkJSONFormat)((0,common_2.checkUTF8)(n,i),i),r=(0,schemaValidate_1.schemaValidate)("plugin",a);if(r.error.length){const o=(0,schemaValidate_1.transValidateResult)(i,r,!0);(0,common_2.throwError)({msg:`pluginJSON$${o}`,code:config_1.PLUGIN_JSON_CONTENT_ERR,filePath:i})}return void 0!==a.themeLocation&&(0,common_2.checkPath)({value:a.themeLocation,tips:'["themeLocation"]',filePath:i}),isKindOfGamePlugin(t)||(checkPublicComponentsAndPages(o,a),checkComponentPath(o,a)),checkMain(o,a),checkWorkers(o,a),a}exports.getDevPluginJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.PLUGIN_JSON,((o,e="")=>{const t=(0,projectconfig_1.getProjectConfigJSON)(o),{pluginRoot:c=""}=t;let i=c;o.type===config_1.COMPILE_TYPE.miniGame&&e&&(i=e),e||c||(0,common_2.throwError)({msg:locales_1.default.config.NOT_FOUND.format('["pluginRoot"]'),filePath:"project.config.json",code:config_1.JSON_CONTENT_ERR});return checkPluginJSON({project:o,filePath:path_1.default.posix.join(i,"plugin.json"),root:i})}));const getGameLocalPluginJSON=async(o,e)=>{const t=await(0,projectconfig_1.getProjectConfigJSON)(o),{miniprogramRoot:c}=t;if(!e)return{};const i=(0,tools_1.normalizePath)(path_1.default.posix.join(c||"",e));return checkPluginJSON({project:(0,reactiveCache_1.tryToGetReactiveProject)(o),filePath:path_1.default.posix.join(i,"plugin.json"),root:i})};exports.getGameLocalPluginJSON=getGameLocalPluginJSON;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPluginPageJSON=getPluginPageJSON;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),common_1=require("../common"),schemaValidate_1=require("../../validate/schemaValidate"),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),common_2=require("../../../../../utils/common"),theme_1=require("../theme"),plugin_1=require("./plugin"),spreadUsingComponent=async(e,t)=>{const{project:a,root:i,filePath:n}=t,o=path_1.default.posix.relative(i,n);if(n.includes("miniprogram_npm/"))return;const r=await(0,plugin_1.getDevPluginJSON)(a,!0),s=Object.assign({},r.usingComponents);if(0!==Object.keys(s).length){e.usingComponents||(e.usingComponents={});for(const t in s){if(e.usingComponents[t])continue;const a=s[t]||"";if(a.startsWith("/")||a.startsWith("plugin://")){e.usingComponents[t]=a;continue}const i=path_1.default.posix.normalize(path_1.default.posix.relative(path_1.default.posix.dirname(o),a));e.usingComponents[t]=i.startsWith(".")?i
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPluginPageJSON=getPluginPageJSON;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),common_1=require("../common"),schemaValidate_1=require("../../validate/schemaValidate"),locales_1=tslib_1.__importDefault(require("../../../../../utils/locales/locales")),common_2=require("../../../../../utils/common"),theme_1=require("../theme"),plugin_1=require("./plugin"),spreadUsingComponent=async(e,t)=>{const{project:a,root:i,filePath:n}=t,o=path_1.default.posix.relative(i,n);if(n.includes("miniprogram_npm/"))return;const r=await(0,plugin_1.getDevPluginJSON)(a,!0),s=Object.assign({},r.usingComponents);if(0!==Object.keys(s).length){e.usingComponents||(e.usingComponents={});for(const t in s){if(e.usingComponents[t])continue;const a=s[t]||"";if(a.startsWith("/")||a.startsWith("plugin://")){e.usingComponents[t]=a;continue}const i=path_1.default.posix.normalize(path_1.default.posix.relative(path_1.default.posix.dirname(o),a));e.usingComponents[t]=i.startsWith(".")?i:`./${i}`}}};async function checkComponentPath(e,t){const{project:a,root:i,filePath:n}=t;await(0,common_1.checkComponentPath)({project:a,root:i,relativePath:path_1.default.posix.relative(i,n),inputJSON:e})}async function getPluginPageJSON(e){const{project:t}=e,{filePath:a}=e;if(!t.stat("",a))return{};const i=await t.getFile("",a),n=(0,common_1.checkJSONFormat)((0,common_2.checkUTF8)(i,a),a),o=await(0,theme_1.getPluginThemeLocation)(t);if(!o){const e=(0,common_1.getPageJSONVariableDecalearProperty)(n);e.length&&(0,common_2.throwError)({msg:`pluginJSON["themeLocation"] is required because:\n${e.map((e=>`"${e.value}" as variable was declared at ${a}:${e.property}`)).join("\n")}`,filePath:a})}let r={light:{},dark:{}};o&&(r=await(0,theme_1.checkThemeJSON)(t,{themeLocation:o,isPlugin:!0}));const s=(0,theme_1.mergeThemeJSONToPageJSON)(r,n,a),l=(0,schemaValidate_1.schemaValidate)("page",s.pageJSONLight),c=(0,schemaValidate_1.schemaValidate)("page",s.pageJSONDark);return l.warning&&(n.__warning__=locales_1.default.config.INVALID.format(l.warning)),o&&c.warning&&(n.__warning__=locales_1.default.config.INVALID.format(c.warning)),(0,schemaValidate_1.transValidateResult)(o?`${a} or ${o}["light"]`:a,l),o&&(0,schemaValidate_1.transValidateResult)(`${a} or ${o}["dark"]`,c),await checkComponentPath(n,e),await spreadUsingComponent(n,e),n}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getProjectConfigJSON=void 0;const tslib_1=require("tslib"),lodash_1=require("lodash"),common_1=require("../../../../utils/common"),schemaValidate_1=require("../validate/schemaValidate"),cache_1=require("../../../../utils/cache"),tools_1=require("../../../../utils/tools"),config_1=require("../../../../config/config"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),reactiveCache_1=require("./reactiveCache"),common_2=require("./common"),PROJECT_CONFIG_JSON="project.config.json",rootConfig=["svr","client","qcloudRoot","miniprogramRoot","pluginRoot","cloudfunctionRoot","jsserverRoot","testRoot"];function formatPath(o=""){return o&&"/"!==o?(o=(0,tools_1.normalizePath)(o
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getProjectConfigJSON=void 0;const tslib_1=require("tslib"),lodash_1=require("lodash"),common_1=require("../../../../utils/common"),schemaValidate_1=require("../validate/schemaValidate"),cache_1=require("../../../../utils/cache"),tools_1=require("../../../../utils/tools"),config_1=require("../../../../config/config"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),reactiveCache_1=require("./reactiveCache"),common_2=require("./common"),PROJECT_CONFIG_JSON="project.config.json",rootConfig=["svr","client","qcloudRoot","miniprogramRoot","pluginRoot","cloudfunctionRoot","jsserverRoot","testRoot"];function formatPath(o=""){return o&&"/"!==o?(o=(0,tools_1.normalizePath)(`${o}/`)).replace(/^(\/)*/,"").replace(/\.\.\//g,"").replace(/^\.\//,""):""}const _getProjectConfigJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.PROJECT_CONFIG,(o=>{if(!o.stat("",PROJECT_CONFIG_JSON))return o.type!==config_1.COMPILE_TYPE.miniGamePlugin&&o.type!==config_1.COMPILE_TYPE.miniProgramPlugin||(0,common_1.throwError)({msg:locales_1.default.config.NOT_FOUND.format("project.config.json"),code:config_1.FILE_NOT_FOUND,filePath:PROJECT_CONFIG_JSON}),{};const e=o.getFile("",PROJECT_CONFIG_JSON),t=(0,common_1.checkUTF8)(e,PROJECT_CONFIG_JSON),i=(0,common_2.checkJSONFormat)(t,PROJECT_CONFIG_JSON),r=(0,schemaValidate_1.schemaValidate)("projectconfig",i);return(0,schemaValidate_1.transValidateResult)(PROJECT_CONFIG_JSON,r),o.miniprogramRoot=i.miniprogramRoot||"",o.pluginRoot=i.pluginRoot||"",rootConfig.forEach((o=>{"string"==typeof i[o]?i[o]=formatPath(i[o]):i[o]=""})),"gamePlugin"!==i.compileType&&"plugin"!==i.compileType||i.pluginRoot||(0,common_1.throwError)({msg:locales_1.default.config.SHOULD_NOT_BE_EMPTY.format('["pluginRoot"]'),filePath:PROJECT_CONFIG_JSON}),"gamePlugin"!==i.compileType&&"plugin"!==i.compileType||i.pluginRoot!==i.miniprogramRoot||(0,common_1.throwError)({msg:locales_1.default.config.PLUGIN_PATH_SAME_WITH_MINIPROGRAM.format([i.pluginRoot,i.miniprogramRoot]),filePath:PROJECT_CONFIG_JSON}),i})),getProjectConfigJSON=function(o){const e=_getProjectConfigJSON(o);return(0,lodash_1.cloneDeep)(e)};exports.getProjectConfigJSON=getProjectConfigJSON;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ReactiveJSONCompiler=exports.ReactiveProject=void 0,exports.tryToGetReactiveProject=tryToGetReactiveProject,exports.tryToGetReactiveJSONCompiler=tryToGetReactiveJSONCompiler,exports.wrapCompileJSONFunc=wrapCompileJSONFunc,exports.cleanReactiveCache=cleanReactiveCache;const process_1=require("process"),reactivity_1=require("@vue/reactivity"),lodash_1=require("lodash"),tools_1=require("../../../../utils/tools"),reactiveProject_1=require("../../../../project/advance/reactiveProject");function makeReadonly(e){return e&&"object"==typeof e?(0,reactivity_1.readonly)(e):e}Object.defineProperty(exports,"ReactiveProject",{enumerable:!0,get:function(){return reactiveProject_1.ReactiveProject}});const reactiveProjectMap=new Map;function tryToGetReactiveProject(e){let t=reactiveProjectMap.get(e.projectPath);return t||(t=new reactiveProject_1.ReactiveProject(e),reactiveProjectMap.set(e.projectPath,t),t)}let isPending=!1;const pendingRunner=new Set,resolvedPromise=Promise.resolve();function runInNextTick(e){pendingRunner.add(e),isPending||(isPending=!0,resolvedPromise.then(()=>{const e=Date.now();try{const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ReactiveJSONCompiler=exports.ReactiveProject=void 0,exports.tryToGetReactiveProject=tryToGetReactiveProject,exports.tryToGetReactiveJSONCompiler=tryToGetReactiveJSONCompiler,exports.wrapCompileJSONFunc=wrapCompileJSONFunc,exports.cleanReactiveCache=cleanReactiveCache;const process_1=require("process"),reactivity_1=require("@vue/reactivity"),lodash_1=require("lodash"),tools_1=require("../../../../utils/tools"),reactiveProject_1=require("../../../../project/advance/reactiveProject");function makeReadonly(e){return e&&"object"==typeof e?(0,reactivity_1.readonly)(e):e}Object.defineProperty(exports,"ReactiveProject",{enumerable:!0,get:function(){return reactiveProject_1.ReactiveProject}});const reactiveProjectMap=new Map;function tryToGetReactiveProject(e){let t=reactiveProjectMap.get(e.projectPath);return t||(t=new reactiveProject_1.ReactiveProject(e),reactiveProjectMap.set(e.projectPath,t),t)}let isPending=!1;const pendingRunner=new Set,resolvedPromise=Promise.resolve();function runInNextTick(e){pendingRunner.add(e),isPending||(isPending=!0,resolvedPromise.then((()=>{const e=Date.now();try{const e=Array.from(pendingRunner);pendingRunner.clear(),isPending=!1,e.forEach((e=>{e()}))}finally{(0,tools_1.devtoolsInfo)(`[reactiveCache] nextTick update cost ${Date.now()-e} ms`)}})))}class ReactiveJSONCompiler{constructor(e){this.pageComputeds=new Map,this.jsonComputeds=new Map,this.project=e}release(){(0,tools_1.devtoolsLog)("[reactiveCache] reactiveJSONCompiler release")}registerOrGet(e,t,...r){let o=this.jsonComputeds.get(e);if(!o){let i;o=(0,reactivity_1.ref)(void 0),this.jsonComputeds.set(e,o),i=(0,reactivity_1.effect)((()=>{try{const e=t.call(null,this.project,...r);(0,lodash_1.isEqual)(e,o.value)||(o.value=makeReadonly(e))}catch(t){o.value=t instanceof Error?t:new Error(t.toString()),(0,tools_1.devtoolsLog)(`[reactiveCache] update ${e} failed: `,t)}}),{scheduler(){i&&i.active&&runInNextTick(i)}})}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(e,t){let r=this.pageComputeds.get(t.pagePath);r||(r={checked:(0,reactivity_1.ref)(void 0),compiled:(0,reactivity_1.ref)(void 0)},this.pageComputeds.set(t.pagePath,r));const o=r[e];if(void 0===o.value){let r;r=(0,reactivity_1.effect)((()=>{try{(0,tools_1.devtoolsInfo)(`[reactiveCache] start to update ${e} ${t.pagePath}`);const r="compiled"===e?ReactiveJSONCompiler.originGetPageJSON(this.project,t):ReactiveJSONCompiler.originCheckPageJSON(this.project,t);o.value=makeReadonly(r),(0,tools_1.devtoolsInfo)(`[reactiveCache] update finish ${e} ${t.pagePath}`)}catch(r){o.value=r instanceof Error?r:new Error(r.toString()),(0,tools_1.devtoolsLog)(`[reactiveCache] update ${e} ${t.pagePath} failed: `,r)}}),{scheduler(){r&&r.active&&(0,process_1.nextTick)(r)}})}const{value:i}=o;if(i instanceof Error)throw i;return i}}exports.ReactiveJSONCompiler=ReactiveJSONCompiler;const reactiveJSONCompilerMap=new Map;function tryToGetReactiveJSONCompiler(e){let t=reactiveJSONCompilerMap.get(e.projectPath);return t||(t=new ReactiveJSONCompiler(e),reactiveJSONCompilerMap.set(e.projectPath,t),t)}function wrapCompileJSONFunc(e,t){var r;return(null===(r=null===process||void 0===process?void 0:process.env)||void 0===r?void 0:r.BUILD_SERVER)?t:function(r,...o){r instanceof reactiveProject_1.ReactiveProject||(r=tryToGetReactiveProject(r));return tryToGetReactiveJSONCompiler(r).registerOrGet(e,t,...o)}}function cleanReactiveCache(){reactiveProjectMap.forEach((e=>{e.release()})),reactiveProjectMap.clear(),reactiveJSONCompilerMap.forEach((e=>{e.release()})),reactiveJSONCompilerMap.clear()}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.friendlyPathMake=exports.trailing=void 0,exports.getAllPluginsWithPath=getAllPluginsWithPath,exports.isPathValid=isPathValid,exports.getAllPluginSignatures=getAllPluginSignatures;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),tools_1=require("../../../../utils/tools"),log=tslib_1.__importStar(require("../../../../utils/log")),game_1=tslib_1.__importDefault(require("./game")),trailing=(t,e)=>t.endsWith(e)?t:t+e;exports.trailing=trailing;const friendlyPathMake=(t,e)=>path_1.default.normalize(path_1.default.join(t,e.replace(/\\/g,"/")).replace(/^\/+/,""));async function getAllPluginsWithPath(t){const e=(0,game_1.default)(t),i=[],a=(t,e="")=>{if(t.plugins)for(const a in t.plugins){if(!t.plugins.hasOwnProperty(a))continue;const r=t.plugins[a];r&&"string"==typeof r.path&&i.push({alias:a,version:r.version||"",provider:r.provider||"",path:r.path,friendlyPath:(0,exports.friendlyPathMake)(e,r.path)})}};a(e,"");const r=e.subPackages||e.subpackages;if(Array.isArray(r))for(const t of r)t&&"string"==typeof t.root&&a(t,t.root);return i}function isPathValid(t,e){if(e=e.replace(/\\/g,"/"),t=t.replace(/\\/g,"/"),e.includes("../")||e.endsWith("/.."))return!1;const i=(0,tools_1.normalizePath)(path_1.default.join(t,e)),a=(0,tools_1.normalizePath)(t);return!!i.startsWith(a)}async function getAllPluginSignatures(t){const e=await getAllPluginsWithPath(t),i=[];let a=t.miniprogramRoot?path_1.default.join(t.projectPath,t.miniprogramRoot):t.projectPath;a=(0,tools_1.normalizePath)(a),a=a.endsWith("/")?a
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.friendlyPathMake=exports.trailing=void 0,exports.getAllPluginsWithPath=getAllPluginsWithPath,exports.isPathValid=isPathValid,exports.getAllPluginSignatures=getAllPluginSignatures;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),fs_extra_1=tslib_1.__importDefault(require("fs-extra")),tools_1=require("../../../../utils/tools"),log=tslib_1.__importStar(require("../../../../utils/log")),game_1=tslib_1.__importDefault(require("./game")),trailing=(t,e)=>t.endsWith(e)?t:t+e;exports.trailing=trailing;const friendlyPathMake=(t,e)=>path_1.default.normalize(path_1.default.join(t,e.replace(/\\/g,"/")).replace(/^\/+/,""));async function getAllPluginsWithPath(t){const e=(0,game_1.default)(t),i=[],a=(t,e="")=>{if(t.plugins)for(const a in t.plugins){if(!t.plugins.hasOwnProperty(a))continue;const r=t.plugins[a];r&&"string"==typeof r.path&&i.push({alias:a,version:r.version||"",provider:r.provider||"",path:r.path,friendlyPath:(0,exports.friendlyPathMake)(e,r.path)})}};a(e,"");const r=e.subPackages||e.subpackages;if(Array.isArray(r))for(const t of r)t&&"string"==typeof t.root&&a(t,t.root);return i}function isPathValid(t,e){if(e=e.replace(/\\/g,"/"),t=t.replace(/\\/g,"/"),e.includes("../")||e.endsWith("/.."))return!1;const i=(0,tools_1.normalizePath)(path_1.default.join(t,e)),a=(0,tools_1.normalizePath)(t);return!!i.startsWith(a)}async function getAllPluginSignatures(t){const e=await getAllPluginsWithPath(t),i=[];let a=t.miniprogramRoot?path_1.default.join(t.projectPath,t.miniprogramRoot):t.projectPath;a=(0,tools_1.normalizePath)(a),a=a.endsWith("/")?a:`${a}/`;for(const t of e)try{const e=path_1.default.join(a,t.friendlyPath);let r=await fs_extra_1.default.pathExists(e);if(!r)continue;const n=await fs_extra_1.default.stat(e);let o=e;n.isDirectory()||(o=path_1.default.dirname(e));const s=path_1.default.join(o,"signature.json");if(r=await fs_extra_1.default.pathExists(s),!r)continue;const l=await fs_extra_1.default.readFile(s,"utf8");let u=null;try{u=JSON.parse(l)}catch(t){log.error(t);continue}if(!u||!Array.isArray(u.signature))continue;const p=[];for(let t=0;t<u.signature.length;t++){const e=u.signature[t];if(!e)continue;if("string"!=typeof e.path||"string"!=typeof e.md5)continue;if(!isPathValid(o,e.path))continue;const i=path_1.default.join(o,e.path);p.push({fullPath:i,md5:e.md5})}i.push({provider:t.provider,fullPath:e,signature:p})}catch(t){log.error(t);continue}return i}exports.friendlyPathMake=friendlyPathMake;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSiteMapJSON=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),tools_1=require("../../../../utils/tools"),common_1=require("../../../../utils/common"),schemaValidate_1=require("../validate/schemaValidate"),cache_1=require("../../../../utils/cache"),config_1=require("../../../../config/config"),reactiveCache_1=require("./reactiveCache"),common_2=require("./common"),projectconfig_1=require("./projectconfig"),appJSON_1=require("./app/appJSON");exports.getSiteMapJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.SITE_MAP_JSON,e=>{const t=(0,projectconfig_1.getProjectConfigJSON)(e),i=(0,appJSON_1.getAppJSON)(e),{sitemapLocation:o=""}=i;let a=o;if(a)a=(0,tools_1.normalizePath)(path_1.default.posix.join(t.miniprogramRoot||"",a));else{if(a=(0,tools_1.normalizePath)(path_1.default.posix.join(t.miniprogramRoot||"","sitemap.json")),!e.stat("",a))return e.type,config_1.COMPILE_TYPE.miniProgramPlugin,{desc:"",rules:[{action:"disallow",page:"*"}]}}const r=e.getFile("",a),c=(0,common_1.checkUTF8)(r,a),s=(0,common_2.checkJSONFormat)(c,a),p=(0,schemaValidate_1.schemaValidate)("sitemap",s);return(0,schemaValidate_1.transValidateResult)(a,p),s});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSiteMapJSON=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),tools_1=require("../../../../utils/tools"),common_1=require("../../../../utils/common"),schemaValidate_1=require("../validate/schemaValidate"),cache_1=require("../../../../utils/cache"),config_1=require("../../../../config/config"),reactiveCache_1=require("./reactiveCache"),common_2=require("./common"),projectconfig_1=require("./projectconfig"),appJSON_1=require("./app/appJSON");exports.getSiteMapJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.SITE_MAP_JSON,(e=>{const t=(0,projectconfig_1.getProjectConfigJSON)(e),i=(0,appJSON_1.getAppJSON)(e),{sitemapLocation:o=""}=i;let a=o;if(a)a=(0,tools_1.normalizePath)(path_1.default.posix.join(t.miniprogramRoot||"",a));else{if(a=(0,tools_1.normalizePath)(path_1.default.posix.join(t.miniprogramRoot||"","sitemap.json")),!e.stat("",a))return e.type,config_1.COMPILE_TYPE.miniProgramPlugin,{desc:"",rules:[{action:"disallow",page:"*"}]}}const r=e.getFile("",a),c=(0,common_1.checkUTF8)(r,a),s=(0,common_2.checkJSONFormat)(c,a),p=(0,schemaValidate_1.schemaValidate)("sitemap",s);return(0,schemaValidate_1.transValidateResult)(a,p),s}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getThemeLocation=void 0,exports.getPluginThemeLocation=getPluginThemeLocation,exports.checkThemeJSON=checkThemeJSON,exports.mergeThemeJSONToAppJSON=mergeThemeJSONToAppJSON,exports.mergeThemeJSONToPageJSON=mergeThemeJSONToPageJSON;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importStar(require("lodash")),tools_1=require("../../../../utils/tools"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),common_1=require("../../../../utils/common"),cache_1=require("../../../../utils/cache"),schemaValidate_1=require("../validate/schemaValidate"),config_1=require("../../../../config/config"),common_2=require("./common"),appJSON_1=require("./app/appJSON"),plugin_1=require("./plugin/plugin"),reactiveCache_1=require("./reactiveCache"),projectconfig_1=require("./projectconfig");async function getPluginThemeLocation(e){return(await(0,plugin_1.getDevPluginJSON)(e)).themeLocation||null}function checkThemeJSON(e,o){const{isPlugin:t}=o;return t?originCheckThemeJSONForPlugin(e,o):originCheckThemeJSONForMiniProgram(e,o)}exports.getThemeLocation=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.APP_JSON_THEME_LOCATION,e=>{const o=(0,appJSON_1.getRawAppJSON)(e),{themeLocation:t}=o;return"[object Undefined]"!==Object.prototype.toString.call(t)?"string"==typeof t?((0,common_1.checkPath)({value:t,tips:'["themeLocation"]',filePath:"app.json"}),t):((0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format('appJSON["themeLocation"]',"string"),filePath:"app.json"}),null):null});const originCheckThemeJSONForMiniProgram=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.THEME_JSON,originCheckThemeJSON),originCheckThemeJSONForPlugin=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.PLUGIN_THEME_JSON,originCheckThemeJSON);function originCheckThemeJSON(e,o){const{isPlugin:t}=o,i=(0,exports.getThemeLocation)(e),a=(0,projectconfig_1.getProjectConfigJSON)(e),r=t?a.pluginRoot:a.miniprogramRoot,c=(0,tools_1.normalizePath)(path_1.default.posix.join(r||"",i));e.stat("",c)||(0,common_1.throwError)({msg:locales_1.default.config.FILE_NOT_FOUND.format(c),filePath:"app.json"});const n=e.getFile("",c),l=(0,common_1.checkUTF8)(n,c),s=(0,common_2.checkJSONFormat)(l,c),h=(0,schemaValidate_1.schemaValidate)("theme",s);return(0,schemaValidate_1.transValidateResult)(c,h),s}function mergeThemeJSONToAppJSON(e,o){var t,i;const{windowPropertWhiteList:a,tabBarPropertyWhiteList:r,tabbarListItemPropertyWhiteList:c}=config_1.jsonVariablePropertyWhiteList,n=/^@/,l=lodash_1.default.cloneDeep(o.window||{}),s=lodash_1.default.cloneDeep(o.window||{});Object.keys(l).forEach(o=>{const t=l[o];if(n.test(t)){a.includes(o)||(0,common_1.throwError)({msg
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getThemeLocation=void 0,exports.getPluginThemeLocation=getPluginThemeLocation,exports.checkThemeJSON=checkThemeJSON,exports.mergeThemeJSONToAppJSON=mergeThemeJSONToAppJSON,exports.mergeThemeJSONToPageJSON=mergeThemeJSONToPageJSON;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importStar(require("lodash")),tools_1=require("../../../../utils/tools"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),common_1=require("../../../../utils/common"),cache_1=require("../../../../utils/cache"),schemaValidate_1=require("../validate/schemaValidate"),config_1=require("../../../../config/config"),common_2=require("./common"),appJSON_1=require("./app/appJSON"),plugin_1=require("./plugin/plugin"),reactiveCache_1=require("./reactiveCache"),projectconfig_1=require("./projectconfig");async function getPluginThemeLocation(e){return(await(0,plugin_1.getDevPluginJSON)(e)).themeLocation||null}function checkThemeJSON(e,o){const{isPlugin:t}=o;return t?originCheckThemeJSONForPlugin(e,o):originCheckThemeJSONForMiniProgram(e,o)}exports.getThemeLocation=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.APP_JSON_THEME_LOCATION,(e=>{const o=(0,appJSON_1.getRawAppJSON)(e),{themeLocation:t}=o;return"[object Undefined]"!==Object.prototype.toString.call(t)?"string"==typeof t?((0,common_1.checkPath)({value:t,tips:'["themeLocation"]',filePath:"app.json"}),t):((0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format('appJSON["themeLocation"]',"string"),filePath:"app.json"}),null):null}));const originCheckThemeJSONForMiniProgram=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.THEME_JSON,originCheckThemeJSON),originCheckThemeJSONForPlugin=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.PLUGIN_THEME_JSON,originCheckThemeJSON);function originCheckThemeJSON(e,o){const{isPlugin:t}=o,i=(0,exports.getThemeLocation)(e),a=(0,projectconfig_1.getProjectConfigJSON)(e),r=t?a.pluginRoot:a.miniprogramRoot,c=(0,tools_1.normalizePath)(path_1.default.posix.join(r||"",i));e.stat("",c)||(0,common_1.throwError)({msg:locales_1.default.config.FILE_NOT_FOUND.format(c),filePath:"app.json"});const n=e.getFile("",c),l=(0,common_1.checkUTF8)(n,c),s=(0,common_2.checkJSONFormat)(l,c),h=(0,schemaValidate_1.schemaValidate)("theme",s);return(0,schemaValidate_1.transValidateResult)(c,h),s}function mergeThemeJSONToAppJSON(e,o){var t,i;const{windowPropertWhiteList:a,tabBarPropertyWhiteList:r,tabbarListItemPropertyWhiteList:c}=config_1.jsonVariablePropertyWhiteList,n=/^@/,l=lodash_1.default.cloneDeep(o.window||{}),s=lodash_1.default.cloneDeep(o.window||{});Object.keys(l).forEach((o=>{const t=l[o];if(n.test(t)){a.includes(o)||(0,common_1.throwError)({msg:`${locales_1.default.config.SHOULD_NOT_IN.format([t,o])}`,filePath:"app.json"});const i=t.slice(1);l[o]=e.light[i]||t,s[o]=e.dark[i]||t}}));const h=(0,lodash_1.cloneDeep)(o),m=(0,lodash_1.cloneDeep)(o);if(h.window=l,m.window=s,null===(i=null===(t=o.tabBar)||void 0===t?void 0:t.list)||void 0===i?void 0:i.length){const t=lodash_1.default.cloneDeep(o.tabBar||{list:[]}),i=lodash_1.default.cloneDeep(o.tabBar||{list:[]});t.list&&t.list.length>0&&Object.keys(t).forEach((o=>{if("list"!==o){const a=t[o];if(n.test(a)){r.includes(o)||(0,common_1.throwError)({msg:`${locales_1.default.config.SHOULD_NOT_IN.format([a,o])}`,filePath:"app.json"});const c=a.slice(1);t[o]=e.light[c]||a,i[o]=e.dark[c]||a}}else t.list.forEach(((o,a)=>{Object.keys(o).forEach((r=>{const l=o[r];if(n.test(l)){c.includes(r)||(0,common_1.throwError)({msg:`${locales_1.default.config.SHOULD_NOT_IN.format([l,r])}`,filePath:"app.json"});const o=l.slice(1);t.list[a][r]=e.light[o]||l,i.list[a][r]=e.dark[o]||l}}))}))})),m.tabBar=i,h.tabBar=t}return{appJSONLight:h,appJSONDark:m}}function mergeThemeJSONToPageJSON(e,o,t){const i=config_1.jsonVariablePropertyWhiteList.windowPropertWhiteList,a=lodash_1.default.cloneDeep(o||{}),r=lodash_1.default.cloneDeep(o||{}),c=/^@/;return Object.keys(o).forEach((n=>{const l=o[n];if(c.test(l)){const o=l.slice(1);i.includes(n)||(0,common_1.throwError)({msg:`${locales_1.default.config.SHOULD_NOT_IN.format([l,n])}`,filePath:t}),r[n]=e.light[o]||l,a[n]=e.dark[o]||l}})),{pageJSONDark:a,pageJSONLight:r}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=default_1;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),read_package_tree_1=tslib_1.__importDefault(require("read-package-tree"));function checkDeps(e,t){var a,r;const n=new Set(Object.keys((null===(a=e.package)||void 0===a?void 0:a.dependencies)||{})),o=[];let s=e;for(;s;){const e=s.children||[];for(const t of e){const e=(null===(r=t.package)||void 0===r?void 0:r.name)||"";n.has(e)&&(n.delete(e),o.push(t))}s=s.parent}for(const e of o)t.has(e)||(t.add(e),checkDeps(e,t))}async function getDeps(e){return new Promise((t,a)=>{(0,read_package_tree_1.default)(e,(e,r)=>{if(e)return a(e);const n=new Set;try{checkDeps(r,n)}catch(e){return a(e)}t(Array.from(n))})})}async function default_1(e,t){if(null==t?void 0:t.length){const a=t.filter(e=>!/([\\/]|\b)node_modules/.test(e)),r=[],n={};for(const t of a){(await getDeps(path_1.default.join(e,path_1.default.dirname(t)))).forEach(e=>{r.push(e)})}for(const e of r){const t=e.isLink?e.path:e.realpath;n[path_1.default.normalize(path_1.default.join(t,"./package.json"))]=e}t=t.filter(t=>{const a=path_1.default.normalize(path_1.default.join(e,t));return!!n[a]})}return t}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=default_1;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),read_package_tree_1=tslib_1.__importDefault(require("read-package-tree"));function checkDeps(e,t){var a,r;const n=new Set(Object.keys((null===(a=e.package)||void 0===a?void 0:a.dependencies)||{})),o=[];let s=e;for(;s;){const e=s.children||[];for(const t of e){const e=(null===(r=t.package)||void 0===r?void 0:r.name)||"";n.has(e)&&(n.delete(e),o.push(t))}s=s.parent}for(const e of o)t.has(e)||(t.add(e),checkDeps(e,t))}async function getDeps(e){return new Promise(((t,a)=>{(0,read_package_tree_1.default)(e,((e,r)=>{if(e)return a(e);const n=new Set;try{checkDeps(r,n)}catch(e){return a(e)}t(Array.from(n))}))}))}async function default_1(e,t){if(null==t?void 0:t.length){const a=t.filter((e=>!/([\\/]|\b)node_modules/.test(e))),r=[],n={};for(const t of a){(await getDeps(path_1.default.join(e,path_1.default.dirname(t)))).forEach((e=>{r.push(e)}))}for(const e of r){const t=e.isLink?e.path:e.realpath;n[path_1.default.normalize(path_1.default.join(t,"./package.json"))]=e}t=t.filter((t=>{const a=path_1.default.normalize(path_1.default.join(e,t));return!!n[a]}))}return t}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.packNpm=packNpm,exports.packNpmManually=packNpmManually;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),fs_1=tslib_1.__importDefault(require("fs")),rimraf_1=tslib_1.__importDefault(require("rimraf")),lodash_1=tslib_1.__importDefault(require("lodash")),glob_1=tslib_1.__importDefault(require("glob")),source_map_1=tslib_1.__importDefault(require("source-map")),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),error_1=require("../../../../utils/error"),log=tslib_1.__importStar(require("../../../../utils/log")),projectconfig_1=require("../json/projectconfig"),config_1=require("../../../../config/config"),filterdeps_1=tslib_1.__importDefault(require("./filterdeps")),acorn=require("acorn"),NPM_RECORD={start_time:Date.now(),pack_time:0,miniprogram_pack_num:0,other_pack_num:0,warn_not_found_num:0,warn_require_var_num:0,warn_require_rename_num:0,extra1:"",extra2:"",extra3:""},REPORT_LIST=["pack_time","miniprogram_pack_num","other_pack_num","warn_not_found_num","warn_require_var_num","warn_require_rename_num","extra1","extra2","extra3"];function wrap(e,t){return function(...a){if(a.length){const e=a.pop();"function"!=typeof e&&a.push(e)}return new Promise((n,r)=>{a.push((e,t)=>{e?r(e):n(t)}),e.apply(t||null,a)})}}const statSync=wrap(fs_1.default.stat),mkdirSync=wrap(fs_1.default.mkdir),readFileSync=wrap(fs_1.default.readFile),writeFileSync=wrap(fs_1.default.writeFile),accessSync=wrap(fs_1.default.access),renameSync=wrap(fs_1.default.rename),globSync=wrap(glob_1.default);let seed=+new Date;function getId(){return++seed}function startRecord(){NPM_RECORD.start_time=Date.now(),REPORT_LIST.forEach(e=>NPM_RECORD[e]=e.startsWith("extra")?"":0)}function endRecord(e){NPM_RECORD.pack_time=Date.now()-NPM_RECORD.start_time;const t={};REPORT_LIST.forEach(e=>t[e]=NPM_RECORD[e]);try{null==e||e(t)}catch(e){}}async function recursiveMkdir(e){const t=path_1.default.posix.dirname(e);try{await accessSync(t)}catch(e){await recursiveMkdir(t)}try{await accessSync(e);const t=await statSync(e);t&&!t.isDirectory()&&(await renameSync(e,e+".bak"),log.warn(e+" already exists but is not a directory, so it will be rename to a file with the suffix ending in '.bak'"),await mkdirSync(e))}catch(t){await mkdirSync(e)}}async function copyFile(e,t){const a=await readFileSync(e);await writeFile(a,t)}async function writeFile(e,t){await recursiveMkdir(path_1.default.posix.dirname(t)),await writeFileSync(t,e)}function walkNode(e,t){t(e),Object.keys(e).forEach(a=>{const n=e[a];Array.isArray(n)&&n.forEach(e=>{(null==e?void 0:e.type)&&walkNode(e,t)}),(null==n?void 0:n.type)&&walkNode(n,t)})}function parseDeps(e,t,a){const n=[];let r,o=[];try{r=acorn.parse(e,{sourceType:"module",locations:!0,allowHashBang:!0,onComment(t,a,n,r){t||"#"!==e[n]||o.push({start:n,end:r,adjustContent:""})}})}catch(e){const a=`parse js file (${t}) failed: ${e.message}`;throw console.error(a),e.message=a,e}return walkNode(r,r=>{const{callee:i}=r,s=r.arguments;if("CallExpression"===r.type&&i&&"Identifier"===i.type&&"require"===i.name&&s&&1===s.length&&("Literal"===s[0].type?n.push(s[0].value):(a.push({jsPath:t,code:e.substring(r.start,r.end),startLine:r.loc.start.line,endLine:r.loc.end.line,tips:"require variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_VAR.format()}),NPM_RECORD.warn_require_var_num++)),"ExpressionStatement"===r.type&&r.expression&&"use strict"===r.expression.value&&o.push({start:r.start,end:r.end,adjustContent:""}),"ImportDeclaration"===r.type){const{source:e}=r,{specifiers:t}=r,a={start:r.start,end:r.end,adjustContent:""},i=[];e&&"Literal"===e.type&&(n.push(e.value),i.push(`var __TEMP__ = require('${e.value}');`)),t&&Array.isArray(t)&&t.forEach(e=>{if("ImportSpecifier"===e.type){const{local:t}=e,{imported:a}=e;"Identifier"===t.type&&"Identifier"===a.type&&i.push(`var ${t.name} = __TEMP__['${a.name}'];`)}else if("ImportDefaultSpecifier"===e.type){const{local:t}=e;"Identifier"===t.type&&i.push(`var ${t.name} = __REQUIRE_DEFAULT__(__TEMP__);`)}else if("ImportNamespaceSpecifier"===e.type){const{local:t}=e;"Identifier"===t.type&&i.push(`var ${t.name} = __REQUIRE_WILDCARD__(__TEMP__);`)}}),a.adjustContent=i.join(""),o.push(a)}if("ExportNamedDeclaration"===r.type){const{source:t}=r,{specifiers:a}=r,{declaration:i}=r;let s=!1;const p={start:r.start,end:r.end,adjustContent:""},c=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];if(t&&"Literal"===t.type&&(n.push(t.value),c.push(`var __TEMP__ = require('${t.value}');`),s=!0),i){if("VariableDeclaration"===i.type){const{declarations:t}=i;t&&Array.isArray(t)&&t.forEach(t=>{if("VariableDeclarator"===t.type){const{id:a}=t,{init:n}=t;a&&"Identifier"===a.type&&(p.notAddLines=!0,c.push(`var ${a.name} = exports.${a.name} = ${n?e.substring(n.start,n.end):"undefined"};`))}})}else if("FunctionDeclaration"===i.type){const{id:t}=i;t&&"Identifier"===t.type&&(p.notAddLines=!0,c.push(`${e.substring(i.start,i.end)};exports.${t.name} = ${t.name}`))}else if("ClassDeclaration"===i.type){const{id:t}=i;t&&"Identifier"===t.type&&(p.notAddLines=!0,c.push(`${e.substring(i.start,i.end)};exports.${t.name} = ${t.name}`))}}else;a&&Array.isArray(a)&&a.forEach(e=>{if("ExportSpecifier"===e.type){const{local:t}=e,{exported:a}=e;"Identifier"===t.type&&"Identifier"===a.type&&c.push(`Object.defineProperty(exports, '${a.name}', { enumerable: true, configurable: true, get: function() { return ${s?"__TEMP__.":""}${t.name}; } });`)}}),p.adjustContent=c.join(""),o.push(p)}else if("ExportAllDeclaration"===r.type){const{source:e}=r,t={start:r.start,end:r.end,adjustContent:""},a=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];e&&"Literal"===e.type&&(n.push(e.value),a.push(`var __TEMP__ = require('${e.value}');`)),a.push('Object.keys(__TEMP__).forEach(function(k) { if (k === "default" || k === "__esModule") return; Object.defineProperty(exports, k, { enumerable: true, configurable: true, get: function() { return __TEMP__[k]; } }); });'),t.adjustContent=a.join(""),o.push(t)}else if("ExportDefaultDeclaration"===r.type){const{declaration:t}=r,a={start:r.start,end:r.end,adjustContent:""},n=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];if(t)if(a.notAddLines=!0,t.id){const{id:a}=t;n.push(`${e.substring(t.start,t.end)};exports.default = ${a.name}`)}else n.push(`exports.default = ${e.substring(t.start,t.end)};`);a.adjustContent=n.join(""),o.push(a)}const{expression:p}=r;"ExpressionStatement"===r.type&&p&&"AssignmentExpression"===p.type&&"Identifier"===p.right.type&&"require"===p.right.name&&(a.push({jsPath:t,code:e.substring(r.start,r.end),startLine:r.loc.start.line,endLine:r.loc.end.line,tips:"assign require function to a variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_ASSIGN.format()}),NPM_RECORD.warn_require_rename_num++);const{declarations:c}=r;"VariableDeclaration"===r.type&&c.length>0&&c.forEach(n=>{const{init:o}=n;"VariableDeclarator"===n.type&&o&&"Identifier"===o.type&&"require"===o.name&&(a.push({jsPath:t,code:e.substring(r.start,r.end),startLine:r.loc.start.line,endLine:r.loc.end.line,tips:"assign require function to a variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_ASSIGN.format()}),NPM_RECORD.warn_require_rename_num++)})}),o=o.sort((e,t)=>t.start-e.start),o.forEach(t=>{const a=e.substring(t.start,t.end),n=t.notAddLines?0:a.split("\n").length;e=e.substring(0,t.start)+t.adjustContent+new Array(n).join("\n")+e.substring(t.end)}),{deps:n,parsedContent:e}}async function parseJs(e,t,a,n,r,o){if(r[t=path_1.default.posix.normalize(t)])return r[t];const i=await readFileSync(t,"utf8"),s=getId(),p=path_1.default.posix.relative(e,t);if(t.endsWith(".json")){const e={id:s,name:p,content:"module.exports = "+i,deps:[],depsMap:{}};return r[t]=s,n.push(e),s}const{deps:c,parsedContent:_}=parseDeps(i,t,o),u={id:s,name:p,content:_,deps:c,depsMap:{}};r[t]=s,n.push(u);for(const i of c){let s,p=path_1.default.posix.join(path_1.default.posix.dirname(t),i);if(!p.endsWith(".js")&&!p.endsWith(".json")){const e=p+".js";try{await accessSync(e),p=e}catch(e){}}try{const e=await statSync(p);(null==e?void 0:e.isDirectory())&&(p=path_1.default.posix.join(p,"index.js"))}catch(e){}p.endsWith(".js")||p.endsWith(".json")||(p+=".js");try{await accessSync(p),s=await parseJs(e,p,a,n,r,o)}catch(e){}s&&(u.depsMap[i]=s)}return s}function addJsToMap(e,t,a,n){const r=t.split("\n").length;for(let o=1;o<=r;o++)e.addMapping({generated:{line:n+o,column:0},original:{line:o,column:0},source:a}),e.setSourceContent(a,t)}function findOutsideDeps(e){const t=new Set;return e.forEach(e=>{e.deps.forEach(a=>{Object.keys(e.depsMap).includes(a)||t.add(a)})}),Array.from(t)}async function packJs(e,t,a){try{const t=await statSync(e);(null==t?void 0:t.isDirectory())&&(e=path_1.default.posix.join(e,"index.js"))}catch(e){}e.endsWith(".js")||e.endsWith(".json")||(e+=".js");try{await accessSync(e)}catch(t){return a.push({jsPath:e,code:"",tips:"entry file is not found",msg:locales_1.default.config.NOT_FOUND_NPM_ENTRY.format()}),void NPM_RECORD.warn_not_found_num++}const n=new source_map_1.default.SourceMapGenerator({file:"index.js"}),r=[];await parseJs(path_1.default.posix.dirname(e),e,t,r,{},a);const o=findOutsideDeps(r),i=["module.exports = (function() {","var __MODS__ = {};","var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };",'var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };',"var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };","var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };"];if(r.length){const e=r.shift();i.push(`__DEFINE__(${e.id}, function(require, module, exports) {`),addJsToMap(n,e.content,e.name,i.length),i.push(e.content),i.push(`}, function(modId) {var map = ${JSON.stringify(e.depsMap)}; return __REQUIRE__(map[modId], modId); })`);for(const e of r)i.push(`__DEFINE__(${e.id}, function(require, module, exports) {`),addJsToMap(n,e.content,e.name,i.length),i.push(e.content),i.push(`}, function(modId) { var map = ${JSON.stringify(e.depsMap)}; return __REQUIRE__(map[modId], modId); })`);i.push(`return __REQUIRE__(${e.id});`)}return i.push("})()"),i.push("//miniprogram-npm-outsideDeps="+JSON.stringify(o)),i.push("//# sourceMappingURL=index.js.map"),{js:i.join("\n"),map:n.toString()}}async function checkIsMiniprogramPack(e,t){let a="miniprogram_dist";t.miniprogram&&"string"==typeof t.miniprogram&&(a=t.miniprogram);try{const t=path_1.default.posix.join(e,a);await accessSync(t);const n=await statSync(t);if(null==n?void 0:n.isDirectory())return t}catch(e){}return""}async function packNpm(e,t={}){const{projectPath:a}=e,n=e.type,r=await(0,projectconfig_1.getProjectConfigJSON)(e),o=r.pluginRoot||"",i=r.miniprogramRoot||"",s="miniProgramPlugin"===n||"miniGamePlugin"===n,{ignores:p,reporter:c}=t;if(!a)throw new error_1.CodeError(locales_1.default.config.SHOULD_NOT_BE_EMPTY.format("projectPath"),config_1.PARAM_ERROR);if("miniProgramPlugin"===n&&!o)throw new error_1.CodeError(locales_1.default.config.SHOULD_NOT_BE_EMPTY.format('project.config.json "pluginRoot"'),config_1.PARAM_ERROR);startRecord();const _=path_1.default.isAbsolute(a)?a:path_1.default.posix.join(process.cwd(),a),u=[{searchRoot:path_1.default.posix.join(_,i),paths:await globSync("**/package.json",{cwd:path_1.default.posix.join(_,i),nodir:!0,dot:!0,ignore:(p||[]).concat("**/node_modules/**")})}];s&&u.push({searchRoot:path_1.default.posix.join(_,o),paths:await globSync("**/package.json",{cwd:path_1.default.posix.join(_,o),nodir:!0,dot:!0,ignore:(p||[]).concat("**/node_modules/**")})});lodash_1.default.flattenDeep(u.map(e=>e.paths.map(t=>path_1.default.posix.join(e.searchRoot,path_1.default.dirname(t),"miniprogram_npm")))).forEach(e=>rimraf_1.default.sync(e));const l=[];for(const e of u)for(const t of e.paths){const a=path_1.default.dirname(path_1.default.posix.join(e.searchRoot,t)),n=lodash_1.default.xorWith(e.paths,[t]).map(e=>path_1.default.posix.join(path_1.default.posix.dirname(e),"/**")).filter(e=>"**"!==e);let r=await globSync("**/package.json",{cwd:a.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:(p||[]).concat(n).concat(["node_modules/@types/**"])});if(r=await(0,filterdeps_1.default)(a,r),r&&r.length)for(const e of r){const t=path_1.default.posix.join(a,e);let n=await readFileSync(t,"utf8");const r=path_1.default.dirname(t);let o=r.replace(/([\b/\\])node_modules([\b/\\])/g,(e,t,a)=>`${t}miniprogram_npm${a}`),i=path_1.default.basename(o);const s=i.split("@");s.length&&(i=s.pop()||""),o=o.replace(path_1.default.basename(o),i),n=JSON.parse(n);const p=path_1.default.posix.join(r,n.main||"index.js"),c=await checkIsMiniprogramPack(r,n);if(c){const e=await globSync("**/*",{cwd:c.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:"**/node_modules/**"});for(const t of e)await copyFile(path_1.default.posix.join(c,t),path_1.default.posix.join(o,t));NPM_RECORD.miniprogram_pack_num++}else{const e=await packJs(p,o,l);if(!e)continue;await writeFile(e.js,path_1.default.posix.join(o,"./index.js")),await writeFile(e.map,path_1.default.posix.join(o,"./index.js.map")),NPM_RECORD.other_pack_num++}}}if(endRecord(c),NPM_RECORD.miniprogram_pack_num+NPM_RECORD.other_pack_num<=0)throw new Error("__NO_NODE_MODULES__ "+locales_1.default.config.NOT_FOUND_NODE_MODULES.format());return"function"==typeof e.updateFileAndDirs&&e.updateFileAndDirs(),l}async function packNpmManually(e){let{packageJsonPath:t,miniprogramNpmDistDir:a}=e;const n=e.ignores||[],r={pack_time:0,miniprogram_pack_num:0,other_pack_num:0,warn_not_found_num:0,warn_require_var_num:0,warn_require_rename_num:0},o=[];if(!a)throw new Error("param miniprogramNpmDistDir is required");if(!t)throw new Error("param packageJsonPath is required");if(path_1.default.isAbsolute(a)||(a=path_1.default.join(process.cwd(),a)),path_1.default.isAbsolute(t)||(t=path_1.default.join(process.cwd(),t)),!fs_1.default.existsSync(t))throw new Error(`param packageJsonPath: ${t} file is not exited`);const i=path_1.default.dirname(t);let s=await globSync("**/package.json",{cwd:i.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:(n||[]).concat(["node_modules/@types/**"])});if(s=await(0,filterdeps_1.default)(i,s),!s||!s.length){const e={jsPath:i,code:"",tips:"",msg:"No miniprogram_npm package was found, please check package.json -> dependencies."};return log.warn(e.msg),o.push(e),{miniProgramPackNum:0,otherNpmPackNum:0,warnList:o}}s=s.filter(e=>e.startsWith("node_modules"));for(const e of s){const t=path_1.default.posix.join(i,e);let n=await readFileSync(t,"utf8");const s=path_1.default.dirname(t);let p=s.replace(/([\b/\\])node_modules([\b/\\])/g,(e,t,a)=>`${t}miniprogram_npm${a}`);p=path_1.default.posix.normalize(path_1.default.posix.join(a,"miniprogram_npm",p.split(/[/\\]miniprogram_npm[/\\]/)[1]));let c=path_1.default.basename(p);const _=c.split("@");_.length&&(c=_.pop()||""),p=p.replace(path_1.default.basename(p),c),n=JSON.parse(n);const u=path_1.default.posix.join(s,n.main||"index.js"),l=await checkIsMiniprogramPack(s,n);if(l){const e=await globSync("**/*",{cwd:l.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:"**/node_modules/**"});for(const t of e)await copyFile(path_1.default.posix.join(l,t),path_1.default.posix.join(p,t));r.miniprogram_pack_num++}else{const e=await packJs(u,p,o);if(!e)continue;await writeFile(e.js,path_1.default.posix.join(p,"./index.js")),await writeFile(e.map,path_1.default.posix.join(p,"./index.js.map")),r.other_pack_num++}}return{miniProgramPackNum:r.miniprogram_pack_num,otherNpmPackNum:r.other_pack_num,warnList:o}}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.packNpm=packNpm,exports.packNpmManually=packNpmManually;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),fs_1=tslib_1.__importDefault(require("fs")),rimraf_1=tslib_1.__importDefault(require("rimraf")),lodash_1=tslib_1.__importDefault(require("lodash")),glob_1=tslib_1.__importDefault(require("glob")),source_map_1=tslib_1.__importDefault(require("source-map")),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),error_1=require("../../../../utils/error"),log=tslib_1.__importStar(require("../../../../utils/log")),projectconfig_1=require("../json/projectconfig"),config_1=require("../../../../config/config"),filterdeps_1=tslib_1.__importDefault(require("./filterdeps")),acorn=require("acorn"),NPM_RECORD={start_time:Date.now(),pack_time:0,miniprogram_pack_num:0,other_pack_num:0,warn_not_found_num:0,warn_require_var_num:0,warn_require_rename_num:0,extra1:"",extra2:"",extra3:""},REPORT_LIST=["pack_time","miniprogram_pack_num","other_pack_num","warn_not_found_num","warn_require_var_num","warn_require_rename_num","extra1","extra2","extra3"];function wrap(e,t){return function(...a){if(a.length){const e=a.pop();"function"!=typeof e&&a.push(e)}return new Promise(((n,r)=>{a.push(((e,t)=>{e?r(e):n(t)})),e.apply(t||null,a)}))}}const statSync=wrap(fs_1.default.stat),mkdirSync=wrap(fs_1.default.mkdir),readFileSync=wrap(fs_1.default.readFile),writeFileSync=wrap(fs_1.default.writeFile),accessSync=wrap(fs_1.default.access),renameSync=wrap(fs_1.default.rename),globSync=wrap(glob_1.default);let seed=+new Date;function getId(){return++seed}function startRecord(){NPM_RECORD.start_time=Date.now(),REPORT_LIST.forEach((e=>NPM_RECORD[e]=e.startsWith("extra")?"":0))}function endRecord(e){NPM_RECORD.pack_time=Date.now()-NPM_RECORD.start_time;const t={};REPORT_LIST.forEach((e=>t[e]=NPM_RECORD[e]));try{null==e||e(t)}catch(e){}}async function recursiveMkdir(e){const t=path_1.default.posix.dirname(e);try{await accessSync(t)}catch(e){await recursiveMkdir(t)}try{await accessSync(e);const t=await statSync(e);t&&!t.isDirectory()&&(await renameSync(e,`${e}.bak`),log.warn(`${e} already exists but is not a directory, so it will be rename to a file with the suffix ending in '.bak'`),await mkdirSync(e))}catch(t){await mkdirSync(e)}}async function copyFile(e,t){const a=await readFileSync(e);await writeFile(a,t)}async function writeFile(e,t){await recursiveMkdir(path_1.default.posix.dirname(t)),await writeFileSync(t,e)}function walkNode(e,t){t(e),Object.keys(e).forEach((a=>{const n=e[a];Array.isArray(n)&&n.forEach((e=>{(null==e?void 0:e.type)&&walkNode(e,t)})),(null==n?void 0:n.type)&&walkNode(n,t)}))}function parseDeps(e,t,a){const n=[];let r,o=[];try{r=acorn.parse(e,{sourceType:"module",locations:!0,allowHashBang:!0,onComment(t,a,n,r){t||"#"!==e[n]||o.push({start:n,end:r,adjustContent:""})}})}catch(e){const a=`parse js file (${t}) failed: ${e.message}`;throw console.error(a),e.message=a,e}return walkNode(r,(r=>{const{callee:i}=r,s=r.arguments;if("CallExpression"===r.type&&i&&"Identifier"===i.type&&"require"===i.name&&s&&1===s.length&&("Literal"===s[0].type?n.push(s[0].value):(a.push({jsPath:t,code:e.substring(r.start,r.end),startLine:r.loc.start.line,endLine:r.loc.end.line,tips:"require variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_VAR.format()}),NPM_RECORD.warn_require_var_num++)),"ExpressionStatement"===r.type&&r.expression&&"use strict"===r.expression.value&&o.push({start:r.start,end:r.end,adjustContent:""}),"ImportDeclaration"===r.type){const{source:e}=r,{specifiers:t}=r,a={start:r.start,end:r.end,adjustContent:""},i=[];e&&"Literal"===e.type&&(n.push(e.value),i.push(`var __TEMP__ = require('${e.value}');`)),t&&Array.isArray(t)&&t.forEach((e=>{if("ImportSpecifier"===e.type){const{local:t}=e,{imported:a}=e;"Identifier"===t.type&&"Identifier"===a.type&&i.push(`var ${t.name} = __TEMP__['${a.name}'];`)}else if("ImportDefaultSpecifier"===e.type){const{local:t}=e;"Identifier"===t.type&&i.push(`var ${t.name} = __REQUIRE_DEFAULT__(__TEMP__);`)}else if("ImportNamespaceSpecifier"===e.type){const{local:t}=e;"Identifier"===t.type&&i.push(`var ${t.name} = __REQUIRE_WILDCARD__(__TEMP__);`)}})),a.adjustContent=i.join(""),o.push(a)}if("ExportNamedDeclaration"===r.type){const{source:t}=r,{specifiers:a}=r,{declaration:i}=r;let s=!1;const p={start:r.start,end:r.end,adjustContent:""},c=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];if(t&&"Literal"===t.type&&(n.push(t.value),c.push(`var __TEMP__ = require('${t.value}');`),s=!0),i){if("VariableDeclaration"===i.type){const{declarations:t}=i;t&&Array.isArray(t)&&t.forEach((t=>{if("VariableDeclarator"===t.type){const{id:a}=t,{init:n}=t;a&&"Identifier"===a.type&&(p.notAddLines=!0,c.push(`var ${a.name} = exports.${a.name} = ${n?e.substring(n.start,n.end):"undefined"};`))}}))}else if("FunctionDeclaration"===i.type){const{id:t}=i;t&&"Identifier"===t.type&&(p.notAddLines=!0,c.push(`${e.substring(i.start,i.end)};exports.${t.name} = ${t.name}`))}else if("ClassDeclaration"===i.type){const{id:t}=i;t&&"Identifier"===t.type&&(p.notAddLines=!0,c.push(`${e.substring(i.start,i.end)};exports.${t.name} = ${t.name}`))}}else;a&&Array.isArray(a)&&a.forEach((e=>{if("ExportSpecifier"===e.type){const{local:t}=e,{exported:a}=e;"Identifier"===t.type&&"Identifier"===a.type&&c.push(`Object.defineProperty(exports, '${a.name}', { enumerable: true, configurable: true, get: function() { return ${s?"__TEMP__.":""}${t.name}; } });`)}})),p.adjustContent=c.join(""),o.push(p)}else if("ExportAllDeclaration"===r.type){const{source:e}=r,t={start:r.start,end:r.end,adjustContent:""},a=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];e&&"Literal"===e.type&&(n.push(e.value),a.push(`var __TEMP__ = require('${e.value}');`)),a.push('Object.keys(__TEMP__).forEach(function(k) { if (k === "default" || k === "__esModule") return; Object.defineProperty(exports, k, { enumerable: true, configurable: true, get: function() { return __TEMP__[k]; } }); });'),t.adjustContent=a.join(""),o.push(t)}else if("ExportDefaultDeclaration"===r.type){const{declaration:t}=r,a={start:r.start,end:r.end,adjustContent:""},n=['if (!exports.__esModule) Object.defineProperty(exports, "__esModule", { value: true });'];if(t)if(a.notAddLines=!0,t.id){const{id:a}=t;n.push(`${e.substring(t.start,t.end)};exports.default = ${a.name}`)}else n.push(`exports.default = ${e.substring(t.start,t.end)};`);a.adjustContent=n.join(""),o.push(a)}const{expression:p}=r;"ExpressionStatement"===r.type&&p&&"AssignmentExpression"===p.type&&"Identifier"===p.right.type&&"require"===p.right.name&&(a.push({jsPath:t,code:e.substring(r.start,r.end),startLine:r.loc.start.line,endLine:r.loc.end.line,tips:"assign require function to a variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_ASSIGN.format()}),NPM_RECORD.warn_require_rename_num++);const{declarations:c}=r;"VariableDeclaration"===r.type&&c.length>0&&c.forEach((n=>{const{init:o}=n;"VariableDeclarator"===n.type&&o&&"Identifier"===o.type&&"require"===o.name&&(a.push({jsPath:t,code:e.substring(r.start,r.end),startLine:r.loc.start.line,endLine:r.loc.end.line,tips:"assign require function to a variable is not allowed",msg:locales_1.default.config.NOT_ALLOWED_REQUIRE_ASSIGN.format()}),NPM_RECORD.warn_require_rename_num++)}))})),o=o.sort(((e,t)=>t.start-e.start)),o.forEach((t=>{const a=e.substring(t.start,t.end),n=t.notAddLines?0:a.split("\n").length;e=e.substring(0,t.start)+t.adjustContent+new Array(n).join("\n")+e.substring(t.end)})),{deps:n,parsedContent:e}}async function parseJs(e,t,a,n,r,o){if(r[t=path_1.default.posix.normalize(t)])return r[t];const i=await readFileSync(t,"utf8"),s=getId(),p=path_1.default.posix.relative(e,t);if(t.endsWith(".json")){const e={id:s,name:p,content:`module.exports = ${i}`,deps:[],depsMap:{}};return r[t]=s,n.push(e),s}const{deps:c,parsedContent:_}=parseDeps(i,t,o),u={id:s,name:p,content:_,deps:c,depsMap:{}};r[t]=s,n.push(u);for(const i of c){let s,p=path_1.default.posix.join(path_1.default.posix.dirname(t),i);if(!p.endsWith(".js")&&!p.endsWith(".json")){const e=`${p}.js`;try{await accessSync(e),p=e}catch(e){}}try{const e=await statSync(p);(null==e?void 0:e.isDirectory())&&(p=path_1.default.posix.join(p,"index.js"))}catch(e){}p.endsWith(".js")||p.endsWith(".json")||(p+=".js");try{await accessSync(p),s=await parseJs(e,p,a,n,r,o)}catch(e){}s&&(u.depsMap[i]=s)}return s}function addJsToMap(e,t,a,n){const r=t.split("\n").length;for(let o=1;o<=r;o++)e.addMapping({generated:{line:n+o,column:0},original:{line:o,column:0},source:a}),e.setSourceContent(a,t)}function findOutsideDeps(e){const t=new Set;return e.forEach((e=>{e.deps.forEach((a=>{Object.keys(e.depsMap).includes(a)||t.add(a)}))})),Array.from(t)}async function packJs(e,t,a){try{const t=await statSync(e);(null==t?void 0:t.isDirectory())&&(e=path_1.default.posix.join(e,"index.js"))}catch(e){}e.endsWith(".js")||e.endsWith(".json")||(e+=".js");try{await accessSync(e)}catch(t){return a.push({jsPath:e,code:"",tips:"entry file is not found",msg:locales_1.default.config.NOT_FOUND_NPM_ENTRY.format()}),void NPM_RECORD.warn_not_found_num++}const n=new source_map_1.default.SourceMapGenerator({file:"index.js"}),r=[];await parseJs(path_1.default.posix.dirname(e),e,t,r,{},a);const o=findOutsideDeps(r),i=["module.exports = (function() {","var __MODS__ = {};","var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };",'var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };',"var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };","var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };"];if(r.length){const e=r.shift();i.push(`__DEFINE__(${e.id}, function(require, module, exports) {`),addJsToMap(n,e.content,e.name,i.length),i.push(e.content),i.push(`}, function(modId) {var map = ${JSON.stringify(e.depsMap)}; return __REQUIRE__(map[modId], modId); })`);for(const e of r)i.push(`__DEFINE__(${e.id}, function(require, module, exports) {`),addJsToMap(n,e.content,e.name,i.length),i.push(e.content),i.push(`}, function(modId) { var map = ${JSON.stringify(e.depsMap)}; return __REQUIRE__(map[modId], modId); })`);i.push(`return __REQUIRE__(${e.id});`)}return i.push("})()"),i.push(`//miniprogram-npm-outsideDeps=${JSON.stringify(o)}`),i.push("//# sourceMappingURL=index.js.map"),{js:i.join("\n"),map:n.toString()}}async function checkIsMiniprogramPack(e,t){let a="miniprogram_dist";t.miniprogram&&"string"==typeof t.miniprogram&&(a=t.miniprogram);try{const t=path_1.default.posix.join(e,a);await accessSync(t);const n=await statSync(t);if(null==n?void 0:n.isDirectory())return t}catch(e){}return""}async function packNpm(e,t={}){const a="miniprogram_npm",{projectPath:n}=e,r=e.type,o=await(0,projectconfig_1.getProjectConfigJSON)(e),i=o.pluginRoot||"",s=o.miniprogramRoot||"",p="miniProgramPlugin"===r||"miniGamePlugin"===r,{ignores:c,reporter:_}=t;if(!n)throw new error_1.CodeError(locales_1.default.config.SHOULD_NOT_BE_EMPTY.format("projectPath"),config_1.PARAM_ERROR);if("miniProgramPlugin"===r&&!i)throw new error_1.CodeError(locales_1.default.config.SHOULD_NOT_BE_EMPTY.format('project.config.json "pluginRoot"'),config_1.PARAM_ERROR);startRecord();const u=path_1.default.isAbsolute(n)?n:path_1.default.posix.join(process.cwd(),n),l=[{searchRoot:path_1.default.posix.join(u,s),paths:await globSync("**/package.json",{cwd:path_1.default.posix.join(u,s),nodir:!0,dot:!0,ignore:(c||[]).concat("**/node_modules/**")})}];p&&l.push({searchRoot:path_1.default.posix.join(u,i),paths:await globSync("**/package.json",{cwd:path_1.default.posix.join(u,i),nodir:!0,dot:!0,ignore:(c||[]).concat("**/node_modules/**")})});lodash_1.default.flattenDeep(l.map((e=>e.paths.map((t=>path_1.default.posix.join(e.searchRoot,path_1.default.dirname(t),a)))))).forEach((e=>rimraf_1.default.sync(e)));const d=[];for(const e of l)for(const t of e.paths){const n=path_1.default.dirname(path_1.default.posix.join(e.searchRoot,t)),r=lodash_1.default.xorWith(e.paths,[t]).map((e=>path_1.default.posix.join(path_1.default.posix.dirname(e),"/**"))).filter((e=>"**"!==e));let o=await globSync("**/package.json",{cwd:n.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:(c||[]).concat(r).concat(["node_modules/@types/**"])});if(o=await(0,filterdeps_1.default)(n,o),o&&o.length)for(const e of o){const t=path_1.default.posix.join(n,e);let r=await readFileSync(t,"utf8");const o=path_1.default.dirname(t);let i=o.replace(/([\b/\\])node_modules([\b/\\])/g,((e,t,n)=>`${t}${a}${n}`)),s=path_1.default.basename(i);const p=s.split("@");p.length&&(s=p.pop()||""),i=i.replace(path_1.default.basename(i),s),r=JSON.parse(r);const c=path_1.default.posix.join(o,r.main||"index.js"),_=await checkIsMiniprogramPack(o,r);if(_){const e=await globSync("**/*",{cwd:_.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:"**/node_modules/**"});for(const t of e)await copyFile(path_1.default.posix.join(_,t),path_1.default.posix.join(i,t));NPM_RECORD.miniprogram_pack_num++}else{const e=await packJs(c,i,d);if(!e)continue;await writeFile(e.js,path_1.default.posix.join(i,"./index.js")),await writeFile(e.map,path_1.default.posix.join(i,"./index.js.map")),NPM_RECORD.other_pack_num++}}}if(endRecord(_),NPM_RECORD.miniprogram_pack_num+NPM_RECORD.other_pack_num<=0)throw new Error(`__NO_NODE_MODULES__ ${locales_1.default.config.NOT_FOUND_NODE_MODULES.format()}`);return"function"==typeof e.updateFileAndDirs&&e.updateFileAndDirs(),d}async function packNpmManually(e){let{packageJsonPath:t,miniprogramNpmDistDir:a}=e;const n=e.ignores||[],r={pack_time:0,miniprogram_pack_num:0,other_pack_num:0,warn_not_found_num:0,warn_require_var_num:0,warn_require_rename_num:0},o=[],i="miniprogram_npm";if(!a)throw new Error("param miniprogramNpmDistDir is required");if(!t)throw new Error("param packageJsonPath is required");if(path_1.default.isAbsolute(a)||(a=path_1.default.join(process.cwd(),a)),path_1.default.isAbsolute(t)||(t=path_1.default.join(process.cwd(),t)),!fs_1.default.existsSync(t))throw new Error(`param packageJsonPath: ${t} file is not exited`);const s=path_1.default.dirname(t);let p=await globSync("**/package.json",{cwd:s.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:(n||[]).concat(["node_modules/@types/**"])});if(p=await(0,filterdeps_1.default)(s,p),!p||!p.length){const e={jsPath:s,code:"",tips:"",msg:"No miniprogram_npm package was found, please check package.json -> dependencies."};return log.warn(e.msg),o.push(e),{miniProgramPackNum:0,otherNpmPackNum:0,warnList:o}}p=p.filter((e=>e.startsWith("node_modules")));for(const e of p){const t=path_1.default.posix.join(s,e);let n=await readFileSync(t,"utf8");const p=path_1.default.dirname(t);let c=p.replace(/([\b/\\])node_modules([\b/\\])/g,((e,t,a)=>`${t}${i}${a}`));c=path_1.default.posix.normalize(path_1.default.posix.join(a,i,c.split(/[/\\]miniprogram_npm[/\\]/)[1]));let _=path_1.default.basename(c);const u=_.split("@");u.length&&(_=u.pop()||""),c=c.replace(path_1.default.basename(c),_),n=JSON.parse(n);const l=path_1.default.posix.join(p,n.main||"index.js"),d=await checkIsMiniprogramPack(p,n);if(d){const e=await globSync("**/*",{cwd:d.replace(/\\/g,"/"),nodir:!0,dot:!0,ignore:"**/node_modules/**"});for(const t of e)await copyFile(path_1.default.posix.join(d,t),path_1.default.posix.join(c,t));r.miniprogram_pack_num++}else{const e=await packJs(l,c,o);if(!e)continue;await writeFile(e.js,path_1.default.posix.join(c,"./index.js")),await writeFile(e.map,path_1.default.posix.join(c,"./index.js.map")),r.other_pack_num++}}return{miniProgramPackNum:r.miniprogram_pack_num,otherNpmPackNum:r.other_pack_num,warnList:o}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.tryTranslateSingleFile=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),parser=tslib_1.__importStar(require("@babel/parser")),traverse_1=tslib_1.__importDefault(require("@babel/traverse")),sourcemap=tslib_1.__importStar(require("source-map")),babel_code_frame_1=tslib_1.__importDefault(require("babel-code-frame"));class TranslateResult{constructor(){this.translated=!0,this.errMsg="",this.debugs=[],this.translatedContent="",this.fullPath="",this.translatedSourceMap=""}}function getErrorCodeFrame(e,n,t,r){let i;try{i=new sourcemap.SourceMapConsumer(n||""),e=i.sourceContentFor(t)||e}catch(e){}const o=[];for(const n of r){let t={line:n.line,column:n.column>0?n.column:0};try{i&&(t=i.originalPositionFor({line:n.line,column:n.column}))}catch(e){}const r=(0,babel_code_frame_1.default)(e,t.line,t.column);o.push(`${n.reason}\n${r}`)}return o.join("\n\n")}function translateCode(e,n){const t=e.replace(/\r\n/g,"\n").split("\n");for(let e=0;e<t.length;e++){const r=t[e],i=n[e+1];if(i){const n=[];let o=0;for(const e in i){const t=i[e];n.push(r.substr(o,t.column-o+1)),n.push(t.toString),o=t.column+t.fromString.length+1}n.push(r.substr(o)),t[e]=n.join("")}}return t.join("\n")}function translateSourceMap(e,n,t){const r=new sourcemap.SourceMapConsumer(e),i=new sourcemap.SourceMapGenerator({file:n});let o;return r.eachMapping(e=>{if("number"!=typeof e.originalLine||"number"!=typeof e.originalColumn)return;const n={generated:{line:e.generatedLine,column:e.generatedColumn},source:e.source,name:e.name,original:{line:e.originalLine,column:e.originalColumn}};if(o&&o.line===e.generatedLine?n.generated.column+=o.offset:o=void 0,t[e.generatedLine]){const n=t[e.generatedLine][e.generatedColumn];n&&(o&&o.line===n.line?o.offset+=n.offset:o={line:n.line,offset:n.offset})}i.addMapping(n)}),i.toString()}function dirname(e){const n=e.split("/");return n.pop(),n.join("/")}function getNpmRequirePath(e,n,t){if(e.startsWith(".")||e.startsWith("/"))return!1;let r,i=n;for(;i;)if(i=dirname(i),r=e.endsWith(".js")?path_1.default.posix.join(i,"miniprogram_npm",e):path_1.default.posix.join(i,"miniprogram_npm",e,"index.js"),t.includes(r))return r;return!1}const tryTranslateSingleFile=e=>{var n,t;const r=new TranslateResult,{filePath:i,nameMapping:o,code:a,rootPath:l,miniProgramJSFiles:s}=e;let u=path_1.default.posix.dirname(path_1.default.posix.relative(l,i));"."===u&&(u="");const c=[];let p;try{p=parser.parse(a)}catch(o){return c.push({line:(null===(n=o.loc)||void 0===n?void 0:n.line)||1,column:(null===(t=o.loc)||void 0===t?void 0:t.column)||1,reason:o.message}),r.translated=!1,r.errMsg=`in ${path_1.default.posix.join(l,i)}\n${getErrorCodeFrame(a,e.sourceMap,e.sourceFileName,c)}`,r}const d={};if((0,traverse_1.default)(p,{AssignmentExpression(e){const n=e.node.loc.start;"Identifier"===e.node.left.type&&"require"===e.node.left.name&&c.push({line:n.line,column:n.column,reason:"assigning other name with 'require'"}),"Identifier"===e.node.right.type&&"require"===e.node.right.name&&c.push({line:n.line,column:n.column,reason:"'require' should not be renamed"})},VariableDeclarator(e){const n=e.node.loc.start;e.node.id&&"Identifier"===e.node.id.type&&"require"===e.node.id.name&&c.push({line:n.line,column:n.column,reason:"(init) assigning other name with 'require'"}),e.node.init&&"Identifier"===e.node.init.type&&"require"===e.node.init.name&&c.push({line:n.line,column:n.column,reason:"(init) 'require' should not be renamed"})},CallExpression(n){const t=n.node.loc.start;for(const e of n.node.arguments)"Identifier"===e.type&&"require"===e.name&&c.push({line:t.line,column:t.column,reason:"passing 'require' as a parameter is not a good taste"});if("Identifier"===n.node.callee.type&&"require"===n.node.callee.name&&(1===n.node.arguments.length&&"StringLiteral"===n.node.arguments[0].type||c.push({line:t.line,column:t.column,reason:"'require' requires one and only one static string literal"})),"require"===n.node.callee.name&&1===n.node.arguments.length&&"StringLiteral"===n.node.arguments[0].type){const t=n.node.arguments[0].loc.start,a=n.node.arguments[0].value,c=e.resolveAlias(a);let p;p=c?path_1.default.posix.join(l,c):path_1.default.posix.normalize(path_1.default.posix.join(u,a)),p.endsWith(".js")||(p+=".js"),p.startsWith("/")&&(p=p.replace(/^\//,""));let m=o[p];if(m)m=o[i]?path_1.default.posix.relative(path_1.default.posix.dirname(o[i]),m):path_1.default.posix.relative(u,m),d[t.line]||(d[t.line]={}),d[t.line][t.column]={line:t.line,column:t.column,fromString:a,toString:m,offset:m.length-a.length},r.debugs.push([i,a,"replace",[p,m]]);else{if(o[i]){const e=getNpmRequirePath(a,i,s);e&&(p=e),m=path_1.default.posix.relative(path_1.default.posix.dirname(o[i]),p),d[t.line]||(d[t.line]={}),d[t.line][t.column]={line:t.line,column:t.column,fromString:a,toString:m,offset:m.length-a.length},r.debugs.push([i,a,"replace",[p,m]])}r.debugs.push([i,a,"ignored"])}}},Identifier(e){const n=e.node.loc.start;if("require"===e.node.name){if("UnaryExpression"===e.parent.type&&"typeof"===e.parent.operator)return;"CallExpression"!==e.parent.type&&c.push({line:n.line,column:n.column,reason:`require is not being used properly in '${e.parent.type}'`})}}}),c.length>0)return r.translated=!1,r.errMsg=`in ${i}\n${getErrorCodeFrame(a,e.sourceMap,e.sourceFileName,c)}`,r;if(Object.keys(d).length>0){r.translatedContent=translateCode(a,d);try{r.translatedSourceMap=translateSourceMap(e.sourceMap||"",e.sourceFileName,d)}catch(e){}}else r.translatedContent=a,r.translatedSourceMap=e.sourceMap;return r};exports.tryTranslateSingleFile=tryTranslateSingleFile;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.tryTranslateSingleFile=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),parser=tslib_1.__importStar(require("@babel/parser")),traverse_1=tslib_1.__importDefault(require("@babel/traverse")),sourcemap=tslib_1.__importStar(require("source-map")),babel_code_frame_1=tslib_1.__importDefault(require("babel-code-frame"));class TranslateResult{constructor(){this.translated=!0,this.errMsg="",this.debugs=[],this.translatedContent="",this.fullPath="",this.translatedSourceMap=""}}function getErrorCodeFrame(e,n,t,r){let i;try{i=new sourcemap.SourceMapConsumer(n||""),e=i.sourceContentFor(t)||e}catch(e){}const o=[];for(const n of r){let t={line:n.line,column:n.column>0?n.column:0};try{i&&(t=i.originalPositionFor({line:n.line,column:n.column}))}catch(e){}const r=(0,babel_code_frame_1.default)(e,t.line,t.column);o.push(`${n.reason}\n${r}`)}return o.join("\n\n")}function translateCode(e,n){const t=e.replace(/\r\n/g,"\n").split("\n");for(let e=0;e<t.length;e++){const r=t[e],i=n[e+1];if(i){const n=[];let o=0;for(const e in i){const t=i[e];n.push(r.substr(o,t.column-o+1)),n.push(t.toString),o=t.column+t.fromString.length+1}n.push(r.substr(o)),t[e]=n.join("")}}return t.join("\n")}function translateSourceMap(e,n,t){const r=new sourcemap.SourceMapConsumer(e),i=new sourcemap.SourceMapGenerator({file:n});let o;return r.eachMapping((e=>{if("number"!=typeof e.originalLine||"number"!=typeof e.originalColumn)return;const n={generated:{line:e.generatedLine,column:e.generatedColumn},source:e.source,name:e.name,original:{line:e.originalLine,column:e.originalColumn}};if(o&&o.line===e.generatedLine?n.generated.column+=o.offset:o=void 0,t[e.generatedLine]){const n=t[e.generatedLine][e.generatedColumn];n&&(o&&o.line===n.line?o.offset+=n.offset:o={line:n.line,offset:n.offset})}i.addMapping(n)})),i.toString()}function dirname(e){const n=e.split("/");return n.pop(),n.join("/")}function getNpmRequirePath(e,n,t){if(e.startsWith(".")||e.startsWith("/"))return!1;let r,i=n;for(;i;)if(i=dirname(i),r=e.endsWith(".js")?path_1.default.posix.join(i,"miniprogram_npm",e):path_1.default.posix.join(i,"miniprogram_npm",e,"index.js"),t.includes(r))return r;return!1}const tryTranslateSingleFile=e=>{var n,t;const r=new TranslateResult,{filePath:i,nameMapping:o,code:a,rootPath:l,miniProgramJSFiles:s}=e;let u=path_1.default.posix.dirname(path_1.default.posix.relative(l,i));"."===u&&(u="");const c=[];let p;try{p=parser.parse(a)}catch(o){return c.push({line:(null===(n=o.loc)||void 0===n?void 0:n.line)||1,column:(null===(t=o.loc)||void 0===t?void 0:t.column)||1,reason:o.message}),r.translated=!1,r.errMsg=`in ${path_1.default.posix.join(l,i)}\n${getErrorCodeFrame(a,e.sourceMap,e.sourceFileName,c)}`,r}const d={};if((0,traverse_1.default)(p,{AssignmentExpression(e){const n=e.node.loc.start;"Identifier"===e.node.left.type&&"require"===e.node.left.name&&c.push({line:n.line,column:n.column,reason:"assigning other name with 'require'"}),"Identifier"===e.node.right.type&&"require"===e.node.right.name&&c.push({line:n.line,column:n.column,reason:"'require' should not be renamed"})},VariableDeclarator(e){const n=e.node.loc.start;e.node.id&&"Identifier"===e.node.id.type&&"require"===e.node.id.name&&c.push({line:n.line,column:n.column,reason:"(init) assigning other name with 'require'"}),e.node.init&&"Identifier"===e.node.init.type&&"require"===e.node.init.name&&c.push({line:n.line,column:n.column,reason:"(init) 'require' should not be renamed"})},CallExpression(n){const t=n.node.loc.start;for(const e of n.node.arguments)"Identifier"===e.type&&"require"===e.name&&c.push({line:t.line,column:t.column,reason:"passing 'require' as a parameter is not a good taste"});if("Identifier"===n.node.callee.type&&"require"===n.node.callee.name&&(1===n.node.arguments.length&&"StringLiteral"===n.node.arguments[0].type||c.push({line:t.line,column:t.column,reason:"'require' requires one and only one static string literal"})),"require"===n.node.callee.name&&1===n.node.arguments.length&&"StringLiteral"===n.node.arguments[0].type){const t=n.node.arguments[0].loc.start,a=n.node.arguments[0].value,c=e.resolveAlias(a);let p;p=c?path_1.default.posix.join(l,c):path_1.default.posix.normalize(path_1.default.posix.join(u,a)),p.endsWith(".js")||(p+=".js"),p.startsWith("/")&&(p=p.replace(/^\//,""));let m=o[p];if(m)m=o[i]?path_1.default.posix.relative(path_1.default.posix.dirname(o[i]),m):path_1.default.posix.relative(u,m),d[t.line]||(d[t.line]={}),d[t.line][t.column]={line:t.line,column:t.column,fromString:a,toString:m,offset:m.length-a.length},r.debugs.push([i,a,"replace",[p,m]]);else{if(o[i]){const e=getNpmRequirePath(a,i,s);e&&(p=e),m=path_1.default.posix.relative(path_1.default.posix.dirname(o[i]),p),d[t.line]||(d[t.line]={}),d[t.line][t.column]={line:t.line,column:t.column,fromString:a,toString:m,offset:m.length-a.length},r.debugs.push([i,a,"replace",[p,m]])}r.debugs.push([i,a,"ignored"])}}},Identifier(e){const n=e.node.loc.start;if("require"===e.node.name){if("UnaryExpression"===e.parent.type&&"typeof"===e.parent.operator)return;"CallExpression"!==e.parent.type&&c.push({line:n.line,column:n.column,reason:`require is not being used properly in '${e.parent.type}'`})}}}),c.length>0)return r.translated=!1,r.errMsg=`in ${i}\n${getErrorCodeFrame(a,e.sourceMap,e.sourceFileName,c)}`,r;if(Object.keys(d).length>0){r.translatedContent=translateCode(a,d);try{r.translatedSourceMap=translateSourceMap(e.sourceMap||"",e.sourceFileName,d)}catch(e){}}else r.translatedContent=a,r.translatedSourceMap=e.sourceMap;return r};exports.tryTranslateSingleFile=tryTranslateSingleFile;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getGameNameMapping=exports.getNameMapping=void 0,exports.uglifyFileNames=uglifyFileNames;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),config_1=require("../../../../config/config"),error_1=require("../../../../utils/error"),tools_1=require("../../../../utils/tools"),game_1=tslib_1.__importDefault(require("../json/game")),app_1=require("../json/app"),url_config_1=require("../../../../config/url.config"),request_1=require("../../../../utils/request"),sign_1=require("../../../../utils/sign"),jsonParse_1=require("../../../../utils/jsonParse"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),config=tslib_1.__importStar(require("../../../../config/config")),common_1=require("../../../../utils/common"),fileFlatter_1=require("./fileFlatter");function checkPrefix(e,t){for(const a of t)if(e.startsWith(a))return a;return""}const getNameMapping=async(e,t)=>{if(process.env.isDevtools)return e.nameMappingFromDevtools||{};const a=e.getFileList(t,".js").map(e=>path_1.default.posix.relative(t,e));try{let r={};if("miniProgram"===e.type){const o=(0,app_1.getAppJSON)(e);r=await getMiniProgramNameMapping(e,t,o,a)}if("miniGame"===e.type){const t=(0,game_1.default)(e);r=await(0,exports.getGameNameMapping)(e,t,a)}return r}catch(e){throw new error_1.CodeError(e.toString(),config_1.CODE_PROTECT_TRANSLATE_FILENAME)}};exports.getNameMapping=getNameMapping;const getMiniProgramNameMapping=async(e,t,a,r)=>{var o;const i=[{type:"file",value:"app.js"},{type:"regex",value:/\/miniprogram_npm\/|^miniprogram_npm\//},{type:"folder",value:"functional-pages/"}],s=e.getFileList(t,".wxml").map(e=>path_1.default.posix.relative(t,e));for(const e of s)i.push({type:"file",value
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getGameNameMapping=exports.getNameMapping=void 0,exports.uglifyFileNames=uglifyFileNames;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),config_1=require("../../../../config/config"),error_1=require("../../../../utils/error"),tools_1=require("../../../../utils/tools"),game_1=tslib_1.__importDefault(require("../json/game")),app_1=require("../json/app"),url_config_1=require("../../../../config/url.config"),request_1=require("../../../../utils/request"),sign_1=require("../../../../utils/sign"),jsonParse_1=require("../../../../utils/jsonParse"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),config=tslib_1.__importStar(require("../../../../config/config")),common_1=require("../../../../utils/common"),fileFlatter_1=require("./fileFlatter");function checkPrefix(e,t){for(const a of t)if(e.startsWith(a))return a;return""}const getNameMapping=async(e,t)=>{if(process.env.isDevtools)return e.nameMappingFromDevtools||{};const a=e.getFileList(t,".js").map((e=>path_1.default.posix.relative(t,e)));try{let r={};if("miniProgram"===e.type){const o=(0,app_1.getAppJSON)(e);r=await getMiniProgramNameMapping(e,t,o,a)}if("miniGame"===e.type){const t=(0,game_1.default)(e);r=await(0,exports.getGameNameMapping)(e,t,a)}return r}catch(e){throw new error_1.CodeError(e.toString(),config_1.CODE_PROTECT_TRANSLATE_FILENAME)}};exports.getNameMapping=getNameMapping;const getMiniProgramNameMapping=async(e,t,a,r)=>{var o;const i=[{type:"file",value:"app.js"},{type:"regex",value:/\/miniprogram_npm\/|^miniprogram_npm\//},{type:"folder",value:"functional-pages/"}],s=e.getFileList(t,".wxml").map((e=>path_1.default.posix.relative(t,e)));for(const e of s)i.push({type:"file",value:`${e.replace(/\.wxml$/,".js")}`});let n=[];return a.subPackages&&(n=a.subPackages.map((e=>e.root))),(null===(o=null==a?void 0:a.widgets)||void 0===o?void 0:o.length)>0&&a.widgets.forEach((e=>{i.push({type:"folder",value:e.path.endsWith("/")?e.path:`${e.path}/`})})),a.workers&&i.push({type:"folder",value:(0,tools_1.getWorkersPath)(a.workers)}),a.openDataContext&&(i.push({type:"file",value:path_1.default.posix.join(a.openDataContext,"index.js")}),n.push(a.openDataContext)),await _getNameMapping(e,r,i,n)},getGameNameMapping=async(e,t,a)=>{const r=[{type:"file",value:"game.js"},{type:"regex",value:/\/miniprogram_npm\/|^miniprogram_npm\//}],o=[];if(t.subPackages&&t.subPackages.forEach((e=>{const t=e.root.replace(/^\//,"");t.endsWith(".js")?(r.push({type:"file",value:t}),o.push(path_1.default.posix.dirname(t))):(r.push({type:"file",value:path_1.default.posix.join(t,"./game.js")}),o.push(t))})),t.openDataContext&&(r.push({type:"file",value:path_1.default.posix.join(t.openDataContext,"index.js")}),o.push(t.openDataContext)),t.workers&&r.push({type:"folder",value:(0,tools_1.getWorkersPath)(t.workers)}),t.plugins)for(const e in t.plugins){const a=t.plugins[e];if(a.path){const e=a.path.replace(/^\//,"");r.push({type:"folder",value:e})}}return await _getNameMapping(e,a,r,o)};async function _getNameMapping(e,t,a,r=[]){const o={},i=[];for(const e of t){let t=!1;for(const r of a)if("file"===r.type&&r.value===e||"folder"===r.type&&e.startsWith(r.value)||"regex"===r.type&&r.value.test(e)){t=!0;break}t||i.push(e)}const s=await(0,sign_1.getSignature)(e.privateKey,e.appid),{body:n}=await(0,request_1.request)({url:url_config_1.TRANSLATE_FILENAME,method:"post",body:JSON.stringify({appid:e.appid,signature:s,arrPaths:i}),headers:{"content-type":"application/json"}}),p=(0,jsonParse_1.jsonRespParse)(n,url_config_1.TRANSLATE_FILENAME);if(0===p.errCode)return p.body.pairs.forEach((e=>{const t=checkPrefix(e.origin,r);o[e.origin]=(0,tools_1.normalizePath)(path_1.default.posix.join(t,`${e.translated}.js`))})),o;throw new Error(`errCode: ${p.errCode} errMsg: ${p.errMsg}`)}function genResolveAlias(e){if(e){const t=[];return Object.keys(e).forEach((a=>{let r=a;a.endsWith("*")&&(r=r.slice(0,-1));let o=e[a];e[a].endsWith("*")&&(o=o.slice(0,-1)),t.push({key:r,value:o})})),e=>{let a={key:"",value:""},r=!1;if(t.forEach((t=>{e.startsWith(t.key)&&a.key.length<t.key.length&&(a=t,r=!0)})),!r)return;let o=e.replace(a.key,a.value);return o.startsWith("/")&&(o=o.slice(1)),o}}return e=>{}}async function uglifyFileNames(e,t,a){let r={miniprogramRoot:""};try{r=JSON.parse(t["project.config.json"].toString())}catch(e){}let o=(0,tools_1.normalizePath)(r.miniprogramRoot);"."===o&&(o=""),a=a||await(0,exports.getNameMapping)(e,e.miniprogramRoot);const i=Object.keys(t).filter((e=>e.endsWith(".js"))),s={};let n,p=t[path_1.default.posix.join(o,"app.json")];p?(Buffer.isBuffer(p)&&(p=p.toString("utf-8")),p=JSON.parse(p),n=genResolveAlias(p.resolveAlias)):n=genResolveAlias(void 0);for(const e of i){if(/\/miniprogram_npm\/|^miniprogram_npm\//.test(e))continue;const r=e,p=t[e].toString(),l=t[`${e}.map`]||"";s[r]=(0,fileFlatter_1.tryTranslateSingleFile)({rootPath:o,code:p,nameMapping:a,check:!0,sourceFileName:e,sourceMap:l,filePath:e,miniProgramJSFiles:i,resolveAlias:n})}const l=Object.keys(t),u={};for(const e of l){u[(0,tools_1.normalizePath)(e)]=t[e]}for(const e in s){const t=(0,tools_1.normalizePath)(e);let r=t;const i=s[e];if(i.errMsg){if(!process.env.isDevtools)throw new Error(`\n${locales_1.default.config.COULD_NOT_USE_CODE_PROTECT}\n${i.errMsg}`);(0,common_1.throwError)({code:config.FILE_FLAT_ERR,msg:`${locales_1.default.config.COULD_NOT_USE_CODE_PROTECT}\n${i.errMsg}`,filePath:t})}const n=path_1.default.posix.relative(o,e);a[n]&&(r=(0,tools_1.normalizePath)(path_1.default.posix.join(o,a[n])),delete u[t],delete u[`${t}.map`]),u[r]=i.translatedContent,i.translatedSourceMap&&(u[`${r}.map`]=i.translatedSourceMap)}return u}exports.getGameNameMapping=getGameNameMapping;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.logger=void 0;const workerThread_1=require("../workerThread"),env_1=require("./env");function pad(e,r=2){return e>10**r?String(e):`${new Array(r).join("0")}${e}`.slice(-r)}const LevelMap={trace:1,info:2,log:3,warn:4,error:5};class Logger{constructor(e){this.output=e,this.enableLevel=LevelMap.log,this.ready=!1,this.logs=[]}setOutput(e){this.output=e}setEnableLevel(e){this.enableLevel=e}setReady(){if(this.ready=!0,this.logs.length>0)for(const e of this.logs)this.output(e.level,e.args)}send(e,r){this.ready?this.output(e,r):this.logs.push({level:e,args:r})}getPrintTime(){const e=new Date;return`${String(e.getFullYear())}-${pad(e.getMonth()+1)}-${pad(e.getDate())} ${pad(e.getHours())}:${pad(e.getMinutes())}:${pad(e.getSeconds())}.${pad(e.getMilliseconds(),3)}`}_receive(e,r,t){const s=LevelMap[e];this.enableLevel>s||(t=[r=`[compiler][${env_1.processEnv}][${this.getPrintTime()}] ${r}`,...t],this.send(e,t))}info(e,...r){this._receive("info",e,r)}log(e,...r){this._receive("log",e,r)}error(e,...r){this._receive("error",e,r)}}if(exports.logger=new Logger((e,r)=>{console[e](...r)}),exports.logger.setReady(),"ci"===env_1.hostEnv&&("compiler"===process.env.debug?exports.logger.setEnableLevel(LevelMap.info):exports.logger.setEnableLevel(LevelMap.warn)),"childprocess"===env_1.processEnv&&exports.logger.setOutput((e,r)=>{process.send({command:workerThread_1.COMMAND.SEND_LOG,data:{level:e,args:r}})}),"workerthread"===env_1.processEnv){const e=require("worker_threads").parentPort;e&&exports.logger.setOutput((r,t)=>{e.postMessage({command:workerThread_1.COMMAND.SEND_LOG,data:{level:r,args:t}})})}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.logger=void 0;const workerThread_1=require("../workerThread"),env_1=require("./env");function pad(e,r=2){return e>10**r?String(e):`${new Array(r).join("0")}${e}`.slice(-r)}const LevelMap={trace:1,info:2,log:3,warn:4,error:5};class Logger{constructor(e){this.output=e,this.enableLevel=LevelMap.log,this.ready=!1,this.logs=[]}setOutput(e){this.output=e}setEnableLevel(e){this.enableLevel=e}setReady(){if(this.ready=!0,this.logs.length>0)for(const e of this.logs)this.output(e.level,e.args)}send(e,r){this.ready?this.output(e,r):this.logs.push({level:e,args:r})}getPrintTime(){const e=new Date;return`${String(e.getFullYear())}-${pad(e.getMonth()+1)}-${pad(e.getDate())} ${pad(e.getHours())}:${pad(e.getMinutes())}:${pad(e.getSeconds())}.${pad(e.getMilliseconds(),3)}`}_receive(e,r,t){const s=LevelMap[e];this.enableLevel>s||(t=[r=`[compiler][${env_1.processEnv}][${this.getPrintTime()}] ${r}`,...t],this.send(e,t))}info(e,...r){this._receive("info",e,r)}log(e,...r){this._receive("log",e,r)}error(e,...r){this._receive("error",e,r)}}if(exports.logger=new Logger(((e,r)=>{console[e](...r)})),exports.logger.setReady(),"ci"===env_1.hostEnv&&("compiler"===process.env.debug?exports.logger.setEnableLevel(LevelMap.info):exports.logger.setEnableLevel(LevelMap.warn)),"childprocess"===env_1.processEnv&&exports.logger.setOutput(((e,r)=>{process.send({command:workerThread_1.COMMAND.SEND_LOG,data:{level:e,args:r}})})),"workerthread"===env_1.processEnv){const e=require("worker_threads").parentPort;e&&exports.logger.setOutput(((r,t)=>{e.postMessage({command:workerThread_1.COMMAND.SEND_LOG,data:{level:r,args:t}})}))}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NEW_CHECK_JSON_WAY=exports.config=void 0,exports.schemaValidate=schemaValidate,exports.transValidateResult=transValidateResult;const tslib_1=require("tslib"),jsonschema_1=require("jsonschema"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),common_1=require("../../../../utils/common"),validator=new jsonschema_1.Validator,app=require("../../../../schema/dist/app.js"),ext=require("../../../../schema/dist/ext.js"),game=require("../../../../schema/dist/game.js"),page=require("../../../../schema/dist/page.js"),plugin=require("../../../../schema/dist/plugin.js"),pluginpage=require("../../../../schema/dist/pluginpage.js"),projectconfig=require("../../../../schema/dist/projectconfig.js"),sitemap=require("../../../../schema/dist/sitemap.js"),theme=require("../../../../schema/dist/theme.js");exports.config={app:app,ext:ext,game:game,page:page,plugin:plugin,pluginpage:pluginpage,projectconfig:projectconfig,sitemap:sitemap,theme:theme};const SchemaMap=Object.assign({},exports.config);function schemaValidate(e,r){const t=validator.validate(r,SchemaMap[e]).errors,a=t.filter(e=>"additionalProperties"===e.name),o=t.filter(e=>"additionalProperties"!==e.name).map(e=>{if("type"===e.name||"enum"===e.name||"anyOf"===e.name){let r=e.argument;if("string"==typeof r&&(r=[r]),"anyOf"===e.name){r=[(e.schema.anyOf||[]).map(e=>e.type).join(", ")]}const t=e.property.replace(/^instance\.?/,"");return{errorType:e.name,errorProperty:t,correctType:r}}return{errorType:e.name,errorProperty:e.property.replace(/^instance\.?/,""),requireProperty:e.argument}});return{warning:a.map(r=>{const t=r.property.replace(/^instance\.?/,"");return`${e}.json ${t.length?t:""}["${r.argument}"]`}).join("、")||"",error:o}}function transValidateResult(e,r,t=!1){var a;if(null===(a=null==r?void 0:r.error)||void 0===a?void 0:a.length){const a=r.error.map(e=>{if("type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType)return locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]);const r=""===e.errorProperty?e.requireProperty:`${e.errorProperty}.${e.requireProperty}`;return locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([r])}).join("\n");return t||(0,common_1.throwError)({msg:a,filePath:e}),a}return""}exports.NEW_CHECK_JSON_WAY=!0;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NEW_CHECK_JSON_WAY=exports.config=void 0,exports.schemaValidate=schemaValidate,exports.transValidateResult=transValidateResult;const tslib_1=require("tslib"),jsonschema_1=require("jsonschema"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),common_1=require("../../../../utils/common"),validator=new jsonschema_1.Validator,app=require("../../../../schema/dist/app.js"),ext=require("../../../../schema/dist/ext.js"),game=require("../../../../schema/dist/game.js"),page=require("../../../../schema/dist/page.js"),plugin=require("../../../../schema/dist/plugin.js"),pluginpage=require("../../../../schema/dist/pluginpage.js"),projectconfig=require("../../../../schema/dist/projectconfig.js"),sitemap=require("../../../../schema/dist/sitemap.js"),theme=require("../../../../schema/dist/theme.js");exports.config={app:app,ext:ext,game:game,page:page,plugin:plugin,pluginpage:pluginpage,projectconfig:projectconfig,sitemap:sitemap,theme:theme};const SchemaMap=Object.assign({},exports.config);function schemaValidate(e,r){const t=validator.validate(r,SchemaMap[e]).errors,a=t.filter((e=>"additionalProperties"===e.name)),o=t.filter((e=>"additionalProperties"!==e.name)).map((e=>{if("type"===e.name||"enum"===e.name||"anyOf"===e.name){let r=e.argument;if("string"==typeof r&&(r=[r]),"anyOf"===e.name){r=[(e.schema.anyOf||[]).map((e=>e.type)).join(", ")]}const t=e.property.replace(/^instance\.?/,"");return{errorType:e.name,errorProperty:t,correctType:r}}return{errorType:e.name,errorProperty:e.property.replace(/^instance\.?/,""),requireProperty:e.argument}}));return{warning:a.map((r=>{const t=r.property.replace(/^instance\.?/,"");return`${e}.json ${t.length?t:""}["${r.argument}"]`})).join("、")||"",error:o}}function transValidateResult(e,r,t=!1){var a;if(null===(a=null==r?void 0:r.error)||void 0===a?void 0:a.length){const a=r.error.map((e=>{if("type"===e.errorType||"enum"===e.errorType||"anyOf"===e.errorType)return locales_1.default.config.JSON_CONTENT_SHOULD_BE.format([e.errorProperty,e.correctType]);const r=""===e.errorProperty?e.requireProperty:`${e.errorProperty}.${e.requireProperty}`;return locales_1.default.config.SHOULD_NOT_BE_EMPTY.format([r])})).join("\n");return t||(0,common_1.throwError)({msg:a,filePath:e}),a}return""}exports.NEW_CHECK_JSON_WAY=!0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const tslib_1=require("tslib"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales"));function getType(e){return Object.prototype.toString.call(e).toLowerCase().split(" ")[1].replace("]","")}class T{constructor(e,t,r){this.type=e,this.required=t||!1;const o=this.valueType=getType(r);if("undefined"!==o)if(r instanceof T){if("array"!==e&&"object"!==e)throw new Error("value can be instance of ValidateType only when type is object or array");this.value=r}else if("array"!==o)if("regexp"!==o)if("object"!==o){if(e!==o)throw new Error(`value should be ${e} instead of ${o}`);this.value=r}else{if("object"!==e)throw new Error(e
|
|
1
|
+
"use strict";const tslib_1=require("tslib"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales"));function getType(e){return Object.prototype.toString.call(e).toLowerCase().split(" ")[1].replace("]","")}class T{constructor(e,t,r){this.type=e,this.required=t||!1;const o=this.valueType=getType(r);if("undefined"!==o)if(r instanceof T){if("array"!==e&&"object"!==e)throw new Error("value can be instance of ValidateType only when type is object or array");this.value=r}else if("array"!==o)if("regexp"!==o)if("object"!==o){if(e!==o)throw new Error(`value should be ${e} instead of ${o}`);this.value=r}else{if("object"!==e)throw new Error(`${e} could not have object value`);for(const e in r)if(!(r[e]instanceof T))throw new Error(`value["${e}"] should be instance of ValidateType`);this.value=r}else{if("regexp"!==e&&"string"!==e)throw new Error(`${e} could not have regexp value`);this.value=r}else{if("array"===e||"object"===e||"function"===e)throw new Error(`${e} could not have optional value`);for(let t=0,o=r.length;t<o;t++){const o=getType(r[t]);if(o!==e)throw new Error(`value[${t}] should be ${e} instead of ${o}`)}this.value=r}}static invalidKeys(e,t){const r=[];if(e instanceof T){try{e.check(t)}catch(e){return}if("object"!==e.type||"object"!==e.valueType||"object"!==getType(t))return;const o=e.value instanceof T;for(const i in t){let n=[];if(o)n=T.invalidKeys(e.value,t[i]);else{if(!e.value.hasOwnProperty(i)){r.push(`["${i}"]`);continue}n=T.invalidKeys(e.value[i],t[i])}n&&n.forEach((e=>{r.push(`["${i}"]${e}`)}))}}else for(const o in t){if(!e.hasOwnProperty(o)){r.push(`["${o}"]`);continue}const i=T.invalidKeys(e[o],t[o]);i&&i.forEach((e=>{r.push(`["${o}"]${e}`)}))}if(r.length>0)return r}check(e){const t=getType(e);if(!this.required&&"undefined"===t)return;if("ignore"===this.type)return;if(t!==this.type)throw new Error(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(["",this.type]));const{valueType:r}=this;if("undefined"!==r){if(this.value instanceof T){if("object"===this.type){for(const t in e)try{this.value.check(e[t])}catch(e){throw new Error(`["${t}"]${e.message}`)}return}if("array"===this.type){if(0===e.length&&this.value.required)throw new Error(locales_1.default.config.SHOULD_AT_LEAST_ONE_ITEM.format(""));for(let t=0,r=e.length;t<r;t++)try{this.value.check(e[t])}catch(e){throw new Error(`[${t}]${e.message}`)}return}}if("array"!==r)if("object"!==r)if("regexp"!==r){if(this.value!==e)throw new Error(locales_1.default.config.SHOULD_EQUAL.format(["",this.value.toString()]))}else{if("string"===this.type){if(!this.value.test(e))throw new Error(locales_1.default.config.SHOULD_MATCH.format(["",this.value.toString()]));return}if("regexp"===this.type&&this.value.toString()!==e.toString())throw new Error(locales_1.default.config.SHOULD_EQUAL.format(["",this.value.toString()]))}else for(const t in this.value){const r=this.value[t];try{r.check(e[t])}catch(e){throw new Error(`["${t}"]${e.message}`)}}else{let t=!1;for(const r of this.value)if(r===e){t=!0;break}if(!t)throw new Error(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(["",this.value.join(` ${locales_1.default.config.OR} `)]))}}}}module.exports=T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
process.env&&process.env.isDevtools&&require("../../../../utils/hackrequire/index"),Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib");require("../../../../utils/processBootstrap").installProcessBootstrap({baseDir:__dirname,hackRequirePath:"../../../../utils/hackrequire/index",moduleFallbackPath:"../../../../../../../unpack/module-fallback"});const log=tslib_1.__importStar(require("../../../../utils/log")),logger_1=require("../utils/logger"),config_1=require("./config"),workerManager_1=require("./workerManager"),workerManager=(0,workerManager_1.getWorkerManager)(!!process.env.isDevtools);class TaskManager{constructor(){this._taskSet=new Set,this._suicideTime=config_1.SUICIDE_TIME["miniprogram-ci"],process.env.isDevtools&&(this._suicideTime=config_1.SUICIDE_TIME.devtools)}runTask(e,s,i){clearTimeout(this._suicideTimer),this._taskSet.add(e),workerManager.runTask(s,i).then(this.onResolve.bind(this,e)).catch(this.onReject.bind(this,e))}onResolve(e,s){this._taskSet.delete(e),process.send({command:config_1.COMMAND.TASK_DONE,data:{taskId:e,result:s}}),this.setUpSuicideTimer()}onReject(e,s){process.send({command:config_1.COMMAND.TASK_DONE,data:{taskId:e,result:{error:s.toString()}}}),this.setUpSuicideTimer()}setUpSuicideTimer(){this._taskSet.size>0||(this._suicideTimer=setTimeout((()=>{clearTimeout(this._suicideTimer),process.exit(0)}),this._suicideTime))}}const taskManager=new TaskManager;function suicide(){try{process.exit(0),setTimeout((()=>{process.kill(process.pid,"SIGTERM")}),5e3)}catch(e){process.kill(process.pid,"SIGTERM")}}process.on("message",(e=>{if("object"!=typeof e)return void log.error(`child process unrecognized message ${e}`);const{command:s,data:i}=e;s===config_1.COMMAND.RUN_TASK?(logger_1.logger.info("child-process recieve message",s,i.filePath),taskManager.runTask(i.taskId,i.taskName,i.data)):log.error(`child process unrecognized message ${e}`)})),process.on("disconnect",(()=>{suicide()}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.childProcessManager=exports.ChildProcessCrashedError=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),child_process_1=require("child_process"),events_1=tslib_1.__importDefault(require("events")),os=tslib_1.__importStar(require("os")),log=tslib_1.__importStar(require("../../../../utils/log")),logger_1=require("../utils/logger"),config_1=require("./config"),cpus=os.cpus().length,FORK_PATH=path_1.default.posix.join(__dirname,"./childprocess.js"),MAX_TASK_TRY_TIME=2;class ChildProcessCrashedError extends Error{constructor(s,e){super(e),this.type=s}}exports.ChildProcessCrashedError=ChildProcessCrashedError;class ChildProcessInstance extends events_1.default{constructor(s){super(),this.status=config_1.EChildProcessStatus.free,this._lastActiveTime=0,this._taskMap={},this._fullload_task_count=4,this._suicideTime=config_1.SUICIDE_TIME["miniprogram-ci"],this._fullload_task_count=s;const e={stdio:["pipe","pipe","pipe","ipc"],env:Object.assign(Object.assign({},process.env),{cpprocessEnv:"childprocess"})};if(e.env.isDevtools=process.__nwjs&&"wechatwebdevtools"===nw.App.manifest.appname,e.env.isDevtools){this._suicideTime=config_1.SUICIDE_TIME.devtools;let s=path_1.default.join(path_1.default.dirname(process.execPath),"node");"darwin"!==process.platform&&(s+=".exe"),e.execPath=s}logger_1.logger.info("fork childprocess start");const t=(0,child_process_1.fork)(FORK_PATH,["--expose-gc"],e);t.stdout.setEncoding("utf8"),logger_1.logger.info("fork childprocess end"),t.stdout.on("data",s=>{log.log(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.childProcessManager=exports.ChildProcessCrashedError=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),child_process_1=require("child_process"),events_1=tslib_1.__importDefault(require("events")),os=tslib_1.__importStar(require("os")),log=tslib_1.__importStar(require("../../../../utils/log")),logger_1=require("../utils/logger"),config_1=require("./config"),cpus=os.cpus().length,FORK_PATH=path_1.default.posix.join(__dirname,"./childprocess.js"),MAX_TASK_TRY_TIME=2;class ChildProcessCrashedError extends Error{constructor(s,e){super(e),this.type=s}}exports.ChildProcessCrashedError=ChildProcessCrashedError;class ChildProcessInstance extends events_1.default{constructor(s){super(),this.status=config_1.EChildProcessStatus.free,this._lastActiveTime=0,this._taskMap={},this._fullload_task_count=4,this._suicideTime=config_1.SUICIDE_TIME["miniprogram-ci"],this._fullload_task_count=s;const e={stdio:["pipe","pipe","pipe","ipc"],env:Object.assign(Object.assign({},process.env),{cpprocessEnv:"childprocess"})};if(e.env.isDevtools=process.__nwjs&&"wechatwebdevtools"===nw.App.manifest.appname,e.env.isDevtools){this._suicideTime=config_1.SUICIDE_TIME.devtools;let s=path_1.default.join(path_1.default.dirname(process.execPath),"node");"darwin"!==process.platform&&(s+=".exe"),e.execPath=s}logger_1.logger.info("fork childprocess start");const t=(0,child_process_1.fork)(FORK_PATH,["--expose-gc"],e);t.stdout.setEncoding("utf8"),logger_1.logger.info("fork childprocess end"),t.stdout.on("data",(s=>{log.log(`child process stdout: ${s}`)})),t.stderr.on("data",(s=>{log.error(`child process stderr: ${s}`),this.checkIfProcessCrashed(s.toString())})),t.on("message",this.onChildSummerProcessMessage.bind(this,t)),t.on("exit",(s=>{this.emit("exit",{code:s,crashedReason:this.crashedReason,status:this.status,tasks:Object.values(this._taskMap),pid:t.pid})})),t.unref(),this._instance=t}checkIfProcessCrashed(s){s.includes("ERR_WORKER_OUT_OF_MEMORY")&&(this.crashedReason=new ChildProcessCrashedError("ERR_WORKER_OUT_OF_MEMORY",s))}onChildSummerProcessMessage(s,e){if("object"!=typeof e)return void logger_1.logger.error("unrecognized message from child process",e);const{command:t,data:i}=e;t!==config_1.COMMAND.SEND_LOG?(logger_1.logger.info(`onChildSummerProcessMessage ${t}`,i),t===config_1.COMMAND.TASK_DONE?this.onTaskDone(i):t===config_1.COMMAND.SEND_LOG&&logger_1.logger.send(i.level,i.args)):logger_1.logger.send(i.level,i.args)}onTaskDone(s){const{taskId:e,result:t}=s,i=this._taskMap[e];delete this._taskMap[e],i?(i.resolve&&(i.onStatusUpdate(config_1.ETaskStatus.done),i.resolve(t)),0===Object.keys(this._taskMap).length&&(this.status=config_1.EChildProcessStatus.free,this.setUpSuicideTimer()),this.emit("taskDone")):log.error(`child process task: ${e} not found`)}setUpSuicideTimer(){this._suicideTimer=setTimeout((()=>{clearTimeout(this._suicideTimer),this.status===config_1.EChildProcessStatus.free?(this.status=config_1.EChildProcessStatus.dying,this._instance.kill("SIGTERM")):this._suicideTimer||this.setUpSuicideTimer()}),this._suicideTime)}runTask(s){clearTimeout(this._suicideTimer),this.status=config_1.EChildProcessStatus.busy,this._lastActiveTime=Date.now();const e=getId();this._taskMap[e]=s,Object.keys(this._taskMap).length>=this._fullload_task_count?this.status=config_1.EChildProcessStatus.fullload:this.status=config_1.EChildProcessStatus.busy,s.onStatusUpdate(config_1.ETaskStatus.progress),this._instance.send({command:config_1.COMMAND.RUN_TASK,data:{taskId:e,taskName:s.name,data:s.data}})}}const getId=(()=>{let s=0;return()=>s++})();class TaskManager{constructor(){this._taskQueue=[],this.onChildProcessExit=s=>{const{code:e,crashedReason:t,status:i,tasks:o,pid:r}=s;if(this._instance=void 0,i===config_1.EChildProcessStatus.busy||i===config_1.EChildProcessStatus.fullload)for(const s of o)s.retryTimes+=1,s.retryTimes<=2?(log.error(`child process: ${r} exit with code: ${e} when it is busy, retry running ${s.retryTimes} times`),this._taskQueue.push(s)):t||t?s.reject(t):s.reject(`child process exit with code: ${e} when it is busy`);this._run()},this.onTaskDone=()=>{this._run()}}runTask(s,e,t=(()=>{})){return new Promise(((i,o)=>{const r={name:s,data:e,resolve:i,reject:o,retryTimes:0,onStatusUpdate:t};t(config_1.ETaskStatus.waiting),this._taskQueue.push(r),this._run()}))}_run(){if(0===this._taskQueue.length)return;const s=this.allocChildProcess();s.status!==config_1.EChildProcessStatus.fullload&&s.status!==config_1.EChildProcessStatus.dying&&(s.runTask(this._taskQueue.shift()),this._run())}allocChildProcess(){return this._instance||(this._instance=new ChildProcessInstance(2*cpus),this._instance.on("exit",this.onChildProcessExit),this._instance.on("taskDone",this.onTaskDone)),this._instance}}exports.childProcessManager=new TaskManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ETaskStatus,EWorkerStatus,EChildProcessStatus;Object.defineProperty(exports,"__esModule",{value:!0}),exports.SUICIDE_TIME=exports.EChildProcessStatus=exports.EWorkerStatus=exports.COMMAND=exports.TASK_NAME=exports.ETaskStatus=void 0,function(s){s[s.waiting=0]="waiting",s[s.progress=1]="progress",s[s.done=2]="done"}(ETaskStatus||(exports.ETaskStatus=ETaskStatus={})),exports.TASK_NAME={COMPILE_JS:"COMPILE_JS",COMPILE_WXSS:"COMPILE_WXSS",MINIFY_WXML:"MINIFY_WXML",SUMMER_HOOK:"SUMMER_HOOK"},exports.COMMAND={RUN_TASK:"RUN_TASK",TASK_DONE:"TASK_DONE",CALL_FUNC:"CALL_FUNC",CALL_FUNC_RESULT:"CALL_FUNC_RESULT",CHILD_PROCESS_READY:"CHILD_PROCESS_READY",SEND_LOG:"SEND_LOG"},function(s){s[s.free=0]="free",s[s.busy=1]="busy",s[s.dying=2]="dying"}(EWorkerStatus||(exports.EWorkerStatus=EWorkerStatus={})),function(s){s[s.free=0]="free",s[s.busy=1]="busy",s[s.fullload=2]="fullload",s[s.dying=3]="dying"}(EChildProcessStatus||(exports.EChildProcessStatus=EChildProcessStatus={})),exports.SUICIDE_TIME={devtools:864e5,"miniprogram-ci":1e4,webide:864e5};
|
|
1
|
+
"use strict";var ETaskStatus,EWorkerStatus,EChildProcessStatus;Object.defineProperty(exports,"__esModule",{value:!0}),exports.SUICIDE_TIME=exports.EChildProcessStatus=exports.EWorkerStatus=exports.COMMAND=exports.TASK_NAME=exports.ETaskStatus=void 0,function(s){s[s.waiting=0]="waiting",s[s.progress=1]="progress",s[s.done=2]="done"}(ETaskStatus||(exports.ETaskStatus=ETaskStatus={})),exports.TASK_NAME={COMPILE_JS:"COMPILE_JS",COMPILE_WXSS:"COMPILE_WXSS",MINIFY_WXML:"MINIFY_WXML",SUMMER_HOOK:"SUMMER_HOOK",PIPE_TASK:"PIPE_TASK"},exports.COMMAND={INIT_START:"INIT_START",INIT_READY:"INIT_READY",RUN_TASK:"RUN_TASK",TASK_DONE:"TASK_DONE",CALL_FUNC:"CALL_FUNC",CALL_FUNC_RESULT:"CALL_FUNC_RESULT",CHILD_PROCESS_READY:"CHILD_PROCESS_READY",SEND_LOG:"SEND_LOG"},function(s){s[s.free=0]="free",s[s.busy=1]="busy",s[s.dying=2]="dying"}(EWorkerStatus||(exports.EWorkerStatus=EWorkerStatus={})),function(s){s[s.free=0]="free",s[s.busy=1]="busy",s[s.fullload=2]="fullload",s[s.dying=3]="dying"}(EChildProcessStatus||(exports.EChildProcessStatus=EChildProcessStatus={})),exports.SUICIDE_TIME={devtools:864e5,"miniprogram-ci":1e4,webide:864e5};
|