├── README.md ├── md ├── devtools │ ├── README.md │ └── images │ │ ├── allow.png │ │ ├── install.png │ │ ├── open-src-app.vue.png │ │ ├── vue-devtools-v2-install.png │ │ └── vue-devtools-v3-install.png ├── release │ ├── README.md │ ├── README.zhihu.md │ └── images │ │ ├── cover.jpg │ │ ├── debugger-terminal.png │ │ ├── publish.png │ │ ├── pushing-to-github.png │ │ ├── release-debugger.png │ │ ├── release-terminal.png │ │ ├── terminal-output.png │ │ ├── terminal-yes.png │ │ ├── vue-dep.png │ │ └── vue-release.png └── utils │ ├── README.md │ ├── README.ts.md │ ├── images │ └── vue-next-debugger.png │ └── regex.js ├── shells └── cp.sh └── vue-next ├── .eslintrc.js ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ └── config.yml ├── commit-convention.md ├── contributing.md ├── dependabot.yml └── workflows │ ├── ci.yml │ └── release-tag.yml ├── .gitignore ├── .prettierrc ├── .vscode ├── launch.json └── settings.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── api-extractor.json ├── examples └── index.html ├── jest.config.js ├── package.json ├── packages ├── compiler-core │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ ├── codegen.spec.ts.snap │ │ │ ├── compile.spec.ts.snap │ │ │ ├── parse.spec.ts.snap │ │ │ └── scopeId.spec.ts.snap │ │ ├── codegen.spec.ts │ │ ├── compile.spec.ts │ │ ├── parse.spec.ts │ │ ├── scopeId.spec.ts │ │ ├── testUtils.ts │ │ ├── transform.spec.ts │ │ ├── transforms │ │ │ ├── __snapshots__ │ │ │ │ ├── hoistStatic.spec.ts.snap │ │ │ │ ├── transformExpressions.spec.ts.snap │ │ │ │ ├── transformText.spec.ts.snap │ │ │ │ ├── vFor.spec.ts.snap │ │ │ │ ├── vIf.spec.ts.snap │ │ │ │ ├── vMemo.spec.ts.snap │ │ │ │ ├── vModel.spec.ts.snap │ │ │ │ ├── vOnce.spec.ts.snap │ │ │ │ └── vSlot.spec.ts.snap │ │ │ ├── hoistStatic.spec.ts │ │ │ ├── noopDirectiveTransform.spec.ts │ │ │ ├── transformElement.spec.ts │ │ │ ├── transformExpressions.spec.ts │ │ │ ├── transformSlotOutlet.spec.ts │ │ │ ├── transformText.spec.ts │ │ │ ├── vBind.spec.ts │ │ │ ├── vFor.spec.ts │ │ │ ├── vIf.spec.ts │ │ │ ├── vMemo.spec.ts │ │ │ ├── vModel.spec.ts │ │ │ ├── vOn.spec.ts │ │ │ ├── vOnce.spec.ts │ │ │ └── vSlot.spec.ts │ │ └── utils.spec.ts │ ├── api-extractor.json │ ├── index.js │ ├── package.json │ └── src │ │ ├── ast.ts │ │ ├── codegen.ts │ │ ├── compat │ │ ├── compatConfig.ts │ │ └── transformFilter.ts │ │ ├── compile.ts │ │ ├── errors.ts │ │ ├── index.ts │ │ ├── options.ts │ │ ├── parse.ts │ │ ├── runtimeHelpers.ts │ │ ├── transform.ts │ │ ├── transforms │ │ ├── hoistStatic.ts │ │ ├── noopDirectiveTransform.ts │ │ ├── transformElement.ts │ │ ├── transformExpression.ts │ │ ├── transformSlotOutlet.ts │ │ ├── transformText.ts │ │ ├── vBind.ts │ │ ├── vFor.ts │ │ ├── vIf.ts │ │ ├── vMemo.ts │ │ ├── vModel.ts │ │ ├── vOn.ts │ │ ├── vOnce.ts │ │ └── vSlot.ts │ │ ├── utils.ts │ │ └── validateExpression.ts ├── compiler-dom │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ └── index.spec.ts.snap │ │ ├── decoderHtmlBrowser.spec.ts │ │ ├── index.spec.ts │ │ ├── parse.spec.ts │ │ └── transforms │ │ │ ├── __snapshots__ │ │ │ ├── vModel.spec.ts.snap │ │ │ ├── vShow.spec.ts.snap │ │ │ └── warnTransitionChildren.spec.ts.snap │ │ │ ├── ignoreSideEffectTags.spec.ts │ │ │ ├── stringifyStatic.spec.ts │ │ │ ├── transformStyle.spec.ts │ │ │ ├── vHtml.spec.ts │ │ │ ├── vModel.spec.ts │ │ │ ├── vOn.spec.ts │ │ │ ├── vShow.spec.ts │ │ │ ├── vText.spec.ts │ │ │ └── warnTransitionChildren.spec.ts │ ├── api-extractor.json │ ├── index.js │ ├── package.json │ └── src │ │ ├── decodeHtml.ts │ │ ├── decodeHtmlBrowser.ts │ │ ├── errors.ts │ │ ├── index.ts │ │ ├── namedChars.json │ │ ├── parserOptions.ts │ │ ├── runtimeHelpers.ts │ │ └── transforms │ │ ├── ignoreSideEffectTags.ts │ │ ├── stringifyStatic.ts │ │ ├── transformStyle.ts │ │ ├── vHtml.ts │ │ ├── vModel.ts │ │ ├── vOn.ts │ │ ├── vShow.ts │ │ ├── vText.ts │ │ └── warnTransitionChildren.ts ├── compiler-sfc │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ ├── compileScript.spec.ts.snap │ │ │ ├── compileScriptRefSugar.spec.ts.snap │ │ │ ├── compileTemplate.spec.ts.snap │ │ │ ├── cssVars.spec.ts.snap │ │ │ ├── templateTransformAssetUrl.spec.ts.snap │ │ │ └── templateTransformSrcset.spec.ts.snap │ │ ├── compileScript.spec.ts │ │ ├── compileScriptParseOnlyMode.spec.ts │ │ ├── compileScriptRefSugar.spec.ts │ │ ├── compileStyle.spec.ts │ │ ├── compileTemplate.spec.ts │ │ ├── cssVars.spec.ts │ │ ├── fixture │ │ │ └── import.scss │ │ ├── parse.spec.ts │ │ ├── rewriteDefault.spec.ts │ │ ├── templateTransformAssetUrl.spec.ts │ │ ├── templateTransformSrcset.spec.ts │ │ ├── templateUtils.spec.ts │ │ └── utils.ts │ ├── api-extractor.json │ ├── package.json │ └── src │ │ ├── cache.ts │ │ ├── compileScript.ts │ │ ├── compileStyle.ts │ │ ├── compileTemplate.ts │ │ ├── cssVars.ts │ │ ├── index.ts │ │ ├── parse.ts │ │ ├── rewriteDefault.ts │ │ ├── shims.d.ts │ │ ├── stylePluginScoped.ts │ │ ├── stylePluginTrim.ts │ │ ├── stylePreprocessors.ts │ │ ├── templateTransformAssetUrl.ts │ │ ├── templateTransformSrcset.ts │ │ ├── templateUtils.ts │ │ └── warn.ts ├── compiler-ssr │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ │ ├── ssrComponent.spec.ts │ │ ├── ssrElement.spec.ts │ │ ├── ssrInjectCssVars.spec.ts │ │ ├── ssrPortal.spec.ts │ │ ├── ssrScopeId.spec.ts │ │ ├── ssrSlotOutlet.spec.ts │ │ ├── ssrSuspense.spec.ts │ │ ├── ssrText.spec.ts │ │ ├── ssrVFor.spec.ts │ │ ├── ssrVIf.spec.ts │ │ ├── ssrVModel.spec.ts │ │ ├── ssrVShow.spec.ts │ │ └── utils.ts │ ├── api-extractor.json │ ├── package.json │ └── src │ │ ├── errors.ts │ │ ├── index.ts │ │ ├── runtimeHelpers.ts │ │ ├── ssrCodegenTransform.ts │ │ └── transforms │ │ ├── ssrInjectCssVars.ts │ │ ├── ssrInjectFallthroughAttrs.ts │ │ ├── ssrTransformComponent.ts │ │ ├── ssrTransformElement.ts │ │ ├── ssrTransformSlotOutlet.ts │ │ ├── ssrTransformSuspense.ts │ │ ├── ssrTransformTeleport.ts │ │ ├── ssrTransformTransitionGroup.ts │ │ ├── ssrVFor.ts │ │ ├── ssrVIf.ts │ │ ├── ssrVModel.ts │ │ └── ssrVShow.ts ├── global.d.ts ├── reactivity │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ │ ├── collections │ │ │ ├── Map.spec.ts │ │ │ ├── Set.spec.ts │ │ │ ├── WeakMap.spec.ts │ │ │ ├── WeakSet.spec.ts │ │ │ └── shallowReadonly.spec.ts │ │ ├── computed.spec.ts │ │ ├── deferredComputed.spec.ts │ │ ├── effect.spec.ts │ │ ├── effectScope.spec.ts │ │ ├── reactive.spec.ts │ │ ├── reactiveArray.spec.ts │ │ ├── readonly.spec.ts │ │ ├── ref.spec.ts │ │ ├── shallowReactive.spec.ts │ │ └── shallowReadonly.spec.ts │ ├── api-extractor.json │ ├── index.js │ ├── package.json │ └── src │ │ ├── baseHandlers.ts │ │ ├── collectionHandlers.ts │ │ ├── computed.ts │ │ ├── deferredComputed.ts │ │ ├── dep.ts │ │ ├── effect.ts │ │ ├── effectScope.ts │ │ ├── index.ts │ │ ├── operations.ts │ │ ├── reactive.ts │ │ ├── ref.ts │ │ └── warning.ts ├── runtime-core │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ │ ├── apiAsyncComponent.spec.ts │ │ ├── apiCreateApp.spec.ts │ │ ├── apiExpose.spec.ts │ │ ├── apiInject.spec.ts │ │ ├── apiLifecycle.spec.ts │ │ ├── apiOptions.spec.ts │ │ ├── apiSetupContext.spec.ts │ │ ├── apiSetupHelpers.spec.ts │ │ ├── apiTemplateRef.spec.ts │ │ ├── apiWatch.spec.ts │ │ ├── componentEmits.spec.ts │ │ ├── componentProps.spec.ts │ │ ├── componentPublicInstance.spec.ts │ │ ├── componentSlots.spec.ts │ │ ├── components │ │ │ ├── BaseTransition.spec.ts │ │ │ ├── KeepAlive.spec.ts │ │ │ ├── Suspense.spec.ts │ │ │ └── Teleport.spec.ts │ │ ├── directives.spec.ts │ │ ├── errorHandling.spec.ts │ │ ├── h.spec.ts │ │ ├── helpers │ │ │ ├── createSlots.spec.ts │ │ │ ├── renderList.spec.ts │ │ │ ├── renderSlot.spec.ts │ │ │ ├── resolveAssets.spec.ts │ │ │ ├── toHandlers.spec.ts │ │ │ └── withMemo.spec.ts │ │ ├── hmr.spec.ts │ │ ├── hydration.spec.ts │ │ ├── misc.spec.ts │ │ ├── rendererAttrsFallthrough.spec.ts │ │ ├── rendererChildren.spec.ts │ │ ├── rendererComponent.spec.ts │ │ ├── rendererElement.spec.ts │ │ ├── rendererFragment.spec.ts │ │ ├── rendererOptimizedMode.spec.ts │ │ ├── scheduler.spec.ts │ │ ├── scopeId.spec.ts │ │ ├── vnode.spec.ts │ │ └── vnodeHooks.spec.ts │ ├── api-extractor.json │ ├── index.js │ ├── package.json │ ├── src │ │ ├── apiAsyncComponent.ts │ │ ├── apiCreateApp.ts │ │ ├── apiDefineComponent.ts │ │ ├── apiInject.ts │ │ ├── apiLifecycle.ts │ │ ├── apiSetupHelpers.ts │ │ ├── apiWatch.ts │ │ ├── compat │ │ │ ├── attrsFallthrough.ts │ │ │ ├── compatConfig.ts │ │ │ ├── component.ts │ │ │ ├── componentAsync.ts │ │ │ ├── componentFunctional.ts │ │ │ ├── componentVModel.ts │ │ │ ├── customDirective.ts │ │ │ ├── data.ts │ │ │ ├── global.ts │ │ │ ├── globalConfig.ts │ │ │ ├── instance.ts │ │ │ ├── instanceChildren.ts │ │ │ ├── instanceEventEmitter.ts │ │ │ ├── instanceListeners.ts │ │ │ ├── props.ts │ │ │ ├── ref.ts │ │ │ ├── renderFn.ts │ │ │ └── renderHelpers.ts │ │ ├── component.ts │ │ ├── componentEmits.ts │ │ ├── componentOptions.ts │ │ ├── componentProps.ts │ │ ├── componentPublicInstance.ts │ │ ├── componentRenderContext.ts │ │ ├── componentRenderUtils.ts │ │ ├── componentSlots.ts │ │ ├── components │ │ │ ├── BaseTransition.ts │ │ │ ├── KeepAlive.ts │ │ │ ├── Suspense.ts │ │ │ └── Teleport.ts │ │ ├── customFormatter.ts │ │ ├── devtools.ts │ │ ├── directives.ts │ │ ├── errorHandling.ts │ │ ├── featureFlags.ts │ │ ├── h.ts │ │ ├── helpers │ │ │ ├── createSlots.ts │ │ │ ├── refSugar.ts │ │ │ ├── renderList.ts │ │ │ ├── renderSlot.ts │ │ │ ├── resolveAssets.ts │ │ │ ├── toHandlers.ts │ │ │ ├── typeUtils.ts │ │ │ ├── useSsrContext.ts │ │ │ └── withMemo.ts │ │ ├── hmr.ts │ │ ├── hydration.ts │ │ ├── index.ts │ │ ├── profiling.ts │ │ ├── renderer.ts │ │ ├── scheduler.ts │ │ ├── vnode.ts │ │ └── warning.ts │ └── types │ │ ├── refBail.d.ts │ │ └── scriptSetupHelpers.d.ts ├── runtime-dom │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ │ ├── createApp.spec.ts │ │ ├── customElement.spec.ts │ │ ├── customizedBuiltIn.spec.ts │ │ ├── directives │ │ │ ├── vCloak.spec.ts │ │ │ ├── vModel.spec.ts │ │ │ ├── vOn.spec.ts │ │ │ └── vShow.spec.ts │ │ ├── helpers │ │ │ ├── useCssModule.spec.ts │ │ │ └── useCssVars.spec.ts │ │ ├── nodeOps.spec.ts │ │ ├── patchAttrs.spec.ts │ │ ├── patchClass.spec.ts │ │ ├── patchEvents.spec.ts │ │ ├── patchProps.spec.ts │ │ ├── patchStyle.spec.ts │ │ └── rendererStaticNode.spec.ts │ ├── api-extractor.json │ ├── index.js │ ├── package.json │ ├── src │ │ ├── apiCustomElement.ts │ │ ├── components │ │ │ ├── Transition.ts │ │ │ └── TransitionGroup.ts │ │ ├── directives │ │ │ ├── vModel.ts │ │ │ ├── vOn.ts │ │ │ └── vShow.ts │ │ ├── helpers │ │ │ ├── useCssModule.ts │ │ │ └── useCssVars.ts │ │ ├── index.ts │ │ ├── modules │ │ │ ├── attrs.ts │ │ │ ├── class.ts │ │ │ ├── events.ts │ │ │ ├── props.ts │ │ │ └── style.ts │ │ ├── nodeOps.ts │ │ └── patchProp.ts │ └── types │ │ ├── jsx.d.ts │ │ └── refBail.d.ts ├── runtime-test │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ │ └── testRuntime.spec.ts │ ├── api-extractor.json │ ├── index.js │ ├── package.json │ └── src │ │ ├── index.ts │ │ ├── nodeOps.ts │ │ ├── patchProp.ts │ │ ├── serialize.ts │ │ └── triggerEvent.ts ├── server-renderer │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ │ ├── render.spec.ts │ │ ├── ssrAttrFallthrough.spec.ts │ │ ├── ssrDirectives.spec.ts │ │ ├── ssrDynamicComponent.spec.ts │ │ ├── ssrInterpolate.spec.ts │ │ ├── ssrRenderAttrs.spec.ts │ │ ├── ssrRenderList.spec.ts │ │ ├── ssrScopeId.spec.ts │ │ ├── ssrSuspense.spec.ts │ │ ├── ssrTeleport.spec.ts │ │ ├── ssrVModelHelpers.spec.ts │ │ └── webStream.spec.ts │ ├── api-extractor.json │ ├── index.js │ ├── package.json │ └── src │ │ ├── helpers │ │ ├── ssrCompile.ts │ │ ├── ssrInterpolate.ts │ │ ├── ssrRenderAttrs.ts │ │ ├── ssrRenderComponent.ts │ │ ├── ssrRenderList.ts │ │ ├── ssrRenderSlot.ts │ │ ├── ssrRenderSuspense.ts │ │ ├── ssrRenderTeleport.ts │ │ └── ssrVModelHelpers.ts │ │ ├── index.ts │ │ ├── render.ts │ │ ├── renderToStream.ts │ │ └── renderToString.ts ├── sfc-playground │ ├── index.html │ ├── package.json │ ├── public │ │ └── logo.svg │ ├── src │ │ ├── App.vue │ │ ├── Header.vue │ │ ├── Message.vue │ │ ├── SplitPane.vue │ │ ├── codemirror │ │ │ ├── CodeMirror.vue │ │ │ ├── codemirror.css │ │ │ └── codemirror.ts │ │ ├── download │ │ │ ├── download.ts │ │ │ └── template │ │ │ │ ├── README.md │ │ │ │ ├── index.html │ │ │ │ ├── main.js │ │ │ │ ├── package.json │ │ │ │ └── vite.config.js │ │ ├── editor │ │ │ ├── Editor.vue │ │ │ └── FileSelector.vue │ │ ├── main.ts │ │ ├── output │ │ │ ├── Output.vue │ │ │ ├── Preview.vue │ │ │ ├── PreviewProxy.ts │ │ │ ├── moduleCompiler.ts │ │ │ └── srcdoc.html │ │ ├── sfcCompiler.ts │ │ ├── store.ts │ │ ├── utils.ts │ │ └── vue-dev-proxy.ts │ └── vite.config.ts ├── shared │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ └── codeframe.spec.ts.snap │ │ ├── codeframe.spec.ts │ │ ├── escapeHtml.spec.ts │ │ ├── looseEqual.spec.ts │ │ ├── normalizeProp.spec.ts │ │ └── toDisplayString.spec.ts │ ├── api-extractor.json │ ├── index.js │ ├── package.json │ └── src │ │ ├── codeframe.ts │ │ ├── domAttrConfig.ts │ │ ├── domTagConfig.ts │ │ ├── escapeHtml.ts │ │ ├── globalsWhitelist.ts │ │ ├── index.ts │ │ ├── looseEqual.ts │ │ ├── makeMap.ts │ │ ├── normalizeProp.ts │ │ ├── patchFlags.ts │ │ ├── shapeFlags.ts │ │ ├── slotFlags.ts │ │ └── toDisplayString.ts ├── size-check │ ├── README.md │ ├── package.json │ └── src │ │ └── index.ts ├── template-explorer │ ├── README.md │ ├── index.html │ ├── local.html │ ├── package.json │ ├── src │ │ ├── index.ts │ │ ├── options.ts │ │ └── theme.ts │ └── style.css ├── vue-compat │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ │ ├── compiler.spec.ts │ │ ├── componentAsync.spec.ts │ │ ├── componentFunctional.spec.ts │ │ ├── componentVModel.spec.ts │ │ ├── filters.spec.ts │ │ ├── global.spec.ts │ │ ├── globalConfig.spec.ts │ │ ├── instance.spec.ts │ │ ├── misc.spec.ts │ │ ├── options.spec.ts │ │ ├── refInfor.spec.ts │ │ ├── renderFn.spec.ts │ │ └── utils.ts │ ├── api-extractor.json │ ├── index.js │ ├── package.json │ └── src │ │ ├── createCompatVue.ts │ │ ├── dev.ts │ │ ├── esm-index.ts │ │ ├── esm-runtime.ts │ │ ├── index.ts │ │ └── runtime.ts └── vue │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ ├── Transition.spec.ts │ ├── TransitionGroup.spec.ts │ ├── e2eUtils.ts │ ├── index.spec.ts │ ├── runtimeCompilerOptions.spec.ts │ ├── svgNamespace.spec.ts │ └── transition.html │ ├── api-extractor.json │ ├── examples │ ├── __tests__ │ │ ├── commits.mock.ts │ │ ├── commits.spec.ts │ │ ├── grid.spec.ts │ │ ├── markdown.spec.ts │ │ ├── svg.spec.ts │ │ ├── todomvc.spec.ts │ │ └── tree.spec.ts │ ├── classic │ │ ├── commits.html │ │ ├── grid.html │ │ ├── markdown.html │ │ ├── svg.html │ │ ├── todomvc.html │ │ └── tree.html │ ├── composition │ │ ├── commits.html │ │ ├── grid.html │ │ ├── markdown.html │ │ ├── svg.html │ │ ├── todomvc.html │ │ └── tree.html │ └── transition │ │ ├── list.html │ │ └── modal.html │ ├── index.js │ ├── package.json │ └── src │ ├── dev.ts │ ├── index.ts │ └── runtime.ts ├── rollup.config.js ├── scripts ├── bootstrap.js ├── build.js ├── checkYarn.js ├── dev.js ├── release.js ├── setupJestEnv.ts ├── utils.js └── verifyCommit.js ├── test-dts ├── README.md ├── component.test-d.ts ├── componentTypeExtensions.test-d.tsx ├── defineComponent.test-d.tsx ├── functionalComponent.test-d.tsx ├── h.test-d.ts ├── index.d.ts ├── inject.test-d.ts ├── reactivity.test-d.ts ├── ref.test-d.ts ├── refSugar.test-d.ts ├── setupHelpers.test-d.ts ├── tsconfig.build.json ├── tsconfig.json ├── tsx.test-d.tsx └── watch.test-d.ts ├── tsconfig.json └── yarn.lock /README.md: -------------------------------------------------------------------------------- 1 | # vue-next-analysis 2 | 3 | 你好,我是[**若川**](https://mp.weixin.qq.com/s/MwYIGKFGvx_qzthi20DehA)。最近组织了[源码共读活动《1个月,200+人,一起读了4周源码》](https://mp.weixin.qq.com/s?__biz=MzA5MjQwMzQyNw==&mid=2650756550&idx=1&sn=9acc5e30325963e455f53ec2f64c1fdd&chksm=8866564abf11df5c41307dba3eb84e8e14de900e1b3500aaebe802aff05b0ba2c24e4690516b&token=917686367&lang=zh_CN#rd),感兴趣的可以加我微信 [ruochuan12](https://mp.weixin.qq.com/s?__biz=MzA5MjQwMzQyNw==&mid=2650756550&idx=1&sn=9acc5e30325963e455f53ec2f64c1fdd&chksm=8866564abf11df5c41307dba3eb84e8e14de900e1b3500aaebe802aff05b0ba2c24e4690516b&token=917686367&lang=zh_CN#rd) 参与,长期交流学习。 4 | 5 | 其中 `md` 文件夹,对应三篇文章 6 | 7 | - [尤雨溪开发的 vue-devtools 如何安装,为何打开文件的功能鲜有人知?](https://juejin.cn/post/6994289281141309476) 8 | 9 | - [初学者也能看懂的 Vue3 源码中那些实用的基础工具函数](https://juejin.cn/post/6994976281053888519) 10 | 11 | - [Vue 3.2 发布了,那尤雨溪是怎么发布 Vue.js 的?](https://juejin.cn/post/6997943192851054606) -------------------------------------------------------------------------------- /md/devtools/images/allow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruochuan12/vue-next-analysis/990dfd7f61b5bdab15beaa07960a37459270bcad/md/devtools/images/allow.png -------------------------------------------------------------------------------- /md/devtools/images/install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruochuan12/vue-next-analysis/990dfd7f61b5bdab15beaa07960a37459270bcad/md/devtools/images/install.png -------------------------------------------------------------------------------- /md/devtools/images/open-src-app.vue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruochuan12/vue-next-analysis/990dfd7f61b5bdab15beaa07960a37459270bcad/md/devtools/images/open-src-app.vue.png -------------------------------------------------------------------------------- /md/devtools/images/vue-devtools-v2-install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruochuan12/vue-next-analysis/990dfd7f61b5bdab15beaa07960a37459270bcad/md/devtools/images/vue-devtools-v2-install.png -------------------------------------------------------------------------------- /md/devtools/images/vue-devtools-v3-install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruochuan12/vue-next-analysis/990dfd7f61b5bdab15beaa07960a37459270bcad/md/devtools/images/vue-devtools-v3-install.png -------------------------------------------------------------------------------- /md/release/images/cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruochuan12/vue-next-analysis/990dfd7f61b5bdab15beaa07960a37459270bcad/md/release/images/cover.jpg -------------------------------------------------------------------------------- /md/release/images/debugger-terminal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruochuan12/vue-next-analysis/990dfd7f61b5bdab15beaa07960a37459270bcad/md/release/images/debugger-terminal.png -------------------------------------------------------------------------------- /md/release/images/publish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruochuan12/vue-next-analysis/990dfd7f61b5bdab15beaa07960a37459270bcad/md/release/images/publish.png -------------------------------------------------------------------------------- /md/release/images/pushing-to-github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruochuan12/vue-next-analysis/990dfd7f61b5bdab15beaa07960a37459270bcad/md/release/images/pushing-to-github.png -------------------------------------------------------------------------------- /md/release/images/release-debugger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruochuan12/vue-next-analysis/990dfd7f61b5bdab15beaa07960a37459270bcad/md/release/images/release-debugger.png -------------------------------------------------------------------------------- /md/release/images/release-terminal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruochuan12/vue-next-analysis/990dfd7f61b5bdab15beaa07960a37459270bcad/md/release/images/release-terminal.png -------------------------------------------------------------------------------- /md/release/images/terminal-output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruochuan12/vue-next-analysis/990dfd7f61b5bdab15beaa07960a37459270bcad/md/release/images/terminal-output.png -------------------------------------------------------------------------------- /md/release/images/terminal-yes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruochuan12/vue-next-analysis/990dfd7f61b5bdab15beaa07960a37459270bcad/md/release/images/terminal-yes.png -------------------------------------------------------------------------------- /md/release/images/vue-dep.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruochuan12/vue-next-analysis/990dfd7f61b5bdab15beaa07960a37459270bcad/md/release/images/vue-dep.png -------------------------------------------------------------------------------- /md/release/images/vue-release.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruochuan12/vue-next-analysis/990dfd7f61b5bdab15beaa07960a37459270bcad/md/release/images/vue-release.png -------------------------------------------------------------------------------- /md/utils/images/vue-next-debugger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruochuan12/vue-next-analysis/990dfd7f61b5bdab15beaa07960a37459270bcad/md/utils/images/vue-next-debugger.png -------------------------------------------------------------------------------- /md/utils/regex.js: -------------------------------------------------------------------------------- 1 | const cacheStringFunction = (fn) => { 2 | const cache = Object.create(null); 3 | return ((str) => { 4 | const hit = cache[str]; 5 | return hit || (cache[str] = fn(str)); 6 | }); 7 | }; 8 | // \w 是 0-9a-zA-Z_ 数字 大小写字母和下划线组成 9 | // () 小括号是 分组捕获 10 | const camelizeRE = /-(\w)/g; 11 | /** 12 | * @private 13 | */ 14 | // 首字母转大写 15 | const camelize = cacheStringFunction((str) => { 16 | return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : '')); 17 | }); 18 | // \B 是指 非 \b 单词边界。 19 | const hyphenateRE = /\B([A-Z])/g; 20 | 21 | // 连字符 22 | /** 23 | * @private 24 | */ 25 | const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, '-$1').toLowerCase()); 26 | // 举例: 27 | const hyphenateResult = hyphenate('onClick'); 28 | console.log('hyphenateResult', hyphenateResult); // on-click 29 | 30 | /** 31 | * @private 32 | */ 33 | // 首字母转大写 34 | const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1)); 35 | /** 36 | * @private 37 | */ 38 | const toHandlerKey = cacheStringFunction((str) => (str ? `on${capitalize(str)}` : ``)); 39 | 40 | const result = toHandlerKey('click'); 41 | console.log(result, 'result'); // 'onClick' -------------------------------------------------------------------------------- /vue-next/.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | open_collective: vuejs 2 | patreon: evanyou 3 | github: yyx990803 4 | -------------------------------------------------------------------------------- /vue-next/.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Create new issue 4 | url: https://new-issue.vuejs.org/?repo=vuejs/vue-next 5 | about: Please use the following link to create a new issue. 6 | - name: Patreon 7 | url: https://www.patreon.com/evanyou 8 | about: Love Vue.js? Please consider supporting us via Patreon. 9 | - name: Open Collective 10 | url: https://opencollective.com/vuejs/donate 11 | about: Love Vue.js? Please consider supporting us via Open Collective. 12 | -------------------------------------------------------------------------------- /vue-next/.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: monthly 7 | open-pull-requests-limit: 10 8 | versioning-strategy: lockfile-only 9 | ignore: 10 | - dependency-name: "@types/node" 11 | versions: 12 | - 14.14.24 13 | - 14.14.37 14 | - dependency-name: "@babel/parser" 15 | versions: 16 | - 7.12.11 17 | - 7.12.13 18 | - 7.12.14 19 | - 7.12.15 20 | - 7.12.16 21 | - 7.12.17 22 | - 7.13.0 23 | - 7.13.10 24 | - 7.13.11 25 | - 7.13.13 26 | - 7.13.4 27 | - 7.13.9 28 | - dependency-name: eslint 29 | versions: 30 | - 7.23.0 31 | - dependency-name: postcss 32 | versions: 33 | - 8.2.4 34 | - 8.2.5 35 | - 8.2.7 36 | - 8.2.8 37 | - dependency-name: typescript 38 | versions: 39 | - 4.2.2 40 | - dependency-name: "@babel/types" 41 | versions: 42 | - 7.12.12 43 | - 7.12.13 44 | - 7.12.17 45 | - 7.13.0 46 | - dependency-name: pug-code-gen 47 | versions: 48 | - 2.0.3 49 | - dependency-name: estree-walker 50 | versions: 51 | - 2.0.2 52 | - dependency-name: "@typescript-eslint/parser" 53 | versions: 54 | - 4.14.2 55 | - 4.15.0 56 | - dependency-name: "@microsoft/api-extractor" 57 | versions: 58 | - 7.13.1 59 | - dependency-name: rollup 60 | versions: 61 | - 2.38.5 62 | - dependency-name: node-notifier 63 | versions: 64 | - 8.0.1 65 | -------------------------------------------------------------------------------- /vue-next/.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: 'ci' 2 | on: 3 | push: 4 | branches: 5 | - '**' 6 | pull_request: 7 | branches: 8 | - master 9 | jobs: 10 | test: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v1 14 | - name: Set node version to 16 15 | uses: actions/setup-node@v2 16 | with: 17 | node-version: 16 18 | - uses: bahmutov/npm-install@v1 19 | - name: Run unit tests 20 | run: yarn test --ci 21 | 22 | test-dts: 23 | runs-on: ubuntu-latest 24 | steps: 25 | - uses: actions/checkout@v1 26 | - name: Set node version to 16 27 | uses: actions/setup-node@v2 28 | with: 29 | node-version: 16 30 | - uses: bahmutov/npm-install@v1 31 | - name: Run type declaration tests 32 | run: yarn test-dts 33 | 34 | size: 35 | runs-on: ubuntu-latest 36 | env: 37 | CI_JOB_NUMBER: 1 38 | steps: 39 | - uses: actions/checkout@v1 40 | - name: Set node version to 16 41 | uses: actions/setup-node@v2 42 | with: 43 | node-version: 16 44 | - uses: bahmutov/npm-install@v1 45 | 46 | - name: Check build size 47 | uses: posva/size-check-action@v1.1.2 48 | with: 49 | github_token: ${{ secrets.GITHUB_TOKEN }} 50 | build_script: size 51 | files: packages/vue/dist/vue.global.prod.js packages/runtime-dom/dist/runtime-dom.global.prod.js packages/size-check/dist/size-check.global.prod.js 52 | -------------------------------------------------------------------------------- /vue-next/.github/workflows/release-tag.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | tags: 4 | - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 5 | 6 | name: Create Release 7 | 8 | jobs: 9 | build: 10 | name: Create Release 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout code 14 | uses: actions/checkout@master 15 | - name: Create Release for Tag 16 | id: release_tag 17 | uses: yyx990803/release-tag@master 18 | env: 19 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 20 | with: 21 | tag_name: ${{ github.ref }} 22 | body: | 23 | Please refer to [CHANGELOG.md](https://github.com/vuejs/vue-next/blob/master/CHANGELOG.md) for details. 24 | -------------------------------------------------------------------------------- /vue-next/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | .DS_Store 3 | node_modules 4 | coverage 5 | temp 6 | explorations 7 | TODOs.md 8 | *.log 9 | -------------------------------------------------------------------------------- /vue-next/.prettierrc: -------------------------------------------------------------------------------- 1 | semi: false 2 | singleQuote: true 3 | printWidth: 80 4 | trailingComma: 'none' 5 | arrowParens: 'avoid' 6 | -------------------------------------------------------------------------------- /vue-next/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Jest", 9 | "type": "node", 10 | "request": "launch", 11 | "program": "${workspaceFolder}/node_modules/.bin/jest", 12 | "stopOnEntry": false, 13 | "args": ["${fileBasename}", "--runInBand", "--detectOpenHandles"], 14 | "cwd": "${workspaceFolder}", 15 | "preLaunchTask": null, 16 | "runtimeExecutable": null, 17 | "runtimeArgs": ["--nolazy"], 18 | "env": { 19 | "NODE_ENV": "development" 20 | }, 21 | "console": "integratedTerminal", 22 | "sourceMaps": true, 23 | "windows": { 24 | "program": "${workspaceFolder}/node_modules/jest/bin/jest", 25 | } 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /vue-next/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use the project's typescript version 3 | "typescript.tsdk": "node_modules/typescript/lib", 4 | 5 | "cSpell.enabledLanguageIds": ["markdown", "plaintext", "text", "yml"], 6 | 7 | // Use prettier to format typescript, javascript and JSON files 8 | "[typescript]": { 9 | "editor.defaultFormatter": "esbenp.prettier-vscode" 10 | }, 11 | "[javascript]": { 12 | "editor.defaultFormatter": "esbenp.prettier-vscode" 13 | }, 14 | "[json]": { 15 | "editor.defaultFormatter": "esbenp.prettier-vscode" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /vue-next/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018-present, Yuxi (Evan) You 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vue-next/api-extractor.json: -------------------------------------------------------------------------------- 1 | // this the shared base config for all packages. 2 | { 3 | "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", 4 | 5 | "apiReport": { 6 | "enabled": true, 7 | "reportFolder": "/temp/" 8 | }, 9 | 10 | "docModel": { 11 | "enabled": true 12 | }, 13 | 14 | "dtsRollup": { 15 | "enabled": true 16 | }, 17 | 18 | "tsdocMetadata": { 19 | "enabled": false 20 | }, 21 | 22 | "messages": { 23 | "compilerMessageReporting": { 24 | "default": { 25 | "logLevel": "warning" 26 | } 27 | }, 28 | 29 | "extractorMessageReporting": { 30 | "default": { 31 | "logLevel": "warning", 32 | "addToApiReportFile": true 33 | }, 34 | 35 | "ae-missing-release-tag": { 36 | "logLevel": "none" 37 | } 38 | }, 39 | 40 | "tsdocMessageReporting": { 41 | "default": { 42 | "logLevel": "warning" 43 | }, 44 | 45 | "tsdoc-undefined-tag": { 46 | "logLevel": "none" 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vue-next/examples/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 若川视野 8 | 9 | 10 |
11 | 12 | 若川的博客 13 |
14 |
15 | 16 | 公众号:若川视野 17 |
18 |
19 | 20 | vue3 中文文档 21 |
22 |
23 | Counter: {{ counter }} 24 |
25 | 26 | 37 | 38 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-core/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018-present, Yuxi (Evan) You 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-core/README.md: -------------------------------------------------------------------------------- 1 | # @vue/compiler-core 2 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-core/__tests__/transforms/__snapshots__/transformExpressions.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`compiler: expression transform bindingMetadata inline mode 1`] = ` 4 | "(_ctx, _cache) => { 5 | return (_openBlock(), _createElementBlock(\\"div\\", null, _toDisplayString(__props.props) + \\" \\" + _toDisplayString(_unref(setup)) + \\" \\" + _toDisplayString(setupConst) + \\" \\" + _toDisplayString(_ctx.data) + \\" \\" + _toDisplayString(_ctx.options), 1 /* TEXT */)) 6 | }" 7 | `; 8 | 9 | exports[`compiler: expression transform bindingMetadata non-inline mode 1`] = ` 10 | "const { toDisplayString: _toDisplayString, openBlock: _openBlock, createElementBlock: _createElementBlock } = Vue 11 | 12 | return function render(_ctx, _cache, $props, $setup, $data, $options) { 13 | return (_openBlock(), _createElementBlock(\\"div\\", null, _toDisplayString($props.props) + \\" \\" + _toDisplayString($setup.setup) + \\" \\" + _toDisplayString($data.data) + \\" \\" + _toDisplayString($options.options), 1 /* TEXT */)) 14 | }" 15 | `; 16 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-core/__tests__/transforms/noopDirectiveTransform.spec.ts: -------------------------------------------------------------------------------- 1 | import { 2 | baseParse as parse, 3 | transform, 4 | ElementNode, 5 | noopDirectiveTransform, 6 | VNodeCall 7 | } from '../../src' 8 | import { transformElement } from '../../src/transforms/transformElement' 9 | 10 | describe('compiler: noop directive transform', () => { 11 | test('should add no props to DOM', () => { 12 | const ast = parse(`
`) 13 | transform(ast, { 14 | nodeTransforms: [transformElement], 15 | directiveTransforms: { 16 | noop: noopDirectiveTransform 17 | } 18 | }) 19 | const node = ast.children[0] as ElementNode 20 | // As v-noop adds no properties the codegen should be identical to 21 | // rendering a div with no props or reactive data (so just the tag as the arg) 22 | expect((node.codegenNode as VNodeCall).props).toBeUndefined() 23 | }) 24 | }) 25 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-core/__tests__/transforms/vMemo.spec.ts: -------------------------------------------------------------------------------- 1 | import { baseCompile } from '../../src' 2 | 3 | describe('compiler: v-memo transform', () => { 4 | function compile(content: string) { 5 | return baseCompile(`
${content}
`, { 6 | mode: 'module', 7 | prefixIdentifiers: true 8 | }).code 9 | } 10 | 11 | test('on root element', () => { 12 | expect( 13 | baseCompile(`
`, { 14 | mode: 'module', 15 | prefixIdentifiers: true 16 | }).code 17 | ).toMatchSnapshot() 18 | }) 19 | 20 | test('on normal element', () => { 21 | expect(compile(`
`)).toMatchSnapshot() 22 | }) 23 | 24 | test('on component', () => { 25 | expect(compile(``)).toMatchSnapshot() 26 | }) 27 | 28 | test('on v-if', () => { 29 | expect( 30 | compile( 31 | `
foobar
32 | ` 33 | ) 34 | ).toMatchSnapshot() 35 | }) 36 | 37 | test('on v-for', () => { 38 | expect( 39 | compile( 40 | `
41 | foobar 42 |
` 43 | ) 44 | ).toMatchSnapshot() 45 | }) 46 | 47 | test('on template v-for', () => { 48 | expect( 49 | compile( 50 | `` 53 | ) 54 | ).toMatchSnapshot() 55 | }) 56 | }) 57 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-core/api-extractor.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../api-extractor.json", 3 | "mainEntryPointFilePath": "./dist/packages//src/index.d.ts", 4 | "dtsRollup": { 5 | "publicTrimmedFilePath": "./dist/.d.ts" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-core/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | if (process.env.NODE_ENV === 'production') { 4 | module.exports = require('./dist/compiler-core.cjs.prod.js') 5 | } else { 6 | module.exports = require('./dist/compiler-core.cjs.js') 7 | } 8 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-core/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@vue/compiler-core", 3 | "version": "3.2.4", 4 | "description": "@vue/compiler-core", 5 | "main": "index.js", 6 | "module": "dist/compiler-core.esm-bundler.js", 7 | "types": "dist/compiler-core.d.ts", 8 | "files": [ 9 | "index.js", 10 | "dist" 11 | ], 12 | "buildOptions": { 13 | "name": "VueCompilerCore", 14 | "compat": true, 15 | "formats": [ 16 | "esm-bundler", 17 | "cjs" 18 | ] 19 | }, 20 | "repository": { 21 | "type": "git", 22 | "url": "git+https://github.com/vuejs/vue-next.git", 23 | "directory": "packages/compiler-core" 24 | }, 25 | "keywords": [ 26 | "vue" 27 | ], 28 | "author": "Evan You", 29 | "license": "MIT", 30 | "bugs": { 31 | "url": "https://github.com/vuejs/vue-next/issues" 32 | }, 33 | "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/compiler-core#readme", 34 | "dependencies": { 35 | "@vue/shared": "3.2.4", 36 | "@babel/parser": "^7.12.0", 37 | "@babel/types": "^7.12.0", 38 | "estree-walker": "^2.0.1", 39 | "source-map": "^0.6.1" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-core/src/transforms/noopDirectiveTransform.ts: -------------------------------------------------------------------------------- 1 | import { DirectiveTransform } from '../transform' 2 | 3 | export const noopDirectiveTransform: DirectiveTransform = () => ({ props: [] }) 4 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-core/src/transforms/vMemo.ts: -------------------------------------------------------------------------------- 1 | import { NodeTransform } from '../transform' 2 | import { findDir, makeBlock } from '../utils' 3 | import { 4 | createCallExpression, 5 | createFunctionExpression, 6 | ElementTypes, 7 | MemoExpression, 8 | NodeTypes, 9 | PlainElementNode 10 | } from '../ast' 11 | import { WITH_MEMO } from '../runtimeHelpers' 12 | 13 | const seen = new WeakSet() 14 | 15 | export const transformMemo: NodeTransform = (node, context) => { 16 | if (node.type === NodeTypes.ELEMENT) { 17 | const dir = findDir(node, 'memo') 18 | if (!dir || seen.has(node)) { 19 | return 20 | } 21 | seen.add(node) 22 | return () => { 23 | const codegenNode = 24 | node.codegenNode || 25 | (context.currentNode as PlainElementNode).codegenNode 26 | if (codegenNode && codegenNode.type === NodeTypes.VNODE_CALL) { 27 | // non-component sub tree should be turned into a block 28 | if (node.tagType !== ElementTypes.COMPONENT) { 29 | makeBlock(codegenNode, context) 30 | } 31 | node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [ 32 | dir.exp!, 33 | createFunctionExpression(undefined, codegenNode), 34 | `_cache`, 35 | String(context.cached++) 36 | ]) as MemoExpression 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-core/src/transforms/vOnce.ts: -------------------------------------------------------------------------------- 1 | import { NodeTransform } from '../transform' 2 | import { findDir } from '../utils' 3 | import { ElementNode, ForNode, IfNode, NodeTypes } from '../ast' 4 | import { SET_BLOCK_TRACKING } from '../runtimeHelpers' 5 | 6 | const seen = new WeakSet() 7 | 8 | export const transformOnce: NodeTransform = (node, context) => { 9 | if (node.type === NodeTypes.ELEMENT && findDir(node, 'once', true)) { 10 | if (seen.has(node) || context.inVOnce) { 11 | return 12 | } 13 | seen.add(node) 14 | context.inVOnce = true 15 | context.helper(SET_BLOCK_TRACKING) 16 | return () => { 17 | context.inVOnce = false 18 | const cur = context.currentNode as ElementNode | IfNode | ForNode 19 | if (cur.codegenNode) { 20 | cur.codegenNode = context.cache(cur.codegenNode, true /* isVNode */) 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-dom/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018-present, Yuxi (Evan) You 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-dom/README.md: -------------------------------------------------------------------------------- 1 | # @vue/compiler-dom -------------------------------------------------------------------------------- /vue-next/packages/compiler-dom/__tests__/__snapshots__/index.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`compile should contain standard transforms 1`] = ` 4 | "const _Vue = Vue 5 | 6 | return function render(_ctx, _cache) { 7 | with (_ctx) { 8 | const { toDisplayString: _toDisplayString, createElementVNode: _createElementVNode, normalizeStyle: _normalizeStyle, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue 9 | 10 | return (_openBlock(), _createElementBlock(_Fragment, null, [ 11 | _createElementVNode(\\"div\\", { 12 | textContent: _toDisplayString(text) 13 | }, null, 8 /* PROPS */, [\\"textContent\\"]), 14 | _createElementVNode(\\"div\\", { innerHTML: html }, null, 8 /* PROPS */, [\\"innerHTML\\"]), 15 | _createElementVNode(\\"div\\", null, \\"test\\"), 16 | _createElementVNode(\\"div\\", { style: {\\"color\\":\\"red\\"} }, \\"red\\"), 17 | _createElementVNode(\\"div\\", { 18 | style: _normalizeStyle({color: 'green'}) 19 | }, null, 4 /* STYLE */) 20 | ], 64 /* STABLE_FRAGMENT */)) 21 | } 22 | }" 23 | `; 24 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-dom/__tests__/decoderHtmlBrowser.spec.ts: -------------------------------------------------------------------------------- 1 | import { decodeHtmlBrowser } from '../src/decodeHtmlBrowser' 2 | 3 | describe('decodeHtmlBrowser', () => { 4 | it('should decode HTML correctly', () => { 5 | expect(decodeHtmlBrowser(' abc 123 ')).toBe(' abc 123 ') 6 | 7 | expect(decodeHtmlBrowser('&')).toBe('&') 8 | expect(decodeHtmlBrowser('&')).toBe('&') 9 | expect(decodeHtmlBrowser('&amp;')).toBe('&') 10 | 11 | expect(decodeHtmlBrowser('<')).toBe('<') 12 | expect(decodeHtmlBrowser('<')).toBe('<') 13 | expect(decodeHtmlBrowser('&lt;')).toBe('<') 14 | 15 | expect(decodeHtmlBrowser('>')).toBe('>') 16 | expect(decodeHtmlBrowser('>')).toBe('>') 17 | expect(decodeHtmlBrowser('&gt;')).toBe('>') 18 | 19 | expect(decodeHtmlBrowser(' ')).toBe('\u00a0') 20 | expect(decodeHtmlBrowser('"')).toBe('"') 21 | expect(decodeHtmlBrowser(''')).toBe("'") 22 | 23 | expect(decodeHtmlBrowser('É')).toBe('\u00c9') 24 | expect(decodeHtmlBrowser('É')).toBe('\u00c9') 25 | expect(decodeHtmlBrowser('É')).toBe('\u00c9') 26 | 27 | // #3001 html tags inside attribute values 28 | expect(decodeHtmlBrowser('Text', true)).toBe( 29 | 'Text' 30 | ) 31 | expect(decodeHtmlBrowser('&', true)).toBe( 32 | '&' 33 | ) 34 | expect( 35 | decodeHtmlBrowser( 36 | '<strong>&</strong>', 37 | true 38 | ) 39 | ).toBe('&') 40 | }) 41 | }) 42 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-dom/__tests__/index.spec.ts: -------------------------------------------------------------------------------- 1 | import { compile } from '../src' 2 | 3 | describe('compile', () => { 4 | it('should contain standard transforms', () => { 5 | const { code } = compile(`
6 |
7 |
test
8 |
red
9 |
`) 10 | 11 | expect(code).toMatchSnapshot() 12 | }) 13 | }) 14 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-dom/__tests__/transforms/__snapshots__/vShow.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`compiler: v-show transform simple expression 1`] = ` 4 | "const _Vue = Vue 5 | 6 | return function render(_ctx, _cache) { 7 | with (_ctx) { 8 | const { vShow: _vShow, withDirectives: _withDirectives, openBlock: _openBlock, createElementBlock: _createElementBlock } = _Vue 9 | 10 | return _withDirectives((_openBlock(), _createElementBlock(\\"div\\", null, null, 512 /* NEED_PATCH */)), [ 11 | [_vShow, a] 12 | ]) 13 | } 14 | }" 15 | `; 16 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-dom/__tests__/transforms/__snapshots__/warnTransitionChildren.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`the v-if/else-if/else branchs in Transition should ignore comments 1`] = ` 4 | "const _Vue = Vue 5 | 6 | return function render(_ctx, _cache) { 7 | with (_ctx) { 8 | const { openBlock: _openBlock, createElementBlock: _createElementBlock, createCommentVNode: _createCommentVNode, createElementVNode: _createElementVNode, Fragment: _Fragment, Transition: _Transition, withCtx: _withCtx, createBlock: _createBlock } = _Vue 9 | 10 | return (_openBlock(), _createBlock(_Transition, null, { 11 | default: _withCtx(() => [ 12 | a 13 | ? (_openBlock(), _createElementBlock(\\"div\\", { key: 0 }, \\"hey\\")) 14 | : b 15 | ? (_openBlock(), _createElementBlock(\\"div\\", { key: 1 }, \\"hey\\")) 16 | : (_openBlock(), _createElementBlock(\\"div\\", { key: 2 }, [ 17 | c 18 | ? (_openBlock(), _createElementBlock(\\"p\\", { key: 0 })) 19 | : (_openBlock(), _createElementBlock(_Fragment, { key: 1 }, [ 20 | _createCommentVNode(\\" this should not be ignored \\"), 21 | _createElementVNode(\\"p\\") 22 | ], 2112 /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */)) 23 | ])) 24 | ]), 25 | _: 1 /* STABLE */ 26 | })) 27 | } 28 | }" 29 | `; 30 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-dom/__tests__/transforms/ignoreSideEffectTags.spec.ts: -------------------------------------------------------------------------------- 1 | import { compile, CompilerError } from '../../src' 2 | 3 | describe('compiler: ignore side effect tags', () => { 4 | it('should ignore script', () => { 5 | let err: CompilerError | undefined 6 | const { code } = compile(``, { 7 | onError(e) { 8 | err = e 9 | } 10 | }) 11 | expect(code).not.toMatch('script') 12 | expect(err).toBeDefined() 13 | expect(err!.message).toMatch(`Tags with side effect`) 14 | }) 15 | 16 | it('should ignore style', () => { 17 | let err: CompilerError | undefined 18 | const { code } = compile(``, { 19 | onError(e) { 20 | err = e 21 | } 22 | }) 23 | expect(code).not.toMatch('style') 24 | expect(err).toBeDefined() 25 | expect(err!.message).toMatch(`Tags with side effect`) 26 | }) 27 | }) 28 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-dom/__tests__/transforms/vShow.spec.ts: -------------------------------------------------------------------------------- 1 | import { 2 | baseParse as parse, 3 | transform, 4 | generate, 5 | CompilerOptions 6 | } from '@vue/compiler-core' 7 | import { transformElement } from '../../../compiler-core/src/transforms/transformElement' 8 | import { transformShow } from '../../src/transforms/vShow' 9 | import { DOMErrorCodes } from '../../src/errors' 10 | 11 | function transformWithShow(template: string, options: CompilerOptions = {}) { 12 | const ast = parse(template) 13 | transform(ast, { 14 | nodeTransforms: [transformElement], 15 | directiveTransforms: { 16 | show: transformShow 17 | }, 18 | ...options 19 | }) 20 | return ast 21 | } 22 | 23 | describe('compiler: v-show transform', () => { 24 | test('simple expression', () => { 25 | const ast = transformWithShow(`
`) 26 | 27 | expect(generate(ast).code).toMatchSnapshot() 28 | }) 29 | 30 | test('should raise error if has no expression', () => { 31 | const onError = jest.fn() 32 | transformWithShow(`
`, { onError }) 33 | 34 | expect(onError).toHaveBeenCalledTimes(1) 35 | expect(onError).toHaveBeenCalledWith( 36 | expect.objectContaining({ 37 | code: DOMErrorCodes.X_V_SHOW_NO_EXPRESSION 38 | }) 39 | ) 40 | }) 41 | }) 42 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-dom/api-extractor.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../api-extractor.json", 3 | "mainEntryPointFilePath": "./dist/packages//src/index.d.ts", 4 | "dtsRollup": { 5 | "publicTrimmedFilePath": "./dist/.d.ts" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-dom/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | if (process.env.NODE_ENV === 'production') { 4 | module.exports = require('./dist/compiler-dom.cjs.prod.js') 5 | } else { 6 | module.exports = require('./dist/compiler-dom.cjs.js') 7 | } 8 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-dom/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@vue/compiler-dom", 3 | "version": "3.2.4", 4 | "description": "@vue/compiler-dom", 5 | "main": "index.js", 6 | "module": "dist/compiler-dom.esm-bundler.js", 7 | "types": "dist/compiler-dom.d.ts", 8 | "unpkg": "dist/compiler-dom.global.js", 9 | "jsdelivr": "dist/compiler-dom.global.js", 10 | "files": [ 11 | "index.js", 12 | "dist" 13 | ], 14 | "sideEffects": false, 15 | "buildOptions": { 16 | "name": "VueCompilerDOM", 17 | "compat": true, 18 | "formats": [ 19 | "esm-bundler", 20 | "esm-browser", 21 | "cjs", 22 | "global" 23 | ] 24 | }, 25 | "repository": { 26 | "type": "git", 27 | "url": "git+https://github.com/vuejs/vue-next.git", 28 | "directory": "packages/compiler-dom" 29 | }, 30 | "keywords": [ 31 | "vue" 32 | ], 33 | "author": "Evan You", 34 | "license": "MIT", 35 | "bugs": { 36 | "url": "https://github.com/vuejs/vue-next/issues" 37 | }, 38 | "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/compiler-dom#readme", 39 | "dependencies": { 40 | "@vue/shared": "3.2.4", 41 | "@vue/compiler-core": "3.2.4" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-dom/src/decodeHtmlBrowser.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-restricted-globals */ 2 | 3 | let decoder: HTMLDivElement 4 | 5 | export function decodeHtmlBrowser(raw: string, asAttr = false): string { 6 | if (!decoder) { 7 | decoder = document.createElement('div') 8 | } 9 | if (asAttr) { 10 | decoder.innerHTML = `
` 11 | return decoder.children[0].getAttribute('foo') as string 12 | } else { 13 | decoder.innerHTML = raw 14 | return decoder.textContent as string 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-dom/src/runtimeHelpers.ts: -------------------------------------------------------------------------------- 1 | import { registerRuntimeHelpers } from '@vue/compiler-core' 2 | 3 | export const V_MODEL_RADIO = Symbol(__DEV__ ? `vModelRadio` : ``) 4 | export const V_MODEL_CHECKBOX = Symbol(__DEV__ ? `vModelCheckbox` : ``) 5 | export const V_MODEL_TEXT = Symbol(__DEV__ ? `vModelText` : ``) 6 | export const V_MODEL_SELECT = Symbol(__DEV__ ? `vModelSelect` : ``) 7 | export const V_MODEL_DYNAMIC = Symbol(__DEV__ ? `vModelDynamic` : ``) 8 | 9 | export const V_ON_WITH_MODIFIERS = Symbol(__DEV__ ? `vOnModifiersGuard` : ``) 10 | export const V_ON_WITH_KEYS = Symbol(__DEV__ ? `vOnKeysGuard` : ``) 11 | 12 | export const V_SHOW = Symbol(__DEV__ ? `vShow` : ``) 13 | 14 | export const TRANSITION = Symbol(__DEV__ ? `Transition` : ``) 15 | export const TRANSITION_GROUP = Symbol(__DEV__ ? `TransitionGroup` : ``) 16 | 17 | registerRuntimeHelpers({ 18 | [V_MODEL_RADIO]: `vModelRadio`, 19 | [V_MODEL_CHECKBOX]: `vModelCheckbox`, 20 | [V_MODEL_TEXT]: `vModelText`, 21 | [V_MODEL_SELECT]: `vModelSelect`, 22 | [V_MODEL_DYNAMIC]: `vModelDynamic`, 23 | [V_ON_WITH_MODIFIERS]: `withModifiers`, 24 | [V_ON_WITH_KEYS]: `withKeys`, 25 | [V_SHOW]: `vShow`, 26 | [TRANSITION]: `Transition`, 27 | [TRANSITION_GROUP]: `TransitionGroup` 28 | }) 29 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-dom/src/transforms/ignoreSideEffectTags.ts: -------------------------------------------------------------------------------- 1 | import { NodeTransform, NodeTypes, ElementTypes } from '@vue/compiler-core' 2 | import { DOMErrorCodes, createDOMCompilerError } from '../errors' 3 | 4 | export const ignoreSideEffectTags: NodeTransform = (node, context) => { 5 | if ( 6 | node.type === NodeTypes.ELEMENT && 7 | node.tagType === ElementTypes.ELEMENT && 8 | (node.tag === 'script' || node.tag === 'style') 9 | ) { 10 | context.onError( 11 | createDOMCompilerError(DOMErrorCodes.X_IGNORED_SIDE_EFFECT_TAG, node.loc) 12 | ) 13 | context.removeNode() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-dom/src/transforms/transformStyle.ts: -------------------------------------------------------------------------------- 1 | import { 2 | NodeTransform, 3 | NodeTypes, 4 | createSimpleExpression, 5 | SimpleExpressionNode, 6 | SourceLocation, 7 | ConstantTypes 8 | } from '@vue/compiler-core' 9 | import { parseStringStyle } from '@vue/shared' 10 | 11 | // Parse inline CSS strings for static style attributes into an object. 12 | // This is a NodeTransform since it works on the static `style` attribute and 13 | // converts it into a dynamic equivalent: 14 | // style="color: red" -> :style='{ "color": "red" }' 15 | // It is then processed by `transformElement` and included in the generated 16 | // props. 17 | export const transformStyle: NodeTransform = node => { 18 | if (node.type === NodeTypes.ELEMENT) { 19 | node.props.forEach((p, i) => { 20 | if (p.type === NodeTypes.ATTRIBUTE && p.name === 'style' && p.value) { 21 | // replace p with an expression node 22 | node.props[i] = { 23 | type: NodeTypes.DIRECTIVE, 24 | name: `bind`, 25 | arg: createSimpleExpression(`style`, true, p.loc), 26 | exp: parseInlineCSS(p.value.content, p.loc), 27 | modifiers: [], 28 | loc: p.loc 29 | } 30 | } 31 | }) 32 | } 33 | } 34 | 35 | const parseInlineCSS = ( 36 | cssText: string, 37 | loc: SourceLocation 38 | ): SimpleExpressionNode => { 39 | const normalized = parseStringStyle(cssText) 40 | return createSimpleExpression( 41 | JSON.stringify(normalized), 42 | false, 43 | loc, 44 | ConstantTypes.CAN_STRINGIFY 45 | ) 46 | } 47 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-dom/src/transforms/vHtml.ts: -------------------------------------------------------------------------------- 1 | import { 2 | DirectiveTransform, 3 | createObjectProperty, 4 | createSimpleExpression 5 | } from '@vue/compiler-core' 6 | import { createDOMCompilerError, DOMErrorCodes } from '../errors' 7 | 8 | export const transformVHtml: DirectiveTransform = (dir, node, context) => { 9 | const { exp, loc } = dir 10 | if (!exp) { 11 | context.onError( 12 | createDOMCompilerError(DOMErrorCodes.X_V_HTML_NO_EXPRESSION, loc) 13 | ) 14 | } 15 | if (node.children.length) { 16 | context.onError( 17 | createDOMCompilerError(DOMErrorCodes.X_V_HTML_WITH_CHILDREN, loc) 18 | ) 19 | node.children.length = 0 20 | } 21 | return { 22 | props: [ 23 | createObjectProperty( 24 | createSimpleExpression(`innerHTML`, true, loc), 25 | exp || createSimpleExpression('', true) 26 | ) 27 | ] 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-dom/src/transforms/vShow.ts: -------------------------------------------------------------------------------- 1 | import { DirectiveTransform } from '@vue/compiler-core' 2 | import { createDOMCompilerError, DOMErrorCodes } from '../errors' 3 | import { V_SHOW } from '../runtimeHelpers' 4 | 5 | export const transformShow: DirectiveTransform = (dir, node, context) => { 6 | const { exp, loc } = dir 7 | if (!exp) { 8 | context.onError( 9 | createDOMCompilerError(DOMErrorCodes.X_V_SHOW_NO_EXPRESSION, loc) 10 | ) 11 | } 12 | 13 | return { 14 | props: [], 15 | needRuntime: context.helper(V_SHOW) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-dom/src/transforms/vText.ts: -------------------------------------------------------------------------------- 1 | import { 2 | DirectiveTransform, 3 | createObjectProperty, 4 | createSimpleExpression, 5 | TO_DISPLAY_STRING, 6 | createCallExpression 7 | } from '@vue/compiler-core' 8 | import { createDOMCompilerError, DOMErrorCodes } from '../errors' 9 | 10 | export const transformVText: DirectiveTransform = (dir, node, context) => { 11 | const { exp, loc } = dir 12 | if (!exp) { 13 | context.onError( 14 | createDOMCompilerError(DOMErrorCodes.X_V_TEXT_NO_EXPRESSION, loc) 15 | ) 16 | } 17 | if (node.children.length) { 18 | context.onError( 19 | createDOMCompilerError(DOMErrorCodes.X_V_TEXT_WITH_CHILDREN, loc) 20 | ) 21 | node.children.length = 0 22 | } 23 | return { 24 | props: [ 25 | createObjectProperty( 26 | createSimpleExpression(`textContent`, true), 27 | exp 28 | ? createCallExpression( 29 | context.helperString(TO_DISPLAY_STRING), 30 | [exp], 31 | loc 32 | ) 33 | : createSimpleExpression('', true) 34 | ) 35 | ] 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-dom/src/transforms/warnTransitionChildren.ts: -------------------------------------------------------------------------------- 1 | import { 2 | NodeTransform, 3 | NodeTypes, 4 | ElementTypes, 5 | ComponentNode, 6 | IfBranchNode 7 | } from '@vue/compiler-core' 8 | import { TRANSITION } from '../runtimeHelpers' 9 | import { createDOMCompilerError, DOMErrorCodes } from '../errors' 10 | 11 | export const warnTransitionChildren: NodeTransform = (node, context) => { 12 | if ( 13 | node.type === NodeTypes.ELEMENT && 14 | node.tagType === ElementTypes.COMPONENT 15 | ) { 16 | const component = context.isBuiltInComponent(node.tag) 17 | if (component === TRANSITION) { 18 | return () => { 19 | if (node.children.length && hasMultipleChildren(node)) { 20 | context.onError( 21 | createDOMCompilerError( 22 | DOMErrorCodes.X_TRANSITION_INVALID_CHILDREN, 23 | { 24 | start: node.children[0].loc.start, 25 | end: node.children[node.children.length - 1].loc.end, 26 | source: '' 27 | } 28 | ) 29 | ) 30 | } 31 | } 32 | } 33 | } 34 | } 35 | 36 | function hasMultipleChildren(node: ComponentNode | IfBranchNode): boolean { 37 | // #1352 filter out potential comment nodes. 38 | const children = (node.children = node.children.filter( 39 | c => c.type !== NodeTypes.COMMENT 40 | )) 41 | const child = children[0] 42 | return ( 43 | children.length !== 1 || 44 | child.type === NodeTypes.FOR || 45 | (child.type === NodeTypes.IF && child.branches.some(hasMultipleChildren)) 46 | ) 47 | } 48 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-sfc/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018-present, Yuxi (Evan) You 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vue-next/packages/compiler-sfc/__tests__/__snapshots__/compileTemplate.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`source map 1`] = ` 4 | Object { 5 | "mappings": ";;;wBACE,oBAA8B;IAAzB,oBAAmB,4BAAbA,WAAM", 6 | "names": Array [ 7 | "render", 8 | ], 9 | "sources": Array [ 10 | "example.vue", 11 | ], 12 | "sourcesContent": Array [ 13 | " 14 |

{{ render }}

15 | ", 16 | ], 17 | "version": 3, 18 | } 19 | `; 20 | 21 | exports[`template errors 1`] = ` 22 | Array [ 23 | [SyntaxError: Error parsing JavaScript expression: Unexpected token (1:3)], 24 | [SyntaxError: v-bind is missing expression.], 25 | [SyntaxError: v-model can only be used on , 7 |
8 |
9 | 10 | 27 | 28 | 63 | -------------------------------------------------------------------------------- /vue-next/packages/vue/examples/composition/markdown.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 |
8 |
9 | 10 | 27 | 28 | 63 | -------------------------------------------------------------------------------- /vue-next/packages/vue/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | if (process.env.NODE_ENV === 'production') { 4 | module.exports = require('./dist/vue.cjs.prod.js') 5 | } else { 6 | module.exports = require('./dist/vue.cjs.js') 7 | } 8 | -------------------------------------------------------------------------------- /vue-next/packages/vue/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue", 3 | "version": "3.2.4", 4 | "description": "The progressive JavaScript framework for buiding modern web UI.", 5 | "main": "index.js", 6 | "module": "dist/vue.runtime.esm-bundler.js", 7 | "types": "dist/vue.d.ts", 8 | "unpkg": "dist/vue.global.js", 9 | "jsdelivr": "dist/vue.global.js", 10 | "files": [ 11 | "index.js", 12 | "dist" 13 | ], 14 | "buildOptions": { 15 | "name": "Vue", 16 | "formats": [ 17 | "esm-bundler", 18 | "esm-bundler-runtime", 19 | "cjs", 20 | "global", 21 | "global-runtime", 22 | "esm-browser", 23 | "esm-browser-runtime" 24 | ] 25 | }, 26 | "repository": { 27 | "type": "git", 28 | "url": "git+https://github.com/vuejs/vue-next.git" 29 | }, 30 | "keywords": [ 31 | "vue" 32 | ], 33 | "author": "Evan You", 34 | "license": "MIT", 35 | "bugs": { 36 | "url": "https://github.com/vuejs/vue-next/issues" 37 | }, 38 | "homepage": "https://github.com/vuejs/vue-next/tree/master/packages/vue#readme", 39 | "dependencies": { 40 | "@vue/shared": "3.2.4", 41 | "@vue/compiler-dom": "3.2.4", 42 | "@vue/runtime-dom": "3.2.4" 43 | }, 44 | "devDependencies": { 45 | "lodash": "^4.17.15", 46 | "marked": "^0.7.0", 47 | "todomvc-app-css": "^2.3.0" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /vue-next/packages/vue/src/dev.ts: -------------------------------------------------------------------------------- 1 | import { initCustomFormatter } from '@vue/runtime-dom' 2 | 3 | export function initDev() { 4 | if (__BROWSER__) { 5 | if (!__ESM_BUNDLER__) { 6 | console.info( 7 | `You are running a development build of Vue.\n` + 8 | `Make sure to use the production build (*.prod.js) when deploying for production.` 9 | ) 10 | } 11 | 12 | initCustomFormatter() 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /vue-next/packages/vue/src/runtime.ts: -------------------------------------------------------------------------------- 1 | // This entry exports the runtime only, and is built as 2 | // `dist/vue.esm-bundler.js` which is used by default for bundlers. 3 | import { initDev } from './dev' 4 | import { warn } from '@vue/runtime-dom' 5 | 6 | if (__DEV__) { 7 | initDev() 8 | } 9 | 10 | export * from '@vue/runtime-dom' 11 | 12 | export const compile = () => { 13 | if (__DEV__) { 14 | warn( 15 | `Runtime compilation is not supported in this build of Vue.` + 16 | (__ESM_BUNDLER__ 17 | ? ` Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js".` 18 | : __ESM_BROWSER__ 19 | ? ` Use "vue.esm-browser.js" instead.` 20 | : __GLOBAL__ 21 | ? ` Use "vue.global.js" instead.` 22 | : ``) /* should not happen */ 23 | ) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /vue-next/scripts/checkYarn.js: -------------------------------------------------------------------------------- 1 | if (!/yarn\.js$/.test(process.env.npm_execpath || '')) { 2 | console.warn( 3 | '\u001b[33mThis repository requires Yarn 1.x for scripts to work properly.\u001b[39m\n' 4 | ) 5 | process.exit(1) 6 | } 7 | -------------------------------------------------------------------------------- /vue-next/scripts/dev.js: -------------------------------------------------------------------------------- 1 | /* 2 | Run Rollup in watch mode for development. 3 | 4 | To specific the package to watch, simply pass its name and the desired build 5 | formats to watch (defaults to "global"): 6 | 7 | ``` 8 | # name supports fuzzy match. will watch all packages with name containing "dom" 9 | yarn dev dom 10 | 11 | # specify the format to output 12 | yarn dev core --formats cjs 13 | 14 | # Can also drop all __DEV__ blocks with: 15 | __DEV__=false yarn dev 16 | ``` 17 | */ 18 | 19 | const execa = require('execa') 20 | const { fuzzyMatchTarget } = require('./utils') 21 | const args = require('minimist')(process.argv.slice(2)) 22 | const target = args._.length ? fuzzyMatchTarget(args._)[0] : 'vue' 23 | const formats = args.formats || args.f 24 | const sourceMap = args.sourcemap || args.s 25 | const commit = execa.sync('git', ['rev-parse', 'HEAD']).stdout.slice(0, 7) 26 | 27 | execa( 28 | 'rollup', 29 | [ 30 | '-wc', 31 | '--environment', 32 | [ 33 | `COMMIT:${commit}`, 34 | `TARGET:${target}`, 35 | `FORMATS:${formats || 'global'}`, 36 | sourceMap ? `SOURCE_MAP:true` : `` 37 | ] 38 | .filter(Boolean) 39 | .join(',') 40 | ], 41 | { 42 | stdio: 'inherit' 43 | } 44 | ) 45 | -------------------------------------------------------------------------------- /vue-next/scripts/utils.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | const chalk = require('chalk') 3 | 4 | const targets = (exports.targets = fs.readdirSync('packages').filter(f => { 5 | if (!fs.statSync(`packages/${f}`).isDirectory()) { 6 | return false 7 | } 8 | const pkg = require(`../packages/${f}/package.json`) 9 | if (pkg.private && !pkg.buildOptions) { 10 | return false 11 | } 12 | return true 13 | })) 14 | 15 | exports.fuzzyMatchTarget = (partialTargets, includeAllMatching) => { 16 | const matched = [] 17 | partialTargets.forEach(partialTarget => { 18 | for (const target of targets) { 19 | if (target.match(partialTarget)) { 20 | matched.push(target) 21 | if (!includeAllMatching) { 22 | break 23 | } 24 | } 25 | } 26 | }) 27 | if (matched.length) { 28 | return matched 29 | } else { 30 | console.log() 31 | console.error( 32 | ` ${chalk.bgRed.white(' ERROR ')} ${chalk.red( 33 | `Target ${chalk.underline(partialTargets)} not found!` 34 | )}` 35 | ) 36 | console.log() 37 | 38 | process.exit(1) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /vue-next/scripts/verifyCommit.js: -------------------------------------------------------------------------------- 1 | // Invoked on the commit-msg git hook by yorkie. 2 | 3 | const chalk = require('chalk') 4 | const msgPath = process.env.GIT_PARAMS 5 | const msg = require('fs') 6 | .readFileSync(msgPath, 'utf-8') 7 | .trim() 8 | 9 | const commitRE = /^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(\(.+\))?: .{1,50}/ 10 | 11 | if (!commitRE.test(msg)) { 12 | console.log() 13 | console.error( 14 | ` ${chalk.bgRed.white(' ERROR ')} ${chalk.red( 15 | `invalid commit message format.` 16 | )}\n\n` + 17 | chalk.red( 18 | ` Proper commit message format is required for automated changelog generation. Examples:\n\n` 19 | ) + 20 | ` ${chalk.green(`feat(compiler): add 'comments' option`)}\n` + 21 | ` ${chalk.green( 22 | `fix(v-model): handle events on blur (close #28)` 23 | )}\n\n` + 24 | chalk.red(` See .github/commit-convention.md for more details.\n`) 25 | ) 26 | process.exit(1) 27 | } 28 | -------------------------------------------------------------------------------- /vue-next/test-dts/README.md: -------------------------------------------------------------------------------- 1 | # Test-ts 2 | 3 | Tests Typescript types to ensure the types remain as expected. 4 | 5 | ## Configuration 6 | 7 | ### tsconfig.json 8 | 9 | Config used to test against the package source 10 | 11 | ### tsconfig.build.json 12 | 13 | Replaces the `vue` and `@vue/*` dependencies with the built Typescript to ensure the published types are correct. 14 | -------------------------------------------------------------------------------- /vue-next/test-dts/componentTypeExtensions.test-d.tsx: -------------------------------------------------------------------------------- 1 | import { defineComponent, expectError, expectType } from './index' 2 | 3 | declare module '@vue/runtime-core' { 4 | interface ComponentCustomOptions { 5 | test?(n: number): void 6 | } 7 | 8 | interface ComponentCustomProperties { 9 | state: 'stopped' | 'running' 10 | } 11 | 12 | interface ComponentCustomProps { 13 | custom?: number 14 | } 15 | } 16 | 17 | export const Custom = defineComponent({ 18 | props: { 19 | bar: String, 20 | baz: { 21 | type: Number, 22 | required: true 23 | } 24 | }, 25 | 26 | data: () => ({ counter: 0 }), 27 | 28 | test(n) { 29 | expectType(n) 30 | }, 31 | 32 | methods: { 33 | aMethod() { 34 | // @ts-expect-error 35 | expectError(this.notExisting) 36 | this.counter++ 37 | this.state = 'running' 38 | // @ts-expect-error 39 | expectError((this.state = 'not valid')) 40 | } 41 | } 42 | }) 43 | 44 | expectType() 45 | expectType() 46 | expectType() 47 | 48 | // @ts-expect-error 49 | expectType() 50 | // @ts-expect-error 51 | expectError() 52 | // @ts-expect-error 53 | expectError() 54 | // @ts-expect-error 55 | expectError() 56 | // @ts-expect-error 57 | expectError() 58 | -------------------------------------------------------------------------------- /vue-next/test-dts/index.d.ts: -------------------------------------------------------------------------------- 1 | // This directory contains a number of d.ts assertions 2 | // use \@ts-expect-error where errors are expected. 3 | 4 | export * from '@vue/runtime-dom' 5 | 6 | export function describe(_name: string, _fn: () => void): void 7 | 8 | export function expectType(value: T): void 9 | export function expectError(value: T): void 10 | export function expectAssignable(value: T2): void 11 | 12 | export type IsUnion = (T extends any 13 | ? (U extends T ? false : true) 14 | : never) extends false 15 | ? false 16 | : true 17 | -------------------------------------------------------------------------------- /vue-next/test-dts/inject.test-d.ts: -------------------------------------------------------------------------------- 1 | import { provide, inject, InjectionKey, expectType } from './index' 2 | 3 | const key: InjectionKey = Symbol() 4 | 5 | provide(key, 1) 6 | // @ts-expect-error 7 | provide(key, 'foo') 8 | 9 | expectType(inject(key)) 10 | expectType(inject(key, 1)) 11 | expectType(inject(key, () => 1, true /* treatDefaultAsFactory */)) 12 | 13 | expectType<() => number>(inject('foo', () => 1)) 14 | expectType<() => number>(inject('foo', () => 1, false)) 15 | expectType(inject('foo', () => 1, true)) 16 | -------------------------------------------------------------------------------- /vue-next/test-dts/reactivity.test-d.ts: -------------------------------------------------------------------------------- 1 | import { ref, readonly, describe, expectError, expectType, Ref } from './index' 2 | 3 | describe('should support DeepReadonly', () => { 4 | const r = readonly({ obj: { k: 'v' } }) 5 | // @ts-expect-error 6 | expectError((r.obj = {})) 7 | // @ts-expect-error 8 | expectError((r.obj.k = 'x')) 9 | }) 10 | 11 | // #4180 12 | describe('readonly ref', () => { 13 | const r = readonly(ref({ count: 1 })) 14 | expectType(r) 15 | }) 16 | -------------------------------------------------------------------------------- /vue-next/test-dts/refSugar.test-d.ts: -------------------------------------------------------------------------------- 1 | import { 2 | expectType, 3 | $ref, 4 | $shallowRef, 5 | $computed, 6 | $fromRefs, 7 | $raw, 8 | ref, 9 | Ref, 10 | ComputedRef 11 | } from './index' 12 | 13 | // $ref 14 | expectType($ref(1)) 15 | expectType($ref(ref(1))) 16 | expectType<{ foo: number }>($ref({ foo: ref(1) })) 17 | 18 | // $shallowRef 19 | expectType($shallowRef(1)) 20 | expectType<{ foo: Ref }>($shallowRef({ foo: ref(1) })) 21 | 22 | // $computed 23 | expectType($computed(() => 1)) 24 | let b = $ref(1) 25 | expectType($computed(() => b)) 26 | 27 | function useFoo() { 28 | return { 29 | x: ref(1), 30 | y: ref('hi'), 31 | z: 123 32 | } 33 | } 34 | 35 | // $fromRefs 36 | const { x, y, z } = $fromRefs(useFoo()) 37 | expectType(x) 38 | expectType(y) 39 | expectType(z) 40 | 41 | // $raw 42 | expectType>($raw(x)) 43 | expectType>($raw(y)) 44 | 45 | const c = $computed(() => 1) 46 | const cRef = $raw(c) 47 | expectType>(cRef) 48 | -------------------------------------------------------------------------------- /vue-next/test-dts/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "noEmit": false, 5 | "paths": { 6 | "@vue/*": ["../packages/*/dist"], 7 | "vue": ["../packages/vue/dist"] 8 | } 9 | }, 10 | "exclude": [ 11 | "../packages/*/__tests__", 12 | "../packages/*/src", 13 | "../packages/template-explorer" 14 | ], 15 | "include": [ 16 | "../packages/global.d.ts", 17 | "../packages/*/dist", 18 | "../packages/runtime-dom/types/jsx.d.ts", 19 | "../packages/*/__tests__", 20 | "../test-dts" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /vue-next/test-dts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "noEmit": true, 5 | "declaration": true 6 | }, 7 | "exclude": ["../packages/*/__tests__", "../packages/template-explorer"] 8 | } 9 | -------------------------------------------------------------------------------- /vue-next/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "outDir": "dist", 5 | "sourceMap": false, 6 | "target": "es2016", 7 | "useDefineForClassFields": false, 8 | "module": "esnext", 9 | "moduleResolution": "node", 10 | "allowJs": false, 11 | "strict": true, 12 | "noUnusedLocals": true, 13 | "experimentalDecorators": true, 14 | "resolveJsonModule": true, 15 | "esModuleInterop": true, 16 | "removeComments": false, 17 | "jsx": "preserve", 18 | "lib": ["esnext", "dom"], 19 | "types": ["jest", "puppeteer", "node"], 20 | "rootDir": ".", 21 | "paths": { 22 | "@vue/compat": ["packages/vue-compat/src"], 23 | "@vue/*": ["packages/*/src"], 24 | "vue": ["packages/vue/src"] 25 | } 26 | }, 27 | "include": [ 28 | "packages/global.d.ts", 29 | "packages/*/src", 30 | "packages/runtime-dom/types/jsx.d.ts", 31 | "packages/*/__tests__", 32 | "test-dts" 33 | ] 34 | } 35 | --------------------------------------------------------------------------------