solid-optimizer 0.3.0 → 1.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile-Cz6hbiQv.mjs","names":["exportName"],"sources":["../src/ast.ts","../src/context.ts","../src/scope.ts","../src/value.ts","../src/constants.ts","../src/jsx.ts","../src/size.ts","../src/fold.ts","../src/provider.ts","../src/copy-size.ts","../src/inline.ts","../src/memo.ts","../src/compile.ts"],"sourcesContent":["import type { Expression, JSXChild, Node, ParserOptions, Program } from 'oxc-parser';\nimport { parseSync, rawTransferSupported, visitorKeys } from 'oxc-parser';\n\n/**\n * Keys that only hold TypeScript types. Types never run, so no pass reads or rewrites them.\n */\nconst TYPE_KEYS = new Set([\n 'typeAnnotation',\n 'typeParameters',\n 'typeArguments',\n 'returnType',\n 'superTypeArguments',\n 'implements',\n]);\n\n/**\n * TypeScript nodes that wrap a runtime expression.\n * Every other TypeScript node is skipped along with its children.\n */\nconst TS_EXPRESSION_WRAPPERS = new Set([\n 'TSAsExpression',\n 'TSSatisfiesExpression',\n 'TSNonNullExpression',\n 'TSTypeAssertion',\n 'TSInstantiationExpression',\n 'TSExportAssignment',\n]);\n\nexport function isNode(value: unknown): value is Node {\n return (\n typeof value === 'object' && value !== null && 'type' in value && typeof value.type === 'string'\n );\n}\n\n/**\n * Calls `visit` for each child node of `node`, in source order.\n */\nexport function forEachChild(node: Node, visit: (child: Node) => void): void {\n if (node.type.startsWith('TS')) {\n if (TS_EXPRESSION_WRAPPERS.has(node.type)) {\n const expression: unknown = Reflect.get(node, 'expression');\n if (isNode(expression)) {\n visit(expression);\n }\n } else if (node.type === 'TSParameterProperty') {\n visit(node.parameter);\n }\n return;\n }\n if (!Object.hasOwn(visitorKeys, node.type)) {\n return;\n }\n for (const key of visitorKeys[node.type]) {\n if (TYPE_KEYS.has(key)) {\n continue;\n }\n const value: unknown = Reflect.get(node, key);\n if (Array.isArray(value)) {\n const items: unknown[] = value;\n for (const item of items) {\n if (isNode(item)) {\n visit(item);\n }\n }\n } else if (isNode(value)) {\n visit(value);\n }\n }\n}\n\nexport type Parents = Map<Node, Node>;\n\nexport function collectParents(program: Program): Parents {\n const parents: Parents = new Map();\n const visit = (node: Node): void => {\n forEachChild(node, (child) => {\n parents.set(child, node);\n visit(child);\n });\n };\n visit(program);\n return parents;\n}\n\n/**\n * Raw transfer hands the AST over in shared memory instead of as JSON, which\n * is several times faster to read. It is not in the options' type yet.\n */\nconst RAW_TRANSFER = rawTransferSupported();\n\nexport function parse(filename: string, code: string): Program {\n const options: ParserOptions & { experimentalRawTransfer?: boolean } = {\n lang: languageOf(filename),\n sourceType: 'module',\n preserveParens: true,\n experimentalRawTransfer: RAW_TRANSFER,\n };\n const result = parseSync(filename, code, options);\n const error = result.errors.at(0);\n if (error) {\n throw new SyntaxError(`[solid-optimizer] ${filename}: ${error.codeframe ?? error.message}`);\n }\n return result.program;\n}\n\nfunction languageOf(filename: string): 'jsx' | 'ts' | 'tsx' {\n if (/\\.tsx$/i.test(filename)) {\n return 'tsx';\n }\n if (/\\.[cm]?ts$/i.test(filename)) {\n return 'ts';\n }\n // Plain `.js` files are parsed as JSX, since bundled chunks keep the JSX they preserved.\n return 'jsx';\n}\n\n/**\n * Removes the parentheses and TypeScript wrappers around an expression.\n */\nexport function unwrap(node: Expression): Expression {\n let current = node;\n while (\n current.type === 'ParenthesizedExpression' ||\n current.type === 'TSAsExpression' ||\n current.type === 'TSSatisfiesExpression' ||\n current.type === 'TSNonNullExpression' ||\n current.type === 'TSTypeAssertion'\n ) {\n current = current.expression;\n }\n return current;\n}\n\nexport function isFunctionNode(node: Node): boolean {\n return (\n node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression' ||\n node.type === 'ArrowFunctionExpression'\n );\n}\n\n/**\n * An intrinsic element name, such as `div` or `my-element`.\n * JSX treats a lowercase first letter as an intrinsic element.\n */\nexport function isIntrinsicTag(name: string): boolean {\n return /^[a-z][\\w-]*$/.test(name);\n}\n\n/**\n * Whether JSX drops this text: whitespace that contains a line break.\n */\nexport function isFilteredText(child: JSXChild): boolean {\n return child.type === 'JSXText' && /^\\s*$/.test(child.value) && /[\\r\\n]/.test(child.value);\n}\n\n/**\n * Whether a JSX child renders nothing: dropped whitespace, or a container\n * that only holds a comment, like `{/* note *\\/}`.\n */\nexport function isInsignificant(child: JSXChild): boolean {\n return (\n isFilteredText(child) ||\n (child.type === 'JSXExpressionContainer' && child.expression.type === 'JSXEmptyExpression')\n );\n}\n\n/**\n * Whether a JSX element or fragment sits in a list of JSX children.\n */\nexport function isJSXChild(node: Node, parents: Parents): boolean {\n const parent = parents.get(node);\n return parent?.type === 'JSXElement' || parent?.type === 'JSXFragment';\n}\n\n/**\n * Node types that bind tighter than any operator, so their text can replace\n * any expression without parentheses.\n */\nconst PRIMARY_TYPES = new Set([\n 'Identifier',\n 'Literal',\n 'ThisExpression',\n 'ArrayExpression',\n 'TemplateLiteral',\n 'ParenthesizedExpression',\n 'JSXElement',\n 'JSXFragment',\n]);\n\nexport function isPrimary(node: Node): boolean {\n if (node.type === 'Literal') {\n // `-1` is a unary expression, but a literal like `1` is primary.\n return typeof node.value !== 'number' || node.value >= 0;\n }\n return PRIMARY_TYPES.has(node.type);\n}\n\n/**\n * The node that starts an expression's text, such as `a` in `a.b()`.\n */\nfunction leftmost(node: Node): Node {\n switch (node.type) {\n case 'MemberExpression':\n return leftmost(node.object);\n case 'CallExpression':\n return leftmost(node.callee);\n case 'TaggedTemplateExpression':\n return leftmost(node.tag);\n case 'BinaryExpression':\n case 'LogicalExpression':\n return leftmost(node.left);\n case 'AssignmentExpression':\n return leftmost(node.left);\n case 'ConditionalExpression':\n return leftmost(node.test);\n case 'SequenceExpression':\n return node.expressions[0] ? leftmost(node.expressions[0]) : node;\n case 'ChainExpression':\n return leftmost(node.expression);\n case 'UpdateExpression':\n return node.prefix ? node : leftmost(node.argument);\n case 'TSAsExpression':\n case 'TSSatisfiesExpression':\n case 'TSNonNullExpression':\n return leftmost(node.expression);\n default:\n return node;\n }\n}\n\n/**\n * Whether `replacement` needs parentheses to take the place of `target`.\n *\n * Replacing an expression with one of its own operands never needs them, since an operand\n * binds at least as tightly as the expression around it. The exceptions are the positions\n * where the first token decides what the parser reads: a statement cannot start with `{`,\n * `function`, or `class`, and neither can an arrow function body.\n */\nexport function needsParensAt(target: Node, replacement: Node, parents: Parents): boolean {\n const parent = parents.get(target);\n if (parent === undefined) {\n return false;\n }\n const statementStart =\n parent.type === 'ExpressionStatement' ||\n parent.type === 'ExportDefaultDeclaration' ||\n (parent.type === 'ArrowFunctionExpression' && parent.body === target);\n if (!statementStart) {\n return false;\n }\n const first = leftmost(replacement);\n return (\n startsLikeStatement(first) ||\n // A string at the start of a statement can turn into a directive, like `\"use strict\"`.\n (first.type === 'Literal' && typeof first.value === 'string')\n );\n}\n\n/**\n * Whether an expression statement starting with `node` would parse as\n * something else: a block, a function declaration, or a class declaration.\n */\nexport function startsLikeStatement(node: Node): boolean {\n const first = leftmost(node);\n return (\n first.type === 'ObjectExpression' ||\n first.type === 'FunctionExpression' ||\n first.type === 'ClassExpression'\n );\n}\n","import type MagicString from 'magic-string';\nimport type { Node, Program } from 'oxc-parser';\nimport type { Parents } from './ast';\nimport type { ResolvedImportedConstants } from './constants';\nimport type { Binding, ScopeAnalysis } from './scope';\nimport type { Primitive } from './value';\n\nexport interface ResolvedOptions {\n /** The control-flow components a tag may resolve to. */\n readonly builtIns: ReadonlySet<string>;\n /** The modules Solid's built-in components are imported from. */\n readonly moduleSources: readonly string[];\n /** Top-level names that refer to a Solid export, keyed by name. */\n readonly builtInAliases: ReadonlyMap<string, string>;\n /** Whether a top-level `var` that nothing writes to counts as a constant. */\n readonly constantVars: boolean;\n /** The constants imported modules export, by import specifier and export name. */\n readonly importedConstants: ResolvedImportedConstants;\n /** Values of global names and paths, like `__DEV__` or `import.meta.env.MODE`. */\n readonly globalConstants: ReadonlyMap<string, Primitive>;\n /** The exports of imported modules that are contexts, by import specifier. */\n readonly importedContexts: ReadonlyMap<string, ReadonlySet<string>>;\n /** Components other modules use too, by the number of modules that use them. */\n readonly sharedComponents: ReadonlyMap<string, number>;\n /** Whether to inline components even where the copies are larger. */\n readonly alwaysInline: boolean;\n}\n\n/**\n * Whether a binding keeps the value it was declared with, like a `const`.\n *\n * `var` is excluded by default. A read before its declaration sees\n * `undefined` rather than throwing. A bundler turns top-level `const` into\n * `var`, so the `constantVars` option counts those too.\n */\nexport function isConstantDeclaration(binding: Binding, options: ResolvedOptions): boolean {\n if (binding.mutated) {\n return false;\n }\n if (binding.kind === 'const' || binding.kind === 'let') {\n return true;\n }\n return binding.kind === 'var' && options.constantVars && binding.scope.parent === undefined;\n}\n\n/**\n * The Solid export a binding refers to, by the name Solid exports it under.\n *\n * An import from a Solid module is decided by its exported name, so `m` from\n * `import { createMemo as m }` is `createMemo`. A bundled chunk declares or\n * imports Solid's exports under names the bundler chose, which\n * `builtInAliases` maps back.\n */\nexport function solidExport(binding: Binding, options: ResolvedOptions): string | undefined {\n if (binding.scope.parent === undefined && options.builtInAliases.has(binding.name)) {\n return options.builtInAliases.get(binding.name);\n }\n if (\n binding.kind === 'import' &&\n binding.source !== undefined &&\n options.moduleSources.includes(binding.source)\n ) {\n return binding.imported;\n }\n return undefined;\n}\n\n/** The passes that record what they leave alone. */\nexport type SkipPass = 'inline' | 'contexts' | 'memos';\n\n/**\n * Something a pass left alone, and why. The `compile` option `report`\n * collects them.\n */\nexport interface Skip {\n readonly pass: SkipPass;\n /** A short code for the reason, like `call-spread`. */\n readonly reason: string;\n /** The component, context, or memo it is about. */\n readonly name: string;\n}\n\n/**\n * Everything a pass needs: the parsed code and the string it edits.\n *\n * A pass reads the AST of the code as it was before the pass started, and\n * writes its edits to `s`. The next pass parses the result again.\n */\nexport interface PassContext {\n readonly code: string;\n /** The file name, which picks the parser. */\n readonly filename: string;\n readonly s: MagicString;\n readonly program: Program;\n readonly parents: Parents;\n readonly scopes: ScopeAnalysis;\n readonly options: ResolvedOptions;\n /** Where a pass records what it leaves alone, when the caller asked for a report. */\n readonly skips: Skip[] | undefined;\n}\n\n/**\n * Records that a pass left something alone, when the caller asked for a report.\n */\nexport function recordSkip(\n context: PassContext,\n pass: SkipPass,\n reason: string,\n name: string,\n): void {\n context.skips?.push({ pass, reason, name });\n}\n\n/**\n * The current text of `node`, including the edits made inside it so far.\n */\nexport function textOf(context: PassContext, node: Node): string {\n return context.s.slice(node.start, node.end);\n}\n","/**\n * Binding resolution for the passes.\n *\n * oxc-parser returns an ESTree AST without scope information, so this module\n * resolves every identifier reference to the declaration it binds to. The\n * passes use it to fold a constant only where it is the same binding, to tell\n * Solid's own components from local ones, and to rename the bindings of an\n * inlined component.\n *\n * Code is treated as an ES module: it is strict, and a function declared in a\n * block is scoped to that block.\n */\nimport type {\n BindingPattern,\n Class,\n Directive,\n Function as FunctionNode,\n JSXElementName,\n ModuleExportName,\n Node,\n ParamPattern,\n Program,\n Statement,\n} from 'oxc-parser';\nimport type { Parents } from './ast';\nimport { forEachChild, isIntrinsicTag } from './ast';\n\nexport type BindingKind =\n | 'var'\n | 'let'\n | 'const'\n | 'function'\n | 'class'\n | 'param'\n | 'import'\n | 'catch'\n | 'other';\n\nexport interface Binding {\n readonly name: string;\n readonly kind: BindingKind;\n readonly scope: Scope;\n /** The identifier that declares the binding. */\n readonly identifier: Node;\n /**\n * The node that declares the binding: a `VariableDeclarator`, a function, a\n * class, an import specifier, or the function or clause that owns a parameter.\n */\n readonly declaration: Node;\n /** The module an import binding comes from. */\n readonly source: string | undefined;\n /** The name an import binding has in its module: an export name, `default`, or `*`. */\n readonly imported: string | undefined;\n /** Every reference, including JSX tag names in opening and closing tags. */\n readonly references: Node[];\n /** Whether anything writes to the binding after its declaration. */\n mutated: boolean;\n}\n\nexport interface Scope {\n readonly node: Node;\n readonly parent: Scope | undefined;\n /** Whether `var` declarations stop here. */\n readonly isFunction: boolean;\n readonly bindings: Map<string, Binding>;\n}\n\nexport interface ScopeAnalysis {\n readonly root: Scope;\n /** What each identifier reference resolves to. `undefined` means a global. */\n readonly references: Map<Node, Binding | undefined>;\n /** The scope each scope-creating node opens. A function body shares its function's scope. */\n readonly scopes: Map<Node, Scope>;\n /** Every identifier name in the program, for generating names that collide with none. */\n readonly names: Set<string>;\n}\n\ninterface PendingReference {\n readonly node: Node;\n readonly name: string;\n readonly scope: Scope;\n readonly write: boolean;\n}\n\nexport function lookup(scope: Scope, name: string): Binding | undefined {\n let current: Scope | undefined = scope;\n while (current) {\n const binding = current.bindings.get(name);\n if (binding) {\n return binding;\n }\n current = current.parent;\n }\n return undefined;\n}\n\n/**\n * The innermost scope that contains `node`.\n */\nexport function scopeAt(analysis: ScopeAnalysis, parents: Parents, node: Node): Scope {\n let current: Node | undefined = parents.get(node);\n while (current) {\n const scope = analysis.scopes.get(current);\n if (scope) {\n return scope;\n }\n current = parents.get(current);\n }\n return analysis.root;\n}\n\n/**\n * Whether `scope` is `ancestor` or nested inside it.\n */\nexport function isWithinScope(scope: Scope, ancestor: Scope): boolean {\n let current: Scope | undefined = scope;\n while (current) {\n if (current === ancestor) {\n return true;\n }\n current = current.parent;\n }\n return false;\n}\n\nfunction exportName(name: ModuleExportName): string {\n return name.type === 'Literal' ? name.value : name.name;\n}\n\nclass Analyzer {\n private scope: Scope;\n\n readonly root: Scope;\n\n readonly scopes = new Map<Node, Scope>();\n\n readonly names = new Set<string>();\n\n private readonly pending: PendingReference[] = [];\n\n constructor(program: Program) {\n this.root = {\n node: program,\n parent: undefined,\n isFunction: true,\n bindings: new Map(),\n };\n this.scopes.set(program, this.root);\n this.scope = this.root;\n }\n\n finish(): Map<Node, Binding | undefined> {\n const references = new Map<Node, Binding | undefined>();\n for (const item of this.pending) {\n const binding = lookup(item.scope, item.name);\n if (binding) {\n binding.references.push(item.node);\n if (item.write) {\n binding.mutated = true;\n }\n }\n references.set(item.node, binding);\n }\n return references;\n }\n\n private withScope(node: Node, isFunction: boolean, run: () => void): Scope {\n const scope: Scope = {\n node,\n parent: this.scope,\n isFunction,\n bindings: new Map(),\n };\n this.scopes.set(node, scope);\n const previous = this.scope;\n this.scope = scope;\n run();\n this.scope = previous;\n return scope;\n }\n\n private declare(\n identifier: Node & { name: string },\n kind: BindingKind,\n declaration: Node,\n source?: string,\n imported?: string,\n ): void {\n let target = this.scope;\n if (kind === 'var') {\n while (!target.isFunction && target.parent) {\n target = target.parent;\n }\n }\n this.names.add(identifier.name);\n const existing = target.bindings.get(identifier.name);\n if (existing) {\n // A redeclaration, like `var a; var a;`. The binding is no longer a\n // single declaration, so no pass treats it as a constant.\n existing.mutated = true;\n existing.references.push(identifier);\n return;\n }\n target.bindings.set(identifier.name, {\n name: identifier.name,\n kind,\n scope: target,\n identifier,\n declaration,\n source,\n imported,\n references: [],\n mutated: false,\n });\n }\n\n private reference(node: Node & { name: string }, write: boolean): void {\n this.names.add(node.name);\n this.pending.push({ node, name: node.name, scope: this.scope, write });\n }\n\n private declarePattern(\n pattern: BindingPattern | ParamPattern,\n kind: BindingKind,\n declaration: Node,\n ): void {\n switch (pattern.type) {\n case 'Identifier':\n this.declare(pattern, kind, declaration);\n break;\n case 'ObjectPattern':\n for (const property of pattern.properties) {\n if (property.type === 'RestElement') {\n this.declarePattern(property.argument, kind, declaration);\n } else {\n if (property.computed) {\n this.visit(property.key);\n }\n this.declarePattern(property.value, kind, declaration);\n }\n }\n break;\n case 'ArrayPattern':\n for (const element of pattern.elements) {\n if (element) {\n this.declarePattern(element, kind, declaration);\n }\n }\n break;\n case 'AssignmentPattern':\n this.declarePattern(pattern.left, kind, declaration);\n this.visit(pattern.right);\n break;\n case 'RestElement':\n this.declarePattern(pattern.argument, kind, declaration);\n break;\n case 'TSParameterProperty':\n this.declarePattern(pattern.parameter, kind, declaration);\n break;\n default:\n break;\n }\n }\n\n /**\n * Visits the target of an assignment, marking every identifier it writes.\n */\n private visitTarget(target: Node): void {\n switch (target.type) {\n case 'Identifier':\n this.reference(target, true);\n break;\n case 'ObjectPattern':\n for (const property of target.properties) {\n if (property.type === 'RestElement') {\n this.visitTarget(property.argument);\n } else {\n if (property.computed) {\n this.visit(property.key);\n }\n this.visitTarget(property.value);\n }\n }\n break;\n case 'ArrayPattern':\n for (const element of target.elements) {\n if (element) {\n this.visitTarget(element);\n }\n }\n break;\n case 'AssignmentPattern':\n this.visitTarget(target.left);\n this.visit(target.right);\n break;\n case 'RestElement':\n this.visitTarget(target.argument);\n break;\n case 'ParenthesizedExpression':\n case 'TSAsExpression':\n case 'TSSatisfiesExpression':\n case 'TSNonNullExpression':\n case 'TSTypeAssertion':\n this.visitTarget(target.expression);\n break;\n default:\n this.visit(target);\n break;\n }\n }\n\n private visitStatements(statements: (Statement | Directive)[]): void {\n for (const statement of statements) {\n this.visit(statement);\n }\n }\n\n private visitFunction(node: FunctionNode): void {\n this.withScope(node, true, () => {\n if (node.type === 'FunctionExpression' && node.id) {\n this.declare(node.id, 'other', node);\n }\n for (const param of node.params) {\n this.declarePattern(param, 'param', node);\n }\n if (node.body) {\n this.scopes.set(node.body, this.scope);\n this.visitStatements(node.body.body);\n }\n });\n }\n\n private visitClass(node: Class): void {\n for (const decorator of node.decorators) {\n this.visit(decorator);\n }\n if (node.superClass) {\n this.visit(node.superClass);\n }\n for (const element of node.body.body) {\n switch (element.type) {\n case 'MethodDefinition':\n case 'PropertyDefinition':\n case 'AccessorProperty':\n for (const decorator of element.decorators) {\n this.visit(decorator);\n }\n if (element.computed) {\n this.visit(element.key);\n }\n if (element.value) {\n this.visit(element.value);\n }\n break;\n case 'StaticBlock':\n this.withScope(element, true, () => {\n this.visitStatements(element.body);\n });\n break;\n default:\n break;\n }\n }\n }\n\n private visitJSXName(name: JSXElementName): void {\n if (name.type === 'JSXIdentifier') {\n if (!isIntrinsicTag(name.name) && name.name !== 'this') {\n this.reference(name, false);\n }\n } else if (name.type === 'JSXMemberExpression') {\n let object = name.object;\n while (object.type === 'JSXMemberExpression') {\n object = object.object;\n }\n if (object.name !== 'this') {\n this.reference(object, false);\n }\n }\n }\n\n visit(node: Node): void {\n switch (node.type) {\n case 'Identifier':\n this.reference(node, false);\n break;\n case 'VariableDeclaration': {\n // `declare const` only tells TypeScript about a global. It is stripped\n // with the types and declares nothing, so its name stays global.\n if (node.declare) {\n break;\n }\n // `using` binds a disposable resource, so it is never a folding candidate.\n let kind: BindingKind = 'other';\n if (node.kind === 'var' || node.kind === 'let' || node.kind === 'const') {\n kind = node.kind;\n }\n for (const declarator of node.declarations) {\n this.declarePattern(declarator.id, kind, declarator);\n if (declarator.init) {\n this.visit(declarator.init);\n }\n }\n break;\n }\n case 'FunctionDeclaration':\n if (node.id) {\n this.declare(node.id, 'function', node);\n }\n this.visitFunction(node);\n break;\n // An overload signature or a `declare function` has no body and is\n // stripped with the types. The implementation declares the name, if there is one.\n case 'TSDeclareFunction':\n this.visitFunction(node);\n break;\n case 'FunctionExpression':\n this.visitFunction(node);\n break;\n case 'ArrowFunctionExpression':\n this.withScope(node, true, () => {\n for (const param of node.params) {\n this.declarePattern(param, 'param', node);\n }\n if (node.body.type === 'BlockStatement') {\n this.scopes.set(node.body, this.scope);\n this.visitStatements(node.body.body);\n } else {\n this.visit(node.body);\n }\n });\n break;\n case 'ClassDeclaration':\n // A `declare class` is stripped with the types, like `declare const`.\n if (node.declare) {\n break;\n }\n if (node.id) {\n this.declare(node.id, 'class', node);\n }\n this.visitClass(node);\n break;\n case 'ClassExpression':\n this.withScope(node, false, () => {\n if (node.id) {\n this.declare(node.id, 'other', node);\n }\n this.visitClass(node);\n });\n break;\n case 'BlockStatement':\n this.withScope(node, false, () => {\n this.visitStatements(node.body);\n });\n break;\n case 'ForStatement':\n this.withScope(node, false, () => {\n if (node.init) {\n this.visit(node.init);\n }\n if (node.test) {\n this.visit(node.test);\n }\n if (node.update) {\n this.visit(node.update);\n }\n this.visit(node.body);\n });\n break;\n case 'ForInStatement':\n case 'ForOfStatement':\n this.withScope(node, false, () => {\n if (node.left.type === 'VariableDeclaration') {\n this.visit(node.left);\n } else {\n this.visitTarget(node.left);\n }\n this.visit(node.right);\n this.visit(node.body);\n });\n break;\n case 'CatchClause':\n this.withScope(node, false, () => {\n if (node.param) {\n this.declarePattern(node.param, 'catch', node);\n }\n this.visit(node.body);\n });\n break;\n case 'SwitchStatement':\n this.visit(node.discriminant);\n this.withScope(node, false, () => {\n for (const item of node.cases) {\n if (item.test) {\n this.visit(item.test);\n }\n this.visitStatements(item.consequent);\n }\n });\n break;\n case 'ImportDeclaration': {\n const source = node.source.value;\n for (const specifier of node.specifiers) {\n let imported = '*';\n if (specifier.type === 'ImportSpecifier') {\n imported = exportName(specifier.imported);\n } else if (specifier.type === 'ImportDefaultSpecifier') {\n imported = 'default';\n }\n this.declare(specifier.local, 'import', specifier, source, imported);\n }\n break;\n }\n case 'ExportNamedDeclaration':\n if (node.declaration) {\n this.visit(node.declaration);\n } else if (!node.source) {\n for (const specifier of node.specifiers) {\n if (specifier.local.type === 'Identifier') {\n this.reference(specifier.local, false);\n }\n }\n }\n break;\n case 'ExportAllDeclaration':\n case 'BreakStatement':\n case 'ContinueStatement':\n case 'MetaProperty':\n case 'PrivateIdentifier':\n case 'Super':\n case 'ThisExpression':\n case 'JSXText':\n case 'JSXEmptyExpression':\n break;\n case 'LabeledStatement':\n this.visit(node.body);\n break;\n case 'MemberExpression':\n this.visit(node.object);\n if (node.computed) {\n this.visit(node.property);\n }\n break;\n case 'Property':\n if (node.computed) {\n this.visit(node.key);\n }\n this.visit(node.value);\n break;\n case 'AssignmentExpression':\n this.visitTarget(node.left);\n this.visit(node.right);\n break;\n case 'UpdateExpression':\n this.visitTarget(node.argument);\n break;\n case 'JSXElement':\n this.visitJSXName(node.openingElement.name);\n for (const attribute of node.openingElement.attributes) {\n if (attribute.type === 'JSXSpreadAttribute') {\n this.visit(attribute.argument);\n } else if (attribute.value) {\n this.visit(attribute.value);\n }\n }\n for (const child of node.children) {\n this.visit(child);\n }\n if (node.closingElement) {\n this.visitJSXName(node.closingElement.name);\n }\n break;\n case 'TSEnumDeclaration':\n case 'TSImportEqualsDeclaration':\n this.declare(node.id, 'other', node);\n break;\n case 'TSModuleDeclaration':\n if (node.id.type === 'Identifier') {\n this.declare(node.id, 'other', node);\n }\n break;\n default:\n forEachChild(node, (child) => {\n this.visit(child);\n });\n break;\n }\n }\n}\n\nexport function analyzeScopes(program: Program): ScopeAnalysis {\n const analyzer = new Analyzer(program);\n analyzer.visit(program);\n const references = analyzer.finish();\n return {\n root: analyzer.root,\n references,\n scopes: analyzer.scopes,\n names: analyzer.names,\n };\n}\n","/**\n * The constant lattice the fold pass evaluates against.\n *\n * Only primitives live here, and every operator runs on them natively, so a\n * folded value is exactly what the engine would produce. Evaluating an\n * operator on primitives runs no user code. Anything that could, like `in`,\n * `instanceof`, or an object operand, is not folded.\n */\nimport type { Expression, Node } from 'oxc-parser';\n\nexport type Primitive = string | number | boolean | null | undefined;\n\nexport interface Const {\n readonly value: Primitive;\n}\n\n/**\n * Looks up the constant a reference resolves to: an identifier, or a member\n * of a namespace import.\n */\nexport type ConstantLookup = (reference: Node) => Const | undefined;\n\nfunction binary(operator: string, left: Primitive, right: Primitive): Const | undefined {\n switch (operator) {\n case '+':\n if (typeof left === 'string' || typeof right === 'string') {\n return { value: String(left) + String(right) };\n }\n return { value: Number(left) + Number(right) };\n case '-':\n return { value: Number(left) - Number(right) };\n case '*':\n return { value: Number(left) * Number(right) };\n case '/':\n return { value: Number(left) / Number(right) };\n case '%':\n return { value: Number(left) % Number(right) };\n case '**':\n return { value: Number(left) ** Number(right) };\n case '===':\n return { value: left === right };\n case '!==':\n return { value: left !== right };\n case '==':\n // Loose equality is the operator being folded, so it has to run as written.\n // oxlint-disable-next-line eqeqeq\n return { value: left == right };\n case '!=':\n // oxlint-disable-next-line eqeqeq\n return { value: left != right };\n case '<':\n case '<=':\n case '>':\n case '>=':\n return { value: compare(operator, left, right) };\n case '&':\n return { value: Number(left) & Number(right) };\n case '|':\n return { value: Number(left) | Number(right) };\n case '^':\n return { value: Number(left) ^ Number(right) };\n case '<<':\n return { value: Number(left) << Number(right) };\n case '>>':\n return { value: Number(left) >> Number(right) };\n case '>>>':\n return { value: Number(left) >>> Number(right) };\n default:\n return undefined;\n }\n}\n\nfunction compare(operator: string, left: Primitive, right: Primitive): boolean {\n // Two strings compare by code unit. Every other pair compares as numbers.\n if (typeof left === 'string' && typeof right === 'string') {\n switch (operator) {\n case '<':\n return left < right;\n case '<=':\n return left <= right;\n case '>':\n return left > right;\n default:\n return left >= right;\n }\n }\n const a = Number(left);\n const b = Number(right);\n switch (operator) {\n case '<':\n return a < b;\n case '<=':\n return a <= b;\n case '>':\n return a > b;\n default:\n return a >= b;\n }\n}\n\nfunction unary(operator: string, argument: Primitive): Const | undefined {\n switch (operator) {\n case '!':\n return { value: !argument };\n case 'typeof':\n return { value: typeof argument };\n case '+':\n return { value: Number(argument) };\n case '-':\n return { value: -Number(argument) };\n case '~':\n return { value: ~Number(argument) };\n case 'void':\n return { value: undefined };\n default:\n return undefined;\n }\n}\n\n/**\n * Evaluates `node` to a primitive, or returns `undefined` when it is not a\n * constant that evaluates without side effects.\n */\nexport function evaluate(node: Node, lookup: ConstantLookup): Const | undefined {\n switch (node.type) {\n case 'Literal':\n if (\n typeof node.value === 'string' ||\n typeof node.value === 'number' ||\n typeof node.value === 'boolean' ||\n node.value === null\n ) {\n // A regular expression whose flags the runtime does not support also has a `null` value.\n return 'regex' in node ? undefined : { value: node.value };\n }\n return undefined;\n case 'Identifier':\n case 'MemberExpression':\n return lookup(node);\n case 'ParenthesizedExpression':\n case 'TSAsExpression':\n case 'TSSatisfiesExpression':\n case 'TSNonNullExpression':\n return evaluate(node.expression, lookup);\n case 'TemplateLiteral': {\n let out = '';\n for (const [index, quasi] of node.quasis.entries()) {\n // A cooked value of `null` means an invalid escape, which only a tagged template allows.\n if (quasi.value.cooked === null) {\n return undefined;\n }\n out += quasi.value.cooked;\n const expression = node.expressions.at(index);\n if (expression) {\n const value = evaluate(expression, lookup);\n if (!value) {\n return undefined;\n }\n out += String(value.value);\n }\n }\n return { value: out };\n }\n case 'UnaryExpression': {\n if (node.operator === 'delete') {\n return undefined;\n }\n const argument = evaluate(node.argument, lookup);\n return argument ? unary(node.operator, argument.value) : undefined;\n }\n case 'BinaryExpression': {\n const left = evaluate(node.left, lookup);\n if (!left) {\n return undefined;\n }\n const right = evaluate(node.right, lookup);\n return right ? binary(node.operator, left.value, right.value) : undefined;\n }\n case 'LogicalExpression': {\n const left = evaluate(node.left, lookup);\n if (!left) {\n return undefined;\n }\n let shortCircuits: boolean;\n if (node.operator === '&&') {\n shortCircuits = !left.value;\n } else if (node.operator === '||') {\n shortCircuits = !!left.value;\n } else {\n shortCircuits = left.value != null;\n }\n return shortCircuits ? left : evaluate(node.right, lookup);\n }\n case 'ConditionalExpression': {\n const test = evaluate(node.test, lookup);\n if (!test) {\n return undefined;\n }\n return evaluate(test.value ? node.consequent : node.alternate, lookup);\n }\n default:\n return undefined;\n }\n}\n\n/**\n * Whether `node` is known to be truthy or falsy.\n *\n * This is wider than `evaluate`. An object, array, function, class, or JSX\n * value has no constant value but is always truthy.\n */\nexport function truthiness(node: Node, lookup: ConstantLookup): boolean | undefined {\n switch (node.type) {\n case 'ObjectExpression':\n case 'ArrayExpression':\n case 'ArrowFunctionExpression':\n case 'FunctionExpression':\n case 'ClassExpression':\n case 'JSXElement':\n case 'JSXFragment':\n return true;\n case 'ParenthesizedExpression':\n return truthiness(node.expression, lookup);\n case 'UnaryExpression':\n if (node.operator === '!') {\n const value = truthiness(node.argument, lookup);\n return value === undefined ? undefined : !value;\n }\n break;\n case 'SequenceExpression': {\n // A sequence evaluates to its last expression. A fold that keeps an\n // effectful condition leaves one in test position.\n const last = node.expressions.at(-1);\n return last ? truthiness(last, lookup) : undefined;\n }\n default:\n break;\n }\n const value = evaluate(node, lookup);\n return value ? !!value.value : undefined;\n}\n\n/**\n * Whether skipping `node` entirely loses nothing observable.\n *\n * Every fold that reads a condition also discards it. `truthiness` answers\n * what a value is worth. This answers whether producing it can be skipped.\n * `[effect()]` is always truthy, yet evaluating it runs a call.\n */\nexport function isSideEffectFree(node: Node): boolean {\n switch (node.type) {\n // Creating a function does not run its body.\n case 'Literal':\n case 'Identifier':\n case 'ThisExpression':\n case 'ArrowFunctionExpression':\n case 'FunctionExpression':\n return true;\n case 'ParenthesizedExpression':\n return isSideEffectFree(node.expression);\n case 'TemplateLiteral':\n return node.expressions.every(isSideEffectFree);\n case 'UnaryExpression':\n // `delete` changes its target.\n return node.operator !== 'delete' && isSideEffectFree(node.argument);\n case 'BinaryExpression':\n // `in` and `instanceof` read the right operand's prototype chain, which a\n // proxy or `Symbol.hasInstance` can observe.\n return (\n node.operator !== 'in' &&\n node.operator !== 'instanceof' &&\n isSideEffectFree(node.left) &&\n isSideEffectFree(node.right)\n );\n case 'LogicalExpression':\n return isSideEffectFree(node.left) && isSideEffectFree(node.right);\n case 'SequenceExpression':\n return node.expressions.every(isSideEffectFree);\n case 'ConditionalExpression':\n return (\n isSideEffectFree(node.test) &&\n isSideEffectFree(node.consequent) &&\n isSideEffectFree(node.alternate)\n );\n case 'ArrayExpression':\n // A spread iterates its argument, which is observable.\n return node.elements.every(\n (element) =>\n element === null || (element.type !== 'SpreadElement' && isSideEffectFree(element)),\n );\n case 'ObjectExpression':\n return node.properties.every(\n (property) =>\n // A spread reads the source's own properties, which a getter observes.\n property.type === 'Property' &&\n (!property.computed || isSideEffectFree(property.key)) &&\n isSideEffectFree(property.value),\n );\n default:\n // A class is never skippable. Evaluating one runs its heritage\n // expression, computed keys, static fields, and static blocks.\n return false;\n }\n}\n\n/**\n * The parts of `node` that must still run when its value is discarded.\n * A sequence is flattened, and every part that can be skipped is dropped.\n */\nexport function effectfulParts(node: Expression, parts: Expression[] = []): Expression[] {\n if (isSideEffectFree(node)) {\n return parts;\n }\n if (node.type === 'SequenceExpression') {\n for (const part of node.expressions) {\n effectfulParts(part, parts);\n }\n } else if (node.type === 'ParenthesizedExpression') {\n effectfulParts(node.expression, parts);\n } else {\n parts.push(node);\n }\n return parts;\n}\n\n/**\n * The element count of an array literal with no spread elements.\n */\nexport function arrayLiteralLength(node: Node): number | undefined {\n if (node.type === 'ParenthesizedExpression') {\n return arrayLiteralLength(node.expression);\n }\n if (node.type !== 'ArrayExpression') {\n return undefined;\n }\n if (node.elements.some((element) => element?.type === 'SpreadElement')) {\n return undefined;\n }\n return node.elements.length;\n}\n\n/**\n * The source text of a constant, or `undefined` when it has no literal\n * spelling worth emitting. `undefined`, `NaN`, the infinities, and `-0`\n * need an expression or a global that a local binding could shadow.\n */\nexport function literalText(value: Primitive): string | undefined {\n switch (typeof value) {\n case 'string':\n return JSON.stringify(value);\n case 'boolean':\n return String(value);\n case 'number':\n if (!Number.isFinite(value) || Object.is(value, -0)) {\n return undefined;\n }\n // A negative number is a unary expression. The parentheses keep it one\n // operand wherever it lands, such as `a - (-1)` or `(-1).toFixed()`.\n return value < 0 ? `(${String(value)})` : String(value);\n case 'object':\n return 'null';\n default:\n return undefined;\n }\n}\n\n/**\n * Whether `node` is already the spelling `literalText` would produce.\n * Folding it again would change nothing.\n */\nexport function isLiteralForm(node: Node): boolean {\n switch (node.type) {\n case 'Literal':\n return true;\n case 'UnaryExpression':\n return (\n node.operator === '-' &&\n node.argument.type === 'Literal' &&\n typeof node.argument.value === 'number'\n );\n case 'ParenthesizedExpression':\n return isLiteralForm(node.expression);\n default:\n return false;\n }\n}\n","/**\n * Constants bindings resolve to, within a module and across its imports.\n *\n * A module only sees its own code, so the values its imports resolve to come\n * from `importedConstants`, which a caller fills with `constantExports` of\n * each imported module.\n */\nimport type { MemberExpression, Node, Program } from 'oxc-parser';\nimport type { ResolvedOptions } from './context';\nimport { isConstantDeclaration } from './context';\nimport type { Binding, ScopeAnalysis } from './scope';\nimport { analyzeScopes } from './scope';\nimport type { Const, ConstantLookup, Primitive } from './value';\nimport { evaluate } from './value';\n\n/**\n * The constants each imported module exports, keyed by the import specifier\n * as the module writes it, then by export name.\n */\nexport type ImportedConstants = Readonly<Record<string, Readonly<Record<string, Primitive>>>>;\n\nexport type ResolvedImportedConstants = ReadonlyMap<string, ReadonlyMap<string, Const>>;\n\nexport function resolveImportedConstants(\n constants: ImportedConstants | undefined,\n): ResolvedImportedConstants {\n const result = new Map<string, Map<string, Const>>();\n for (const [source, exports] of Object.entries(constants ?? {})) {\n result.set(source, new Map(Object.entries(exports).map(([name, value]) => [name, { value }])));\n }\n return result;\n}\n\nfunction globalValue(name: string): Const | undefined {\n switch (name) {\n case 'undefined':\n return { value: undefined };\n case 'NaN':\n return { value: Number.NaN };\n case 'Infinity':\n return { value: Number.POSITIVE_INFINITY };\n default:\n return undefined;\n }\n}\n\n/**\n * Resolves identifier references to constants, caching each binding.\n */\nexport class ConstantTable {\n readonly lookup: ConstantLookup;\n\n private readonly constants = new Map<Binding, Const | null>();\n\n private readonly evaluating = new Set<Binding>();\n\n constructor(\n scopes: ScopeAnalysis,\n private readonly options: ResolvedOptions,\n ) {\n this.lookup = (reference) => {\n if (reference.type === 'MemberExpression') {\n return this.namespaceMember(scopes, reference) ?? this.globalMember(scopes, reference);\n }\n if (!scopes.references.has(reference) || reference.type !== 'Identifier') {\n return undefined;\n }\n const binding = scopes.references.get(reference);\n if (binding) {\n return this.constantOf(binding);\n }\n return this.globalConstant(reference.name) ?? globalValue(reference.name);\n };\n }\n\n private globalConstant(path: string): Const | undefined {\n const { globalConstants } = this.options;\n return globalConstants.has(path) ? { value: globalConstants.get(path) } : undefined;\n }\n\n /**\n * The value of a path like `import.meta.env.MODE` or `process.env.X` that\n * `globalConstants` holds. The path starts at `import.meta` or at a name\n * nothing declares, and goes through plain property reads.\n */\n private globalMember(scopes: ScopeAnalysis, node: MemberExpression): Const | undefined {\n if (this.options.globalConstants.size === 0) {\n return undefined;\n }\n const names: string[] = [];\n let current: Node = node;\n while (current.type === 'MemberExpression') {\n if (current.computed || current.optional || current.property.type !== 'Identifier') {\n return undefined;\n }\n names.unshift(current.property.name);\n current = current.object;\n }\n if (current.type === 'MetaProperty') {\n names.unshift(`${current.meta.name}.${current.property.name}`);\n } else if (\n current.type === 'Identifier' &&\n scopes.references.has(current) &&\n scopes.references.get(current) === undefined\n ) {\n names.unshift(current.name);\n } else {\n return undefined;\n }\n return this.globalConstant(names.join('.'));\n }\n\n /**\n * The value of `ns.NAME`, where `ns` is `import * as ns` from a module\n * whose constants are known.\n */\n private namespaceMember(scopes: ScopeAnalysis, node: MemberExpression): Const | undefined {\n const { object, property } = node;\n if (object.type !== 'Identifier' || node.optional) {\n return undefined;\n }\n const binding = scopes.references.get(object);\n if (binding?.kind !== 'import' || binding.imported !== '*' || binding.source === undefined) {\n return undefined;\n }\n let name: string | undefined;\n if (!node.computed && property.type === 'Identifier') {\n name = property.name;\n } else if (node.computed && property.type === 'Literal' && typeof property.value === 'string') {\n name = property.value;\n }\n return name === undefined\n ? undefined\n : this.options.importedConstants.get(binding.source)?.get(name);\n }\n\n /**\n * The value of a `const`, of a `let` nothing writes to, or of an import\n * whose module exports a known constant.\n *\n * A reference that runs before its declaration throws at runtime, and\n * folding turns it into the value. Minifiers make the same trade.\n */\n constantOf(binding: Binding): Const | undefined {\n const cached = this.constants.get(binding);\n if (cached !== undefined) {\n return cached ?? undefined;\n }\n let value: Const | undefined;\n const { declaration } = binding;\n if (binding.kind === 'import') {\n if (binding.source !== undefined && binding.imported !== undefined) {\n value = this.options.importedConstants.get(binding.source)?.get(binding.imported);\n }\n } else if (\n isConstantDeclaration(binding, this.options) &&\n declaration.type === 'VariableDeclarator' &&\n declaration.id === binding.identifier &&\n declaration.init &&\n !this.evaluating.has(binding)\n ) {\n this.evaluating.add(binding);\n value = evaluate(declaration.init, this.lookup);\n this.evaluating.delete(binding);\n }\n this.constants.set(binding, value ?? null);\n return value;\n }\n}\n\n/**\n * The modules `program` imports or re-exports bindings from. Their\n * constant exports are what `importedConstants` can hold.\n */\nexport function namedImportSources(program: Program): string[] {\n const sources = new Set<string>();\n for (const statement of program.body) {\n if (statement.type === 'ImportDeclaration') {\n if (\n statement.importKind !== 'type' &&\n statement.specifiers.some(\n (specifier) => !(specifier.type === 'ImportSpecifier' && specifier.importKind === 'type'),\n )\n ) {\n sources.add(statement.source.value);\n }\n } else if (\n (statement.type === 'ExportNamedDeclaration' && statement.source) ||\n (statement.type === 'ExportAllDeclaration' && !statement.exported)\n ) {\n if (statement.exportKind !== 'type' && statement.source) {\n sources.add(statement.source.value);\n }\n }\n }\n return [...sources];\n}\n\nfunction exportName(node: Node): string | undefined {\n if (node.type === 'Identifier') {\n return node.name;\n }\n if (node.type === 'Literal' && typeof node.value === 'string') {\n return node.value;\n }\n return undefined;\n}\n\n/**\n * The constants a module exports: `export const` bindings whose value folds,\n * and names exported from such a binding, or re-exported from a module in\n * `importedConstants`.\n *\n * A `let` counts when the module never writes to it, since nothing else can.\n */\nexport function constantExports(\n program: Program,\n options: ResolvedOptions,\n scopes: ScopeAnalysis = analyzeScopes(program),\n): Record<string, Primitive> {\n const table = new ConstantTable(scopes, options);\n const topLevel = scopes.root;\n const result: Record<string, Primitive> = {};\n const add = (name: string | undefined, value: Const | undefined): void => {\n if (name !== undefined && value) {\n result[name] = value.value;\n }\n };\n const starSources: string[] = [];\n for (const statement of program.body) {\n if (statement.type === 'ExportDefaultDeclaration') {\n const { declaration } = statement;\n if (declaration.type !== 'FunctionDeclaration' && declaration.type !== 'ClassDeclaration') {\n add('default', evaluate(declaration, table.lookup));\n }\n continue;\n }\n if (statement.type === 'ExportAllDeclaration') {\n if (!statement.exported && statement.exportKind !== 'type') {\n starSources.push(statement.source.value);\n }\n continue;\n }\n if (statement.type !== 'ExportNamedDeclaration' || statement.exportKind === 'type') {\n continue;\n }\n const { declaration } = statement;\n if (declaration?.type === 'VariableDeclaration') {\n for (const declarator of declaration.declarations) {\n if (declarator.id.type === 'Identifier') {\n const binding = topLevel.bindings.get(declarator.id.name);\n add(declarator.id.name, binding ? table.constantOf(binding) : undefined);\n }\n }\n continue;\n }\n for (const specifier of statement.specifiers) {\n if (specifier.exportKind === 'type') {\n continue;\n }\n const local = exportName(specifier.local);\n const exported = exportName(specifier.exported);\n if (local === undefined) {\n continue;\n }\n if (statement.source) {\n add(exported, options.importedConstants.get(statement.source.value)?.get(local));\n } else {\n const binding = topLevel.bindings.get(local);\n add(exported, binding ? table.constantOf(binding) : undefined);\n }\n }\n }\n // `export *` never re-exports `default`, and loses to a name the module\n // exports itself. A name two of them export is ambiguous, so neither counts.\n const explicit = new Set(Object.keys(result));\n const starred = new Map<string, Const | null>();\n for (const source of starSources) {\n for (const [name, value] of options.importedConstants.get(source) ?? []) {\n if (name !== 'default' && !explicit.has(name)) {\n starred.set(name, starred.has(name) ? null : value);\n }\n }\n }\n for (const [name, value] of starred) {\n add(name, value ?? undefined);\n }\n return result;\n}\n","/**\n * Helpers for replacing JSX children as text.\n *\n * Adjacent JSX text is one text node to the parser, and JSX trims a text\n * node as a whole: `a` and `b` on separate lines render as `ab` when an\n * element sits between them, but as `a b` once they are one text node. So\n * whenever a replacement would put two texts that were apart next to each\n * other, an empty `{}` keeps them apart.\n */\nimport type { JSXAttribute, JSXChild, JSXElement, JSXFragment, JSXText, Node } from 'oxc-parser';\nimport { isFilteredText } from './ast';\nimport type MagicString from 'magic-string';\n\n/**\n * What a JSX child turns into.\n */\nexport interface Piece {\n /** The child the piece replaces. */\n readonly node: JSXChild;\n /** The replacement text, or `undefined` to keep the child as written. */\n text: string | undefined;\n /** The JSX text the replacement starts with. */\n startText: JSXText | undefined;\n /** The JSX text the replacement ends with. */\n endText: JSXText | undefined;\n}\n\nexport function keptPiece(node: JSXChild): Piece {\n const text = node.type === 'JSXText' ? node : undefined;\n return { node, text: undefined, startText: text, endText: text };\n}\n\n/**\n * A piece that splices `children` in place of `node`.\n */\nexport function splicePiece(s: MagicString, node: JSXChild, children: readonly JSXChild[]): Piece {\n const first = children.at(0);\n const last = children.at(-1);\n if (!first || !last) {\n return replacedPiece(node, '');\n }\n return {\n node,\n text: s.slice(first.start, last.end),\n startText: first.type === 'JSXText' ? first : undefined,\n endText: last.type === 'JSXText' ? last : undefined,\n };\n}\n\nexport function replacedPiece(node: JSXChild, text: string): Piece {\n return { node, text, startText: undefined, endText: undefined };\n}\n\n/**\n * Whether two texts render differently as one text node than apart.\n * Two texts that JSX drops, like line breaks and indentation, still drop together.\n */\nfunction mergeChangesText(before: JSXText | undefined, after: JSXText | undefined): boolean {\n return (\n before !== undefined &&\n after !== undefined &&\n !(isFilteredText(before) && isFilteredText(after))\n );\n}\n\n/**\n * Puts `{}` between two pieces that meet as text, on whichever side is replaced.\n */\nfunction separate(previous: Piece, next: Piece, emptiesBetween: readonly Piece[]): void {\n if (next.text !== undefined) {\n next.text = `{}${next.text}`;\n next.startText = undefined;\n return;\n }\n if (previous.text !== undefined) {\n previous.text = `${previous.text}{}`;\n previous.endText = undefined;\n return;\n }\n // Two kept texts only meet across a removed child.\n const empty = emptiesBetween.at(-1);\n if (empty) {\n empty.text = '{}';\n }\n}\n\n/**\n * Writes the replaced pieces of a child list, adding `{}` wherever two texts\n * would otherwise merge.\n */\nexport function writePieces(s: MagicString, pieces: readonly Piece[]): boolean {\n let changed = false;\n // The last piece that renders anything, and the empty pieces after it.\n let previous: Piece | undefined;\n let emptiesSincePrevious: Piece[] = [];\n for (const piece of pieces) {\n if (piece.text === '') {\n emptiesSincePrevious.push(piece);\n continue;\n }\n if (previous && mergeChangesText(previous.endText, piece.startText)) {\n separate(previous, piece, emptiesSincePrevious);\n }\n previous = piece;\n emptiesSincePrevious = [];\n }\n for (const piece of pieces) {\n if (piece.text === undefined) {\n continue;\n }\n changed = true;\n if (piece.text === '') {\n s.remove(piece.node.start, piece.node.end);\n } else {\n s.overwrite(piece.node.start, piece.node.end, piece.text);\n }\n }\n return changed;\n}\n\nexport function findAttribute(element: JSXElement, name: string): JSXAttribute | undefined {\n for (const attribute of element.openingElement.attributes) {\n if (\n attribute.type === 'JSXAttribute' &&\n attribute.name.type === 'JSXIdentifier' &&\n attribute.name.name === name\n ) {\n return attribute;\n }\n }\n return undefined;\n}\n\nexport function hasSpreadAttribute(element: JSXElement): boolean {\n return element.openingElement.attributes.some(\n (attribute) => attribute.type === 'JSXSpreadAttribute',\n );\n}\n\n/**\n * Whether any child is a function, which the runtime may call with the\n * narrowed value. Folding one away would drop that call.\n */\nexport function hasCallbackChild(children: readonly JSXChild[]): boolean {\n return children.some((child) => {\n if (child.type !== 'JSXExpressionContainer') {\n return false;\n }\n let expression: Node = child.expression;\n while (expression.type === 'ParenthesizedExpression') {\n expression = expression.expression;\n }\n return (\n expression.type === 'ArrowFunctionExpression' || expression.type === 'FunctionExpression'\n );\n });\n}\n\n/**\n * The text between an element's tags, or an empty string for a self-closing element.\n */\nexport function innerText(s: MagicString, node: JSXElement | JSXFragment): string {\n if (node.type === 'JSXFragment') {\n return s.slice(node.openingFragment.end, node.closingFragment.start);\n }\n if (!node.closingElement) {\n return '';\n }\n return s.slice(node.openingElement.end, node.closingElement.start);\n}\n","/**\n * Estimates how many bytes code takes once Solid's JSX transform has\n * lowered it and a minifier has compacted it.\n *\n * The inline pass compares the call sites of a component with the copies\n * that would replace them. A copy merges its elements into the template\n * around it and drops the component call, but repeats the component's own\n * code at every call. The estimate only has to rank the two, so it counts\n * what lowering adds to the JSX as written:\n *\n * - each template: its declaration and the clone that renders it;\n * - each dynamic attribute, child, spread, or event handler of an element:\n * the effect or `insert` that sets it, and the walk to its element;\n * - each component element: the `createComponent` call, and a getter for\n * each prop that is not a literal.\n *\n * Other code counts as its text without the whitespace a minifier removes.\n */\nimport type {\n Expression,\n JSXAttribute,\n JSXAttributeItem,\n JSXChild,\n JSXElement,\n JSXElementName,\n JSXEmptyExpression,\n JSXFragment,\n Node,\n} from 'oxc-parser';\nimport { forEachChild, isInsignificant, isIntrinsicTag, unwrap } from './ast';\n\n/** A template's declaration, and the function that clones and returns it. */\nconst TEMPLATE = 40;\n/** A walk to an element, like `e.firstChild.nextSibling`. */\nconst WALK = 12;\n/** An `insert()` of a dynamic child. */\nconst INSERT = 12;\n/** A render effect that sets an attribute, like `createRenderEffect(() => setAttribute(...))`. */\nconst EFFECT = 24;\n/** An event handler assignment, like `e.$$click = ...`. */\nconst HANDLER = 10;\n/** A `spread()` of props onto an element. */\nconst SPREAD = 16;\n/** A `createComponent(Name, {})` call. */\nconst COMPONENT = 8;\n/** A getter, `get name() { return ... }`. */\nconst GETTER = 16;\n/** A `mergeProps()` around the props of a component with a spread. */\nconst MERGE = 6;\n\n/**\n * The length of `text` once a minifier removes the whitespace it does not need.\n */\nexport function compactLength(text: string): number {\n return text.replaceAll(/\\s*([{}()[\\];,:=<>+\\-*/?&|!.])\\s*/g, '$1').replaceAll(/\\s+/g, ' ').length;\n}\n\nfunction nameLength(name: JSXElementName): number {\n switch (name.type) {\n case 'JSXIdentifier':\n return name.name.length;\n case 'JSXNamespacedName':\n return name.namespace.name.length + name.name.name.length + 1;\n case 'JSXMemberExpression':\n return nameLength(name.object) + name.property.name.length + 1;\n default:\n return 4;\n }\n}\n\n/** Whether an expression lowers to text in the template, like a literal. */\nfunction isStaticText(node: Expression | JSXEmptyExpression): boolean {\n if (node.type === 'JSXEmptyExpression') {\n return false;\n }\n const inner = unwrap(node);\n if (inner.type === 'Literal') {\n return typeof inner.value === 'string' || typeof inner.value === 'number';\n }\n if (inner.type === 'TemplateLiteral') {\n return inner.expressions.length === 0;\n }\n return (\n inner.type === 'UnaryExpression' &&\n inner.operator === '-' &&\n inner.argument.type === 'Literal' &&\n typeof inner.argument.value === 'number'\n );\n}\n\nfunction isIntrinsic(element: JSXElement): boolean {\n const { name } = element.openingElement;\n return name.type === 'JSXIdentifier' && isIntrinsicTag(name.name);\n}\n\nfunction attributeName(attribute: JSXAttribute): string {\n const { name } = attribute;\n return name.type === 'JSXIdentifier' ? name.name : `${name.namespace.name}:${name.name.name}`;\n}\n\n/**\n * Estimates lowered sizes in one piece of code.\n */\nexport class SizeEstimator {\n constructor(private readonly code: string) {}\n\n private text(node: Node): number {\n return compactLength(this.code.slice(node.start, node.end));\n }\n\n /**\n * The size of any node: JSX as lowered, other code as its compact text\n * with the JSX in it as lowered.\n */\n node(node: Node): number {\n if (node.type === 'JSXElement' || node.type === 'JSXFragment') {\n return this.jsx(node, false);\n }\n let size = this.text(node);\n const visit = (child: Node): void => {\n if (child.type === 'JSXElement' || child.type === 'JSXFragment') {\n size += this.jsx(child, false) - this.text(child);\n return;\n }\n forEachChild(child, visit);\n };\n forEachChild(node, visit);\n return size;\n }\n\n /**\n * The size of a JSX element or fragment. `inTemplate` is whether it sits\n * directly in an element, whose template it joins.\n */\n jsx(node: JSXElement | JSXFragment, inTemplate: boolean): number {\n if (node.type === 'JSXFragment') {\n return this.children(node.children) + 2;\n }\n if (!isIntrinsic(node)) {\n return (inTemplate ? INSERT + WALK : 0) + this.component(node);\n }\n const tag = nameLength(node.openingElement.name);\n let size = (inTemplate ? 0 : TEMPLATE) + tag * 2 + 5;\n let dynamic = false;\n for (const attribute of node.openingElement.attributes) {\n const cost = this.elementAttribute(attribute);\n size += cost.size;\n dynamic ||= cost.dynamic;\n }\n for (const child of node.children) {\n if (isInsignificant(child)) {\n continue;\n }\n if (child.type === 'JSXText') {\n size += compactLength(child.value);\n } else if (child.type === 'JSXExpressionContainer' && isStaticText(child.expression)) {\n // A literal child is written into the template as text.\n size += this.text(child.expression);\n } else if (child.type === 'JSXElement') {\n size += this.jsx(child, true);\n } else {\n size += INSERT + this.child(child);\n dynamic = true;\n }\n }\n return size + (dynamic ? WALK : 0);\n }\n\n private elementAttribute(attribute: JSXAttributeItem): { size: number; dynamic: boolean } {\n if (attribute.type === 'JSXSpreadAttribute') {\n return { size: SPREAD + this.node(attribute.argument), dynamic: true };\n }\n const name = attributeName(attribute);\n const { value } = attribute;\n if (!value || value.type === 'Literal') {\n return { size: name.length + (value ? this.text(value) : 0) + 1, dynamic: false };\n }\n if (value.type !== 'JSXExpressionContainer') {\n return { size: name.length + 1 + this.jsx(value, false), dynamic: true };\n }\n const { expression } = value;\n if (expression.type === 'JSXEmptyExpression') {\n return { size: 0, dynamic: false };\n }\n const inner = unwrap(expression);\n // A literal in braces lowers like a quoted value.\n if (\n inner.type === 'Literal' ||\n (inner.type === 'TemplateLiteral' && inner.expressions.length === 0)\n ) {\n return { size: name.length + this.text(inner) + 1, dynamic: false };\n }\n const extra = /^on[A-Z:]/.test(name) || name === 'ref' ? HANDLER : EFFECT;\n return { size: extra + name.length + this.node(inner), dynamic: true };\n }\n\n private child(child: JSXChild): number {\n if (child.type === 'JSXExpressionContainer') {\n return child.expression.type === 'JSXEmptyExpression' ? 0 : this.node(child.expression);\n }\n if (child.type === 'JSXSpreadChild') {\n return this.node(child.expression);\n }\n if (child.type === 'JSXText') {\n return compactLength(child.value) + 2;\n }\n return this.jsx(child, false);\n }\n\n /**\n * Children outside a template, which lower to an array of values.\n */\n private children(children: readonly JSXChild[]): number {\n let size = 0;\n for (const child of children) {\n if (!isInsignificant(child)) {\n size += this.child(child) + 1;\n }\n }\n return size;\n }\n\n private component(element: JSXElement): number {\n let size = COMPONENT + nameLength(element.openingElement.name);\n let spread = false;\n for (const attribute of element.openingElement.attributes) {\n if (attribute.type === 'JSXSpreadAttribute') {\n spread = true;\n size += this.node(attribute.argument) + 1;\n continue;\n }\n const name = attributeName(attribute);\n const { value } = attribute;\n if (!value || value.type === 'Literal') {\n size += name.length + 1 + (value ? this.text(value) : 4);\n } else if (value.type === 'JSXExpressionContainer') {\n const { expression } = value;\n if (expression.type !== 'JSXEmptyExpression') {\n const inner = unwrap(expression);\n const literal =\n inner.type === 'Literal' ||\n inner.type === 'Identifier' ||\n inner.type === 'ArrowFunctionExpression' ||\n inner.type === 'FunctionExpression';\n size += name.length + 1 + (literal ? 0 : GETTER) + this.node(inner);\n }\n } else {\n size += name.length + GETTER + this.jsx(value, false);\n }\n }\n const significant = element.children.filter((child) => !isInsignificant(child));\n if (significant.length > 0) {\n size += GETTER + 'children'.length + this.children(significant);\n }\n return size + (spread ? MERGE : 0);\n }\n\n /**\n * The size of what a component returns. JSX lowers as JSX, and anything\n * else is inserted when it sits in an element.\n */\n root(node: Expression, inTemplate: boolean): number {\n const inner = unwrap(node);\n if (inner.type === 'JSXElement' || inner.type === 'JSXFragment') {\n return this.jsx(inner, inTemplate);\n }\n return (inTemplate ? INSERT + WALK : 0) + this.node(inner);\n }\n}\n","/**\n * The fold pass: constant folding, dead-code elimination, and static\n * resolution of Solid's control-flow components.\n *\n * It runs on JSX before it is lowered, so whatever it resolves never reaches\n * the JSX transform. A `<Show>` whose condition is a constant becomes its\n * branch, and the branch joins the surrounding template instead of paying for\n * a component call, a memo, and an insert.\n *\n * This is a port of the `optimize` option of `@solidjs/compiler`\n * (https://github.com/solidjs/solid/pull/3231).\n *\n * # What folds\n *\n * - Constant expressions: literals, template literals, and the unary, binary,\n * logical, and conditional operators over them.\n * - `const` bindings, and `let` bindings nothing writes to, at any scope.\n * - Statements a constant condition makes unreachable: `if`/`else` branches,\n * `while (false)` loops, and anything after a `return`, `throw`, `break`,\n * or `continue`.\n * - A call of an arrow function whose body is JSX, with constant arguments,\n * as an element's child. The call becomes the JSX with the arguments in\n * place of the parameters, so it joins the template around it.\n * - `<For>` over a constant list, which becomes one copy of its row per\n * item when the copies are no larger than the loop.\n * - `<Show when>`, `<For each>`, `<Repeat count>`, `<Switch>`/`<Match when>`,\n * and `<Dynamic component>` with a static intrinsic tag name or a\n * component declared at the top level that nothing reassigns.\n *\n * # What does not fold\n *\n * `<Portal>`, `<Loading>`, `<Errored>`, and `<Reveal>` exist for a runtime\n * condition no static analysis can decide. A control-flow component with a\n * spread attribute is left alone, since the spread can supply or override the\n * prop the fold reads. Function children also stop a fold, since the runtime\n * decides from their arity whether to call them.\n */\nimport type {\n CallExpression,\n ConditionalExpression,\n Directive,\n Expression,\n IdentifierReference,\n IfStatement,\n JSXChild,\n JSXElement,\n JSXEmptyExpression,\n JSXFragment,\n LogicalExpression,\n Node,\n Statement,\n WhileStatement,\n} from 'oxc-parser';\nimport MagicString from 'magic-string';\nimport type { Parents } from './ast';\nimport {\n forEachChild,\n isInsignificant,\n isIntrinsicTag,\n isJSXChild,\n isPrimary,\n needsParensAt,\n parse,\n startsLikeStatement,\n} from './ast';\nimport type { PassContext } from './context';\nimport { ConstantTable } from './constants';\nimport { isConstantDeclaration, solidExport, textOf } from './context';\nimport type { Piece } from './jsx';\nimport {\n findAttribute,\n hasCallbackChild,\n hasSpreadAttribute,\n innerText,\n keptPiece,\n replacedPiece,\n splicePiece,\n writePieces,\n} from './jsx';\nimport type { Binding } from './scope';\nimport { lookup, scopeAt } from './scope';\nimport { SizeEstimator, compactLength } from './size';\nimport type { ConstantLookup } from './value';\nimport {\n arrayLiteralLength,\n effectfulParts,\n evaluate,\n isLiteralForm,\n isSideEffectFree,\n literalText,\n truthiness,\n} from './value';\n\n/**\n * The control-flow components this pass resolves.\n * `Match` is absent: it only has meaning inside a `<Switch>`, which folds it.\n */\nconst FOLDABLE_FLOW = new Set(['Show', 'For', 'Repeat', 'Switch', 'Dynamic']);\n\n/**\n * What a resolved control-flow element renders in its place.\n */\ntype Fold =\n /** JSX children, spliced in. */\n | { readonly kind: 'children'; readonly children: readonly JSXChild[] }\n /** An element or fragment, as source text. */\n | { readonly kind: 'jsx'; readonly text: string }\n /** An expression, such as a `fallback` prop's value. */\n | {\n readonly kind: 'expression';\n readonly text: string;\n readonly primary: boolean;\n }\n | { readonly kind: 'empty' };\n\nconst EMPTY: Fold = { kind: 'empty' };\n\n/** Solid's calls that only create a value, so the bundler can drop an unused one. */\nconst PURE_CALLS = new Set(['lazy', 'createContext']);\n\n/**\n * The globals worth folding. They only apply to a reference that binds to\n * nothing, which is when the global is what runs.\n */\n/**\n * Whether `node` is written to: assigned, updated, deleted, or destructured into.\n */\nfunction isWriteTarget(node: Node, parents: Parents): boolean {\n let current = node;\n let parent = parents.get(current);\n // A destructuring pattern writes to every target inside it.\n while (\n parent &&\n (parent.type === 'ArrayPattern' ||\n parent.type === 'ObjectPattern' ||\n parent.type === 'RestElement' ||\n parent.type === 'AssignmentPattern' ||\n (parent.type === 'Property' && parents.get(parent)?.type === 'ObjectPattern'))\n ) {\n if (parent.type === 'AssignmentPattern' && parent.left !== current) {\n return false;\n }\n current = parent;\n parent = parents.get(current);\n }\n if (!parent) {\n return false;\n }\n switch (parent.type) {\n case 'AssignmentExpression':\n return parent.left === current;\n case 'UpdateExpression':\n return true;\n case 'UnaryExpression':\n return parent.operator === 'delete';\n case 'ForInStatement':\n case 'ForOfStatement':\n return parent.left === current;\n default:\n return current !== node;\n }\n}\n\nfunction isTerminator(statement: Node): boolean {\n return (\n statement.type === 'ReturnStatement' ||\n statement.type === 'ThrowStatement' ||\n statement.type === 'BreakStatement' ||\n statement.type === 'ContinueStatement'\n );\n}\n\n/**\n * Whether removing `statement` would remove a `var` or function declaration\n * that is hoisted out of it. Nested functions are their own scope.\n */\nfunction containsHoistedDeclaration(statement: Node): boolean {\n let found = false;\n const visit = (node: Node): void => {\n if (found) {\n return;\n }\n if (node.type === 'VariableDeclaration' && node.kind === 'var') {\n found = true;\n return;\n }\n if (node.type === 'FunctionDeclaration') {\n found = true;\n return;\n }\n if (\n node.type === 'FunctionExpression' ||\n node.type === 'ArrowFunctionExpression' ||\n node.type === 'ClassDeclaration' ||\n node.type === 'ClassExpression'\n ) {\n return;\n }\n forEachChild(node, visit);\n };\n visit(statement);\n return found;\n}\n\n/**\n * Whether a statement starting with `text` could join the statement before\n * it when that one has no semicolon.\n */\nfunction continuesPreviousStatement(text: string): boolean {\n return /^[([`+\\-/]/.test(text);\n}\n\n/** The name a property key or a computed member's string literal gives. */\nfunction keyName(node: Node): string | undefined {\n if (node.type === 'Identifier') {\n return node.name;\n }\n return node.type === 'Literal' && typeof node.value === 'string' ? node.value : undefined;\n}\n\ntype ConstantItem =\n | { readonly kind: 'primitive'; readonly text: string }\n | { readonly kind: 'object'; readonly keys: ReadonlyMap<string, string> };\n\n/**\n * The text of an expression that always gives the same primitive: a literal\n * other than a regular expression, a template literal without expressions,\n * or a negated number.\n */\nfunction primitiveText(context: PassContext, node: Expression): string | undefined {\n let expression: Expression = node;\n while (expression.type === 'ParenthesizedExpression') {\n expression = expression.expression;\n }\n switch (expression.type) {\n case 'Literal':\n return 'regex' in expression ? undefined : textOf(context, expression);\n case 'TemplateLiteral':\n return expression.expressions.length === 0 ? textOf(context, expression) : undefined;\n case 'UnaryExpression':\n return expression.operator === '-' &&\n expression.argument.type === 'Literal' &&\n typeof expression.argument.value === 'number'\n ? textOf(context, expression)\n : undefined;\n default:\n return undefined;\n }\n}\n\n/** Whether a child of `parent` is inserted into its template, not passed as a prop. */\nfunction joinsTemplate(parent: JSXElement | JSXFragment): boolean {\n if (parent.type === 'JSXFragment') {\n return true;\n }\n const { name } = parent.openingElement;\n return name.type === 'JSXIdentifier' && isIntrinsicTag(name.name);\n}\n\n/**\n * Whether JSX holds a `ref` or a spread, which run while the JSX is made.\n */\nfunction hasRefOrSpread(root: Node): boolean {\n let found = false;\n const visit = (node: Node): void => {\n if (found) {\n return;\n }\n if (\n node.type === 'JSXSpreadAttribute' ||\n node.type === 'JSXSpreadChild' ||\n (node.type === 'JSXAttribute' &&\n node.name.type === 'JSXIdentifier' &&\n node.name.name === 'ref')\n ) {\n found = true;\n return;\n }\n forEachChild(node, visit);\n };\n visit(root);\n return found;\n}\n\nclass Folder {\n changed = false;\n\n private readonly lookup: ConstantLookup;\n\n constructor(private readonly context: PassContext) {\n this.lookup = new ConstantTable(context.scopes, context.options).lookup;\n }\n\n // ---------------------------------------------------------------------------\n // Traversal\n // ---------------------------------------------------------------------------\n\n walk(node: Node): void {\n forEachChild(node, (child) => {\n this.walk(child);\n });\n this.exit(node);\n }\n\n private exit(node: Node): void {\n switch (node.type) {\n case 'Program':\n case 'BlockStatement':\n case 'StaticBlock':\n this.eliminateDeadStatements(node.body);\n break;\n case 'SwitchCase':\n this.eliminateDeadStatements(node.consequent);\n break;\n case 'JSXElement':\n this.foldChildren(node);\n if (!this.isJSXChildOrAttribute(node)) {\n this.foldFlowExpression(node);\n }\n break;\n case 'JSXFragment':\n this.foldChildren(node);\n break;\n case 'LogicalExpression':\n this.foldLogical(node);\n break;\n case 'ConditionalExpression':\n this.foldConditional(node);\n break;\n case 'Identifier':\n if (this.context.scopes.references.has(node)) {\n this.foldConstant(node);\n }\n break;\n case 'TemplateLiteral':\n // A tagged template passes its strings to the tag, so they are not constants.\n if (this.context.parents.get(node)?.type !== 'TaggedTemplateExpression') {\n this.foldConstant(node);\n }\n break;\n case 'UnaryExpression':\n case 'BinaryExpression':\n case 'ParenthesizedExpression':\n this.foldConstant(node);\n break;\n case 'MemberExpression':\n // Only a read folds. Writing to a namespace member throws, so it stays.\n if (!isWriteTarget(node, this.context.parents)) {\n this.foldConstant(node);\n }\n break;\n case 'CallExpression':\n this.annotatePure(node);\n break;\n default:\n break;\n }\n }\n\n private isJSXChildOrAttribute(node: Node): boolean {\n return (\n isJSXChild(node, this.context.parents) ||\n this.context.parents.get(node)?.type === 'JSXAttribute'\n );\n }\n\n private replace(node: Node, text: string): void {\n if (textOf(this.context, node) === text) {\n return;\n }\n this.context.s.overwrite(node.start, node.end, text);\n this.changed = true;\n }\n\n // ---------------------------------------------------------------------------\n // Expressions\n // ---------------------------------------------------------------------------\n\n /**\n * Marks a call to Solid's `lazy` or `createContext` as pure. `lazy` only\n * creates the component, and loads nothing until it renders. A folded\n * branch can leave it unused, and the annotation lets the bundler drop it\n * along with its dynamic import. `createContext` only creates the context,\n * which inlining can leave unused.\n */\n private annotatePure(call: CallExpression): void {\n if (call.callee.type !== 'Identifier') {\n return;\n }\n const binding = this.context.scopes.references.get(call.callee);\n const identity = binding ? solidExport(binding, this.context.options) : undefined;\n if (identity === undefined || !PURE_CALLS.has(identity)) {\n return;\n }\n const before = this.context.code.slice(0, call.start).trimEnd();\n if (/(#|@)__PURE__\\s*\\*\\/$/.test(before)) {\n return;\n }\n this.context.s.prependLeft(call.start, '/* @__PURE__ */ ');\n this.changed = true;\n }\n\n private foldConstant(node: Node): void {\n if (isLiteralForm(node)) {\n return;\n }\n const value = evaluate(node, this.lookup);\n if (!value) {\n return;\n }\n let text = literalText(value.value);\n if (text === undefined) {\n return;\n }\n const parent = this.context.parents.get(node);\n if (node.type === 'Identifier') {\n // `export { A }` names the binding, not its value.\n if (parent?.type === 'ExportSpecifier') {\n return;\n }\n // `{ enabled }` cannot stay shorthand once its value is a literal.\n if (parent?.type === 'Property' && parent.shorthand) {\n this.replace(node, `${node.name}: ${text}`);\n return;\n }\n }\n if (\n parent?.type === 'MemberExpression' &&\n parent.object === node &&\n typeof value.value === 'number' &&\n !text.startsWith('(')\n ) {\n // `1.toFixed()` does not parse.\n text = `(${text})`;\n }\n if (parent?.type === 'ExpressionStatement' && typeof value.value === 'string') {\n // A string at the start of a statement can turn into a directive.\n text = `(${text})`;\n }\n this.replace(node, text);\n }\n\n /**\n * Keeps `value`, evaluating `discarded` first when it has side effects.\n * `(discarded, value)` runs it in the same order and yields the same result.\n */\n private keepAfter(target: Node, discarded: Expression | undefined, value: Expression): string {\n const parts = discarded ? effectfulParts(discarded) : [];\n if (parts.length === 0) {\n const text = textOf(this.context, value);\n return needsParensAt(target, value, this.context.parents) ? `(${text})` : text;\n }\n const texts = parts.map((part) => textOf(this.context, part));\n texts.push(textOf(this.context, value));\n return `(${texts.join(', ')})`;\n }\n\n private foldLogical(node: LogicalExpression): void {\n const left = truthiness(node.left, this.lookup);\n if (left === undefined) {\n return;\n }\n let takesLeft: boolean;\n if (node.operator === '&&') {\n takesLeft = !left;\n } else if (node.operator === '||') {\n takesLeft = left;\n } else {\n // `??` depends on nullishness, not truthiness, so it only folds against a constant.\n const value = evaluate(node.left, this.lookup);\n if (!value) {\n return;\n }\n takesLeft = value.value != null;\n }\n // The side a short-circuit never reaches never runs, so dropping it is free.\n // The side that does run has to be skippable before the other replaces it.\n if (takesLeft) {\n this.replace(node, this.keepAfter(node, undefined, node.left));\n } else {\n const discarded = this.isSkippable(node.left) ? undefined : node.left;\n this.replace(node, this.keepAfter(node, discarded, node.right));\n }\n }\n\n /**\n * Whether dropping `node` changes nothing. An expression that evaluates to\n * a constant only reads bindings and runs operators on primitives.\n */\n private isSkippable(node: Expression): boolean {\n return isSideEffectFree(node) || evaluate(node, this.lookup) !== undefined;\n }\n\n private foldConditional(node: ConditionalExpression): void {\n const test = truthiness(node.test, this.lookup);\n if (test === undefined) {\n return;\n }\n const discarded = this.isSkippable(node.test) ? undefined : node.test;\n this.replace(node, this.keepAfter(node, discarded, test ? node.consequent : node.alternate));\n }\n\n // ---------------------------------------------------------------------------\n // Control-flow components\n // ---------------------------------------------------------------------------\n\n /**\n * The Solid built-in a tag refers to.\n *\n * Being in `builtIns` only makes a name a candidate. The tag has to resolve\n * to Solid's own component: a tag that binds to nothing is the built-in the\n * JSX transform imports, and an import from a Solid module is decided by\n * the name the module exports, so `<Cond>` from `import { Show as Cond }` is\n * `Show`. A local `Show` or one from another module is a different component.\n */\n private builtInTag(element: JSXElement): string | undefined {\n const { name } = element.openingElement;\n if (name.type !== 'JSXIdentifier') {\n return undefined;\n }\n const { references } = this.context.scopes;\n if (!references.has(name)) {\n return undefined;\n }\n const binding = references.get(name);\n const identity = binding ? solidExport(binding, this.context.options) : name.name;\n if (identity === undefined || !this.context.options.builtIns.has(identity)) {\n return undefined;\n }\n return identity;\n }\n\n /**\n * The name of the component an identifier refers to, when it is a\n * capitalized top-level binding nothing reassigns, holding a function or a\n * `lazy` component. A JSX tag with that name calls the same component. An\n * import could hold anything, such as a tag name string, so it is left out.\n */\n private componentName(identifier: IdentifierReference): string | undefined {\n const binding = this.context.scopes.references.get(identifier);\n if (\n !binding ||\n binding.mutated ||\n binding.scope.parent !== undefined ||\n !/^[A-Z]/.test(binding.name)\n ) {\n return undefined;\n }\n const { declaration } = binding;\n if (declaration.type === 'FunctionDeclaration') {\n return declaration.async || declaration.generator ? undefined : binding.name;\n }\n if (\n declaration.type !== 'VariableDeclarator' ||\n declaration.id !== binding.identifier ||\n !declaration.init ||\n !isConstantDeclaration(binding, this.context.options)\n ) {\n return undefined;\n }\n let init: Expression = declaration.init;\n while (init.type === 'ParenthesizedExpression') {\n init = init.expression;\n }\n if (init.type === 'ArrowFunctionExpression' || init.type === 'FunctionExpression') {\n return init.async || init.generator ? undefined : binding.name;\n }\n if (init.type === 'CallExpression' && init.callee.type === 'Identifier') {\n const callee = this.context.scopes.references.get(init.callee);\n return callee && solidExport(callee, this.context.options) === 'lazy'\n ? binding.name\n : undefined;\n }\n return undefined;\n }\n\n private flowTag(element: JSXElement): string | undefined {\n const tag = this.builtInTag(element);\n return tag !== undefined && FOLDABLE_FLOW.has(tag) ? tag : undefined;\n }\n\n private foldFlow(element: JSXElement): Fold | undefined {\n const tag = this.flowTag(element);\n if (tag === undefined || hasSpreadAttribute(element)) {\n return undefined;\n }\n switch (tag) {\n case 'Show':\n return this.foldShow(element);\n case 'For':\n return this.foldFor(element);\n case 'Repeat':\n return this.foldRepeat(element);\n case 'Switch':\n return this.foldSwitch(element);\n case 'Dynamic':\n return this.foldDynamic(element);\n default:\n return undefined;\n }\n }\n\n /**\n * Whether a prop is statically truthy or falsy. A bare attribute is `true`.\n * The prop is discarded by the fold, so it also has to be skippable.\n */\n private attributeTruthiness(element: JSXElement, name: string): boolean | undefined {\n const attribute = findAttribute(element, name);\n if (!attribute) {\n return undefined;\n }\n const { value } = attribute;\n if (value === null) {\n return true;\n }\n switch (value.type) {\n case 'Literal':\n return value.value !== '';\n case 'JSXElement':\n case 'JSXFragment':\n return true;\n default:\n if (value.expression.type === 'JSXEmptyExpression' || !isSideEffectFree(value.expression)) {\n return undefined;\n }\n return truthiness(value.expression, this.lookup);\n }\n }\n\n /**\n * What the element renders when its condition fails: its `fallback` prop, or nothing.\n */\n private fallback(element: JSXElement): Fold | undefined {\n const attribute = findAttribute(element, 'fallback');\n if (!attribute?.value) {\n // A bare `fallback` is `fallback={true}`, which renders nothing.\n return EMPTY;\n }\n const { value } = attribute;\n switch (value.type) {\n case 'Literal':\n // An attribute string can hold HTML entities, which are not decoded here.\n if (value.value.includes('&')) {\n return undefined;\n }\n return {\n kind: 'expression',\n text: JSON.stringify(value.value),\n primary: true,\n };\n case 'JSXElement':\n case 'JSXFragment':\n return { kind: 'jsx', text: textOf(this.context, value) };\n default:\n if (value.expression.type === 'JSXEmptyExpression') {\n return EMPTY;\n }\n // JSX in a container splices like JSX, so it can join the surrounding template.\n if (value.expression.type === 'JSXElement' || value.expression.type === 'JSXFragment') {\n return { kind: 'jsx', text: textOf(this.context, value.expression) };\n }\n return {\n kind: 'expression',\n text: textOf(this.context, value.expression),\n primary: isPrimary(value.expression),\n };\n }\n }\n\n private foldShow(element: JSXElement): Fold | undefined {\n const when = this.attributeTruthiness(element, 'when');\n if (when === undefined) {\n return undefined;\n }\n if (!when) {\n return this.fallback(element);\n }\n if (hasCallbackChild(element.children)) {\n return undefined;\n }\n return { kind: 'children', children: element.children };\n }\n\n private foldFor(element: JSXElement): Fold | undefined {\n const each = findAttribute(element, 'each');\n if (\n each?.value?.type !== 'JSXExpressionContainer' ||\n each.value.expression.type === 'JSXEmptyExpression'\n ) {\n return undefined;\n }\n const { expression } = each.value;\n // `each={[]}` renders the fallback, and so does a statically falsy `each`,\n // which `mapArray` treats as an empty list. Either way the expression is\n // dropped, so it has to be skippable.\n const empty =\n arrayLiteralLength(expression) === 0 || truthiness(expression, this.lookup) === false;\n if (!empty) {\n return this.unrollFor(element, expression);\n }\n if (!isSideEffectFree(expression)) {\n return undefined;\n }\n return this.fallback(element);\n }\n\n /**\n * Unrolls `<For>` over a constant list into one copy of its row per item.\n *\n * The list is an array literal, or a binding of one that only `<For>`\n * reads, so nothing can change it. Each item is a primitive literal, or an\n * object literal of them. The row is an arrow function whose body is JSX,\n * and reads the item as `item.key`, or as itself when it is a primitive.\n * Each row ran once, untracked, under its own owner. A copy is made with\n * the JSX around it instead, which runs untracked too, and the JSX\n * transform gives every dynamic part its own effect. A `ref` or a spread\n * would run while the copy is made, so either one keeps the loop.\n */\n private unrollFor(element: JSXElement, expression: Expression): Fold | undefined {\n if (\n element.openingElement.attributes.some(\n (attribute) =>\n attribute.type === 'JSXAttribute' &&\n attribute.name.type === 'JSXIdentifier' &&\n attribute.name.name === 'keyed' &&\n !(\n attribute.value?.type === 'JSXExpressionContainer' &&\n attribute.value.expression.type === 'Literal' &&\n attribute.value.expression.value === false\n ),\n )\n ) {\n return undefined;\n }\n const byIndex = findAttribute(element, 'keyed') !== undefined;\n const list = this.constantList(expression);\n if (!list) {\n return undefined;\n }\n const significant = element.children.filter((child) => !isInsignificant(child));\n const only = significant.at(0);\n if (significant.length !== 1 || only?.type !== 'JSXExpressionContainer') {\n return undefined;\n }\n let row: Node = only.expression;\n while (row.type === 'ParenthesizedExpression') {\n row = row.expression;\n }\n if (\n row.type !== 'ArrowFunctionExpression' ||\n row.async ||\n !row.expression ||\n row.params.length > 2\n ) {\n return undefined;\n }\n let body: Node = row.body;\n while (body.type === 'ParenthesizedExpression') {\n body = body.expression;\n }\n if ((body.type !== 'JSXElement' && body.type !== 'JSXFragment') || hasRefOrSpread(body)) {\n return undefined;\n }\n // A fold inside the row in this pass would be lost, so it waits for the next pass.\n if (\n this.context.s.slice(body.start, body.end) !== this.context.code.slice(body.start, body.end)\n ) {\n return undefined;\n }\n const scope = this.context.scopes.scopes.get(row);\n if (!scope) {\n return undefined;\n }\n const params: Binding[] = [];\n for (const param of row.params) {\n const binding = param.type === 'Identifier' ? scope.bindings.get(param.name) : undefined;\n if (!binding || binding.mutated) {\n return undefined;\n }\n params.push(binding);\n }\n const itemParam = params.at(0);\n const indexParam = params.at(1);\n const rows: string[] = [];\n for (const [index, item] of list.items.entries()) {\n const copy = new MagicString(this.context.code);\n // With `keyed={false}` the item is an accessor and the index a number, and the other way around otherwise.\n if (\n (itemParam && !this.substituteItem(copy, itemParam, item, byIndex)) ||\n (indexParam && !this.substituteIndex(copy, indexParam, index, !byIndex))\n ) {\n return undefined;\n }\n rows.push(copy.slice(body.start, body.end));\n }\n const text = `<>${rows.join('')}</>`;\n if (!this.unrollingPays(element, text, list.declaration)) {\n return undefined;\n }\n return { kind: 'jsx', text };\n }\n\n /**\n * The items of a constant list, and the declaration that goes once no\n * `<For>` reads it.\n */\n private constantList(\n expression: Expression,\n ): { items: ConstantItem[]; declaration: Node | undefined } | undefined {\n let node: Expression = expression;\n while (node.type === 'ParenthesizedExpression') {\n node = node.expression;\n }\n let declaration: Node | undefined;\n if (node.type === 'Identifier') {\n const binding = this.context.scopes.references.get(node);\n if (\n binding?.declaration.type !== 'VariableDeclarator' ||\n binding.declaration.id !== binding.identifier ||\n !binding.declaration.init ||\n !isConstantDeclaration(binding, this.context.options)\n ) {\n return undefined;\n }\n // Any other use could change the list, and an export can be changed by another module.\n const statement = this.context.parents.get(binding.declaration);\n const owner = statement ? this.context.parents.get(statement) : undefined;\n if (\n owner?.type === 'ExportNamedDeclaration' ||\n !binding.references.every((reference) => this.isForEach(reference))\n ) {\n return undefined;\n }\n node = binding.declaration.init;\n while (node.type === 'ParenthesizedExpression') {\n node = node.expression;\n }\n declaration =\n binding.references.length === 1 &&\n statement?.type === 'VariableDeclaration' &&\n statement.declarations.length === 1\n ? statement\n : undefined;\n }\n if (node.type !== 'ArrayExpression') {\n return undefined;\n }\n const items: ConstantItem[] = [];\n for (const element of node.elements) {\n const item =\n element && element.type !== 'SpreadElement' ? this.constantItem(element) : undefined;\n if (!item) {\n return undefined;\n }\n items.push(item);\n }\n return { items, declaration };\n }\n\n /** Whether a reference is the whole `each` of a Solid `<For>`. */\n private isForEach(reference: Node): boolean {\n const container = this.context.parents.get(reference);\n const attribute = container ? this.context.parents.get(container) : undefined;\n const opening = attribute ? this.context.parents.get(attribute) : undefined;\n const element = opening ? this.context.parents.get(opening) : undefined;\n return (\n container?.type === 'JSXExpressionContainer' &&\n attribute?.type === 'JSXAttribute' &&\n attribute.name.type === 'JSXIdentifier' &&\n attribute.name.name === 'each' &&\n element?.type === 'JSXElement' &&\n this.builtInTag(element) === 'For'\n );\n }\n\n /** A list item whose value is known: a primitive literal, or an object literal of them. */\n private constantItem(node: Expression): ConstantItem | undefined {\n const primitive = primitiveText(this.context, node);\n if (primitive !== undefined) {\n return { kind: 'primitive', text: primitive };\n }\n if (node.type !== 'ObjectExpression') {\n return undefined;\n }\n const keys = new Map<string, string>();\n for (const property of node.properties) {\n if (\n property.type !== 'Property' ||\n property.kind !== 'init' ||\n property.method ||\n property.computed\n ) {\n return undefined;\n }\n const key = keyName(property.key);\n const value = primitiveText(this.context, property.value);\n if (key === undefined || value === undefined || key === '__proto__') {\n return undefined;\n }\n keys.set(key, value);\n }\n return { kind: 'object', keys };\n }\n\n /**\n * Writes an item's value over each read of the row's item parameter.\n * `false` when a read is not one the value can take the place of.\n */\n private substituteItem(\n copy: MagicString,\n param: Binding,\n item: ConstantItem,\n accessor: boolean,\n ): boolean {\n for (const reference of param.references) {\n let read: Node = reference;\n if (accessor) {\n const call = this.context.parents.get(reference);\n if (\n call?.type !== 'CallExpression' ||\n call.callee !== reference ||\n call.arguments.length > 0\n ) {\n return false;\n }\n read = call;\n }\n if (item.kind === 'primitive') {\n copy.overwrite(read.start, read.end, this.valueAt(read, item.text));\n continue;\n }\n const member = this.context.parents.get(read);\n if (\n member?.type !== 'MemberExpression' ||\n member.object !== read ||\n isWriteTarget(member, this.context.parents)\n ) {\n return false;\n }\n // `item[name]` reads a variable key, so only a string literal counts when computed.\n let key: string | undefined;\n if (!member.computed) {\n key = member.property.type === 'Identifier' ? member.property.name : undefined;\n } else if (member.property.type === 'Literal') {\n key = keyName(member.property);\n }\n // A call would run with the item as `this`, and a missing key could be on the prototype.\n const parent = this.context.parents.get(member);\n if (\n key === undefined ||\n (parent?.type === 'CallExpression' && parent.callee === member) ||\n !item.keys.has(key)\n ) {\n return false;\n }\n copy.overwrite(\n member.start,\n member.end,\n this.valueAt(member, item.keys.get(key) ?? 'void 0'),\n );\n }\n return true;\n }\n\n /** A value's text in place of `node`, with parentheses unless it fills a JSX container. */\n private valueAt(node: Node, text: string): string {\n return this.context.parents.get(node)?.type === 'JSXExpressionContainer' ? text : `(${text})`;\n }\n\n /** Writes an item's index over each read of the row's index parameter. */\n private substituteIndex(\n copy: MagicString,\n param: Binding,\n index: number,\n accessor: boolean,\n ): boolean {\n for (const reference of param.references) {\n let read: Node = reference;\n if (accessor) {\n const call = this.context.parents.get(reference);\n if (\n call?.type !== 'CallExpression' ||\n call.callee !== reference ||\n call.arguments.length > 0\n ) {\n return false;\n }\n read = call;\n }\n copy.overwrite(read.start, read.end, String(index));\n }\n return true;\n }\n\n /**\n * Whether the copies are estimated to be no larger, once lowered, than\n * the loop and the list it no longer needs.\n */\n private unrollingPays(element: JSXElement, text: string, declaration: Node | undefined): boolean {\n const inTemplate = this.joinsParentTemplate(element);\n const loop =\n new SizeEstimator(this.context.code).jsx(element, inTemplate) +\n (declaration\n ? compactLength(this.context.code.slice(declaration.start, declaration.end))\n : 0);\n const code = `const __so_rows__ = ${text};`;\n const program = parse(this.context.filename, code);\n const statement = program.body.at(0);\n const init =\n statement?.type === 'VariableDeclaration' ? statement.declarations.at(0)?.init : undefined;\n if (init?.type !== 'JSXFragment') {\n return false;\n }\n // In an element, the rows splice into its template. Elsewhere they are a fragment of templates.\n const estimator = new SizeEstimator(code);\n const unrolled = inTemplate\n ? init.children.reduce(\n (size, child) =>\n size +\n (child.type === 'JSXElement' ? estimator.jsx(child, true) : estimator.node(child)),\n 0,\n )\n : estimator.jsx(init, false);\n return unrolled <= loop;\n }\n\n /** Whether an element sits directly in an element or fragment whose template it joins. */\n private joinsParentTemplate(element: JSXElement): boolean {\n const parent = this.context.parents.get(element);\n return (\n (parent?.type === 'JSXElement' && joinsTemplate(parent)) || parent?.type === 'JSXFragment'\n );\n }\n\n private foldRepeat(element: JSXElement): Fold | undefined {\n const count = findAttribute(element, 'count');\n if (\n count?.value?.type !== 'JSXExpressionContainer' ||\n count.value.expression.type === 'JSXEmptyExpression'\n ) {\n return undefined;\n }\n const value = evaluate(count.value.expression, this.lookup);\n if (typeof value?.value !== 'number') {\n return undefined;\n }\n // Written this way so `NaN` counts as empty, like `repeat` does.\n if (value.value >= 1) {\n return undefined;\n }\n return this.fallback(element);\n }\n\n /**\n * Resolves a `<Switch>` as far as its `<Match when>` conditions allow.\n * Statically false matches are dropped, a statically true match with no\n * undecided match before it wins, and a switch whose every match is false\n * renders its fallback.\n */\n private foldSwitch(element: JSXElement): Fold | undefined {\n const matches: { element: JSXElement; when: boolean | undefined }[] = [];\n for (const child of element.children) {\n if (isInsignificant(child)) {\n continue;\n }\n // Anything else in a `<Switch>` is outside what this pass models.\n if (\n child.type !== 'JSXElement' ||\n this.builtInTag(child) !== 'Match' ||\n hasSpreadAttribute(child) ||\n !findAttribute(child, 'when')\n ) {\n return undefined;\n }\n matches.push({ element: child, when: this.attributeTruthiness(child, 'when') });\n }\n if (matches.length === 0) {\n return undefined;\n }\n\n const winner = matches.findIndex((item) => item.when === true);\n if (winner !== -1 && matches.slice(0, winner).every((item) => item.when === false)) {\n const match = matches.at(winner);\n if (!match || hasCallbackChild(match.element.children)) {\n return undefined;\n }\n return { kind: 'children', children: match.element.children };\n }\n\n if (matches.every((item) => item.when === false)) {\n return this.fallback(element);\n }\n\n // No outcome yet. A statically false match never renders, but the runtime\n // would still evaluate it each time the switch updates, so it is removed.\n for (const item of matches) {\n if (item.when === false) {\n this.context.s.remove(item.element.start, item.element.end);\n this.changed = true;\n }\n }\n return undefined;\n }\n\n /**\n * `<Dynamic component=\"div\">` is just `<div>`, which the JSX transform can\n * put in a template instead of creating the element at runtime.\n */\n /**\n * `<Dynamic component=\"div\">` becomes `<div>`. `<Dynamic component={Card}>`\n * becomes `<Card>` when `Card` is a component declared at the top level\n * that nothing reassigns. `<Dynamic>` then only renders `Card` with the\n * other props, through a memo that never changes.\n */\n private foldDynamic(element: JSXElement): Fold | undefined {\n const component = findAttribute(element, 'component');\n if (!component?.value) {\n return undefined;\n }\n let tag: string | undefined;\n const { value } = component;\n if (value.type === 'Literal') {\n tag = isIntrinsicTag(value.value) ? value.value : undefined;\n } else if (\n value.type === 'JSXExpressionContainer' &&\n value.expression.type !== 'JSXEmptyExpression'\n ) {\n const expression =\n value.expression.type === 'ParenthesizedExpression'\n ? value.expression.expression\n : value.expression;\n if (expression.type === 'Identifier') {\n tag = this.componentName(expression);\n }\n if (tag === undefined) {\n const result = evaluate(value.expression, this.lookup);\n if (typeof result?.value === 'string' && isIntrinsicTag(result.value)) {\n tag = result.value;\n }\n }\n }\n if (tag === undefined) {\n return undefined;\n }\n const attributes = element.openingElement.attributes\n .filter((attribute) => attribute !== component)\n .map((attribute) => textOf(this.context, attribute));\n const opening = [tag, ...attributes].join(' ');\n const text = element.closingElement\n ? `<${opening}>${innerText(this.context.s, element)}</${tag}>`\n : `<${opening} />`;\n return { kind: 'jsx', text };\n }\n\n /**\n * Replaces a control-flow element that is not a JSX child.\n */\n private foldFlowExpression(element: JSXElement): void {\n const resolved = this.foldFlow(element);\n if (!resolved) {\n return;\n }\n this.replace(element, this.expressionText(resolved));\n }\n\n private expressionText(resolved: Fold): string {\n switch (resolved.kind) {\n case 'empty':\n return 'null';\n case 'jsx':\n return resolved.text;\n case 'expression':\n return resolved.primary ? resolved.text : `(${resolved.text})`;\n default: {\n const significant = resolved.children.filter((child) => !isInsignificant(child));\n const only = significant.at(0);\n if (only === undefined) {\n return 'null';\n }\n if (\n significant.length === 1 &&\n (only.type === 'JSXElement' || only.type === 'JSXFragment')\n ) {\n return textOf(this.context, only);\n }\n const first = resolved.children.at(0);\n const last = resolved.children.at(-1);\n if (!first || !last) {\n return 'null';\n }\n return `<>${this.context.s.slice(first.start, last.end)}</>`;\n }\n }\n }\n\n /**\n * Replaces every resolvable control-flow child with what it renders.\n */\n private foldChildren(parent: JSXElement | JSXFragment): void {\n const pieces: Piece[] = [];\n let folded = false;\n for (const child of parent.children) {\n // A fragment among JSX children is the same as its children, and Solid's\n // JSX transform only compiles the spliced form.\n if (child.type === 'JSXFragment') {\n folded = true;\n pieces.push(splicePiece(this.context.s, child, child.children));\n continue;\n }\n const reduced =\n child.type === 'JSXExpressionContainer' && joinsTemplate(parent)\n ? this.reducedCall(child.expression)\n : undefined;\n if (reduced !== undefined) {\n folded = true;\n pieces.push(replacedPiece(child, reduced));\n continue;\n }\n const resolved = child.type === 'JSXElement' ? this.foldFlow(child) : undefined;\n if (!resolved) {\n pieces.push(keptPiece(child));\n continue;\n }\n folded = true;\n switch (resolved.kind) {\n case 'children':\n pieces.push(splicePiece(this.context.s, child, resolved.children));\n break;\n case 'jsx':\n pieces.push(replacedPiece(child, resolved.text));\n break;\n case 'expression':\n pieces.push(replacedPiece(child, `{${resolved.text}}`));\n break;\n default:\n pieces.push(replacedPiece(child, ''));\n break;\n }\n }\n if (folded && writePieces(this.context.s, pieces)) {\n this.changed = true;\n }\n }\n\n /**\n * The JSX a call like `((n) => <li>{n}</li>)(1)` makes, with each\n * argument in place of its parameter, or `undefined` when that could\n * behave differently.\n *\n * The child is inserted by an effect that makes the JSX. The JSX\n * transform wraps every dynamic part of JSX in an effect of its own, so\n * making it reads nothing the outer effect tracks, and the outer effect\n * runs once. A `ref` runs while the JSX is made, and a spread reads its\n * object there, so either one keeps the call. Each argument has to be a\n * constant or a binding nothing reassigns, so reading it again where the\n * parameter was gives the same value.\n */\n private reducedCall(expression: Expression | JSXEmptyExpression): string | undefined {\n if (expression.type !== 'CallExpression' || expression.optional) {\n return undefined;\n }\n let callee: Expression = expression.callee;\n while (callee.type === 'ParenthesizedExpression') {\n callee = callee.expression;\n }\n if (callee.type !== 'ArrowFunctionExpression' || callee.async || !callee.expression) {\n return undefined;\n }\n let body: Node = callee.body;\n while (body.type === 'ParenthesizedExpression') {\n body = body.expression;\n }\n if (body.type !== 'JSXElement' && body.type !== 'JSXFragment') {\n return undefined;\n }\n const { params } = callee;\n const args = expression.arguments;\n if (params.length !== args.length || hasRefOrSpread(body)) {\n return undefined;\n }\n // A fold inside the body in this pass would be lost, so it waits for the next pass.\n if (\n this.context.s.slice(body.start, body.end) !== this.context.code.slice(body.start, body.end)\n ) {\n return undefined;\n }\n const scope = this.context.scopes.scopes.get(callee);\n if (!scope) {\n return undefined;\n }\n const copy = new MagicString(this.context.code);\n for (const [index, param] of params.entries()) {\n const arg = args.at(index);\n if (param.type !== 'Identifier' || !arg || arg.type === 'SpreadElement') {\n return undefined;\n }\n const binding = scope.bindings.get(param.name);\n const text = this.argumentText(arg);\n if (!binding || binding.mutated || text === undefined) {\n return undefined;\n }\n for (const reference of binding.references) {\n // A binding argument has to mean the same where the parameter was read.\n if (\n arg.type === 'Identifier' &&\n lookup(scopeAt(this.context.scopes, this.context.parents, reference), arg.name) !==\n this.context.scopes.references.get(arg)\n ) {\n return undefined;\n }\n const parent = this.context.parents.get(reference);\n const shorthand =\n parent?.type === 'Property' && parent.shorthand && parent.value === reference;\n copy.overwrite(reference.start, reference.end, shorthand ? `${param.name}: ${text}` : text);\n }\n }\n return copy.slice(body.start, body.end);\n }\n\n /** The text of an argument that reads the same wherever it is copied. */\n private argumentText(arg: Expression): string | undefined {\n let node: Expression = arg;\n while (node.type === 'ParenthesizedExpression') {\n node = node.expression;\n }\n switch (node.type) {\n case 'Literal':\n return 'regex' in node ? undefined : textOf(this.context, node);\n case 'TemplateLiteral':\n return node.expressions.length === 0 ? textOf(this.context, node) : undefined;\n case 'UnaryExpression':\n return node.operator === '-' && node.argument.type === 'Literal'\n ? `(${textOf(this.context, node)})`\n : undefined;\n case 'Identifier': {\n const binding = this.context.scopes.references.get(node);\n return binding && !binding.mutated ? node.name : undefined;\n }\n default:\n return undefined;\n }\n }\n\n // ---------------------------------------------------------------------------\n // Dead statements\n // ---------------------------------------------------------------------------\n\n private eliminateDeadStatements(statements: (Statement | Directive)[]): void {\n let terminator = -1;\n for (const [index, statement] of statements.entries()) {\n let terminates = isTerminator(statement);\n if (statement.type === 'IfStatement') {\n const kept = this.resolveIf(statement);\n if (kept !== undefined) {\n terminates = kept !== null && isTerminator(kept);\n }\n } else if (statement.type === 'WhileStatement') {\n this.resolveWhile(statement);\n }\n if (terminates && terminator === -1) {\n terminator = index;\n }\n }\n\n // Everything after the first terminator is unreachable, but a `var` or\n // function declaration in it is still hoisted, so the list stays intact.\n if (terminator === -1) {\n return;\n }\n const unreachable = statements.slice(terminator + 1);\n const first = unreachable.at(0);\n const last = unreachable.at(-1);\n if (first && last && !unreachable.some(containsHoistedDeclaration)) {\n this.context.s.remove(first.start, last.end);\n this.changed = true;\n }\n }\n\n private replaceStatement(statement: Node, text: string): void {\n if (text === '') {\n this.context.s.remove(statement.start, statement.end);\n this.changed = true;\n return;\n }\n this.replace(statement, continuesPreviousStatement(text) ? `;${text}` : text);\n }\n\n /**\n * A statement that keeps a discarded test's side effects, or `undefined`\n * when skipping the test changes nothing.\n */\n private discardedTest(test: Expression): string | undefined {\n const parts = effectfulParts(test);\n const first = parts.at(0);\n if (first === undefined) {\n return undefined;\n }\n const text = parts.map((part) => textOf(this.context, part)).join(', ');\n return startsLikeStatement(first) ? `(${text});` : `${text};`;\n }\n\n /**\n * Resolves an `if` with a constant test. Returns the kept branch, `null`\n * when no branch is kept, or `undefined` when the statement stays.\n */\n private resolveIf(statement: IfStatement): Statement | null | undefined {\n const test = truthiness(statement.test, this.lookup);\n if (test === undefined) {\n return undefined;\n }\n const dropped = test ? statement.alternate : statement.consequent;\n if (dropped && containsHoistedDeclaration(dropped)) {\n return undefined;\n }\n const kept = test ? statement.consequent : statement.alternate;\n // A bare function declaration as a branch is web-compatibility semantics,\n // not something to move into the enclosing list.\n if (kept?.type === 'FunctionDeclaration') {\n return undefined;\n }\n const parts: string[] = [];\n const effect = this.discardedTest(statement.test);\n if (effect !== undefined) {\n parts.push(effect);\n }\n if (kept) {\n parts.push(textOf(this.context, kept));\n }\n this.replaceStatement(statement, parts.join(' '));\n return kept;\n }\n\n private resolveWhile(statement: WhileStatement): void {\n if (truthiness(statement.test, this.lookup) !== false) {\n return;\n }\n if (containsHoistedDeclaration(statement.body)) {\n return;\n }\n // A `while` with a falsy test evaluates the test once and never enters the body.\n this.replaceStatement(statement, this.discardedTest(statement.test) ?? '');\n }\n}\n\n/**\n * Runs the fold pass over a parsed program. Returns whether anything changed.\n */\nexport function fold(context: PassContext): boolean {\n const folder = new Folder(context);\n folder.walk(context.program);\n return folder.changed;\n}\n","/**\n * The provider pass: removes context providers whose reads are all visible.\n *\n * In Solid 2.0, a context is its own provider component. The provider reads\n * `props.value` once, untracked, when it is created, and every\n * `useContext(Ctx)` under it returns that value. When every code path that\n * can run under a provider is visible, each read can take the value\n * directly, and the provider only costs a component call, a root owner, and\n * a template boundary:\n *\n * ```jsx\n * <Theme value=\"dark\">\n * <span>{useContext(Theme)}</span>\n * </Theme>\n * ```\n *\n * becomes `<><span>{\"dark\"}</span></>`.\n *\n * Most reads sit in a consumer component's statements. The inline pass\n * moves those consumers out through a closed provider and replaces their\n * reads, and this pass removes the provider once nothing under it is a\n * component anymore.\n *\n * # Accepted differences\n *\n * - The provider's root owner is gone, which shifts the hydration keys\n * after it. A server build and its client build must compile with the\n * same options.\n * - A getter defined by the app, other than on a component's props, that\n * calls `useContext` is not seen.\n */\nimport type {\n CallExpression,\n Expression,\n JSXAttribute,\n JSXElement,\n MemberExpression,\n Node,\n ObjectExpression,\n} from 'oxc-parser';\nimport { forEachChild, isFunctionNode, isIntrinsicTag, unwrap } from './ast';\nimport type { PassContext } from './context';\nimport { isConstantDeclaration, recordSkip, solidExport } from './context';\nimport type { Binding } from './scope';\nimport { lookup, scopeAt } from './scope';\nimport { evaluate, isSideEffectFree, literalText } from './value';\n\n/**\n * Solid's primitives that run no code of the app, except the functions\n * passed to them. Those functions are checked like any other code.\n */\nexport const CONTEXT_SAFE_PRIMITIVES = [\n 'createSignal',\n 'createMemo',\n 'createEffect',\n 'createRenderEffect',\n 'createStore',\n 'createProjection',\n 'createOptimistic',\n 'onCleanup',\n 'onSettled',\n 'untrack',\n 'useContext',\n 'flush',\n 'mapArray',\n 'repeat',\n 'merge',\n 'omit',\n];\n\n/** Primitives that return a getter and a setter, as `[get, set]`. */\nconst ACCESSOR_PAIRS = new Set(['createSignal', 'createStore', 'createOptimistic']);\n\nexport interface Provider {\n readonly element: JSXElement;\n /** The top-level `createContext()` binding the tag refers to. */\n readonly context: Binding;\n readonly value: Expression;\n}\n\n/**\n * The provider a JSX element creates: a tag that refers to a top-level\n * `createContext(...)` from Solid, nothing writes to, with one `value`\n * attribute holding a value that is never `undefined`.\n *\n * `useContext` throws when the value and the default are both `undefined`,\n * so a value that could be `undefined` keeps its provider.\n */\nexport function providerOf(context: PassContext, element: JSXElement): Provider | undefined {\n const binding = contextBinding(context, element.openingElement.name);\n if (!binding || element.openingElement.selfClosing) {\n return undefined;\n }\n const { attributes } = element.openingElement;\n const attribute = attributes.at(0);\n if (\n attributes.length !== 1 ||\n attribute?.type !== 'JSXAttribute' ||\n attribute.name.type !== 'JSXIdentifier' ||\n attribute.name.name !== 'value' ||\n !attribute.value\n ) {\n return undefined;\n }\n let value: Expression;\n if (attribute.value.type === 'Literal') {\n value = attribute.value;\n } else if (\n attribute.value.type === 'JSXExpressionContainer' &&\n attribute.value.expression.type !== 'JSXEmptyExpression'\n ) {\n value = attribute.value.expression;\n } else {\n return undefined;\n }\n if (!isDefined(context, value, 0)) {\n return undefined;\n }\n return { element, context: binding, value };\n}\n\n/**\n * The top-level context binding a tag or identifier refers to.\n */\nexport function contextBinding(context: PassContext, name: Node): Binding | undefined {\n if (name.type !== 'JSXIdentifier' && name.type !== 'Identifier') {\n return undefined;\n }\n const binding = context.scopes.references.get(name);\n if (!binding || binding.mutated || binding.scope.parent !== undefined) {\n return undefined;\n }\n if (binding.kind === 'import') {\n const { source, imported } = binding;\n const known =\n source !== undefined &&\n imported !== undefined &&\n context.options.importedContexts.get(source)?.has(imported) === true;\n return known ? binding : undefined;\n }\n const { declaration } = binding;\n if (\n declaration.type !== 'VariableDeclarator' ||\n declaration.id !== binding.identifier ||\n !isConstantDeclaration(binding, context.options) ||\n !declaration.init\n ) {\n return undefined;\n }\n const init = unwrap(declaration.init);\n return init.type === 'CallExpression' && solidCallee(context, init) === 'createContext'\n ? binding\n : undefined;\n}\n\n/**\n * The Solid export a call calls, like `createSignal`.\n */\nexport function solidCallee(context: PassContext, call: CallExpression): string | undefined {\n const callee = unwrap(call.callee);\n if (callee.type !== 'Identifier') {\n return undefined;\n }\n const binding = context.scopes.references.get(callee);\n return binding ? solidExport(binding, context.options) : undefined;\n}\n\n/**\n * Whether evaluating `node` never gives `undefined`.\n */\nfunction isDefined(context: PassContext, node: Expression, depth: number): boolean {\n const expression = unwrap(node);\n switch (expression.type) {\n case 'ObjectExpression':\n case 'ArrayExpression':\n case 'ArrowFunctionExpression':\n case 'FunctionExpression':\n case 'ClassExpression':\n case 'NewExpression':\n case 'TemplateLiteral':\n case 'JSXElement':\n case 'JSXFragment':\n return true;\n case 'Identifier': {\n const binding = context.scopes.references.get(expression);\n if (!binding || binding.mutated || depth > 2) {\n return false;\n }\n if (binding.kind === 'function' || binding.kind === 'class' || isAccessor(context, binding)) {\n return true;\n }\n const { declaration } = binding;\n return (\n isConstantDeclaration(binding, context.options) &&\n declaration.type === 'VariableDeclarator' &&\n declaration.id === binding.identifier &&\n declaration.init !== null &&\n isDefined(context, declaration.init, depth + 1)\n );\n }\n default: {\n return evaluate(expression, () => undefined)?.value !== undefined;\n }\n }\n}\n\n/**\n * The text a read of a provider's value can be replaced with at `site`: a\n * literal, or a binding that never changes and means the same there.\n * `undefined` when the value has to be stored first.\n */\nexport function stableValueText(\n context: PassContext,\n provider: Provider,\n site: Node,\n): string | undefined {\n const value = unwrap(provider.value);\n const constant = evaluate(value, () => undefined);\n if (constant) {\n return literalText(constant.value);\n }\n if (value.type !== 'Identifier') {\n return undefined;\n }\n const binding = context.scopes.references.get(value);\n if (!binding || binding.mutated) {\n return undefined;\n }\n const unchanging =\n binding.kind === 'function' ||\n binding.kind === 'class' ||\n binding.kind === 'import' ||\n isConstantDeclaration(binding, context.options);\n if (!unchanging) {\n return undefined;\n }\n const scope = scopeAt(context.scopes, context.parents, site);\n return lookup(scope, value.name) === binding ? value.name : undefined;\n}\n\n/**\n * Whether an attribute is an event handler given as a function. The\n * function runs with no owner, so a `useContext` in it throws whether or\n * not a provider is above it.\n */\nfunction isHandlerFunction(attribute: JSXAttribute): boolean {\n const { name, value } = attribute;\n const text =\n name.type === 'JSXIdentifier' ? name.name : `${name.namespace.name}:${name.name.name}`;\n if (!/^on(?:[A-Z]|:)/.test(text) || value?.type !== 'JSXExpressionContainer') {\n return false;\n }\n const expression = value.expression.type === 'JSXEmptyExpression' ? undefined : value.expression;\n return expression !== undefined && isFunctionNode(unwrap(expression));\n}\n\n/**\n * Whether a binding is a signal or store getter or setter, or a memo, which\n * run no code of the app when called.\n */\nfunction isAccessor(context: PassContext, binding: Binding): boolean {\n if (binding.mutated) {\n return false;\n }\n const { declaration } = binding;\n if (declaration.type !== 'VariableDeclarator') {\n return false;\n }\n const { id, init } = declaration;\n const call = init ? unwrap(init) : undefined;\n if (call?.type !== 'CallExpression') {\n return false;\n }\n const callee = solidCallee(context, call);\n if (id === binding.identifier) {\n return callee === 'createMemo';\n }\n if (id.type !== 'ArrayPattern' || callee === undefined || !ACCESSOR_PAIRS.has(callee)) {\n return false;\n }\n const index = id.elements.findIndex((element) => element === binding.identifier);\n return index === 0 || index === 1;\n}\n\nexport interface ClosedOptions {\n /** Whether a component element can be treated as visible code. */\n readonly component: (element: JSXElement) => boolean;\n /** A component's own props, whose reads are replaced when it is inlined. */\n readonly props?: Binding;\n /** The value a read of a context gets, when the provider is known. */\n readonly contextValue?: (target: Binding) => Expression | undefined;\n /** Called with a short code for the code that is not visible, for the report. */\n readonly onOpen?: (reason: string) => void;\n}\n\n/**\n * Whether all code that can run under `root` is visible, so a provider\n * above it has no reader that is not in it.\n *\n * Calls are limited to Solid's primitives, signal and memo accessors, and\n * methods of known object literals. A use of another component's props\n * runs code of its parent, so it counts as a call. A component's own props\n * are replaced when it is inlined.\n */\nexport function isClosed(context: PassContext, root: Node, options: ClosedOptions): boolean {\n let closed = true;\n const open = (reason: string): void => {\n closed = false;\n options.onOpen?.(reason);\n };\n const visit = (node: Node): void => {\n if (!closed) {\n return;\n }\n switch (node.type) {\n case 'JSXAttribute':\n if (isHandlerFunction(node)) {\n return;\n }\n break;\n case 'JSXSpreadAttribute':\n // A view of the component's own props is expanded when it inlines.\n if (!isOwnView(context, node.argument, options.props, 0)) {\n open('open-spread');\n return;\n }\n break;\n case 'NewExpression':\n open('open-new');\n return;\n case 'JSXSpreadChild':\n case 'TaggedTemplateExpression':\n case 'ImportExpression':\n open('open-other');\n return;\n case 'JSXElement':\n if (!isVisibleElement(context, node, options)) {\n open('open-component');\n return;\n }\n break;\n case 'CallExpression':\n if (!isVisibleCall(context, node, options)) {\n open('open-call');\n return;\n }\n break;\n case 'Identifier': {\n // Another component's props run its parent's code when read, and\n // passing them on, as to `merge()`, reads them somewhere else. A\n // binding declared under `root`, like a callback's parameter, is a value.\n const binding = context.scopes.references.get(node);\n if (binding && runsOutsideCode(context, binding, root, options, 0)) {\n open('open-outer');\n return;\n }\n break;\n }\n default:\n break;\n }\n forEachChild(node, visit);\n };\n visit(root);\n return closed;\n}\n\n/**\n * Whether using a binding declared outside `root` can run code that is not\n * under `root`:\n *\n * - another component's props, whose getters run its parent's code;\n * - a value built from them, like `mergeDefaultProps(defaults, props)`,\n * whose getters do the same;\n * - a function, which `root` can call or pass on to be called.\n *\n * A component's own props, and values built from them, are replaced when\n * it is inlined.\n */\nfunction runsOutsideCode(\n context: PassContext,\n binding: Binding,\n root: Node,\n options: ClosedOptions,\n depth: number,\n): boolean {\n const { identifier, declaration } = binding;\n if (\n binding === options.props ||\n (identifier.start >= root.start && identifier.end <= root.end) ||\n isAccessor(context, binding) ||\n // Calls of Solid's own functions are checked where they are made.\n solidExport(binding, context.options) !== undefined\n ) {\n return false;\n }\n if (binding.kind === 'param' || binding.kind === 'function' || depth > 4) {\n return true;\n }\n if (declaration.type !== 'VariableDeclarator' || !declaration.init) {\n return false;\n }\n const init = unwrap(declaration.init);\n if (isFunctionNode(init)) {\n return true;\n }\n let found = false;\n const visit = (node: Node): void => {\n if (found) {\n return;\n }\n if (node.type === 'Identifier') {\n const target = context.scopes.references.get(node);\n if (\n target &&\n target !== binding &&\n (target.kind === 'param' || target.kind === 'const' || target.kind === 'let') &&\n runsOutsideCode(context, target, root, options, depth + 1)\n ) {\n found = true;\n return;\n }\n }\n forEachChild(node, visit);\n };\n visit(init);\n return found;\n}\n\n/**\n * Whether an expression is a `merge()` or `omit()` view of a component's\n * own props, with only literal objects and keys besides.\n */\nfunction isOwnView(\n context: PassContext,\n node: Expression,\n props: Binding | undefined,\n depth: number,\n): boolean {\n const expression = unwrap(node);\n if (props === undefined || depth > 4) {\n return false;\n }\n let call: Node | undefined = expression;\n if (expression.type === 'Identifier') {\n const binding = context.scopes.references.get(expression);\n if (binding === props) {\n return true;\n }\n const init = binding ? constantInit(context, binding) : undefined;\n call = init ? unwrap(init) : undefined;\n }\n if (call?.type !== 'CallExpression') {\n return false;\n }\n const callee = solidCallee(context, call);\n if (callee !== 'merge' && callee !== 'omit') {\n return false;\n }\n return call.arguments.every((argument) => {\n if (argument.type === 'SpreadElement') {\n return false;\n }\n const inner = unwrap(argument);\n return (\n inner.type === 'ObjectExpression' ||\n (inner.type === 'Literal' && typeof inner.value === 'string') ||\n isOwnView(context, inner, props, depth + 1)\n );\n });\n}\n\nfunction isVisibleElement(\n context: PassContext,\n element: JSXElement,\n options: ClosedOptions,\n): boolean {\n const { name } = element.openingElement;\n if (name.type !== 'JSXIdentifier') {\n return false;\n }\n if (isIntrinsicTag(name.name)) {\n return true;\n }\n if (contextBinding(context, name)) {\n return true;\n }\n const binding = context.scopes.references.get(name);\n const identity = binding ? solidExport(binding, context.options) : name.name;\n // `<Dynamic>` renders a component it is given, which is not visible.\n if (identity !== undefined && identity !== 'Dynamic' && context.options.builtIns.has(identity)) {\n return true;\n }\n return options.component(element);\n}\n\nfunction isVisibleCall(\n context: PassContext,\n call: CallExpression,\n options: ClosedOptions,\n): boolean {\n const callee = unwrap(call.callee);\n if (callee.type === 'MemberExpression') {\n return isVisibleMethod(context, callee, options);\n }\n if (callee.type !== 'Identifier') {\n return false;\n }\n const binding = context.scopes.references.get(callee);\n if (!binding) {\n return false;\n }\n const identity = solidExport(binding, context.options);\n if (identity !== undefined) {\n return CONTEXT_SAFE_PRIMITIVES.includes(identity);\n }\n return isAccessorValue(context, callee, options, 0);\n}\n\n/**\n * Whether an expression evaluates to a signal, store, or memo accessor,\n * through bindings that never change and reads of a context whose value is\n * known.\n */\nfunction isAccessorValue(\n context: PassContext,\n node: Expression,\n options: ClosedOptions,\n depth: number,\n): boolean {\n const expression = unwrap(node);\n if (depth > 4) {\n return false;\n }\n if (expression.type === 'CallExpression') {\n const value = contextValueOf(context, expression, options);\n return value !== undefined && isAccessorValue(context, value, options, depth + 1);\n }\n if (expression.type !== 'Identifier') {\n return false;\n }\n const binding = context.scopes.references.get(expression);\n if (!binding) {\n return false;\n }\n if (isAccessor(context, binding)) {\n return true;\n }\n const init = constantInit(context, binding);\n return init !== undefined && isAccessorValue(context, init, options, depth + 1);\n}\n\n/**\n * The initializer of a binding that never changes, declared on its own.\n */\nfunction constantInit(context: PassContext, binding: Binding): Expression | undefined {\n const { declaration } = binding;\n if (\n !isConstantDeclaration(binding, context.options) ||\n declaration.type !== 'VariableDeclarator' ||\n declaration.id !== binding.identifier ||\n !declaration.init\n ) {\n return undefined;\n }\n return declaration.init;\n}\n\n/**\n * The value `useContext(Ctx)` returns, when the provider is known.\n */\nfunction contextValueOf(\n context: PassContext,\n call: CallExpression,\n options: ClosedOptions,\n): Expression | undefined {\n const argument = call.arguments.at(0);\n if (\n solidCallee(context, call) !== 'useContext' ||\n call.arguments.length !== 1 ||\n argument === undefined ||\n argument.type === 'SpreadElement'\n ) {\n return undefined;\n }\n const target = contextBinding(context, unwrap(argument));\n return target ? options.contextValue?.(target) : undefined;\n}\n\n/**\n * Whether calling `object.name()` runs only visible code: the object is an\n * object literal, directly or through bindings that never change or a\n * context read, and the property is an accessor or a visible function.\n */\nfunction isVisibleMethod(\n context: PassContext,\n member: MemberExpression,\n options: ClosedOptions,\n): boolean {\n if (member.computed || member.property.type !== 'Identifier' || member.optional) {\n return false;\n }\n const object = objectLiteralOf(context, member.object, options, 0);\n if (!object || object.properties.some((property) => property.type !== 'Property')) {\n return false;\n }\n const { name } = member.property;\n const matches = object.properties.filter(\n (property) =>\n property.type === 'Property' &&\n !property.computed &&\n property.key.type === 'Identifier' &&\n property.key.name === name,\n );\n const property = matches.at(0);\n if (matches.length !== 1 || property?.type !== 'Property' || property.kind !== 'init') {\n return false;\n }\n const value = unwrap(property.value);\n if (isFunctionNode(value)) {\n return isClosed(context, value, options);\n }\n if (value.type !== 'Identifier') {\n return false;\n }\n const binding = context.scopes.references.get(value);\n if (!binding) {\n return false;\n }\n const identity = solidExport(binding, context.options);\n return identity === undefined\n ? isAccessorValue(context, value, options, 0)\n : CONTEXT_SAFE_PRIMITIVES.includes(identity);\n}\n\n/**\n * The object literal an expression evaluates to, through bindings that\n * never change and reads of a context whose value is known.\n */\nfunction objectLiteralOf(\n context: PassContext,\n node: Expression,\n options: ClosedOptions,\n depth: number,\n): ObjectExpression | undefined {\n const expression = unwrap(node);\n if (depth > 4) {\n return undefined;\n }\n if (expression.type === 'ObjectExpression') {\n return expression;\n }\n if (expression.type === 'CallExpression') {\n const value = contextValueOf(context, expression, options);\n return value ? objectLiteralOf(context, value, options, depth + 1) : undefined;\n }\n if (expression.type !== 'Identifier') {\n return undefined;\n }\n const binding = context.scopes.references.get(expression);\n const init = binding ? constantInit(context, binding) : undefined;\n return init ? objectLiteralOf(context, init, options, depth + 1) : undefined;\n}\n\n/**\n * The `useContext(Ctx)` calls under `root` that run under its owner, so\n * not in an event handler, and that no other provider of `Ctx` under\n * `root` answers.\n */\nexport function contextReads(context: PassContext, root: Node, target: Binding): CallExpression[] {\n const reads: CallExpression[] = [];\n const visit = (node: Node): void => {\n if (node.type === 'JSXAttribute' && isHandlerFunction(node)) {\n return;\n }\n // A read under another provider of the same context belongs to that one.\n if (\n node !== root &&\n node.type === 'JSXElement' &&\n contextBinding(context, node.openingElement.name) === target\n ) {\n return;\n }\n if (node.type === 'CallExpression' && solidCallee(context, node) === 'useContext') {\n const argument = node.arguments.at(0);\n if (\n node.arguments.length === 1 &&\n argument?.type !== 'SpreadElement' &&\n argument !== undefined &&\n contextBinding(context, unwrap(argument)) === target\n ) {\n reads.push(node);\n }\n }\n forEachChild(node, visit);\n };\n visit(root);\n return reads;\n}\n\n/**\n * Whether a provider of the same context sits under `element`. A read under\n * it belongs to it, so the inner one is rewritten first.\n */\nexport function hasNestedProvider(context: PassContext, provider: Provider): boolean {\n let nested = false;\n const visit = (node: Node): void => {\n if (nested) {\n return;\n }\n if (\n node !== provider.element &&\n node.type === 'JSXElement' &&\n contextBinding(context, node.openingElement.name) === provider.context\n ) {\n nested = true;\n return;\n }\n forEachChild(node, visit);\n };\n for (const child of provider.element.children) {\n visit(child);\n }\n return nested;\n}\n\n/**\n * Every provider in the program, outermost first.\n */\nexport function findProviders(context: PassContext): Provider[] {\n const providers: Provider[] = [];\n const visit = (node: Node): void => {\n if (node.type === 'JSXElement') {\n const provider = providerOf(context, node);\n if (provider) {\n providers.push(provider);\n }\n }\n forEachChild(node, visit);\n };\n visit(context.program);\n return providers;\n}\n\nclass ProviderRemover {\n changed = false;\n\n constructor(private readonly context: PassContext) {}\n\n private readonly removed: JSXElement[] = [];\n\n run(): void {\n for (const provider of findProviders(this.context)) {\n // A provider inside one removed in this pass waits for the next pass,\n // so their edits do not overlap.\n const { element } = provider;\n const overlaps = this.removed.some(\n (other) => element.start < other.end && other.start < element.end,\n );\n if (overlaps) {\n continue;\n }\n if (hasNestedProvider(this.context, provider)) {\n this.skip(provider, 'provider-nested');\n } else if (this.tryRemove(provider)) {\n this.removed.push(element);\n }\n }\n if (this.context.skips) {\n this.reportShapes();\n }\n }\n\n private skip(provider: Provider, reason: string): void {\n recordSkip(this.context, 'contexts', reason, provider.context.name);\n }\n\n /**\n * Records each context tag that is not a provider this pass understands,\n * such as one with more attributes than `value`.\n */\n private reportShapes(): void {\n const visit = (node: Node): void => {\n if (node.type === 'JSXElement') {\n const binding = contextBinding(this.context, node.openingElement.name);\n if (binding && !providerOf(this.context, node)) {\n // A lone `value` is turned down because it could be `undefined`.\n const { attributes } = node.openingElement;\n const attribute = attributes.at(0);\n const onlyValue =\n attributes.length === 1 &&\n attribute?.type === 'JSXAttribute' &&\n attribute.name.type === 'JSXIdentifier' &&\n attribute.name.name === 'value';\n recordSkip(\n this.context,\n 'contexts',\n onlyValue && !node.openingElement.selfClosing ? 'provider-undefined' : 'provider-shape',\n binding.name,\n );\n }\n }\n forEachChild(node, visit);\n };\n visit(this.context.program);\n }\n\n private tryRemove(provider: Provider): boolean {\n const { element } = provider;\n const children = element.children;\n let reason = 'open-other';\n const closed = children.every((child) =>\n isClosed(this.context, child, {\n component: () => false,\n contextValue: (target) => (target === provider.context ? provider.value : undefined),\n onOpen: (open) => {\n reason = open;\n },\n }),\n );\n if (!closed) {\n this.skip(provider, reason);\n return false;\n }\n const reads = children.flatMap((child) => contextReads(this.context, child, provider.context));\n const texts: string[] = [];\n for (const read of reads) {\n const text = stableValueText(this.context, provider, read);\n if (text === undefined) {\n this.skip(provider, 'provider-value');\n return false;\n }\n texts.push(text);\n }\n // With no reads, the value is only dropped when evaluating it does nothing.\n if (reads.length === 0 && !isSideEffectFree(provider.value)) {\n const stable = stableValueText(this.context, provider, element);\n if (stable === undefined) {\n this.skip(provider, 'provider-value');\n return false;\n }\n }\n const { s } = this.context;\n for (const [index, read] of reads.entries()) {\n s.overwrite(read.start, read.end, texts[index] ?? '');\n }\n const { openingElement, closingElement } = element;\n s.overwrite(openingElement.start, openingElement.end, '<>');\n if (closingElement) {\n s.overwrite(closingElement.start, closingElement.end, '</>');\n }\n this.changed = true;\n return true;\n }\n}\n\n/**\n * Runs the provider pass over a parsed program. Returns whether anything changed.\n */\nexport function removeProviders(context: PassContext): boolean {\n const remover = new ProviderRemover(context);\n remover.run();\n return remover.changed;\n}\n","/**\n * Measures a component's copy at a call site: folds it as the passes after\n * inlining would, then estimates its size with `SizeEstimator`.\n */\nimport MagicString from 'magic-string';\nimport { collectParents, parse } from './ast';\nimport type { ResolvedOptions } from './context';\nimport { fold } from './fold';\nimport { analyzeScopes } from './scope';\nimport { SizeEstimator } from './size';\n\n/** The name of the function a copy is wrapped in to be folded and measured. */\nconst WRAPPER = '__so_size__';\n\nexport interface Copy {\n /** The statements the copy hoists out of the JSX. */\n readonly statements: readonly string[];\n /** The JSX that replaces the call site. */\n readonly root: string;\n}\n\n/**\n * The size of a component's copy at one call site, once its props have\n * folded. `header` declares the names the fold pass needs to know, like\n * imports of Solid. `inTemplate` is whether the call site sits directly in\n * an element.\n */\nexport function copySize(\n filename: string,\n header: string,\n copy: Copy,\n inTemplate: boolean,\n options: ResolvedOptions,\n): number {\n let code = `${header}\\nfunction ${WRAPPER}() {\\n${copy.statements.join('\\n')}\\nreturn (${copy.root});\\n}\\n`;\n // Constant props fold the copy's conditions, as later passes would.\n for (let round = 0; round < 3; round += 1) {\n const program = parse(filename, code);\n const s = new MagicString(code);\n const changed = fold({\n code,\n filename,\n s,\n program,\n parents: collectParents(program),\n scopes: analyzeScopes(program),\n options,\n // Only the copy is measured, so nothing it skips is reported.\n skips: undefined,\n });\n if (!changed) {\n break;\n }\n code = s.toString();\n }\n const program = parse(filename, code);\n const wrapper = program.body.at(-1);\n if (wrapper?.type !== 'FunctionDeclaration' || !wrapper.body) {\n return Number.POSITIVE_INFINITY;\n }\n const estimator = new SizeEstimator(code);\n let size = 0;\n for (const statement of wrapper.body.body) {\n if (statement.type !== 'ReturnStatement') {\n size += estimator.node(statement);\n continue;\n }\n if (statement.argument) {\n size += estimator.root(statement.argument, inTemplate);\n }\n }\n return size;\n}\n","/**\n * The inline pass: replaces a component call with the component's body.\n *\n * `<Card title=\"Hi\" />` with `function Card(props) { return <div>{props.title}</div>; }`\n * becomes `<div>{\"Hi\"}</div>`. The JSX transform then sees one tree instead of\n * two, so it emits one template, one clone, and fewer hydration markers.\n *\n * A component inlines when its shape keeps the result equivalent:\n *\n * - It is declared once at the top level of the module, with a capitalized\n * name, as a function declaration or a `const` bound to a function.\n * - It takes no parameter, or one identifier that is only read as `props.name`,\n * or spread onto an element as `{...props}`.\n * - Its body is statements followed by one final `return` of JSX, or an arrow\n * function whose body is JSX.\n * - It does not use `this`, `arguments`, `new.target`, or `super`.\n *\n * A call site inlines when it passes plain attributes: no spread and no\n * namespaced attribute. A `ref` moves to the element the component forwards\n * `props.ref` to. See `refValue`.\n *\n * # How props keep their meaning\n *\n * Solid passes a dynamic prop as a getter, so every read of `props.name`\n * evaluates the attribute's expression again. Inlining replaces each read\n * with the expression itself, which does the same.\n *\n * A static prop, such as an identifier or a function, is evaluated once when\n * the component is created. Its expression is substituted directly when that\n * gives the same value, such as a literal or a binding nothing reassigns, or\n * when the prop is read exactly once. Otherwise its value is stored in a\n * `const` before the component body runs.\n *\n * # Where a component body can go\n *\n * A component whose body is only JSX inlines anywhere JSX can go.\n *\n * Statements, and stored props, have to run where the component would have\n * been created. Solid runs a component untracked, so the statements move into\n * the function whose returned JSX holds the call, when that function also\n * runs untracked:\n *\n * - a component;\n * - the child callback of `<For>` or `<Repeat>`, which runs once per item\n * under its own owner;\n * - the child callback of `<Show>` or `<Match>` that takes the value, which\n * runs once each time the condition turns true;\n * - the callback given to `render`, which runs once under its root.\n *\n * The call has to be in that returned JSX with only intrinsic elements and\n * fragments around it, so it is created exactly once each time that function\n * runs.\n *\n * A context provider is a component, so statements do not move out of it,\n * and `useContext` still runs under it. The exception is a provider whose\n * subtree only runs visible code. Statements move out through it, and each\n * `useContext` of its context in a copy becomes its value. See `provider.ts`.\n *\n * The props can also be read through `merge()` and `omit()` views declared\n * in the component. Each call site knows which props it passes, so a read\n * of a view resolves to a prop, a literal default, or `undefined`, and a\n * spread of a view becomes the attributes it holds.\n *\n * # Accepted differences\n *\n * - A prop that is a function and is called as `props.name()` runs with\n * `this` set to its own receiver instead of the props object.\n * - Statements moved into the host run before the host's JSX is created,\n * instead of while it is created. The order of `onSettled` and effect\n * registration across siblings can change.\n */\nimport MagicString from 'magic-string';\nimport type {\n ArrowFunctionExpression,\n CallExpression,\n Expression,\n Function as FunctionNode,\n JSXAttribute,\n JSXChild,\n JSXElement,\n JSXExpressionContainer,\n JSXFragment,\n JSXSpreadAttribute,\n MemberExpression,\n Node,\n ReturnStatement,\n Statement,\n} from 'oxc-parser';\nimport {\n forEachChild,\n isFunctionNode,\n isInsignificant,\n isIntrinsicTag,\n isJSXChild,\n isPrimary,\n unwrap,\n} from './ast';\nimport type { PassContext, ResolvedOptions } from './context';\nimport { isConstantDeclaration, recordSkip, solidExport, textOf } from './context';\nimport type { Piece } from './jsx';\nimport type { ClosedOptions, Provider } from './provider';\nimport {\n contextBinding,\n contextReads,\n findProviders,\n isClosed,\n solidCallee,\n stableValueText,\n} from './provider';\nimport { keptPiece, replacedPiece, writePieces } from './jsx';\nimport type { Binding, Scope } from './scope';\nimport { isWithinScope, lookup, scopeAt } from './scope';\nimport { copySize } from './copy-size';\nimport { SizeEstimator } from './size';\nimport { evaluate, literalText } from './value';\n\ntype ComponentFunction = FunctionNode | ArrowFunctionExpression;\n\ninterface ReadCount {\n /** Whether the read can run more than once per component instance. */\n readonly repeated: boolean;\n}\n\ninterface PropRead extends ReadCount {\n readonly member: MemberExpression;\n readonly name: string;\n}\n\n/**\n * One source of a `merge()` or `omit()` view: the props, or an object of\n * literal defaults, with the keys an `omit()` hides from it.\n */\ninterface ViewSource {\n /** The default of each key, as literal text, or `undefined` for the props. */\n readonly defaults: ReadonlyMap<string, string> | undefined;\n readonly hidden: ReadonlySet<string>;\n}\n\n/** A props object made with `merge()` and `omit()`, in source order. */\ninterface View {\n readonly sources: readonly ViewSource[];\n}\n\ninterface ViewRead extends PropRead {\n readonly view: View;\n}\n\ninterface ResolvedSpread {\n readonly spread: ViewSpread;\n /** Each key and its default text, or `undefined` when the props hold it. */\n readonly keys: ReadonlyMap<string, string | undefined>;\n}\n\ninterface ResolvedViews {\n /** Reads of the props, including view reads the props answer. */\n readonly propReads: readonly PropRead[];\n /** View reads a default or nothing answers, and their text. */\n readonly texts: ReadonlyMap<Node, string>;\n readonly spreads: readonly ResolvedSpread[];\n}\n\ninterface ViewSpread extends ReadCount {\n readonly attribute: JSXSpreadAttribute;\n readonly element: JSXElement;\n readonly view: View;\n}\n\ninterface OuterReference {\n readonly name: string;\n readonly binding: Binding | undefined;\n}\n\ninterface Component {\n readonly binding: Binding;\n readonly fn: ComponentFunction;\n /** The statement that declares the component, when it can be removed. */\n readonly declaration: Node | undefined;\n readonly statements: readonly Statement[];\n readonly root: JSXElement | JSXFragment;\n readonly props: readonly PropRead[];\n /** The props parameter, when there is one. */\n readonly param: Binding | undefined;\n /** Reads of a `merge()` or `omit()` view, which a call site resolves. */\n readonly viewReads: readonly ViewRead[];\n /** Spreads of a view onto an element, which become the attributes it holds. */\n readonly viewSpreads: readonly ViewSpread[];\n /** The declarations of the views, which a copy drops. */\n readonly viewDeclarations: readonly Statement[];\n /** Bindings declared inside the component, which get fresh names in every copy. */\n readonly locals: readonly Binding[];\n /** References to bindings outside the component, which must mean the same at the call site. */\n readonly outer: readonly OuterReference[];\n}\n\ninterface CallSite {\n readonly component: Component;\n readonly element: JSXElement;\n}\n\n/** A copy of a component, ready to replace a call site. */\ninterface PreparedSite {\n readonly element: JSXElement;\n /** Where the statements go, when there are any. */\n readonly host: { fn: Node; host: Host } | undefined;\n readonly statements: string[];\n readonly root: string;\n}\n\nfunction isWithin(node: Node, container: Node): boolean {\n return node.start >= container.start && node.end <= container.end;\n}\n\n/**\n * Orders call sites so every call inside a component's body comes before\n * the calls to that component, and every call nested inside another call's\n * element comes before that call. An outer call copies the current text of\n * the calls inside it, so they must be done first.\n */\nfunction inBodyOrder(sites: readonly CallSite[]): CallSite[] {\n const pending = [...sites];\n const ordered: CallSite[] = [];\n while (pending.length > 0) {\n const ready = pending.filter(\n (site) =>\n !pending.some(\n (other) =>\n other !== site &&\n (isWithin(other.element, site.component.fn) || isWithin(other.element, site.element)),\n ),\n );\n // A cycle cannot happen, since a component that renders itself is not\n // inlined, but falling back to the original order keeps this finite.\n const next = ready.length > 0 ? ready : pending;\n for (const site of next) {\n ordered.push(site);\n pending.splice(pending.indexOf(site), 1);\n }\n }\n return ordered;\n}\n\n/**\n * Where a component's statements go.\n */\ntype Host =\n | { readonly kind: 'return'; readonly statement: ReturnStatement }\n | { readonly kind: 'arrow'; readonly body: Expression };\n\n/**\n * How one prop is read in a copy of the component.\n */\ntype PropValue =\n /** Replaced with an expression at every read. */\n | { readonly kind: 'expression'; readonly text: string; readonly primary: boolean }\n /** JSX, spliced in place when read as a JSX child. */\n | { readonly kind: 'jsx'; readonly text: string; readonly primary: boolean }\n /** JSX children, spliced in place when read as a JSX child. */\n | {\n readonly kind: 'children';\n readonly children: readonly JSXChild[];\n readonly text: string;\n readonly primary: boolean;\n };\n\nconst UNDEFINED: PropValue = { kind: 'expression', text: 'void 0', primary: false };\n\nfunction isCapitalized(name: string): boolean {\n return /^[A-Z]/.test(name);\n}\n\nfunction isReservedPropName(name: string): boolean {\n return name === '__proto__' || Object.hasOwn(Object.prototype, name);\n}\n\n/**\n * Whether `node` uses what its enclosing function provides: `this`,\n * `arguments`, `super`, `new.target`, `await`, or `yield`. Moving such code\n * into another function would change what it refers to.\n */\nexport function usesFunctionContext(context: PassContext, node: Node): boolean {\n let found = false;\n const visit = (current: Node): void => {\n if (found) {\n return;\n }\n switch (current.type) {\n case 'ThisExpression':\n case 'Super':\n case 'AwaitExpression':\n case 'YieldExpression':\n found = true;\n return;\n case 'MetaProperty':\n found = current.meta.name === 'new';\n return;\n case 'Identifier':\n // `arguments` and a direct `eval` read the function they run in.\n found =\n (current.name === 'arguments' || current.name === 'eval') &&\n context.scopes.references.has(current) &&\n context.scopes.references.get(current) === undefined;\n break;\n // These have their own `this`, `arguments`, and `new.target`.\n case 'FunctionDeclaration':\n case 'FunctionExpression':\n case 'ClassDeclaration':\n case 'ClassExpression':\n return;\n default:\n forEachChild(current, visit);\n }\n };\n forEachChild(node, visit);\n return found;\n}\n\n/**\n * Whether `node` contains a `return` that belongs to the function being searched.\n */\nfunction containsReturn(node: Node): boolean {\n let found = false;\n const visit = (current: Node): void => {\n if (found || isFunctionNode(current)) {\n return;\n }\n if (current.type === 'ReturnStatement') {\n found = true;\n return;\n }\n forEachChild(current, visit);\n };\n visit(node);\n return found;\n}\n\n/**\n * Whether Solid would pass an attribute expression as a getter. The JSX\n * transform wraps any expression that reads a member or calls a function.\n */\nfunction isDynamic(node: Node): boolean {\n let found = false;\n const visit = (current: Node): void => {\n if (found) {\n return;\n }\n switch (current.type) {\n case 'CallExpression':\n case 'NewExpression':\n case 'MemberExpression':\n case 'TaggedTemplateExpression':\n case 'ChainExpression':\n case 'JSXElement':\n case 'JSXFragment':\n found = true;\n break;\n case 'ArrowFunctionExpression':\n case 'FunctionExpression':\n break;\n default:\n forEachChild(current, visit);\n }\n };\n visit(node);\n return found;\n}\n\n/**\n * Whether any expression short of a sequence can replace `node` without\n * parentheses, because its slot is a whole expression of its own.\n */\nfunction acceptsAnyExpression(context: PassContext, node: Node): boolean {\n const parent = context.parents.get(node);\n if (!parent) {\n return false;\n }\n switch (parent.type) {\n case 'JSXExpressionContainer':\n case 'JSXSpreadAttribute':\n case 'SpreadElement':\n case 'ArrayExpression':\n case 'TemplateLiteral':\n case 'ReturnStatement':\n return true;\n case 'CallExpression':\n case 'NewExpression':\n return parent.callee !== node;\n case 'VariableDeclarator':\n return parent.init === node;\n case 'AssignmentExpression':\n return parent.right === node;\n case 'Property':\n return parent.value === node && !parent.shorthand;\n default:\n return false;\n }\n}\n\n/**\n * The function a top-level binding declares, if it declares one.\n */\nfunction functionOf(binding: Binding, options: ResolvedOptions): ComponentFunction | undefined {\n const { declaration } = binding;\n if (binding.kind === 'function' && declaration.type === 'FunctionDeclaration') {\n return declaration;\n }\n if (\n isConstantDeclaration(binding, options) &&\n declaration.type === 'VariableDeclarator' &&\n declaration.id === binding.identifier &&\n declaration.init\n ) {\n const init = unwrap(declaration.init);\n if (init.type === 'ArrowFunctionExpression' || init.type === 'FunctionExpression') {\n return init;\n }\n }\n return undefined;\n}\n\n/**\n * The attributes of a call site by name, or `undefined` when one cannot be inlined.\n */\nfunction attributesOf(element: JSXElement): Map<string, JSXAttribute> | undefined {\n const attributes = new Map<string, JSXAttribute>();\n for (const attribute of element.openingElement.attributes) {\n // A spread can supply any prop, and a namespaced attribute is something\n // the JSX transform handles on its own.\n if (\n attribute.type !== 'JSXAttribute' ||\n attribute.name.type !== 'JSXIdentifier' ||\n (attribute.name.name === 'ref' && !isForwardableRef(attribute)) ||\n attributes.has(attribute.name.name)\n ) {\n return undefined;\n }\n attributes.set(attribute.name.name, attribute);\n }\n return attributes;\n}\n\n/**\n * Whether a top-level statement declares only constants made of literals,\n * like `const ROWS = [{ name: 'a' }]`. An export keeps its `export`, since\n * the fold pass treats an exported list differently.\n */\nfunction isDataDeclaration(statement: Node): boolean {\n const declaration =\n statement.type === 'ExportNamedDeclaration' ? statement.declaration : statement;\n return (\n declaration?.type === 'VariableDeclaration' &&\n !declaration.declare &&\n (declaration.kind === 'const' || declaration.kind === 'var') &&\n declaration.declarations.every(\n (declarator) =>\n declarator.id.type === 'Identifier' &&\n declarator.init !== null &&\n isDataLiteral(declarator.init),\n )\n );\n}\n\n/** Whether an expression is a literal, or an array or object literal of them. */\nfunction isDataLiteral(node: Expression): boolean {\n switch (node.type) {\n case 'Literal':\n return !('regex' in node);\n case 'TemplateLiteral':\n return node.expressions.length === 0;\n case 'UnaryExpression':\n return node.operator === '-' && node.argument.type === 'Literal';\n case 'ParenthesizedExpression':\n case 'TSAsExpression':\n case 'TSSatisfiesExpression':\n return isDataLiteral(node.expression);\n case 'ArrayExpression':\n return node.elements.every(\n (element) => element !== null && element.type !== 'SpreadElement' && isDataLiteral(element),\n );\n case 'ObjectExpression':\n return node.properties.every(\n (property) =>\n property.type === 'Property' &&\n property.kind === 'init' &&\n !property.method &&\n !property.computed &&\n isDataLiteral(property.value),\n );\n default:\n return false;\n }\n}\n\nfunction isMemberRead(read: ReadCount): read is PropRead {\n return 'member' in read;\n}\n\n/**\n * Whether a `ref` at a call site can move to the element the component\n * forwards it to: a name, a function, or an array of them. A name is\n * assigned the element, so it has to stay the name itself. Anything else\n * would be evaluated when the element is made, outside the `untrack` the\n * component's `ref` runs it in.\n */\nfunction isForwardableRef(attribute: JSXAttribute): boolean {\n const { value } = attribute;\n if (value?.type !== 'JSXExpressionContainer' || value.expression.type === 'JSXEmptyExpression') {\n return false;\n }\n const isTarget = (node: Expression): boolean => {\n const inner = unwrap(node);\n if (inner.type === 'ArrayExpression') {\n return inner.elements.every(\n (element) => element !== null && element.type !== 'SpreadElement' && isTarget(element),\n );\n }\n return (\n inner.type === 'Identifier' ||\n inner.type === 'ArrowFunctionExpression' ||\n inner.type === 'FunctionExpression'\n );\n };\n return isTarget(value.expression);\n}\n\n/**\n * Why `attributesOf` turns down a call site, for the report.\n */\nfunction callSiteReason(element: JSXElement): string {\n const names = new Set<string>();\n for (const attribute of element.openingElement.attributes) {\n if (attribute.type !== 'JSXAttribute') {\n return 'call-spread';\n }\n if (attribute.name.type !== 'JSXIdentifier') {\n return 'call-namespace';\n }\n if (attribute.name.name === 'ref') {\n return 'call-ref';\n }\n if (names.has(attribute.name.name)) {\n break;\n }\n names.add(attribute.name.name);\n }\n return 'call-duplicate';\n}\n\nfunction isAssignmentTarget(context: PassContext, node: Node): boolean {\n const parent = context.parents.get(node);\n if (!parent) {\n return false;\n }\n switch (parent.type) {\n case 'AssignmentExpression':\n return parent.left === node;\n case 'UpdateExpression':\n return true;\n case 'UnaryExpression':\n return parent.operator === 'delete';\n case 'ForInStatement':\n case 'ForOfStatement':\n return parent.left === node;\n case 'ArrayPattern':\n case 'ObjectPattern':\n case 'RestElement':\n return true;\n case 'AssignmentPattern':\n return parent.left === node;\n case 'Property':\n return parent.value === node && context.parents.get(parent)?.type === 'ObjectPattern';\n case 'ParenthesizedExpression':\n return isAssignmentTarget(context, parent);\n default:\n return false;\n }\n}\n\nclass Inliner {\n changed = false;\n\n private readonly hosts = new Map<Node, { host: Host; texts: string[] }>();\n\n /**\n * Providers whose subtree is closed, so statements can move out through\n * them. Each maps to the text its reads become, or `undefined` when a\n * binding that never changes is read at each site.\n */\n private readonly transparent = new Map<JSXElement, { provider: Provider; text?: string }>();\n\n constructor(private readonly context: PassContext) {}\n\n /** Why the last component or call site was turned down, for the report. */\n private reason = '';\n\n /**\n * Whether a binding holds a component made by Solid's `lazy`, for the\n * report. In a chunk, `lazy` can be a local declaration under another\n * name, so a call given a function with a dynamic import counts too.\n */\n private isLazy(binding: Binding): boolean {\n const { declaration } = binding;\n const init =\n declaration.type === 'VariableDeclarator' && declaration.init\n ? unwrap(declaration.init)\n : undefined;\n if (init?.type !== 'CallExpression' || init.callee.type !== 'Identifier') {\n return false;\n }\n const callee = this.context.scopes.references.get(init.callee);\n if (callee && solidExport(callee, this.context.options) === 'lazy') {\n return true;\n }\n const loader = init.arguments.at(0);\n if (!loader || !isFunctionNode(loader)) {\n return false;\n }\n let imports = false;\n const visit = (node: Node): void => {\n if (node.type === 'ImportExpression') {\n imports = true;\n }\n if (!imports) {\n forEachChild(node, visit);\n }\n };\n visit(loader);\n return imports;\n }\n\n // ---------------------------------------------------------------------------\n // Components\n // ---------------------------------------------------------------------------\n\n private scopeOf(fn: ComponentFunction): Scope | undefined {\n return this.context.scopes.scopes.get(fn);\n }\n\n /**\n * The statement to remove once nothing uses the component, or `undefined`\n * when the declaration has to stay, like an exported one.\n */\n private removableDeclaration(binding: Binding): Node | undefined {\n const { declaration } = binding;\n if (declaration.type === 'FunctionDeclaration') {\n return this.context.parents.get(declaration)?.type === 'Program' ? declaration : undefined;\n }\n const statement = this.context.parents.get(declaration);\n if (\n statement?.type === 'VariableDeclaration' &&\n statement.declarations.length === 1 &&\n this.context.parents.get(statement)?.type === 'Program'\n ) {\n return statement;\n }\n return undefined;\n }\n\n private analyzeComponent(binding: Binding): Component | undefined {\n if (!isCapitalized(binding.name)) {\n return undefined;\n }\n if (binding.mutated) {\n this.reason = 'component-mutated';\n return undefined;\n }\n const fn = functionOf(binding, this.context.options);\n if (!fn?.body) {\n this.reason = this.isLazy(binding) ? 'lazy' : 'not-a-function';\n return undefined;\n }\n if (fn.async || fn.generator) {\n this.reason = 'component-async';\n return undefined;\n }\n if (fn.params.length > 1) {\n this.reason = 'component-params';\n return undefined;\n }\n const scope = this.scopeOf(fn);\n if (!scope) {\n this.reason = 'not-a-function';\n return undefined;\n }\n\n // The body: statements, then one `return` of JSX.\n let statements: Statement[] = [];\n let root: Expression;\n if (fn.body.type === 'BlockStatement') {\n const body = fn.body.body;\n const last = body.at(-1);\n if (last?.type !== 'ReturnStatement' || !last.argument) {\n this.reason = 'component-body';\n return undefined;\n }\n const rest: Statement[] = [];\n for (const statement of body.slice(0, -1)) {\n // A directive like `\"use strict\"` changes how the body runs.\n // TypeScript's AST gives every expression statement a `directive`\n // key, which is `null` unless the statement is a directive.\n const directive = 'directive' in statement ? statement.directive : null;\n if (typeof directive === 'string') {\n this.reason = 'component-directive';\n return undefined;\n }\n if (containsReturn(statement)) {\n this.reason = 'component-return';\n return undefined;\n }\n rest.push(statement);\n }\n statements = rest;\n root = unwrap(last.argument);\n } else {\n root = unwrap(fn.body);\n }\n if (root.type !== 'JSXElement' && root.type !== 'JSXFragment') {\n this.reason = 'component-body';\n return undefined;\n }\n if (usesFunctionContext(this.context, fn.body)) {\n this.reason = 'component-this';\n return undefined;\n }\n\n // The parameter is only read as `props.name`.\n const param = fn.params.at(0);\n let paramBinding: Binding | undefined;\n if (param) {\n if (param.type !== 'Identifier') {\n this.reason = 'component-params';\n return undefined;\n }\n paramBinding = scope.bindings.get(param.name);\n if (!paramBinding || paramBinding.mutated) {\n this.reason = 'props-use';\n return undefined;\n }\n }\n const views = this.analyzeViews(fn, scope, statements, paramBinding);\n if (!views) {\n this.reason = 'view-use';\n return undefined;\n }\n const props: PropRead[] = [];\n for (const reference of paramBinding?.references ?? []) {\n if (views.arguments.has(reference)) {\n continue;\n }\n const read = this.propRead(fn, reference);\n if (!read) {\n this.reason = 'props-use';\n return undefined;\n }\n props.push(read);\n }\n statements = statements.filter((statement) => !views.declarations.includes(statement));\n\n const locals: Binding[] = [];\n const seen = new Set<Scope>();\n for (const inner of this.context.scopes.scopes.values()) {\n if (seen.has(inner) || !isWithinScope(inner, scope)) {\n continue;\n }\n seen.add(inner);\n for (const local of inner.bindings.values()) {\n // A view's declaration and every use of it are replaced in a copy.\n if (local !== paramBinding && !views.bindings.has(local)) {\n locals.push(local);\n }\n }\n }\n\n const outer: OuterReference[] = [];\n for (const [reference, target] of this.context.scopes.references) {\n if (reference.start < fn.start || reference.end > fn.end) {\n continue;\n }\n // A component that renders itself cannot be inlined into itself.\n if (target === binding) {\n this.reason = 'component-recursive';\n return undefined;\n }\n if (target && isWithinScope(target.scope, scope)) {\n continue;\n }\n if (reference.type === 'Identifier' || reference.type === 'JSXIdentifier') {\n outer.push({ name: reference.name, binding: target });\n }\n }\n\n return {\n binding,\n fn,\n declaration: this.removableDeclaration(binding),\n statements,\n root,\n props,\n param: paramBinding,\n viewReads: views.reads,\n viewSpreads: views.spreads,\n viewDeclarations: views.declarations,\n locals,\n outer,\n };\n }\n\n private propRead(fn: ComponentFunction, reference: Node): PropRead | undefined {\n const member = this.context.parents.get(reference);\n if (member?.type !== 'MemberExpression' || member.object !== reference) {\n return undefined;\n }\n let name: string;\n if (!member.computed && member.property.type === 'Identifier') {\n name = member.property.name;\n } else if (\n member.computed &&\n member.property.type === 'Literal' &&\n typeof member.property.value === 'string'\n ) {\n name = member.property.value;\n } else {\n return undefined;\n }\n if (isReservedPropName(name) || isAssignmentTarget(this.context, member)) {\n return undefined;\n }\n return { member, name, repeated: this.isRepeated(fn, member) };\n }\n\n /**\n * Whether `node` can run more than once each time `fn` runs.\n */\n private isRepeated(fn: ComponentFunction, node: Node): boolean {\n let current = this.context.parents.get(node);\n while (current && current !== fn) {\n if (\n isFunctionNode(current) ||\n current.type === 'ForStatement' ||\n current.type === 'ForInStatement' ||\n current.type === 'ForOfStatement' ||\n current.type === 'WhileStatement' ||\n current.type === 'DoWhileStatement'\n ) {\n return true;\n }\n current = this.context.parents.get(current);\n }\n return false;\n }\n\n /**\n * Finds the `merge()` and `omit()` views of the props declared in a\n * component's statements, and how each is used. A view can only be read\n * as `view.name`, spread onto an element, or passed to another view.\n * `undefined` when a view is used any other way.\n */\n private analyzeViews(\n fn: ComponentFunction,\n scope: Scope,\n statements: readonly Statement[],\n param: Binding | undefined,\n ):\n | {\n bindings: Set<Binding>;\n arguments: Set<Node>;\n declarations: Statement[];\n reads: ViewRead[];\n spreads: ViewSpread[];\n }\n | undefined {\n const views = new Map<Binding, View>();\n const args = new Set<Node>();\n const declarations: Statement[] = [];\n for (const statement of statements) {\n const declarator =\n statement.type === 'VariableDeclaration' ? statement.declarations.at(0) : undefined;\n if (\n statement.type !== 'VariableDeclaration' ||\n statement.kind !== 'const' ||\n statement.declarations.length !== 1 ||\n declarator?.id.type !== 'Identifier' ||\n !declarator.init\n ) {\n continue;\n }\n const init = unwrap(declarator.init);\n const callee = init.type === 'CallExpression' ? solidCallee(this.context, init) : undefined;\n if (init.type !== 'CallExpression' || (callee !== 'merge' && callee !== 'omit')) {\n continue;\n }\n const view = this.viewOf(callee, init, param, views, args);\n if (view === null) {\n continue;\n }\n const binding = scope.bindings.get(declarator.id.name);\n if (!view || !binding || binding.mutated) {\n return undefined;\n }\n views.set(binding, view);\n declarations.push(statement);\n }\n\n const reads: ViewRead[] = [];\n const spreads: ViewSpread[] = [];\n // `{...props}` spreads every prop, like a view of the props with nothing hidden.\n const whole: View = { sources: [{ defaults: undefined, hidden: new Set() }] };\n for (const reference of param?.references ?? []) {\n const spread = this.spreadOnElement(reference);\n if (spread) {\n args.add(reference);\n spreads.push({\n attribute: spread.attribute,\n element: spread.element,\n view: whole,\n repeated: this.isRepeated(fn, spread.attribute),\n });\n }\n }\n for (const [binding, view] of views) {\n for (const reference of binding.references) {\n if (args.has(reference)) {\n continue;\n }\n const spread = this.spreadOnElement(reference);\n if (spread) {\n spreads.push({\n attribute: spread.attribute,\n element: spread.element,\n view,\n repeated: this.isRepeated(fn, spread.attribute),\n });\n continue;\n }\n const read = this.propRead(fn, reference);\n if (!read) {\n return undefined;\n }\n reads.push({ ...read, view });\n }\n }\n return { bindings: new Set(views.keys()), arguments: args, declarations, reads, spreads };\n }\n\n /** The spread a reference is the whole argument of, and the element it is on. */\n private spreadOnElement(\n reference: Node,\n ): { attribute: JSXSpreadAttribute; element: JSXElement } | undefined {\n const parent = this.context.parents.get(reference);\n const opening = parent ? this.context.parents.get(parent) : undefined;\n const element = opening ? this.context.parents.get(opening) : undefined;\n return parent?.type === 'JSXSpreadAttribute' &&\n opening?.type === 'JSXOpeningElement' &&\n element?.type === 'JSXElement'\n ? { attribute: parent, element }\n : undefined;\n }\n\n /**\n * The view a `merge()` or `omit()` call makes. `null` when it does not\n * take the props or another view, and `undefined` when it does but its\n * other arguments are not literal.\n */\n private viewOf(\n callee: 'merge' | 'omit',\n call: CallExpression,\n param: Binding | undefined,\n views: ReadonlyMap<Binding, View>,\n args: Set<Node>,\n ): View | null | undefined {\n const sourcesOf = (argument: Node): readonly ViewSource[] | undefined => {\n if (argument.type === 'CallExpression') {\n const nested = solidCallee(this.context, argument);\n if (nested !== 'merge' && nested !== 'omit') {\n return undefined;\n }\n return this.viewOf(nested, argument, param, views, args)?.sources;\n }\n if (argument.type !== 'Identifier') {\n return undefined;\n }\n const binding = this.context.scopes.references.get(argument);\n if (binding && binding === param) {\n return [{ defaults: undefined, hidden: new Set() }];\n }\n return binding ? views.get(binding)?.sources : undefined;\n };\n const involved = call.arguments.some(\n (argument) => argument.type !== 'SpreadElement' && sourcesOf(unwrap(argument)) !== undefined,\n );\n if (!involved) {\n return null;\n }\n\n if (callee === 'omit') {\n const first = call.arguments.at(0);\n const keys = call.arguments.slice(1);\n if (first === undefined || first.type === 'SpreadElement') {\n return undefined;\n }\n const target = unwrap(first);\n const base = sourcesOf(target);\n const hidden: string[] = [];\n for (const key of keys) {\n if (key.type !== 'Literal' || typeof key.value !== 'string') {\n return undefined;\n }\n hidden.push(key.value);\n }\n if (!base) {\n return undefined;\n }\n args.add(target);\n return {\n sources: base.map((source) => ({\n defaults: source.defaults,\n hidden: new Set([...source.hidden, ...hidden]),\n })),\n };\n }\n\n const sources: ViewSource[] = [];\n for (const argument of call.arguments) {\n if (argument.type === 'SpreadElement') {\n return undefined;\n }\n const inner = unwrap(argument);\n const existing = sourcesOf(inner);\n if (existing) {\n args.add(inner);\n sources.push(...existing);\n continue;\n }\n if (inner.type !== 'ObjectExpression') {\n return undefined;\n }\n const defaults = new Map<string, string>();\n for (const property of inner.properties) {\n if (property.type !== 'Property' || property.kind !== 'init' || property.computed) {\n return undefined;\n }\n let key: string;\n if (property.key.type === 'Identifier') {\n key = property.key.name;\n } else if (property.key.type === 'Literal' && typeof property.key.value === 'string') {\n key = property.key.value;\n } else {\n return undefined;\n }\n const value = evaluate(property.value, () => undefined);\n const text = value ? literalText(value.value) : undefined;\n if (text === undefined || isReservedPropName(key)) {\n return undefined;\n }\n defaults.set(key, text);\n }\n sources.push({ defaults, hidden: new Set() });\n }\n return { sources };\n }\n\n // ---------------------------------------------------------------------------\n // Call sites\n // ---------------------------------------------------------------------------\n\n /**\n * Whether a function is a component, which Solid runs untracked. Only a\n * capitalized function bound at its declaration counts.\n */\n private isComponentFunction(fn: Node): boolean {\n if (fn.type === 'FunctionDeclaration') {\n return !fn.async && !fn.generator && fn.id !== null && isCapitalized(fn.id.name);\n }\n if (fn.type !== 'FunctionExpression' && fn.type !== 'ArrowFunctionExpression') {\n return false;\n }\n if (fn.async || fn.generator) {\n return false;\n }\n let parent = this.context.parents.get(fn);\n while (parent?.type === 'ParenthesizedExpression') {\n parent = this.context.parents.get(parent);\n }\n return (\n parent?.type === 'VariableDeclarator' &&\n parent.id.type === 'Identifier' &&\n isCapitalized(parent.id.name)\n );\n }\n\n /**\n * Whether a function runs untracked, once each time the JSX it returns is\n * created, so it can take a component's statements. See \"Where a component\n * body can go\" above.\n */\n private isHostFunction(fn: Node): boolean {\n if (this.isComponentFunction(fn)) {\n return true;\n }\n if (\n (fn.type !== 'FunctionExpression' && fn.type !== 'ArrowFunctionExpression') ||\n fn.async ||\n fn.generator\n ) {\n return false;\n }\n let node: Node = fn;\n let parent = this.context.parents.get(node);\n while (parent?.type === 'ParenthesizedExpression') {\n node = parent;\n parent = this.context.parents.get(node);\n }\n // `render(() => <App />, element)` calls it once under a new root.\n if (parent?.type === 'CallExpression') {\n return parent.arguments.at(0) === node && this.solidCallee(parent.callee) === 'render';\n }\n // A built-in's only child.\n const element =\n parent?.type === 'JSXExpressionContainer' ? this.context.parents.get(parent) : undefined;\n if (element?.type !== 'JSXElement') {\n return false;\n }\n const significant = element.children.filter((child) => !isInsignificant(child));\n if (significant.length !== 1 || significant.at(0) !== parent) {\n return false;\n }\n switch (this.solidCallee(element.openingElement.name)) {\n case 'For':\n case 'Repeat':\n return true;\n // These only call a callback that takes the value. One without a parameter is a child to insert.\n case 'Show':\n case 'Match':\n return fn.params.length > 0;\n default:\n return false;\n }\n }\n\n /** The Solid export a callee or tag refers to. */\n private solidCallee(name: Node): string | undefined {\n if (name.type !== 'Identifier' && name.type !== 'JSXIdentifier') {\n return undefined;\n }\n const { references } = this.context.scopes;\n if (!references.has(name)) {\n return undefined;\n }\n const binding = references.get(name);\n return binding ? solidExport(binding, this.context.options) : undefined;\n }\n\n /**\n * Where the statements of a component created at `element` can go: the\n * returned JSX of a component, with only intrinsic elements, fragments,\n * and closed providers between it and the call.\n */\n private hostOf(element: JSXElement): { fn: Node; host: Host } | undefined {\n let node: Node = element;\n for (;;) {\n const parent = this.context.parents.get(node);\n if (!parent) {\n return undefined;\n }\n if (parent.type === 'JSXElement') {\n const { name } = parent.openingElement;\n const passable =\n this.assumedHosts?.has(parent) === true ||\n (name.type === 'JSXIdentifier' &&\n (isIntrinsicTag(name.name) || this.transparent.has(parent)));\n if (!passable) {\n return undefined;\n }\n const child = node;\n if (!parent.children.some((item) => item === child)) {\n return undefined;\n }\n } else if (parent.type === 'ReturnStatement') {\n const list = this.context.parents.get(parent);\n if (list?.type !== 'BlockStatement' && list?.type !== 'SwitchCase') {\n return undefined;\n }\n let fn = this.context.parents.get(list);\n while (fn && !isFunctionNode(fn)) {\n fn = this.context.parents.get(fn);\n }\n if (!fn || !this.isHostFunction(fn)) {\n return undefined;\n }\n return { fn, host: { kind: 'return', statement: parent } };\n } else if (parent.type === 'ArrowFunctionExpression') {\n if (parent.body !== node || !this.isHostFunction(parent)) {\n return undefined;\n }\n return { fn: parent, host: { kind: 'arrow', body: parent.body } };\n } else if (parent.type !== 'JSXFragment' && parent.type !== 'ParenthesizedExpression') {\n return undefined;\n }\n node = parent;\n }\n }\n\n private childrenValue(\n element: JSXElement,\n reads: readonly ReadCount[],\n fresh: (base: string) => string,\n snapshots: string[],\n ): PropValue | undefined {\n const { children } = element;\n if (children.some((child) => child.type === 'JSXSpreadChild')) {\n return undefined;\n }\n const significant = children.filter((child) => !isInsignificant(child));\n const only = significant.at(0);\n if (only === undefined) {\n return { kind: 'children', children: [], text: 'void 0', primary: false };\n }\n let text: string;\n let primary = true;\n if (significant.length > 1 || only.type === 'JSXText') {\n text = `<>${this.context.s.slice(element.openingElement.end, element.closingElement?.start ?? element.end)}</>`;\n } else if (only.type === 'JSXExpressionContainer') {\n if (only.expression.type === 'JSXEmptyExpression') {\n return undefined;\n }\n // A single expression is passed like an attribute value, such as a\n // render function that has to stay one function.\n const value = this.expressionValue(only.expression, 'children', reads, fresh, snapshots);\n if (value.kind !== 'expression' || value.text !== textOf(this.context, only.expression)) {\n return value;\n }\n text = value.text;\n primary = value.primary;\n } else {\n text = textOf(this.context, only);\n }\n return { kind: 'children', children, text, primary };\n }\n\n /**\n * How a `ref` from the call site reads in a copy. Solid passes a `ref` to\n * a component as a function that sets the call site's ref to the element\n * it is given. The component applies it with its own `ref`, which runs\n * while the element is made, so the call site's `ref` can move to that\n * element. Every read has to be the whole `ref` of an element or of\n * another component, or a key of a spread, which becomes one.\n */\n private refValue(\n attribute: JSXAttribute | undefined,\n reads: readonly ReadCount[],\n ): PropValue | undefined {\n const value = attribute?.value;\n if (\n value?.type !== 'JSXExpressionContainer' ||\n value.expression.type === 'JSXEmptyExpression'\n ) {\n return undefined;\n }\n for (const read of reads) {\n if (!isMemberRead(read)) {\n continue;\n }\n const container = this.context.parents.get(read.member);\n const owner = container ? this.context.parents.get(container) : undefined;\n if (\n container?.type !== 'JSXExpressionContainer' ||\n owner?.type !== 'JSXAttribute' ||\n owner.name.type !== 'JSXIdentifier' ||\n owner.name.name !== 'ref'\n ) {\n return undefined;\n }\n }\n return { kind: 'expression', text: textOf(this.context, value.expression), primary: true };\n }\n\n /**\n * How a prop reads in a copy of the component, and the `const` that stores\n * it first when the value has to be evaluated once.\n */\n private propValue(\n attribute: JSXAttribute | undefined,\n reads: readonly ReadCount[],\n fresh: (base: string) => string,\n snapshots: string[],\n ): PropValue | undefined {\n if (!attribute) {\n return UNDEFINED;\n }\n const { value } = attribute;\n if (value === null) {\n return { kind: 'expression', text: 'true', primary: true };\n }\n switch (value.type) {\n case 'Literal':\n // An attribute string can hold HTML entities, which are not decoded here.\n if (value.value.includes('&')) {\n return undefined;\n }\n return { kind: 'expression', text: JSON.stringify(value.value), primary: true };\n case 'JSXElement':\n case 'JSXFragment':\n return { kind: 'jsx', text: textOf(this.context, value), primary: true };\n default:\n break;\n }\n const { expression } = value;\n if (expression.type === 'JSXEmptyExpression') {\n return undefined;\n }\n const name = attribute.name.type === 'JSXIdentifier' ? attribute.name.name : 'prop';\n return this.expressionValue(expression, name, reads, fresh, snapshots);\n }\n\n /**\n * How an expression passed as a prop reads in a copy of the component.\n */\n private expressionValue(\n expression: Expression,\n name: string,\n reads: readonly ReadCount[],\n fresh: (base: string) => string,\n snapshots: string[],\n ): PropValue {\n const text = textOf(this.context, expression);\n const inner = unwrap(expression);\n if (inner.type === 'JSXElement' || inner.type === 'JSXFragment') {\n return { kind: 'jsx', text, primary: true };\n }\n const primary = isPrimary(expression);\n if (isDynamic(expression) || this.isStable(inner)) {\n return { kind: 'expression', text, primary };\n }\n // A static value is evaluated once. One read that runs once keeps that.\n const read = reads.at(0);\n if (reads.length === 1 && read && !read.repeated) {\n return { kind: 'expression', text, primary };\n }\n const local = fresh(name);\n snapshots.push(`const ${local} = ${text};`);\n return { kind: 'expression', text: local, primary: true };\n }\n\n /**\n * Whether evaluating `node` again gives the same value.\n */\n private isStable(node: Node): boolean {\n switch (node.type) {\n case 'Literal':\n // A regular expression literal creates a new object each time.\n return !('regex' in node);\n case 'TemplateLiteral':\n return node.expressions.length === 0;\n case 'UnaryExpression':\n return node.operator === '-' && node.argument.type === 'Literal';\n case 'Identifier': {\n const { references } = this.context.scopes;\n if (!references.has(node)) {\n return false;\n }\n const binding = references.get(node);\n if (!binding) {\n return node.name === 'undefined' || node.name === 'NaN' || node.name === 'Infinity';\n }\n return !binding.mutated;\n }\n default:\n return false;\n }\n }\n\n /** The names `freshName` takes from while copies are only measured. */\n private scratchNames: Set<string> | undefined;\n\n /**\n * Component calls measured as if they were inlined already, so the calls\n * in their children can hoist statements through them.\n */\n private assumedHosts: ReadonlySet<JSXElement> | undefined;\n\n private freshName(name: string): string {\n const names = this.scratchNames ?? this.context.scopes.names;\n // A name a copy gave out before, like `theme$1`, is renamed from `theme` again.\n const base = name.replace(/\\$\\d+$/, '');\n let index = 1;\n let fresh = `${base}$${String(index)}`;\n while (names.has(fresh)) {\n index += 1;\n fresh = `${base}$${String(index)}`;\n }\n names.add(fresh);\n return fresh;\n }\n\n /**\n * The copy of `component` that would replace `element`, or `undefined`\n * when it cannot be inlined there. Nothing is written until `commit`.\n */\n private prepare(component: Component, element: JSXElement): PreparedSite | undefined {\n const attributes = attributesOf(element);\n if (!attributes) {\n this.reason = callSiteReason(element);\n return undefined;\n }\n const hasChildren = element.children.some((child) => !isInsignificant(child));\n if (hasChildren && attributes.has('children')) {\n this.reason = 'call-children';\n return undefined;\n }\n for (const attribute of attributes.values()) {\n if (attribute.value && usesFunctionContext(this.context, attribute.value)) {\n this.reason = 'call-this';\n return undefined;\n }\n }\n for (const child of element.children) {\n if (usesFunctionContext(this.context, child)) {\n this.reason = 'call-this';\n return undefined;\n }\n }\n\n // What each view read and spread resolves to at this call site.\n const views = this.resolveViews(component, attributes, hasChildren);\n if (!views) {\n this.reason = 'view-conflict';\n return undefined;\n }\n\n // What each prop reads as.\n const snapshots: string[] = [];\n const fresh = (base: string): string => this.freshName(base);\n const readsByName = new Map<string, ReadCount[]>();\n const count = (name: string, read: ReadCount): void => {\n const reads = readsByName.get(name) ?? [];\n reads.push(read);\n readsByName.set(name, reads);\n };\n for (const read of views.propReads) {\n count(read.name, read);\n }\n for (const spread of views.spreads) {\n for (const [key, source] of spread.keys) {\n if (source === undefined) {\n count(key, spread.spread);\n }\n }\n }\n const values = new Map<string, PropValue>();\n for (const [name, reads] of readsByName) {\n let value: PropValue | undefined;\n if (name === 'children' && !attributes.has('children')) {\n value = this.childrenValue(element, reads, fresh, snapshots);\n } else if (name === 'ref' && attributes.has('ref')) {\n value = this.refValue(attributes.get('ref'), reads);\n } else {\n value = this.propValue(attributes.get(name), reads, fresh, snapshots);\n }\n if (!value) {\n // A `ref` is turned down when the component uses it other than as a `ref`.\n this.reason = name === 'ref' && attributes.has('ref') ? 'ref-use' : 'prop-value';\n return undefined;\n }\n values.set(name, value);\n }\n\n // The component's outer references must mean the same at the call site.\n const scope = scopeAt(this.context.scopes, this.context.parents, element);\n for (const reference of component.outer) {\n if (lookup(scope, reference.name) !== reference.binding) {\n this.reason = 'shadowed';\n return undefined;\n }\n }\n\n const hoisted = component.statements.length > 0 || snapshots.length > 0;\n const host = hoisted ? this.hostOf(element) : undefined;\n if (hoisted && !host) {\n this.reason = 'no-host';\n return undefined;\n }\n\n const contextTexts = this.contextTexts(component, element);\n if (!contextTexts) {\n this.reason = 'context-value';\n return undefined;\n }\n\n // Build the copy on the original code, so this pass's other edits stay out of it.\n const copy = new MagicString(this.context.code);\n this.renameLocals(copy, component, fresh);\n this.substituteProps(copy, views.propReads, values);\n this.substituteViews(copy, component, element, views, values);\n for (const [read, text] of contextTexts) {\n copy.overwrite(read.start, read.end, text);\n }\n\n const statements = [...snapshots];\n const first = component.statements.at(0);\n const last = component.statements.at(-1);\n if (first && last) {\n statements.push(copy.slice(first.start, last.end));\n }\n return {\n element,\n host,\n statements,\n root: copy.slice(component.root.start, component.root.end),\n };\n }\n\n /**\n * Writes a prepared copy over its call site.\n */\n private commit(site: PreparedSite): void {\n this.context.s.overwrite(site.element.start, site.element.end, site.root);\n if (site.host) {\n const entry = this.hosts.get(site.host.fn) ?? { host: site.host.host, texts: [] };\n entry.texts.push(...site.statements);\n this.hosts.set(site.host.fn, entry);\n }\n }\n\n /**\n * The context reads in a component's copy at `element` that a closed\n * provider above it answers, with the text each becomes. `undefined` when\n * a read cannot take the value there.\n */\n private contextTexts(component: Component, element: JSXElement): Map<Node, string> | undefined {\n const texts = new Map<Node, string>();\n for (const { provider, text } of this.answeringProviders(element)) {\n for (const read of contextReads(this.context, component.fn, provider.context)) {\n const value = text ?? stableValueText(this.context, provider, element);\n if (value === undefined) {\n return undefined;\n }\n texts.set(read, value);\n }\n }\n return texts;\n }\n\n /**\n * The closed providers that answer context reads at `element`. The nearest\n * provider of each context answers its reads, closed or not.\n */\n private answeringProviders(element: JSXElement): { provider: Provider; text?: string }[] {\n const answering: { provider: Provider; text?: string }[] = [];\n const seen = new Set<Binding>();\n for (\n let node = this.context.parents.get(element);\n node;\n node = this.context.parents.get(node)\n ) {\n const target =\n node.type === 'JSXElement'\n ? contextBinding(this.context, node.openingElement.name)\n : undefined;\n if (node.type !== 'JSXElement' || !target || seen.has(target)) {\n continue;\n }\n seen.add(target);\n const entry = this.transparent.get(node);\n if (entry) {\n answering.push(entry);\n }\n }\n return answering;\n }\n\n /**\n * Finds the providers statements can move out through: a subtree with\n * only visible code, where every component is one this pass can inline.\n * A value that is not a literal or a binding that never changes is\n * stored in a `const` of the host first, so every read gets the same one.\n */\n private findTransparentProviders(\n components: readonly Component[],\n sites: readonly CallSite[],\n ): Component[] {\n const byBinding = new Map(components.map((component) => [component.binding, component]));\n // Whether a subtree under `provider` only runs visible code, where each\n // component is one this pass inlines and is visible too.\n const closedUnder = (provider: Provider): ((node: Node) => boolean) => {\n const closedComponents = new Map<Component, boolean>();\n const options: ClosedOptions = {\n component: (element) => {\n const binding = this.context.scopes.references.get(element.openingElement.name);\n const component = binding ? byBinding.get(binding) : undefined;\n if (!component) {\n return false;\n }\n const known = closedComponents.get(component);\n if (known !== undefined) {\n return known;\n }\n // A component that renders itself is never closed.\n closedComponents.set(component, false);\n const closed = isClosed(this.context, component.fn, {\n ...options,\n props: component.param,\n });\n closedComponents.set(component, closed);\n return closed;\n },\n contextValue: (target) => (target === provider.context ? provider.value : undefined),\n };\n return (node) => isClosed(this.context, node, options);\n };\n\n const changed: Component[] = [];\n for (const provider of findProviders(this.context)) {\n const { element } = provider;\n const inside = sites.some(\n (site) => isWithin(site.element, element) && site.element !== element,\n );\n if (!inside) {\n continue;\n }\n const isClosedNode = closedUnder(provider);\n const closed = element.children.every((child) => isClosedNode(child));\n if (!closed) {\n continue;\n }\n if (stableValueText(this.context, provider, element) !== undefined) {\n this.transparent.set(element, { provider });\n continue;\n }\n const host = this.hostOf(element);\n if (!host) {\n continue;\n }\n const name = this.freshName(\n `${provider.context.name.charAt(0).toLowerCase()}${provider.context.name.slice(1)}Value`,\n );\n const entry = this.hosts.get(host.fn) ?? { host: host.host, texts: [] };\n entry.texts.push(`const ${name} = ${textOf(this.context, provider.value)};`);\n this.hosts.set(host.fn, entry);\n this.context.s.overwrite(provider.value.start, provider.value.end, name);\n this.transparent.set(element, { provider, text: name });\n this.changed = true;\n for (const component of components) {\n if (isWithin(element, component.fn)) {\n changed.push(component);\n }\n }\n }\n return changed;\n }\n\n /**\n * Resolves each view read and spread of a component at a call site. A\n * read becomes a read of the props, or the text of a default. A spread\n * becomes the keys it holds, in the order `merge()` gives them, and its\n * `children` become the element's children. `undefined` when a spread\n * repeats an attribute, or holds `children` for an element that has some.\n */\n private resolveViews(\n component: Component,\n attributes: ReadonlyMap<string, JSXAttribute>,\n hasChildren: boolean,\n ): ResolvedViews | undefined {\n const has = (key: string): boolean =>\n attributes.has(key) || (key === 'children' && hasChildren);\n // The last source that has the key answers, even when its value is `undefined`.\n const resolve = (view: View, key: string): string | undefined => {\n for (let index = view.sources.length - 1; index >= 0; index -= 1) {\n const source = view.sources.at(index);\n if (!source || source.hidden.has(key)) {\n continue;\n }\n const text = source.defaults?.get(key);\n if (text !== undefined) {\n return text;\n }\n if (!source.defaults && has(key)) {\n return undefined;\n }\n }\n return 'void 0';\n };\n\n const propReads: PropRead[] = [...component.props];\n const texts = new Map<Node, string>();\n for (const read of component.viewReads) {\n const text = resolve(read.view, read.name);\n if (text === undefined) {\n propReads.push(read);\n } else {\n texts.set(read.member, text);\n }\n }\n\n const callKeys = [...attributes.keys()];\n if (hasChildren && !attributes.has('children')) {\n callKeys.push('children');\n }\n const spreads: ResolvedSpread[] = [];\n const taken = new Map<JSXElement, Set<string>>();\n for (const spread of component.viewSpreads) {\n // A key sits where the last source that carries it puts it.\n const order: string[] = [];\n for (const source of spread.view.sources) {\n const keys = source.defaults ? [...source.defaults.keys()] : callKeys;\n for (const key of keys.filter((name) => !source.hidden.has(name))) {\n const index = order.indexOf(key);\n if (index !== -1) {\n order.splice(index, 1);\n }\n order.push(key);\n }\n }\n let names = taken.get(spread.element);\n if (!names) {\n names = new Set();\n for (const attribute of spread.element.openingElement.attributes) {\n if (attribute.type === 'JSXAttribute') {\n names.add(\n attribute.name.type === 'JSXIdentifier'\n ? attribute.name.name\n : textOf(this.context, attribute.name),\n );\n }\n }\n taken.set(spread.element, names);\n }\n const keys = new Map<string, string | undefined>();\n for (const key of order) {\n // Children become the element's children, so it must have none of its own.\n const fits =\n key === 'children'\n ? spread.element.openingElement.selfClosing\n : /^[A-Za-z_$][\\w$-]*$/.test(key);\n if (!fits || names.has(key)) {\n return undefined;\n }\n names.add(key);\n keys.set(key, resolve(spread.view, key));\n }\n spreads.push({ spread, keys });\n }\n return { propReads, texts, spreads };\n }\n\n /**\n * Writes the resolved view reads and spreads into a copy, and drops the\n * view declarations.\n */\n private substituteViews(\n copy: MagicString,\n component: Component,\n element: JSXElement,\n views: ResolvedViews,\n values: ReadonlyMap<string, PropValue>,\n ): void {\n for (const [member, text] of views.texts) {\n const bare = text !== 'void 0' || acceptsAnyExpression(this.context, member);\n copy.overwrite(member.start, member.end, bare ? text : `(${text})`);\n }\n for (const { spread, keys } of views.spreads) {\n const parts: string[] = [];\n let children: string | undefined;\n for (const [key, text] of keys) {\n const value = values.get(key);\n if (key === 'children') {\n children = this.spreadChildren(element, text, value);\n } else {\n parts.push(`${key}={${text ?? value?.text ?? 'void 0'}}`);\n }\n }\n const { attribute } = spread;\n if (parts.length === 0) {\n copy.remove(attribute.start, attribute.end);\n } else {\n copy.overwrite(attribute.start, attribute.end, parts.join(' '));\n }\n if (children !== undefined) {\n const opening = spread.element.openingElement;\n const tag = textOf(this.context, opening.name);\n const close = this.context.code.lastIndexOf('/>', opening.end);\n copy.overwrite(close, opening.end, `>${children}</${tag}>`);\n }\n }\n for (const declaration of component.viewDeclarations) {\n copy.remove(declaration.start, declaration.end);\n }\n }\n\n /**\n * The JSX children a spread's `children` becomes: the call site's own\n * children, or the value of a single expression or default.\n */\n private spreadChildren(\n element: JSXElement,\n text: string | undefined,\n value: PropValue | undefined,\n ): string | undefined {\n if (text !== undefined) {\n return text === 'void 0' ? undefined : `{${text}}`;\n }\n if (!value) {\n return undefined;\n }\n if (value.kind === 'children' && element.closingElement) {\n return this.context.s.slice(element.openingElement.end, element.closingElement.start);\n }\n return `{${value.text}}`;\n }\n\n private renameLocals(\n copy: MagicString,\n component: Component,\n fresh: (base: string) => string,\n ): void {\n for (const local of component.locals) {\n const name = fresh(local.name);\n for (const node of [local.identifier, ...local.references]) {\n const parent = this.context.parents.get(node);\n // `{ a }` and `{ a = 1 }` are shorthand for `{ a: a }` and `{ a: a = 1 }`.\n const shorthand =\n (parent?.type === 'Property' && parent.shorthand) ||\n (parent?.type === 'AssignmentPattern' &&\n this.context.parents.get(parent)?.type === 'Property' &&\n parent.left === node &&\n this.isShorthandValue(parent));\n copy.overwrite(node.start, node.end, shorthand ? `${local.name}: ${name}` : name);\n }\n }\n }\n\n private isShorthandValue(node: Node): boolean {\n const parent = this.context.parents.get(node);\n return parent?.type === 'Property' && parent.shorthand && parent.value === node;\n }\n\n private substituteProps(\n copy: MagicString,\n reads: readonly PropRead[],\n values: ReadonlyMap<string, PropValue>,\n ): void {\n // Reads that are a JSX child on their own, like `{props.children}`,\n // splice their JSX in place. They are grouped by parent so neighboring\n // text stays apart.\n const spliced = new Map<JSXElement | JSXFragment, Map<JSXChild, Piece>>();\n for (const read of reads) {\n const value = values.get(read.name);\n if (!value) {\n continue;\n }\n const container = this.context.parents.get(read.member);\n const parent = container ? this.context.parents.get(container) : undefined;\n if (\n value.kind !== 'expression' &&\n container?.type === 'JSXExpressionContainer' &&\n (parent?.type === 'JSXElement' || parent?.type === 'JSXFragment') &&\n isJSXChild(container, this.context.parents)\n ) {\n const pieces = spliced.get(parent) ?? new Map<JSXChild, Piece>();\n pieces.set(container, this.splicedPiece(container, value));\n spliced.set(parent, pieces);\n continue;\n }\n const bare = value.primary || acceptsAnyExpression(this.context, read.member);\n copy.overwrite(read.member.start, read.member.end, bare ? value.text : `(${value.text})`);\n }\n for (const [parent, pieces] of spliced) {\n writePieces(\n copy,\n parent.children.map((child) => pieces.get(child) ?? keptPiece(child)),\n );\n }\n }\n\n private splicedPiece(container: JSXExpressionContainer, value: PropValue): Piece {\n if (value.kind === 'children') {\n const first = value.children.at(0);\n const last = value.children.at(-1);\n if (!first || !last) {\n return replacedPiece(container, '');\n }\n return {\n node: container,\n text: this.context.s.slice(first.start, last.end),\n startText: first.type === 'JSXText' ? first : undefined,\n endText: last.type === 'JSXText' ? last : undefined,\n };\n }\n return replacedPiece(container, value.text);\n }\n\n // ---------------------------------------------------------------------------\n // Pass\n // ---------------------------------------------------------------------------\n\n /**\n * The components worth inlining in this pass: those whose copies are no\n * larger than what they replace, which is their calls, and their\n * declaration when nothing else uses it.\n */\n private worthwhileComponents(\n sites: readonly CallSite[],\n postponed: ReadonlySet<Component>,\n otherUses: ReadonlyMap<Component, number>,\n ): Set<Component> {\n const byComponent = new Map<Component, JSXElement[]>();\n for (const site of sites) {\n if (!postponed.has(site.component)) {\n const elements = byComponent.get(site.component) ?? [];\n elements.push(site.element);\n byComponent.set(site.component, elements);\n }\n }\n const result = new Set<Component>();\n if (this.context.options.alwaysInline) {\n for (const component of byComponent.keys()) {\n result.add(component);\n }\n return result;\n }\n // The copies made here are only measured, so their fresh names are not kept.\n this.scratchNames = new Set(this.context.scopes.names);\n try {\n const copiesOf = new Map<Component, Map<JSXElement, PreparedSite | undefined>>();\n for (const [component, elements] of byComponent) {\n copiesOf.set(\n component,\n new Map(elements.map((element) => [element, this.prepare(component, element)])),\n );\n }\n for (const [component, byElement] of copiesOf) {\n const copies = [...byElement.values()].filter((copy) => copy !== undefined);\n if (copies.length === 0) {\n continue;\n }\n const gain =\n this.inliningGain(component, copies, this.removedShare(component, byElement, otherUses)) +\n this.enabledGain(component, copies, copiesOf, otherUses);\n if (gain >= 0) {\n result.add(component);\n }\n }\n } finally {\n this.scratchNames = undefined;\n }\n return result;\n }\n\n /**\n * How much of a component's declaration inlining every call removes: all\n * of it when nothing else uses it, the module's share when other modules\n * use it too, and none when a call cannot be inlined or anything else\n * keeps it.\n */\n private removedShare(\n component: Component,\n copies: ReadonlyMap<JSXElement, PreparedSite | undefined>,\n otherUses: ReadonlyMap<Component, number>,\n ): number {\n if (\n component.declaration === undefined ||\n otherUses.get(component) !== 0 ||\n [...copies.values()].some((copy) => copy === undefined)\n ) {\n return 0;\n }\n const users = this.context.options.sharedComponents.get(component.binding.name) ?? 1;\n return users > 0 ? 1 / users : 0;\n }\n\n /**\n * What inlining `component` saves through the calls in its children that\n * can only be inlined once it is: a component with statements needs an\n * element around its call to hoist them to.\n */\n private enabledGain(\n component: Component,\n copies: readonly PreparedSite[],\n copiesOf: ReadonlyMap<Component, ReadonlyMap<JSXElement, PreparedSite | undefined>>,\n otherUses: ReadonlyMap<Component, number>,\n ): number {\n const elements = copies.map((copy) => copy.element);\n this.assumedHosts = new Set(elements);\n let gain = 0;\n try {\n for (const [other, byElement] of copiesOf) {\n if (other === component) {\n continue;\n }\n const enabled = new Map(byElement);\n let changed = false;\n for (const [element, copy] of byElement) {\n if (!copy && elements.some((outer) => isWithin(element, outer))) {\n const next = this.prepare(other, element);\n enabled.set(element, next);\n changed ||= next !== undefined;\n }\n }\n if (!changed) {\n continue;\n }\n const now = [...byElement.values()].filter((copy) => copy !== undefined);\n const then = [...enabled.values()].filter((copy) => copy !== undefined);\n const before = now.length > 0 ? Math.max(0, this.inliningGain(other, now, 0)) : 0;\n const after = this.inliningGain(other, then, this.removedShare(other, enabled, otherUses));\n gain += Math.max(0, after - before);\n }\n } finally {\n this.assumedHosts = undefined;\n }\n return gain;\n }\n\n /**\n * How much smaller the copies are than the calls they replace, once\n * lowered, counting the `share` of the declaration they remove.\n * Negative when they are larger.\n */\n private inliningGain(\n component: Component,\n copies: readonly PreparedSite[],\n share: number,\n ): number {\n const estimator = this.estimator();\n let calls =\n share > 0 && component.declaration ? share * estimator.node(component.declaration) : 0;\n let inlined = 0;\n for (const copy of copies) {\n const inTemplate = this.sitsInTemplate(copy.element);\n calls += estimator.jsx(copy.element, inTemplate);\n inlined += copySize(\n this.context.filename,\n this.sizeHeader(),\n copy,\n inTemplate,\n this.context.options,\n );\n }\n return calls - inlined;\n }\n\n /**\n * Whether an element sits directly in an intrinsic element, whose\n * template its copy joins. A provider this pass makes transparent is\n * removed once its consumers are inlined, so the element above it counts.\n */\n private sitsInTemplate(element: JSXElement): boolean {\n let parent = this.context.parents.get(element);\n while (parent?.type === 'JSXElement' && this.transparent.has(parent)) {\n parent = this.context.parents.get(parent);\n }\n if (parent?.type === 'JSXElement' && this.assumedHosts?.has(parent) === true) {\n return true;\n }\n return (\n parent?.type === 'JSXElement' &&\n parent.openingElement.name.type === 'JSXIdentifier' &&\n isIntrinsicTag(parent.openingElement.name.name)\n );\n }\n\n private sizeEstimator: SizeEstimator | undefined;\n\n private estimator(): SizeEstimator {\n this.sizeEstimator ??= new SizeEstimator(this.context.code);\n return this.sizeEstimator;\n }\n\n private header: string | undefined;\n\n /**\n * What a copy measured on its own needs to know: the module's imports,\n * and the names that alias Solid's exports.\n */\n private sizeHeader(): string {\n if (this.header === undefined) {\n // The imports, and the top-level constants made of literals, so a copy\n // folds with the values its call site passes by name, as it will once inlined.\n const imports = this.context.program.body\n .filter(\n (statement) => statement.type === 'ImportDeclaration' || isDataDeclaration(statement),\n )\n .map((statement) => this.context.code.slice(statement.start, statement.end));\n const aliases = [...this.context.options.builtInAliases.keys()];\n if (aliases.length > 0) {\n imports.push(`var ${aliases.join(', ')};`);\n }\n this.header = imports.join('\\n');\n }\n return this.header;\n }\n\n run(): void {\n const components: Component[] = [];\n const rejected = new Map<Binding, string>();\n for (const binding of this.context.scopes.root.bindings.values()) {\n this.reason = 'not-a-function';\n const component = this.analyzeComponent(binding);\n if (component) {\n components.push(component);\n } else {\n rejected.set(binding, this.reason);\n }\n }\n // Why each call site that stays a call was not inlined, for the report.\n const siteReasons = new Map<JSXElement, string>();\n if (components.length === 0) {\n this.report(rejected, siteReasons);\n return;\n }\n\n const sites: CallSite[] = [];\n const otherUses = new Map<Component, number>();\n for (const component of components) {\n let uses = 0;\n for (const reference of component.binding.references) {\n const parent = this.context.parents.get(reference);\n if (parent?.type === 'JSXClosingElement') {\n continue;\n }\n const element = parent ? this.context.parents.get(parent) : undefined;\n if (parent?.type === 'JSXOpeningElement' && element?.type === 'JSXElement') {\n sites.push({ component, element });\n } else {\n uses += 1;\n }\n }\n otherUses.set(component, uses);\n }\n\n // Inner call sites first, so an outer one copies their inlined text.\n sites.sort((a, b) => a.element.end - b.element.end);\n const inlined = new Map<Component, JSXElement[]>();\n // A component whose body changed in this pass is copied in the next one,\n // from its new body. A copy made now would miss what was inlined into it.\n const changedBodies = new Set<Component>(this.findTransparentProviders(components, sites));\n const worthwhile = this.worthwhileComponents(sites, changedBodies, otherUses);\n for (const site of inBodyOrder(sites)) {\n const postponed = changedBodies.has(site.component);\n // Each copy is made now, so it takes in the call sites inside it that\n // were inlined before it.\n const copy =\n postponed || !worthwhile.has(site.component)\n ? undefined\n : this.prepare(site.component, site.element);\n const done = copy !== undefined;\n if (copy) {\n this.commit(copy);\n this.changed = true;\n const elements = inlined.get(site.component) ?? [];\n elements.push(site.element);\n inlined.set(site.component, elements);\n } else {\n otherUses.set(site.component, (otherUses.get(site.component) ?? 0) + 1);\n if (this.context.skips && !postponed) {\n siteReasons.set(site.element, this.siteReason(site, worthwhile));\n }\n }\n // A component holding a call that was inlined now, or postponed to the\n // next pass, waits too. A copy made now would copy the call as it is.\n if (done || postponed) {\n for (const component of components) {\n if (isWithin(site.element, component.fn)) {\n changedBodies.add(component);\n }\n }\n }\n }\n\n this.writeHosts();\n this.report(rejected, siteReasons);\n\n // A component nothing uses anymore is removed. A copy made in this pass\n // comes from the original code, so a component used inside a copied\n // component stays until the next pass inlines it there too.\n const copied = [...inlined.keys()];\n for (const [component, elements] of inlined) {\n const insideCopy = elements.some((element) =>\n copied.some(\n (other) =>\n other !== component && element.start >= other.fn.start && element.end <= other.fn.end,\n ),\n );\n if (component.declaration && otherUses.get(component) === 0 && !insideCopy) {\n this.context.s.remove(component.declaration.start, component.declaration.end);\n }\n }\n }\n\n /**\n * Why a call site of a component was not inlined. A component that is\n * not worth inlining is only turned down for its size when the call site\n * could be inlined.\n */\n private siteReason(site: CallSite, worthwhile: ReadonlySet<Component>): string {\n if (worthwhile.has(site.component)) {\n return this.reason;\n }\n this.scratchNames = new Set(this.context.scopes.names);\n try {\n return this.prepare(site.component, site.element) ? 'size' : this.reason;\n } finally {\n this.scratchNames = undefined;\n }\n }\n\n /**\n * Records each component call that stays a call, and why. Solid's\n * built-ins and context providers are left out. The provider pass\n * reports providers.\n */\n private report(\n rejected: ReadonlyMap<Binding, string>,\n siteReasons: ReadonlyMap<JSXElement, string>,\n ): void {\n if (!this.context.skips) {\n return;\n }\n const visit = (node: Node): void => {\n if (node.type === 'JSXElement') {\n const reason = this.callReason(node, rejected, siteReasons);\n if (reason) {\n recordSkip(this.context, 'inline', reason.reason, reason.name);\n }\n }\n forEachChild(node, visit);\n };\n visit(this.context.program);\n }\n\n private callReason(\n element: JSXElement,\n rejected: ReadonlyMap<Binding, string>,\n siteReasons: ReadonlyMap<JSXElement, string>,\n ): { reason: string; name: string } | undefined {\n const tag = element.openingElement.name;\n if (tag.type === 'JSXMemberExpression') {\n return { reason: 'member-tag', name: textOf(this.context, tag) };\n }\n if (tag.type !== 'JSXIdentifier' || !isCapitalized(tag.name)) {\n return undefined;\n }\n const { name } = tag;\n const binding = this.context.scopes.references.get(tag);\n const identity = binding ? solidExport(binding, this.context.options) : name;\n if (\n (identity !== undefined && this.context.options.builtIns.has(identity)) ||\n contextBinding(this.context, tag)\n ) {\n return undefined;\n }\n if (!binding) {\n return { reason: 'global', name };\n }\n if (binding.kind === 'import') {\n // A chunk imports other chunks through placeholders the bundler fills in later.\n const source = (binding.source ?? '').replaceAll(/!~\\{\\w+\\}~/g, '*');\n return { reason: 'imported', name: `${name} (${source})` };\n }\n if (binding.scope.parent !== undefined) {\n return { reason: 'nested', name };\n }\n const reason = rejected.get(binding) ?? siteReasons.get(element);\n return reason === undefined ? undefined : { reason, name };\n }\n\n /**\n * The whitespace before `position` on its line.\n */\n private indentationAt(position: number): string {\n const { code } = this.context;\n const lineStart = code.lastIndexOf('\\n', position - 1) + 1;\n return /^[ \\t]*/.exec(code.slice(lineStart, position))?.[0] ?? '';\n }\n\n private writeHosts(): void {\n for (const { host, texts } of this.hosts.values()) {\n if (host.kind === 'return') {\n const indent = this.indentationAt(host.statement.start);\n this.context.s.prependRight(\n host.statement.start,\n texts.map((text) => `${text}\\n${indent}`).join(''),\n );\n } else {\n this.context.s.prependRight(host.body.start, `{ ${texts.join(' ')} return `);\n this.context.s.appendLeft(host.body.end, '; }');\n }\n }\n }\n}\n\n/**\n * Runs the inline pass over a parsed program. Returns whether anything changed.\n */\nexport function inline(context: PassContext): boolean {\n const inliner = new Inliner(context);\n inliner.run();\n return inliner.changed;\n}\n","/**\n * The memo pass: inlines a `createMemo` whose memoization does nothing.\n *\n * A memo does two things for its readers. It runs its computation once and\n * shares the result, and it only notifies them when the result changes. A\n * memo that returns a new object, array, function, or JSX element on every\n * run, or that sets `equals: false`, notifies on every run, so the second\n * part never applies. When such a memo is also read exactly once, the first\n * part does not apply either, and the read can run the computation itself:\n *\n * ```jsx\n * const style = createMemo(() => ({ color: color() }));\n * return <p style={style()} />;\n * ```\n *\n * becomes `<p style={{ color: color() }} />`.\n *\n * The read has to be the whole of a tracked expression, so it depends on\n * exactly what the memo depended on and reruns exactly as often. It also has\n * to run once each time the function holding the memo runs, so a read in a\n * callback, a loop, or a component's children stays a read of the memo.\n *\n * A memo whose computation folds to a literal reads no signals, so it never\n * runs again and its value never changes. Every read of it becomes the\n * literal, however many there are:\n *\n * ```jsx\n * const size = createMemo(() => 3);\n * return <p>{size() * 2}</p>;\n * ```\n *\n * becomes `<p>{3 * 2}</p>`, which the next fold turns into `6`.\n *\n * Solid's `children` helper is a memo too. It resolves the children once,\n * caches them, and flattens them in a second memo. When the children are JSX,\n * nothing they read at the top makes either memo run again, and inserting the\n * JSX directly resolves it the same way. So a `children(() => <jsx />)` read\n * once as an element's child becomes that JSX, which joins the template:\n *\n * ```jsx\n * const c = children(() => <b>x</b>);\n * return <div>{c()}</div>;\n * ```\n *\n * becomes `<div><b>x</b></div>`.\n *\n * # Accepted differences\n *\n * - The computation first runs when its reader first runs, instead of when\n * the memo is created.\n * - The memo no longer takes a slot in the owner tree, which shifts the\n * hydration keys after it. A server build and its client build must\n * compile with the same options.\n */\nimport type {\n ArrowFunctionExpression,\n CallExpression,\n Expression,\n Function as FunctionNode,\n JSXExpressionContainer,\n Node,\n VariableDeclarator,\n} from 'oxc-parser';\nimport { isFunctionNode, isIntrinsicTag, unwrap } from './ast';\nimport type { PassContext } from './context';\nimport { recordSkip, solidExport, textOf } from './context';\nimport { usesFunctionContext } from './inline';\nimport type { Binding } from './scope';\nimport { lookup, scopeAt } from './scope';\n\n/**\n * Props of Solid's built-in components that are read inside a memo, once per update.\n */\nconst TRACKED_PROPS = new Map([\n ['Show', 'when'],\n ['Match', 'when'],\n ['For', 'each'],\n ['Repeat', 'count'],\n]);\n\n/**\n * Whether evaluating `node` always creates a new value, which reference\n * equality never finds equal to the last one.\n */\nfunction isFresh(node: Node): boolean {\n switch (node.type) {\n case 'ObjectExpression':\n case 'ArrayExpression':\n case 'ArrowFunctionExpression':\n case 'FunctionExpression':\n case 'ClassExpression':\n case 'NewExpression':\n case 'JSXElement':\n case 'JSXFragment':\n return true;\n case 'ParenthesizedExpression':\n return isFresh(node.expression);\n case 'ConditionalExpression':\n return isFresh(node.consequent) && isFresh(node.alternate);\n case 'SequenceExpression': {\n const last = node.expressions.at(-1);\n return last !== undefined && isFresh(last);\n }\n default:\n return false;\n }\n}\n\n/**\n * The expression a compute function returns, when that is all it does.\n */\ntype MemoKind = 'createMemo' | 'children';\n\n/**\n * The text of an expression that always gives the same primitive: a literal\n * other than a regular expression, a template literal without expressions,\n * or a negated number.\n */\nfunction constantText(context: PassContext, node: Expression): string | undefined {\n const expression = unwrap(node);\n switch (expression.type) {\n case 'Literal':\n return 'regex' in expression ? undefined : textOf(context, expression);\n case 'TemplateLiteral':\n return expression.expressions.length === 0 ? textOf(context, expression) : undefined;\n case 'UnaryExpression':\n return expression.operator === '-' &&\n expression.argument.type === 'Literal' &&\n typeof expression.argument.value === 'number'\n ? textOf(context, expression)\n : undefined;\n default:\n return undefined;\n }\n}\n\nfunction returnedExpression(fn: FunctionNode | ArrowFunctionExpression): Expression | undefined {\n if (fn.async || fn.generator || fn.params.length > 0 || !fn.body) {\n return undefined;\n }\n if (fn.body.type !== 'BlockStatement') {\n return fn.body;\n }\n const statements = fn.body.body;\n const statement = statements.at(0);\n if (statements.length !== 1 || statement?.type !== 'ReturnStatement' || !statement.argument) {\n return undefined;\n }\n return statement.argument;\n}\n\nclass MemoInliner {\n changed = false;\n\n constructor(private readonly context: PassContext) {}\n\n /** Why the last memo was turned down, for the report. Empty for a call that is not a memo. */\n private reason = '';\n\n /** Whether a callee is Solid's `createMemo` or `children`. */\n private memoKind(callee: Node): MemoKind | undefined {\n if (callee.type !== 'Identifier') {\n return undefined;\n }\n const binding = this.context.scopes.references.get(callee);\n const identity = binding ? solidExport(binding, this.context.options) : undefined;\n return identity === 'createMemo' || identity === 'children' ? identity : undefined;\n }\n\n /**\n * The expression a memo's computation returns, and whether `equals: false`\n * makes it notify on every run.\n */\n private computation(\n declarator: VariableDeclarator,\n ): { expression: Expression; alwaysNotifies: boolean; kind: MemoKind } | undefined {\n const init = declarator.init ? unwrap(declarator.init) : undefined;\n const kind = init?.type === 'CallExpression' ? this.memoKind(init.callee) : undefined;\n if (init?.type !== 'CallExpression' || kind === undefined) {\n return undefined;\n }\n const args = init.arguments;\n if (kind === 'children' && args.length > 1) {\n this.reason = 'memo-options';\n return undefined;\n }\n const compute = args.at(0);\n const options = args.at(1);\n if (args.length > 2 || compute === undefined || compute.type === 'SpreadElement') {\n this.reason = 'memo-computation';\n return undefined;\n }\n const fn = unwrap(compute);\n if (fn.type !== 'ArrowFunctionExpression' && fn.type !== 'FunctionExpression') {\n this.reason = 'memo-computation';\n return undefined;\n }\n const expression = returnedExpression(fn);\n if (!expression) {\n this.reason = 'memo-computation';\n return undefined;\n }\n let alwaysNotifies = false;\n if (options !== undefined) {\n // Only `equals: false` is understood. Any other option changes what the memo does.\n if (options.type !== 'ObjectExpression' || options.properties.length !== 1) {\n this.reason = 'memo-options';\n return undefined;\n }\n const property = options.properties.at(0);\n if (\n property?.type !== 'Property' ||\n property.computed ||\n property.key.type !== 'Identifier' ||\n property.key.name !== 'equals' ||\n property.value.type !== 'Literal' ||\n property.value.value !== false\n ) {\n this.reason = 'memo-options';\n return undefined;\n }\n alwaysNotifies = true;\n }\n return { expression, alwaysNotifies, kind };\n }\n\n /**\n * Replaces every read of a memo whose computation is a literal with the\n * literal. Each reference has to be a call after the declaration, since a\n * call before it would throw.\n */\n private inlineConstant(\n declarator: VariableDeclarator,\n binding: Binding,\n text: string,\n ): true | undefined {\n const statement = this.context.parents.get(declarator);\n if (statement?.type !== 'VariableDeclaration' || statement.declarations.length !== 1) {\n this.reason = 'memo-declaration';\n return undefined;\n }\n const calls: CallExpression[] = [];\n for (const reference of binding.references) {\n const call = this.context.parents.get(reference);\n if (\n call?.type !== 'CallExpression' ||\n call.callee !== reference ||\n call.arguments.length > 0 ||\n call.start < declarator.end\n ) {\n this.reason = 'memo-constant';\n return undefined;\n }\n calls.push(call);\n }\n for (const call of calls) {\n // `3.toFixed()` and `-1 ** 2` do not parse, so a literal under an operator or a member gets parentheses.\n const parent = this.context.parents.get(call);\n const bare =\n parent?.type === 'JSXExpressionContainer' ||\n parent?.type === 'VariableDeclarator' ||\n parent?.type === 'ReturnStatement' ||\n parent?.type === 'ArrayExpression' ||\n parent?.type === 'Property' ||\n (parent?.type === 'CallExpression' && parent.callee !== call);\n this.context.s.overwrite(call.start, call.end, bare ? text : `(${text})`);\n }\n this.context.s.remove(statement.start, statement.end);\n this.changed = true;\n return true;\n }\n\n /**\n * The function a node runs in.\n */\n private functionOf(node: Node): Node | undefined {\n let current = this.context.parents.get(node);\n while (current && !isFunctionNode(current)) {\n current = this.context.parents.get(current);\n }\n return current;\n }\n\n /** The JSX expression container a call is the whole of. */\n private containerOf(call: Node): JSXExpressionContainer | undefined {\n let parent = this.context.parents.get(call);\n while (parent?.type === 'ParenthesizedExpression') {\n parent = this.context.parents.get(parent);\n }\n return parent?.type === 'JSXExpressionContainer' ? parent : undefined;\n }\n\n /**\n * Whether a call is the whole of an expression that Solid tracks, and that\n * runs once each time `fn` runs.\n */\n private isSingleTrackedRead(call: Node, fn: Node): boolean {\n let node = call;\n let parent = this.context.parents.get(node);\n while (parent?.type === 'ParenthesizedExpression') {\n node = parent;\n parent = this.context.parents.get(node);\n }\n if (parent?.type !== 'JSXExpressionContainer') {\n return false;\n }\n const container = parent;\n const owner = this.context.parents.get(container);\n let element: Node | undefined;\n if (owner?.type === 'JSXFragment') {\n element = owner;\n } else if (owner?.type === 'JSXElement') {\n // A child of an element is inserted, which tracks it. A child of a\n // component is a prop, which the component can read any number of times.\n const { name } = owner.openingElement;\n if (name.type !== 'JSXIdentifier' || !isIntrinsicTag(name.name)) {\n return false;\n }\n element = owner;\n } else if (owner?.type === 'JSXAttribute' && owner.name.type === 'JSXIdentifier') {\n const attribute = owner.name.name;\n const opening = this.context.parents.get(owner);\n element = opening ? this.context.parents.get(opening) : undefined;\n if (element?.type !== 'JSXElement' || element.openingElement.name.type !== 'JSXIdentifier') {\n return false;\n }\n const tag = element.openingElement.name.name;\n if (isIntrinsicTag(tag)) {\n // An event handler or ref is read once and never tracked.\n if (attribute.startsWith('on') || attribute === 'ref') {\n return false;\n }\n } else if (\n this.builtInOf(element.openingElement.name) !== tag ||\n TRACKED_PROPS.get(tag) !== attribute\n ) {\n // A component can read a prop any number of times.\n return false;\n }\n } else {\n return false;\n }\n return this.isStaticJSX(element, fn);\n }\n\n private builtInOf(name: Node): string | undefined {\n if (name.type !== 'JSXIdentifier') {\n return undefined;\n }\n const { references } = this.context.scopes;\n if (!references.has(name)) {\n return undefined;\n }\n const binding = references.get(name);\n return binding ? solidExport(binding, this.context.options) : name.name;\n }\n\n /**\n * Whether JSX is created once each time `fn` runs: it sits in JSX that `fn`\n * returns, with only intrinsic elements and fragments around it.\n */\n private isStaticJSX(element: Node, fn: Node): boolean {\n let node = element;\n for (;;) {\n const parent = this.context.parents.get(node);\n if (!parent) {\n return false;\n }\n if (parent === fn) {\n // An arrow function's expression body.\n return true;\n }\n switch (parent.type) {\n case 'JSXElement': {\n const { name } = parent.openingElement;\n if (name.type !== 'JSXIdentifier' || !isIntrinsicTag(name.name)) {\n return false;\n }\n break;\n }\n case 'JSXFragment':\n case 'ParenthesizedExpression':\n break;\n case 'ReturnStatement':\n return this.functionOf(parent) === fn && !this.inLoop(parent, fn);\n default:\n return false;\n }\n node = parent;\n }\n }\n\n private inLoop(node: Node, fn: Node): boolean {\n let current = this.context.parents.get(node);\n while (current && current !== fn) {\n if (\n current.type === 'ForStatement' ||\n current.type === 'ForInStatement' ||\n current.type === 'ForOfStatement' ||\n current.type === 'WhileStatement' ||\n current.type === 'DoWhileStatement'\n ) {\n return true;\n }\n current = this.context.parents.get(current);\n }\n return false;\n }\n\n /**\n * Whether every name in `expression` means the same at `site`.\n */\n private resolvesSameAt(expression: Node, site: Node, memo: Binding): boolean {\n const scope = scopeAt(this.context.scopes, this.context.parents, site);\n for (const [reference, binding] of this.context.scopes.references) {\n if (reference.start < expression.start || reference.end > expression.end) {\n continue;\n }\n if (binding === memo) {\n return false;\n }\n // A name declared inside the computation, like a callback's parameter, moves with it.\n if (\n binding !== undefined &&\n binding.identifier.start >= expression.start &&\n binding.identifier.end <= expression.end\n ) {\n continue;\n }\n if (\n (reference.type === 'Identifier' || reference.type === 'JSXIdentifier') &&\n lookup(scope, reference.name) !== binding\n ) {\n return false;\n }\n }\n return true;\n }\n\n private tryInline(declarator: VariableDeclarator, binding: Binding): void {\n this.reason = '';\n if (this.inline(declarator, binding) === undefined && this.reason !== '') {\n recordSkip(this.context, 'memos', this.reason, binding.name);\n }\n }\n\n private inline(declarator: VariableDeclarator, binding: Binding): true | undefined {\n const found = this.computation(declarator);\n if (!found) {\n return undefined;\n }\n const { expression, alwaysNotifies, kind } = found;\n if (kind === 'children') {\n // Only JSX is resolved the same by `insert`, and never makes the helper run again.\n const root = unwrap(expression);\n if (root.type !== 'JSXElement' && root.type !== 'JSXFragment') {\n this.reason = 'children-dynamic';\n return undefined;\n }\n } else {\n const constant = constantText(this.context, expression);\n if (constant !== undefined) {\n return this.inlineConstant(declarator, binding, constant);\n }\n // A memo whose result can equal its last one stops updates, which is what it is for.\n if (!alwaysNotifies && !isFresh(expression)) {\n return undefined;\n }\n }\n if (binding.references.length !== 1) {\n this.reason = 'memo-reads';\n return undefined;\n }\n const statement = this.context.parents.get(declarator);\n const fn = this.functionOf(declarator);\n if (statement?.type !== 'VariableDeclaration' || statement.declarations.length !== 1 || !fn) {\n this.reason = 'memo-declaration';\n return undefined;\n }\n const reference = binding.references.at(0);\n const call = reference ? this.context.parents.get(reference) : undefined;\n if (call?.type !== 'CallExpression' || call.callee !== reference || call.arguments.length > 0) {\n this.reason = 'memo-read';\n return undefined;\n }\n if (!this.isSingleTrackedRead(call, fn)) {\n this.reason = 'memo-read-place';\n return undefined;\n }\n // The resolved children are inserted, so the read has to be a child, not an attribute.\n const container = this.containerOf(call);\n const owner = container ? this.context.parents.get(container) : undefined;\n if (\n kind === 'children' &&\n (!container || (owner?.type !== 'JSXElement' && owner?.type !== 'JSXFragment'))\n ) {\n this.reason = 'memo-read-place';\n return undefined;\n }\n if (\n !this.resolvesSameAt(expression, call, binding) ||\n usesFunctionContext(this.context, expression)\n ) {\n this.reason = 'memo-scope';\n return undefined;\n }\n if (kind === 'children' && container) {\n // The JSX takes the place of its container, so it joins the template around it.\n this.context.s.overwrite(container.start, container.end, textOf(this.context, expression));\n } else {\n // The read sits in a JSX container, which takes any expression.\n this.context.s.overwrite(call.start, call.end, textOf(this.context, expression));\n }\n this.context.s.remove(statement.start, statement.end);\n this.changed = true;\n return true;\n }\n\n run(): void {\n for (const scope of new Set(this.context.scopes.scopes.values())) {\n // A memo outside any function has no owner, and disposes differently.\n if (scope.parent === undefined) {\n continue;\n }\n for (const binding of scope.bindings.values()) {\n const { declaration } = binding;\n if (\n binding.kind === 'const' &&\n !binding.mutated &&\n declaration.type === 'VariableDeclarator' &&\n declaration.id === binding.identifier\n ) {\n this.tryInline(declaration, binding);\n }\n }\n }\n }\n}\n\n/**\n * Runs the memo pass over a parsed program. Returns whether anything changed.\n */\nexport function inlineMemos(context: PassContext): boolean {\n const inliner = new MemoInliner(context);\n inliner.run();\n return inliner.changed;\n}\n","import type { SourceMap } from '@jridgewell/remapping';\nimport type { Program } from 'oxc-parser';\nimport remapping from '@jridgewell/remapping';\nimport MagicString from 'magic-string';\nimport type { Parents } from './ast';\nimport { collectParents, parse } from './ast';\nimport type { ImportedConstants } from './constants';\nimport { constantExports, namedImportSources, resolveImportedConstants } from './constants';\nimport type { PassContext, ResolvedOptions, Skip } from './context';\nimport { fold } from './fold';\nimport { inline } from './inline';\nimport { inlineMemos } from './memo';\nimport { removeProviders } from './provider';\nimport type { ScopeAnalysis } from './scope';\nimport { analyzeScopes } from './scope';\nimport type { Primitive } from './value';\n\nexport interface CompileOptions {\n /**\n * The file name, used to pick the parser (`.ts` and `.tsx` parse as\n * TypeScript, anything else as JSX) and as the source in the source map.\n *\n * @default 'input.jsx'\n */\n filename?: string;\n /**\n * Fold constants, remove unreachable code, and resolve control-flow\n * components whose props are constants.\n *\n * @default true\n */\n fold?: boolean;\n /**\n * Replace component calls with the component's body.\n *\n * @default true\n */\n inline?: boolean;\n /**\n * Remove context providers whose reads are all visible, and give each\n * read the provider's value.\n *\n * @default true\n */\n contexts?: boolean;\n /**\n * Replace a `createMemo` that always produces a new value and is read once\n * with its computation.\n *\n * @default true\n */\n memos?: boolean;\n /**\n * The names of Solid's built-in components. A tag only folds when it is\n * one of these, and an empty list turns control-flow folding off.\n *\n * @default ['For', 'Show', 'Switch', 'Match', 'Loading', 'Reveal', 'Portal', 'Repeat', 'Dynamic', 'Errored']\n */\n builtIns?: readonly string[];\n /**\n * The modules that export Solid's built-in components. A tag imported from\n * anywhere else is a different component.\n *\n * @default ['solid-js', '@solidjs/web']\n */\n moduleSources?: readonly string[];\n /**\n * Top-level names that refer to Solid's built-in components, mapped to the\n * built-in's name. A bundler renames bindings, so a chunk can call `Show`\n * something else, or declare it instead of importing it.\n */\n builtInAliases?: Readonly<Record<string, string>>;\n /**\n * Treat a top-level `var` that nothing writes to as a constant. Bundlers\n * turn top-level `const` into `var`, so this is on for bundled chunks.\n *\n * @default false\n */\n constantVars?: boolean;\n /**\n * The constants imported modules export, keyed by the import specifier as\n * the code writes it, then by export name. An import of one of them folds\n * like a local `const`. `constantExports` reads them from a module.\n */\n importedConstants?: ImportedConstants;\n /**\n * Values of global names and paths that fold like constants, such as the\n * `define` entries of a bundler: `{ __DEV__: false, 'import.meta.env.MODE': 'production' }`.\n * A path starts at `import.meta` or at a name the module does not declare.\n */\n globalConstants?: Readonly<Record<string, Primitive>>;\n /**\n * The exports of imported modules that are contexts made by Solid's\n * `createContext`, keyed by the import specifier as the code writes it.\n * A provider of an imported context can be removed like a local one.\n */\n importedContexts?: Readonly<Record<string, readonly string[]>>;\n /**\n * Top-level components that other modules use too, by the number of\n * modules that use them, this one included. Inlining one here only counts\n * its share of the declaration, which goes away once every one of them\n * inlines it. `0` keeps it whatever is inlined, like a component that is\n * also passed as a value.\n */\n sharedComponents?: Readonly<Record<string, number>>;\n /**\n * Inline every component that can be, even where the copies are larger\n * than the calls and declaration they replace. By default, a component is\n * only inlined where its copies are estimated to be no larger.\n *\n * @default false\n */\n alwaysInline?: boolean;\n /**\n * The most passes to run. One pass can expose work for the next, such as\n * an inlined component whose props now fold. Compilation stops early once\n * a pass changes nothing.\n *\n * @default 10\n */\n maxPasses?: number;\n /**\n * Generate a source map.\n *\n * @default true\n */\n sourceMap?: boolean;\n /**\n * Record what the inline, provider, and memo passes leave alone, and why.\n * The result lists them in `skipped`.\n *\n * @default false\n */\n report?: boolean;\n}\n\nexport interface CompileResult {\n code: string;\n /** The map from the output back to the input, or `null` when nothing changed or maps are off. */\n map: SourceMap | null;\n /**\n * What the last round left alone, and why, when `report` is set. The last\n * round changes nothing, unless `maxPasses` stopped the rounds first.\n */\n skipped?: Skip[];\n}\n\nconst DEFAULT_BUILT_INS = [\n 'For',\n 'Show',\n 'Switch',\n 'Match',\n 'Loading',\n 'Reveal',\n 'Portal',\n 'Repeat',\n 'Dynamic',\n 'Errored',\n];\n\nconst DEFAULT_MODULE_SOURCES = ['solid-js', '@solidjs/web'];\n\nfunction resolveOptions(options: CompileOptions): ResolvedOptions {\n return {\n builtIns: new Set(options.builtIns ?? DEFAULT_BUILT_INS),\n moduleSources: options.moduleSources ?? DEFAULT_MODULE_SOURCES,\n builtInAliases: new Map(Object.entries(options.builtInAliases ?? {})),\n constantVars: options.constantVars ?? false,\n importedConstants: resolveImportedConstants(options.importedConstants),\n globalConstants: new Map(Object.entries(options.globalConstants ?? {})),\n importedContexts: new Map(\n Object.entries(options.importedContexts ?? {}).map(([source, names]) => [\n source,\n new Set(names),\n ]),\n ),\n sharedComponents: new Map(Object.entries(options.sharedComponents ?? {})),\n alwaysInline: options.alwaysInline ?? false,\n };\n}\n\ntype Pass = (context: PassContext) => boolean;\n\ninterface PassResult {\n code: string;\n map: string | undefined;\n}\n\n/** A parse of some code, which passes that change nothing can share. */\ninterface Parsed {\n readonly code: string;\n readonly program: Program;\n readonly parents: Parents;\n readonly scopes: ScopeAnalysis;\n}\n\nfunction parseCode(code: string, filename: string): Parsed {\n const program = parse(filename, code);\n return { code, program, parents: collectParents(program), scopes: analyzeScopes(program) };\n}\n\nfunction runPass(\n parsed: Parsed,\n filename: string,\n options: ResolvedOptions,\n sourceMap: boolean,\n pass: Pass,\n skips: Skip[] | undefined,\n): PassResult | undefined {\n const { code } = parsed;\n const context: PassContext = {\n code,\n filename,\n s: new MagicString(code),\n program: parsed.program,\n parents: parsed.parents,\n // A pass adds the names it gives out, so each pass starts from the parse's own.\n scopes: { ...parsed.scopes, names: new Set(parsed.scopes.names) },\n options,\n skips,\n };\n if (!pass(context)) {\n return undefined;\n }\n return {\n code: context.s.toString(),\n map: sourceMap\n ? context.s.generateMap({ source: filename, hires: true, includeContent: true }).toString()\n : undefined,\n };\n}\n\n/**\n * Optimizes JSX before it is lowered by Solid's JSX transform.\n *\n * The input is JavaScript or TypeScript with JSX, such as a module, or a\n * bundled chunk that kept its JSX. The output keeps JSX too, so the JSX\n * transform runs after this.\n *\n * The output changes the shape of the rendered tree, and with it the\n * hydration keys. A server build and its client build must compile the same\n * code with the same options.\n */\nexport function compile(code: string, options: CompileOptions = {}): CompileResult {\n const filename = options.filename ?? 'input.jsx';\n const sourceMap = options.sourceMap ?? true;\n const resolved = resolveOptions(options);\n const passes: Pass[] = [];\n if (options.fold ?? true) {\n passes.push(fold);\n }\n if (options.inline ?? true) {\n passes.push(inline);\n }\n if (options.contexts ?? true) {\n passes.push(removeProviders);\n }\n if (options.memos ?? true) {\n passes.push(inlineMemos);\n }\n\n const maps: string[] = [];\n let current = code;\n // A pass that changes nothing leaves the code as it was, so the next pass\n // reuses the parse instead of parsing the same code again.\n let parsed: Parsed | undefined;\n const parsedCurrent = (): Parsed => {\n if (parsed?.code !== current) {\n parsed = parseCode(current, filename);\n }\n return parsed;\n };\n const maxPasses = options.maxPasses ?? 10;\n let skipped: Skip[] | undefined;\n for (let round = 0; round < maxPasses; round += 1) {\n let changed = false;\n // Only the last round's skips are kept. An earlier round can skip what a later one takes.\n skipped = options.report === true ? [] : undefined;\n for (const pass of passes) {\n const result = runPass(parsedCurrent(), filename, resolved, sourceMap, pass, skipped);\n if (result) {\n changed = true;\n current = result.code;\n if (result.map !== undefined) {\n maps.push(result.map);\n }\n }\n }\n if (!changed) {\n break;\n }\n }\n\n const report = skipped ? { skipped } : {};\n if (maps.length === 0) {\n return { code: current, map: null, ...report };\n }\n // Each map points at the output of the pass before it, so they chain from the last one.\n return { code: current, map: remapping(maps.reverse(), () => null), ...report };\n}\n\nexport interface ModuleConstants {\n /**\n * The modules this module imports or re-exports named bindings from, as\n * written. `importedConstants` of `compile` takes their constants.\n */\n imports: string[];\n /**\n * The constants this module exports, by export name: `export const`\n * bindings whose value folds, names exported from them, and names\n * re-exported from `importedConstants`.\n */\n exports: Record<string, Primitive>;\n}\n\n/**\n * Reads what a module imports and the constants it exports, so that\n * `compile` can fold them in the modules that import it.\n *\n * Only `filename`, `importedConstants`, and `globalConstants` of the options are used.\n */\nexport function readModuleConstants(\n code: string,\n options: Pick<CompileOptions, 'filename' | 'importedConstants' | 'globalConstants'> = {},\n): ModuleConstants {\n const program = parse(options.filename ?? 'input.jsx', code);\n return {\n imports: namedImportSources(program),\n exports: constantExports(program, resolveOptions(options)),\n };\n}\n"],"mappings":";;;;;;;AAMA,MAAM,4BAAY,IAAI,IAAI;CACxB;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;AAMD,MAAM,yCAAyB,IAAI,IAAI;CACrC;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAgB,OAAO,OAA+B;CACpD,OACE,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAAS,OAAO,MAAM,SAAS;AAE5F;;;;AAKA,SAAgB,aAAa,MAAY,OAAoC;CAC3E,IAAI,KAAK,KAAK,WAAW,IAAI,GAAG;EAC9B,IAAI,uBAAuB,IAAI,KAAK,IAAI,GAAG;GACzC,MAAM,aAAsB,QAAQ,IAAI,MAAM,YAAY;GAC1D,IAAI,OAAO,UAAU,GACnB,MAAM,UAAU;EAEpB,OAAO,IAAI,KAAK,SAAS,uBACvB,MAAM,KAAK,SAAS;EAEtB;CACF;CACA,IAAI,CAAC,OAAO,OAAO,aAAa,KAAK,IAAI,GACvC;CAEF,KAAK,MAAM,OAAO,YAAY,KAAK,OAAO;EACxC,IAAI,UAAU,IAAI,GAAG,GACnB;EAEF,MAAM,QAAiB,QAAQ,IAAI,MAAM,GAAG;EAC5C,IAAI,MAAM,QAAQ,KAAK,GAAG;GACxB,MAAM,QAAmB;GACzB,KAAK,MAAM,QAAQ,OACjB,IAAI,OAAO,IAAI,GACb,MAAM,IAAI;EAGh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