From 4e43deb42a6ea59532eaeec16b2838d72ea7d533 Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Fri, 12 May 2023 17:36:51 +0200 Subject: [PATCH] Convert src/compiler/compile/nodes/AwaitBlock.ts to JavaScript --- src/compiler/compile/nodes/Attribute.js | 8 +- src/compiler/compile/nodes/AwaitBlock.ts | 140 +++++++++++++---------- 2 files changed, 83 insertions(+), 65 deletions(-) diff --git a/src/compiler/compile/nodes/Attribute.js b/src/compiler/compile/nodes/Attribute.js index 02be0c10bf..f02a82e19a 100644 --- a/src/compiler/compile/nodes/Attribute.js +++ b/src/compiler/compile/nodes/Attribute.js @@ -46,10 +46,10 @@ export default class Attribute extends Node { dependencies; /** - * @param {import('../Component.js').default} component * - * @param {import('./shared/Node.js').default} parent * - * @param {import('./shared/TemplateScope.js').default} scope * - * @param {import('../../interfaces.js').TemplateNode} info undefined + * @param {import('../Component.js').default} component + * @param {import('./shared/Node.js').default} parent + * @param {import('./shared/TemplateScope.js').default} scope + * @param {import('../../interfaces.js').TemplateNode} info */ constructor(component, parent, scope, info) { super(component, parent, scope, info); diff --git a/src/compiler/compile/nodes/AwaitBlock.ts b/src/compiler/compile/nodes/AwaitBlock.ts index 00c47e852a..9f6b5054e0 100644 --- a/src/compiler/compile/nodes/AwaitBlock.ts +++ b/src/compiler/compile/nodes/AwaitBlock.ts @@ -1,64 +1,82 @@ -import Node from './shared/Node'; -import PendingBlock from './PendingBlock'; -import ThenBlock from './ThenBlock'; -import CatchBlock from './CatchBlock'; -import Expression from './shared/Expression'; -import Component from '../Component'; -import TemplateScope from './shared/TemplateScope'; -import { TemplateNode } from '../../interfaces'; -import { Context, unpack_destructuring } from './shared/Context'; -import { Node as ESTreeNode } from 'estree'; +import Node from './shared/Node.js'; +import PendingBlock from './PendingBlock.js'; +import ThenBlock from './ThenBlock.js'; +import CatchBlock from './CatchBlock.js'; +import Expression from './shared/Expression.js'; +import { unpack_destructuring } from './shared/Context.js'; +/** @extends Node */ export default class AwaitBlock extends Node { - type: 'AwaitBlock'; - expression: Expression; - - then_contexts: Context[]; - catch_contexts: Context[]; - - then_node: ESTreeNode | null; - catch_node: ESTreeNode | null; - - pending: PendingBlock; - then: ThenBlock; - catch: CatchBlock; - - context_rest_properties: Map = new Map(); - - constructor(component: Component, parent: Node, scope: TemplateScope, info: TemplateNode) { - super(component, parent, scope, info); - this.cannot_use_innerhtml(); - this.not_static_content(); - - this.expression = new Expression(component, this, scope, info.expression); - - this.then_node = info.value; - this.catch_node = info.error; - - if (this.then_node) { - this.then_contexts = []; - unpack_destructuring({ - contexts: this.then_contexts, - node: info.value, - scope, - component, - context_rest_properties: this.context_rest_properties - }); - } - - if (this.catch_node) { - this.catch_contexts = []; - unpack_destructuring({ - contexts: this.catch_contexts, - node: info.error, - scope, - component, - context_rest_properties: this.context_rest_properties - }); - } - - this.pending = new PendingBlock(component, this, scope, info.pending); - this.then = new ThenBlock(component, this, scope, info.then); - this.catch = new CatchBlock(component, this, scope, info.catch); - } + + /** @type {'AwaitBlock'} */ + type; + + /** @type {import('./shared/Expression.js').default} */ + expression; + + /** @type {import('./shared/Context.js').Context[]} */ + then_contexts; + + /** @type {import('./shared/Context.js').Context[]} */ + catch_contexts; + + /** @type {ESTreeNode | null} */ + then_node; + + /** @type {ESTreeNode | null} */ + catch_node; + + /** @type {import('./PendingBlock.js').default} */ + pending; + + /** @type {import('./ThenBlock.js').default} */ + then; + + /** @type {import('./CatchBlock.js').default} */ + catch; + + /** @type {Map} */ + context_rest_properties = new Map(); + + /** + * @param {import('../Component.js').default} component * + * @param {import('./shared/Node.js').default} parent * + * @param {import('./shared/TemplateScope.js').default} scope * + * @param {import('../../interfaces.js').TemplateNode} info undefined + */ + constructor(component, parent, scope, info) { + super(component, parent, scope, info); + this.cannot_use_innerhtml(); + this.not_static_content(); + this.expression = new Expression(component, this, scope, info.expression); + this.then_node = info.value; + this.catch_node = info.error; + if (this.then_node) { + this.then_contexts = []; + unpack_destructuring({ + contexts: this.then_contexts, + node: info.value, + scope, + component, + context_rest_properties: this.context_rest_properties + }); + } + if (this.catch_node) { + this.catch_contexts = []; + unpack_destructuring({ + contexts: this.catch_contexts, + node: info.error, + scope, + component, + context_rest_properties: this.context_rest_properties + }); + } + this.pending = new PendingBlock(component, this, scope, info.pending); + this.then = new ThenBlock(component, this, scope, info.then); + this.catch = new CatchBlock(component, this, scope, info.catch); + } } + + + +