From 5dc374a8613d397fac09b757034ff271c1b7420f Mon Sep 17 00:00:00 2001 From: Evan You Date: Sun, 2 Feb 2020 00:06:49 -0500 Subject: [PATCH] chore: remove stale file --- packages/compiler-ssr/src/codegen.ts | 94 ---------------------------- 1 file changed, 94 deletions(-) delete mode 100644 packages/compiler-ssr/src/codegen.ts diff --git a/packages/compiler-ssr/src/codegen.ts b/packages/compiler-ssr/src/codegen.ts deleted file mode 100644 index 27d599da..00000000 --- a/packages/compiler-ssr/src/codegen.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { - CodegenResult, - RootNode, - generate as baseGenerate, - CodegenOptions, - NodeTypes, - locStub, - BlockStatement, - ElementTypes, - createCallExpression, - TemplateLiteral, - createTemplateLiteral, - CallExpression, - TemplateChildNode -} from '@vue/compiler-dom' -import { isString } from '@vue/shared' - -export function generate( - ast: RootNode, - options: CodegenOptions -): CodegenResult { - // construct a SSR-specific codegen tree to pass to core codegen - const body: BlockStatement['body'] = [] - let currentCall: CallExpression | null = null - let currentString: TemplateLiteral | null = null - - function ensureCurrentString() { - if (!currentCall) { - currentCall = createCallExpression(`_push`) - body.push(currentCall) - } - if (!currentString) { - currentString = createTemplateLiteral([]) - currentCall.arguments.push(currentString) - } - return currentString.elements - } - - function pushStringPart(part: TemplateLiteral['elements'][0]) { - const bufferedElements = ensureCurrentString() - const lastItem = bufferedElements[bufferedElements.length - 1] - if (isString(part) && isString(lastItem)) { - bufferedElements[bufferedElements.length - 1] += part - } else { - bufferedElements.push(part) - } - } - - function processChildren(children: TemplateChildNode[]) { - for (let i = 0; i < children.length; i++) { - const child = children[i] - if (child.type === NodeTypes.ELEMENT) { - if (child.tagType === ElementTypes.ELEMENT) { - const elementsToAdd = child.ssrCodegenNode!.elements - for (let j = 0; j < elementsToAdd.length; j++) { - pushStringPart(elementsToAdd[j]) - } - if (child.children.length) { - processChildren(child.children) - } - // push closing tag - pushStringPart(``) - } else if (child.tagType === ElementTypes.COMPONENT) { - // TODO - } else if (child.tagType === ElementTypes.SLOT) { - // TODO - } - } else if (child.type === NodeTypes.TEXT) { - // TODO - } else if (child.type === NodeTypes.IF) { - // TODO - } else if (child.type === NodeTypes.FOR) { - // TODO - } - } - } - - const isFragment = ast.children.length > 1 - if (isFragment) { - pushStringPart(``) - } - processChildren(ast.children) - if (isFragment) { - pushStringPart(``) - } - - ast.codegenNode = { - type: NodeTypes.JS_BLOCK_STATEMENT, - loc: locStub, - body - } - - return baseGenerate(ast, options) -}