Convert src/compiler/compile/nodes/shared/Expression.ts to JavaScript

pull/8569/head
Simon Holthausen 3 years ago
parent f78ca010f6
commit 86884827ea

@ -1,170 +1,175 @@
import Component from '../../Component';
import { walk } from 'estree-walker'; import { walk } from 'estree-walker';
import is_reference from 'is-reference'; import is_reference from 'is-reference';
import flatten_reference from '../../utils/flatten_reference'; import flatten_reference from '../../utils/flatten_reference.js';
import { create_scopes, Scope, extract_names } from '../../utils/scope'; import { create_scopes, extract_names } from '../../utils/scope.js';
import { sanitize } from '../../../utils/names'; import { sanitize } from '../../../utils/names.js';
import TemplateScope from './TemplateScope'; import get_object from '../../utils/get_object.js';
import get_object from '../../utils/get_object'; import is_dynamic from '../../render_dom/wrappers/shared/is_dynamic.js';
import Block from '../../render_dom/Block';
import is_dynamic from '../../render_dom/wrappers/shared/is_dynamic';
import { b } from 'code-red'; import { b } from 'code-red';
import { invalidate } from '../../render_dom/invalidate'; import { invalidate } from '../../render_dom/invalidate.js';
import { Node, FunctionExpression, Identifier } from 'estree'; import { is_reserved_keyword } from '../../utils/reserved_keywords.js';
import { INode } from '../interfaces'; import replace_object from '../../utils/replace_object.js';
import { is_reserved_keyword } from '../../utils/reserved_keywords'; import is_contextual from './is_contextual.js';
import replace_object from '../../utils/replace_object'; import { clone } from '../../../utils/clone.js';
import is_contextual from './is_contextual'; import compiler_errors from '../../compiler_errors.js';
import EachBlock from '../EachBlock';
import { clone } from '../../../utils/clone';
import compiler_errors from '../../compiler_errors';
type Owner = INode;
const regex_contains_term_function_expression = /FunctionExpression/; const regex_contains_term_function_expression = /FunctionExpression/;
export default class Expression { export default class Expression {
type: 'Expression' = 'Expression' as const;
component: Component;
owner: Owner;
node: Node;
references: Set<string> = new Set();
dependencies: Set<string> = new Set();
contextual_dependencies: Set<string> = new Set();
template_scope: TemplateScope;
scope: Scope;
scope_map: WeakMap<Node, Scope>;
declarations: Array<Node | Node[]> = [];
uses_context = false;
manipulated: Node; /** @type {'Expression'} */
type = ('Expression');
/** @type {import('../../Component.js').default} */
component;
constructor( /** @type {Owner} */
component: Component, owner;
owner: Owner,
template_scope: TemplateScope, /** @type {import('estree').Node} */
info: Node, node;
lazy?: boolean
) { /** @type {Set<string>} */
references = new Set();
/** @type {Set<string>} */
dependencies = new Set();
/** @type {Set<string>} */
contextual_dependencies = new Set();
/** @type {import('./TemplateScope.js').default} */
template_scope;
/** @type {import('../../utils/scope.js').Scope} */
scope;
/** @type {WeakMap<import('estree').Node, import('../../utils/scope.js').Scope>} */
scope_map;
/** @type {Array<import('estree').Node | import('estree').Node[]>} */
declarations = [];
/** */
uses_context = false;
/** @type {import('estree').Node} */
manipulated;
/**
* @param {import('../../Component.js').default} component *
* @param {Owner} owner *
* @param {import('./TemplateScope.js').default} template_scope *
* @param {import('estree').Node} info *
* @param {boolean} [lazy] undefined
*/
constructor(component, owner, template_scope, info, lazy) {
// TODO revert to direct property access in prod? // TODO revert to direct property access in prod?
Object.defineProperties(this, { Object.defineProperties(this, {
component: { component: {
value: component value: component
} }
}); });
this.node = info; this.node = info;
this.template_scope = template_scope; this.template_scope = template_scope;
this.owner = owner; this.owner = owner;
const { dependencies, contextual_dependencies, references } = this; const { dependencies, contextual_dependencies, references } = this;
let { map, scope } = create_scopes(info); let { map, scope } = create_scopes(info);
this.scope = scope; this.scope = scope;
this.scope_map = map; this.scope_map = map;
const expression = this; const expression = this;
let function_expression; let function_expression;
// discover dependencies, but don't change the code yet // discover dependencies, but don't change the code yet
walk(info, { walk(info, {
enter(node: any, parent: any, key: string) {
/**
* @param {any} node
* @param {any} parent
* @param {string} key
*/
enter(node, parent, key) {
// don't manipulate shorthand props twice // don't manipulate shorthand props twice
if (key === 'key' && parent.shorthand) return; if (key === 'key' && parent.shorthand)
return;
// don't manipulate `import.meta`, `new.target` // don't manipulate `import.meta`, `new.target`
if (node.type === 'MetaProperty') return this.skip(); if (node.type === 'MetaProperty')
return this.skip();
if (map.has(node)) { if (map.has(node)) {
scope = map.get(node); scope = map.get(node);
} }
if (!function_expression && regex_contains_term_function_expression.test(node.type)) { if (!function_expression && regex_contains_term_function_expression.test(node.type)) {
function_expression = node; function_expression = node;
} }
if (is_reference(node, parent)) { if (is_reference(node, parent)) {
const { name, nodes } = flatten_reference(node); const { name, nodes } = flatten_reference(node);
references.add(name); references.add(name);
if (scope.has(name))
if (scope.has(name)) return; return;
if (name[0] === '$') { if (name[0] === '$') {
const store_name = name.slice(1); const store_name = name.slice(1);
if (template_scope.names.has(store_name) || scope.has(store_name)) { if (template_scope.names.has(store_name) || scope.has(store_name)) {
return component.error(node, compiler_errors.contextual_store); return component.error(node, compiler_errors.contextual_store);
} }
} }
if (template_scope.is_let(name)) { if (template_scope.is_let(name)) {
if (!lazy) { if (!lazy) {
contextual_dependencies.add(name); contextual_dependencies.add(name);
dependencies.add(name); dependencies.add(name);
} }
} else if (template_scope.names.has(name)) { }
else if (template_scope.names.has(name)) {
expression.uses_context = true; expression.uses_context = true;
contextual_dependencies.add(name); contextual_dependencies.add(name);
const owner = template_scope.get_owner(name); const owner = template_scope.get_owner(name);
const is_index = owner.type === 'EachBlock' && owner.key && name === owner.index; const is_index = owner.type === 'EachBlock' && owner.key && name === owner.index;
if (!lazy || is_index) { if (!lazy || is_index) {
template_scope.dependencies_for_name template_scope.dependencies_for_name
.get(name) .get(name)
.forEach((name) => dependencies.add(name)); .forEach(/** @param {any} name */ (name) => dependencies.add(name));
}
} }
} else { else {
if (!lazy) { if (!lazy) {
dependencies.add(name); dependencies.add(name);
} }
component.add_reference(node, name); component.add_reference(node, name);
component.warn_if_undefined(name, nodes[0], template_scope); component.warn_if_undefined(name, nodes[0], template_scope);
} }
this.skip(); this.skip();
} }
// track any assignments from template expressions as mutable // track any assignments from template expressions as mutable
let names; let names;
let deep = false; let deep = false;
if (function_expression) { if (function_expression) {
if (node.type === 'AssignmentExpression') { if (node.type === 'AssignmentExpression') {
deep = node.left.type === 'MemberExpression'; deep = node.left.type === 'MemberExpression';
names = extract_names(deep ? get_object(node.left) : node.left); names = extract_names(deep ? get_object(node.left) : node.left);
} else if (node.type === 'UpdateExpression') { }
else if (node.type === 'UpdateExpression') {
deep = node.argument.type === 'MemberExpression'; deep = node.argument.type === 'MemberExpression';
names = extract_names(get_object(node.argument)); names = extract_names(get_object(node.argument));
} }
} }
if (names) { if (names) {
names.forEach((name) => { names.forEach(/** @param {any} name */ (name) => {
if (template_scope.names.has(name)) { if (template_scope.names.has(name)) {
if (template_scope.is_const(name)) { if (template_scope.is_const(name)) {
component.error(node, compiler_errors.invalid_const_update(name)); component.error(node, compiler_errors.invalid_const_update(name));
} }
template_scope.dependencies_for_name.get(name).forEach(/** @param {any} name */ (name) => {
template_scope.dependencies_for_name.get(name).forEach((name) => {
const variable = component.var_lookup.get(name); const variable = component.var_lookup.get(name);
if (variable) variable[deep ? 'mutated' : 'reassigned'] = true; if (variable)
variable[deep ? 'mutated' : 'reassigned'] = true;
}); });
const each_block = template_scope.get_owner(name); const each_block = template_scope.get_owner(name);
(each_block as EachBlock).has_binding = true; ( /** @type {import('../EachBlock.js').default} */(each_block)).has_binding = true;
} else { }
else {
component.add_reference(node, name); component.add_reference(node, name);
const variable = component.var_lookup.get(name); const variable = component.var_lookup.get(name);
if (variable) { if (variable) {
variable[deep ? 'mutated' : 'reassigned'] = true; variable[deep ? 'mutated' : 'reassigned'] = true;
} }
const declaration: any = scope.find_owner(name)?.declarations.get(name); /** @type {any} */
const declaration = scope.find_owner(name)?.declarations.get(name);
if (declaration) { if (declaration) {
if (declaration.kind === 'const' && !deep) { if (declaration.kind === 'const' && !deep) {
component.error(node, { component.error(node, {
@ -172,7 +177,8 @@ export default class Expression {
message: 'You are assigning to a const' message: 'You are assigning to a const'
}); });
} }
} else if (variable && variable.writable === false && !deep) { }
else if (variable && variable.writable === false && !deep) {
component.error(node, { component.error(node, {
code: 'assignment-to-const', code: 'assignment-to-const',
message: 'You are assigning to a const' message: 'You are assigning to a const'
@ -183,93 +189,98 @@ export default class Expression {
} }
}, },
leave(node: Node) { /** @param {import('estree').Node} node */
leave(node) {
if (map.has(node)) { if (map.has(node)) {
scope = scope.parent; scope = scope.parent;
} }
if (node === function_expression) { if (node === function_expression) {
function_expression = null; function_expression = null;
} }
} }
}); });
} }
dynamic_dependencies() { dynamic_dependencies() {
return Array.from(this.dependencies).filter((name) => { return Array.from(this.dependencies).filter(/** @param {any} name */ (name) => {
if (this.template_scope.is_let(name)) return true; if (this.template_scope.is_let(name))
if (is_reserved_keyword(name)) return true; return true;
if (is_reserved_keyword(name))
return true;
const variable = this.component.var_lookup.get(name); const variable = this.component.var_lookup.get(name);
return is_dynamic(variable); return is_dynamic(variable);
}); });
} }
dynamic_contextual_dependencies() { dynamic_contextual_dependencies() {
return Array.from(this.contextual_dependencies).filter((name) => { return Array.from(this.contextual_dependencies).filter(/** @param {any} name */ (name) => {
return Array.from(this.template_scope.dependencies_for_name.get(name)).some( return Array.from(this.template_scope.dependencies_for_name.get(name)).some(
/** @param {any} variable_name */
(variable_name) => { (variable_name) => {
const variable = this.component.var_lookup.get(variable_name); const variable = this.component.var_lookup.get(variable_name);
return is_dynamic(variable); return is_dynamic(variable);
} });
);
}); });
} }
// TODO move this into a render-dom wrapper? // TODO move this into a render-dom wrapper?
manipulate(block?: Block, ctx?: string | void) {
/**
* @param {import('../../render_dom/Block.js').default} [block]
* @param {string | void} [ctx]
*/
manipulate(block, ctx) {
// TODO ideally we wouldn't end up calling this method // TODO ideally we wouldn't end up calling this method
// multiple times // multiple times
if (this.manipulated) return this.manipulated; if (this.manipulated)
return this.manipulated;
const { component, declarations, scope_map: map, template_scope, owner } = this; const { component, declarations, scope_map: map, template_scope, owner } = this;
let scope = this.scope; let scope = this.scope;
let function_expression; let function_expression;
let dependencies: Set<string>; /** @type {Set<string>} */
let contextual_dependencies: Set<string>; let dependencies;
/** @type {Set<string>} */
let contextual_dependencies;
const node = walk(this.node, { const node = walk(this.node, {
enter(node: any, parent: any) {
/**
* @param {any} node
* @param {any} parent
*/
enter(node, parent) {
if (node.type === 'Property' && node.shorthand) { if (node.type === 'Property' && node.shorthand) {
node.value = clone(node.value); node.value = clone(node.value);
node.shorthand = false; node.shorthand = false;
} }
if (map.has(node)) { if (map.has(node)) {
scope = map.get(node); scope = map.get(node);
} }
if (node.type === 'Identifier' && is_reference(node, parent)) { if (node.type === 'Identifier' && is_reference(node, parent)) {
const { name } = flatten_reference(node); const { name } = flatten_reference(node);
if (scope.has(name))
if (scope.has(name)) return; return;
if (function_expression) { if (function_expression) {
if (template_scope.names.has(name)) { if (template_scope.names.has(name)) {
contextual_dependencies.add(name); contextual_dependencies.add(name);
template_scope.dependencies_for_name.get(name).forEach(/** @param {any} dependency */ (dependency) => {
template_scope.dependencies_for_name.get(name).forEach((dependency) => {
dependencies.add(dependency); dependencies.add(dependency);
}); });
} else { }
else {
dependencies.add(name); dependencies.add(name);
component.add_reference(node, name); // TODO is this redundant/misplaced? component.add_reference(node, name); // TODO is this redundant/misplaced?
} }
} else if (is_contextual(component, template_scope, name)) { }
else if (is_contextual(component, template_scope, name)) {
const reference = block.renderer.reference(node, ctx); const reference = block.renderer.reference(node, ctx);
this.replace(reference); this.replace(reference);
} }
this.skip(); this.skip();
} }
if (!function_expression) { if (!function_expression) {
if (node.type === 'AssignmentExpression') { if (node.type === 'AssignmentExpression') {
// TODO should this be a warning/error? `<p>{foo = 1}</p>` // TODO should this be a warning/error? `<p>{foo = 1}</p>`
} }
if (node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression') { if (node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression') {
function_expression = node; function_expression = node;
dependencies = new Set(); dependencies = new Set();
@ -278,104 +289,113 @@ export default class Expression {
} }
}, },
leave(node: Node, parent: Node) { /**
if (map.has(node)) scope = scope.parent; * @param {import('estree').Node} node
* @param {import('estree').Node} parent
*/
leave(node, parent) {
if (map.has(node))
scope = scope.parent;
if (node === function_expression) { if (node === function_expression) {
const id = component.get_unique_name(sanitize(get_function_name(node, owner))); const id = component.get_unique_name(sanitize(get_function_name(node, owner)));
const declaration = b `const ${id} = ${node}`;
const declaration = b`const ${id} = ${node}`;
const extract_functions = () => { const extract_functions = () => {
const deps = Array.from(contextual_dependencies); const deps = Array.from(contextual_dependencies);
const function_expression = node as FunctionExpression; const function_expression = /** @type {import('estree').FunctionExpression} */ (node);
const has_args = function_expression.params.length > 0; const has_args = function_expression.params.length > 0;
function_expression.params = [ function_expression.params = [
...deps.map((name) => ({ type: 'Identifier', name } as Identifier)), ...deps.map(/** @param {any} name */ (name) => ( /** @type {import('estree').Identifier} */({ type: 'Identifier', name }))),
...function_expression.params ...function_expression.params
]; ];
const context_args = deps.map(/** @param {any} name */ (name) => block.renderer.reference(name, ctx));
const context_args = deps.map((name) => block.renderer.reference(name, ctx));
component.partly_hoisted.push(declaration); component.partly_hoisted.push(declaration);
block.renderer.add_to_context(id.name); block.renderer.add_to_context(id.name);
const callee = block.renderer.reference(id); const callee = block.renderer.reference(id);
this.replace(/** @type {any} */ (id));
this.replace(id as any);
const func_declaration = has_args const func_declaration = has_args
? b`function ${id}(...args) { ? b `function ${id}(...args) {
return ${callee}(${context_args}, ...args); return ${callee}(${context_args}, ...args);
}` }`
: b`function ${id}() { : b `function ${id}() {
return ${callee}(${context_args}); return ${callee}(${context_args});
}`; }`;
return { deps, func_declaration }; return { deps, func_declaration };
}; };
if (owner.type === 'ConstTag') { if (owner.type === 'ConstTag') {
// we need a combo block/init recipe // we need a combo block/init recipe
if (contextual_dependencies.size === 0) { if (contextual_dependencies.size === 0) {
let child_scope = scope; let child_scope = scope;
walk(node, { walk(node, {
enter(node: Node, parent: any) {
if (map.has(node)) child_scope = map.get(node); /**
* @param {import('estree').Node} node
* @param {any} parent
*/
enter(node, parent) {
if (map.has(node))
child_scope = map.get(node);
if (node.type === 'Identifier' && is_reference(node, parent)) { if (node.type === 'Identifier' && is_reference(node, parent)) {
if (child_scope.has(node.name)) return; if (child_scope.has(node.name))
return;
this.replace(block.renderer.reference(node, ctx)); this.replace(block.renderer.reference(node, ctx));
} }
}, },
leave(node: Node) {
if (map.has(node)) child_scope = child_scope.parent; /** @param {import('estree').Node} node */
leave(node) {
if (map.has(node))
child_scope = child_scope.parent;
} }
}); });
} else { }
else {
const { func_declaration } = extract_functions(); const { func_declaration } = extract_functions();
this.replace(func_declaration[0]); this.replace(func_declaration[0]);
} }
} else if (dependencies.size === 0 && contextual_dependencies.size === 0) { }
else if (dependencies.size === 0 && contextual_dependencies.size === 0) {
// we can hoist this out of the component completely // we can hoist this out of the component completely
component.fully_hoisted.push(declaration); component.fully_hoisted.push(declaration);
this.replace(/** @type {any} */ (id));
this.replace(id as any);
component.add_var(node, { component.add_var(node, {
name: id.name, name: id.name,
internal: true, internal: true,
hoistable: true, hoistable: true,
referenced: true referenced: true
}); });
} else if (contextual_dependencies.size === 0) { }
else if (contextual_dependencies.size === 0) {
// function can be hoisted inside the component init // function can be hoisted inside the component init
component.partly_hoisted.push(declaration); component.partly_hoisted.push(declaration);
block.renderer.add_to_context(id.name); block.renderer.add_to_context(id.name);
this.replace(block.renderer.reference(id)); this.replace(block.renderer.reference(id));
} else { }
else {
// we need a combo block/init recipe // we need a combo block/init recipe
const { deps, func_declaration } = extract_functions(); const { deps, func_declaration } = extract_functions();
if (owner.type === 'Attribute' && owner.parent.name === 'slot') { if (owner.type === 'Attribute' && owner.parent.name === 'slot') {
const dep_scopes = new Set<INode>(deps.map((name) => template_scope.get_owner(name))); const dep_scopes = new Set(deps.map(/** @param {any} name */ (name) => template_scope.get_owner(name)));
// find the nearest scopes // find the nearest scopes
let node: INode = owner.parent;
/** @type {import('../interfaces.js').INode} */
let node = owner.parent;
while (node && !dep_scopes.has(node)) { while (node && !dep_scopes.has(node)) {
node = node.parent; node = node.parent;
} }
const func_expression = func_declaration[0]; const func_expression = func_declaration[0];
if (node.type === 'InlineComponent' || node.type === 'SlotTemplate') { if (node.type === 'InlineComponent' || node.type === 'SlotTemplate') {
// <Comp let:data /> // <Comp let:data />
this.replace(func_expression); this.replace(func_expression);
} else { }
else {
// {#each}, {#await} // {#each}, {#await}
const func_id = component.get_unique_name(id.name + '_func'); const func_id = component.get_unique_name(id.name + '_func');
block.renderer.add_to_context(func_id.name, true); block.renderer.add_to_context(func_id.name, true);
// rename #ctx -> child_ctx; // rename #ctx -> child_ctx;
walk(func_expression, { walk(func_expression, {
enter(node: Node) {
/** @param {import('estree').Node} node */
enter(node) {
if (node.type === 'Identifier' && node.name === '#ctx') { if (node.type === 'Identifier' && node.name === '#ctx') {
node.name = 'child_ctx'; node.name = 'child_ctx';
} }
@ -383,92 +403,94 @@ export default class Expression {
}); });
// add to get_xxx_context // add to get_xxx_context
// child_ctx[x] = function () { ... } // child_ctx[x] = function () { ... }
(template_scope.get_owner(deps[0]) as EachBlock).contexts.push({ ( /** @type {import('../EachBlock.js').default} */(template_scope.get_owner(deps[0]))).contexts.push({
type: 'DestructuredVariable', type: 'DestructuredVariable',
key: func_id, key: func_id,
modifier: () => func_expression, modifier: () => func_expression,
default_modifier: (node) => node default_modifier: /** @param {any} node */ (node) => node
}); });
this.replace(block.renderer.reference(func_id)); this.replace(block.renderer.reference(func_id));
} }
} else { }
else {
declarations.push(func_declaration); declarations.push(func_declaration);
} }
} }
function_expression = null; function_expression = null;
dependencies = null; dependencies = null;
contextual_dependencies = null; contextual_dependencies = null;
if (parent && parent.type === 'Property') { if (parent && parent.type === 'Property') {
parent.method = false; parent.method = false;
} }
} }
if (node.type === 'AssignmentExpression' || node.type === 'UpdateExpression') { if (node.type === 'AssignmentExpression' || node.type === 'UpdateExpression') {
const assignee = node.type === 'AssignmentExpression' ? node.left : node.argument; const assignee = node.type === 'AssignmentExpression' ? node.left : node.argument;
const object_name = get_object(assignee).name; const object_name = get_object(assignee).name;
if (scope.has(object_name))
if (scope.has(object_name)) return; return;
// normally (`a = 1`, `b.c = 2`), there'll be a single name // normally (`a = 1`, `b.c = 2`), there'll be a single name
// (a or b). In destructuring cases (`[d, e] = [e, d]`) there // (a or b). In destructuring cases (`[d, e] = [e, d]`) there
// may be more, in which case we need to tack the extra ones // may be more, in which case we need to tack the extra ones
// onto the initial function call // onto the initial function call
const names = new Set(extract_names(assignee as Node)); const names = new Set(extract_names(/** @type {import('estree').Node} */ (assignee)));
const traced: Set<string> = new Set(); /** @type {Set<string>} */
names.forEach((name) => { const traced = new Set();
names.forEach(/** @param {any} name */ (name) => {
const dependencies = template_scope.dependencies_for_name.get(name); const dependencies = template_scope.dependencies_for_name.get(name);
if (dependencies) { if (dependencies) {
dependencies.forEach((name) => traced.add(name)); dependencies.forEach(/** @param {any} name */ (name) => traced.add(name));
} else { }
else {
traced.add(name); traced.add(name);
} }
}); });
const context = block.bindings.get(object_name); const context = block.bindings.get(object_name);
if (context) { if (context) {
// for `{#each array as item}` // for `{#each array as item}`
// replace `item = 1` to `each_array[each_index] = 1`, this allow us to mutate the array // replace `item = 1` to `each_array[each_index] = 1`, this allow us to mutate the array
// rather than mutating the local `item` variable // rather than mutating the local `item` variable
const { snippet, object, property } = context; const { snippet, object, property } = context;
const replaced: any = replace_object(assignee, snippet);
/** @type {any} */
const replaced = replace_object(assignee, snippet);
if (node.type === 'AssignmentExpression') { if (node.type === 'AssignmentExpression') {
node.left = replaced; node.left = replaced;
} else { }
else {
node.argument = replaced; node.argument = replaced;
} }
contextual_dependencies.add(object.name); contextual_dependencies.add(object.name);
contextual_dependencies.add(property.name); contextual_dependencies.add(property.name);
} }
this.replace(invalidate(block.renderer, scope, node, traced)); this.replace(invalidate(block.renderer, scope, node, traced));
} }
} }
}); });
if (declarations.length > 0) { if (declarations.length > 0) {
block.maintain_context = true; block.maintain_context = true;
declarations.forEach((declaration) => { declarations.forEach(/** @param {any} declaration */ (declaration) => {
block.chunks.init.push(declaration); block.chunks.init.push(declaration);
}); });
} }
return (this.manipulated = /** @type {import('estree').Node} */ (node));
return (this.manipulated = node as Node);
} }
} }
/**
* @param {any} _node
* @param {any} parent
*/
function get_function_name(_node, parent) { function get_function_name(_node, parent) {
if (parent.type === 'EventHandler') { if (parent.type === 'EventHandler') {
return `${parent.name}_handler`; return `${parent.name}_handler`;
} }
if (parent.type === 'Action') { if (parent.type === 'Action') {
return `${parent.name}_function`; return `${parent.name}_function`;
} }
return 'func'; return 'func';
} }
/** @typedef {INode} Owner */

Loading…
Cancel
Save