@stencil/react-output-target
Version:
React output target for @stencil/core components.
1 lines • 44.4 kB
Source Map (JSON)
{"version":3,"file":"index.cjs","sources":["../src/utils/string-utils.ts","../src/create-es-modules-components-file.ts","../src/create-stencil-react-components.ts","../src/create-tag-transformer.ts","../src/create-component-wrappers.ts","../src/index.ts"],"sourcesContent":["export const kebabToPascalCase = (str: string) =>\n str\n .toLowerCase()\n .split('-')\n .map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))\n .join('');\n\nexport const kebabToCamelCase = (str: string) => str.replace(/-([_a-z])/g, (_, letter) => letter.toUpperCase());\n\nconst slashesToCamelCase = (str: string) => str.replace(/\\/([a-z])/g, (_, letter) => letter.toUpperCase());\n\nexport const eventListenerName = (eventName: string) => {\n const slashesConverted = slashesToCamelCase(eventName);\n return kebabToCamelCase(`on-${slashesConverted}`);\n};\n\n/**\n * Normalizes a type string by removing single-line comments and collapsing whitespace.\n * This is necessary because multiline types with comments would break when collapsed to a single line.\n */\nexport const normalizeTypeString = (type: string) =>\n type\n .replace(/\\/\\/.*$/gm, '') // Remove single-line comments\n .replace(/\\n/g, ' ') // Replace newlines with spaces\n .replace(/\\s{2,}/g, ' ') // Collapse multiple spaces\n .trim();\n","import type { ComponentCompilerMeta } from '@stencil/core/internal';\nimport path from 'node:path';\nimport { Project, VariableDeclarationKind } from 'ts-morph';\nimport { kebabToPascalCase } from './utils/string-utils.js';\nimport type { RenderToStringOptions } from './runtime/ssr.js';\n\nexport const createEsModulesComponentsFile = async ({\n components,\n project,\n outDir,\n filename = 'components.ts',\n componentSuffix = '',\n serializeShadowRoot,\n}: {\n components: ComponentCompilerMeta[];\n project?: Project;\n outDir?: string;\n filename?: string;\n componentSuffix?: string;\n serializeShadowRoot?: RenderToStringOptions['serializeShadowRoot'];\n}) => {\n const tsProject = project || new Project({ useInMemoryFileSystem: true });\n const disableEslint = `/* eslint-disable */\\n`;\n const autogeneratedComment = `/**\n * This file was automatically generated by the Stencil React Output Target.\n * Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.\n */\\n\\n`;\n const outFile = path.join(outDir || '', filename);\n const sourceFile = tsProject.createSourceFile(outFile, autogeneratedComment + disableEslint, {\n overwrite: true,\n });\n\n /**\n * Server barrel: emit a single shared `serializeShadowRoot` so consumers\n * don't need to import a per-component file just to get the constant.\n */\n if (componentSuffix) {\n sourceFile.addImportDeclaration({\n moduleSpecifier: '@stencil/react-output-target/ssr',\n namedImports: [{ name: 'SerializeShadowRootOptions', isTypeOnly: true }],\n });\n sourceFile.addVariableStatement({\n isExported: true,\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: 'serializeShadowRoot',\n type: 'SerializeShadowRootOptions',\n initializer: serializeShadowRoot\n ? JSON.stringify(serializeShadowRoot)\n : '{ default: \"declarative-shadow-dom\" }',\n },\n ],\n });\n }\n\n for (const component of components) {\n const tagName = component.tagName;\n const reactTagName = kebabToPascalCase(tagName);\n const fileName = component.tagName;\n sourceFile.addExportDeclaration({\n moduleSpecifier: `./${fileName}${componentSuffix}.js`,\n namedExports: [reactTagName],\n });\n }\n\n sourceFile.organizeImports();\n sourceFile.formatText();\n await sourceFile.save();\n\n return sourceFile;\n};\n","import type { ComponentCompilerMeta } from '@stencil/core/internal';\nimport { Project, VariableDeclarationKind } from 'ts-morph';\nimport { eventListenerName, kebabToPascalCase, normalizeTypeString } from './utils/string-utils.js';\nimport type { RenderToStringOptions } from './runtime/ssr.js';\n\ninterface ReactEvent {\n originalName: string;\n name: string;\n type: string;\n}\n\nexport const createStencilReactComponents = ({\n components,\n stencilPackageName,\n customElementsDir,\n componentsTypesDir,\n hydrateModule,\n clientModule,\n serializeShadowRoot,\n transformTag,\n exportMaps,\n typesFromComponentsFile,\n}: {\n components: ComponentCompilerMeta[];\n stencilPackageName: string;\n customElementsDir: string;\n componentsTypesDir: string;\n hydrateModule?: string;\n clientModule?: string;\n serializeShadowRoot?: RenderToStringOptions['serializeShadowRoot'];\n transformTag?: boolean;\n /**\n * The Stencil project generates a package.json `exports` map, so import through its\n * entries (`<pkg>/<tag>`, `<pkg>/components`) instead of deep `dist/` paths the map would block.\n */\n exportMaps?: boolean;\n /**\n * `componentsTypesDir` points at the `types` output's `components.d.ts` (Stencil v5), so\n * event types can come from there too instead of relying on the package root exporting them.\n */\n typesFromComponentsFile?: boolean;\n}) => {\n const project = new Project({ useInMemoryFileSystem: true });\n // `components.d.ts` from deep link - e.g. `dist/types/components.d.ts`\n // or export map - e.g. `@my-components/components`\n const componentsTypesModule = exportMaps\n ? `${stencilPackageName}/components`\n : `${stencilPackageName}/${componentsTypesDir}`;\n // Stencil v4 keeps importing event types from the package root, as it always has.\n const eventTypesModule = exportMaps || typesFromComponentsFile ? componentsTypesModule : stencilPackageName;\n\n /**\n * automatically attach the `use client` directive if we are not generating\n * server side rendering components.\n */\n const useClientDirective = `'use client';\\n\\n`;\n const autogeneratedComment = `/**\n * This file was automatically generated by the Stencil React Output Target.\n * Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.\n */\\n\\n`;\n\n const disableEslint = `/* eslint-disable */\\n`;\n const getTagTransformerImport = transformTag ? `import { getTagTransformer } from './tag-transformer.js';\\n` : '';\n const createComponentImport = hydrateModule\n ? [\n getTagTransformerImport,\n `import { createComponent, type SerializeShadowRootOptions, type HydrateModule, type ReactWebComponent } from '@stencil/react-output-target/ssr';`,\n ]\n .filter(Boolean)\n .join('\\n')\n : `import { createComponent } from '@stencil/react-output-target/runtime';`;\n // transformTag should be imported from tag-transformer for both client and server\n const transformTagImport = transformTag ? `import { transformTag } from './tag-transformer.js';\\n` : '';\n const sourceFile = project.createSourceFile(\n 'component.ts',\n `${useClientDirective}${autogeneratedComment}${disableEslint}\nimport React from 'react';\n${createComponentImport}\nimport type { EventName, StencilReactComponent } from '@stencil/react-output-target/runtime';\n${transformTagImport}\nimport type { Components } from \"${componentsTypesModule}\";\n `\n );\n\n /**\n * Add the `clientComponents` import if hydrateModule is provided.\n * This import needs a @ts-ignore comment, which will be added after organizeImports().\n */\n if (hydrateModule && clientModule) {\n sourceFile.addImportDeclaration({\n moduleSpecifier: clientModule,\n namespaceImport: 'clientComponents',\n });\n }\n\n /**\n * Add the `serializeShadowRoot` variable to the file if the hydrateModule is provided.\n */\n if (hydrateModule) {\n sourceFile.addVariableStatement({\n isExported: true,\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: 'serializeShadowRoot',\n type: 'SerializeShadowRootOptions',\n initializer: serializeShadowRoot\n ? JSON.stringify(serializeShadowRoot)\n : '{ default: \"declarative-shadow-dom\" }',\n },\n ],\n });\n }\n\n for (const component of components) {\n const tagName = component.tagName;\n const reactTagName = kebabToPascalCase(tagName);\n const componentElement = `${reactTagName}Element`;\n const componentCustomEvent = `${reactTagName}CustomEvent`;\n\n sourceFile.addImportDeclaration({\n moduleSpecifier: exportMaps\n ? `${stencilPackageName}/${tagName}`\n : `${stencilPackageName}/${customElementsDir}/${tagName}.js`,\n namedImports: [\n {\n name: reactTagName,\n alias: componentElement,\n },\n {\n name: 'defineCustomElement',\n alias: `define${reactTagName}`,\n },\n ],\n });\n\n const publicEvents = (component.events || []).filter((e) => e.internal === false);\n const events: ReactEvent[] = [];\n const importedEventDetailTypes = new Set<string>();\n let importedComponentCustomEvent = false;\n\n for (const event of publicEvents) {\n /**\n * Import the referenced types from the component library.\n * Stencil will automatically re-export type definitions from the components,\n * if they are used in the component's property or event types.\n */\n if (Object.keys(event.complexType.references).length > 0) {\n for (const referenceKey of Object.keys(event.complexType.references)) {\n const reference = event.complexType.references[referenceKey];\n const isGlobalType = reference.location === 'global';\n\n /**\n * Global type references should not have an explicit import.\n * The type should be available globally.\n */\n if (!isGlobalType && !importedEventDetailTypes.has(referenceKey)) {\n importedEventDetailTypes.add(referenceKey);\n sourceFile.addImportDeclaration({\n moduleSpecifier: eventTypesModule,\n namedImports: [\n {\n name: referenceKey,\n isTypeOnly: true,\n },\n ],\n });\n }\n }\n }\n\n /**\n * Import the CustomEvent type for the web component from the Stencil package.\n *\n * For example:\n * ```\n * import type { ComponentCustomEvent } from 'my-component-library';\n * ```\n */\n if (!importedComponentCustomEvent) {\n importedComponentCustomEvent = true;\n sourceFile.addImportDeclaration({\n moduleSpecifier: eventTypesModule,\n namedImports: [\n {\n name: componentCustomEvent,\n isTypeOnly: true,\n },\n ],\n });\n }\n\n // Always type events using the Stencil per-component CustomEvent type.\n events.push({\n originalName: event.name,\n name: eventListenerName(event.name),\n type: `EventName<${componentCustomEvent}<${normalizeTypeString(event.complexType.original)}>>`,\n });\n }\n\n const componentEventNamesType = `${reactTagName}Events`;\n\n const requiredProps = component.properties.filter((p) => p.required && !p.internal).map((p) => `'${p.name}'`);\n const requiredGeneric = requiredProps.length > 0 ? `, ${requiredProps.join(' | ')}` : '';\n\n sourceFile.addTypeAlias({\n isExported: true,\n name: componentEventNamesType,\n type: events.length > 0 ? `{ ${events.map((e) => `${e.name}: ${e.type}`).join(',\\n')} }` : 'NonNullable<unknown>',\n });\n\n const transformTagParam = transformTag ? ',\\n transformTag' : '';\n const clientComponentCall = `/*@__PURE__*/ createComponent<${componentElement}, ${componentEventNamesType}, Components.${reactTagName}${requiredGeneric}>({\n tagName: '${tagName}',\n elementClass: ${componentElement},\n // @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.\n react: React,\n events: {${events.map((e) => `${e.name}: '${e.originalName}'`).join(',\\n')}} as ${componentEventNamesType},\n defineCustomElement: define${reactTagName}${transformTagParam}\n })`;\n\n const getTagTransformerParam = transformTag ? ',\\n getTagTransformer' : '';\n const serverComponentCall = `/*@__PURE__*/ createComponent<${componentElement}, ${componentEventNamesType}, Components.${reactTagName}${requiredGeneric}>({\n tagName: '${tagName}',\n properties: {${component.properties\n /**\n * Filter out properties that don't have an attribute.\n * These are properties with complex types and can't be serialized.\n */\n .filter((prop) => Boolean(prop.attribute))\n .map((e) => `${e.name}: '${e.attribute}'`)\n .join(',\\n')}},\n hydrateModule: typeof window === 'undefined' ? (import('${hydrateModule}') as Promise<HydrateModule>) : undefined,\n clientModule: clientComponents.${reactTagName} as StencilReactComponent<${componentElement}, ${componentEventNamesType}, Components.${reactTagName}${requiredGeneric}>,\n serializeShadowRoot${getTagTransformerParam}\n })`;\n\n sourceFile.addVariableStatement({\n isExported: true,\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: reactTagName,\n type: `StencilReactComponent<${componentElement}, ${componentEventNamesType}, Components.${reactTagName}${requiredGeneric}>`,\n initializer: hydrateModule ? serverComponentCall : clientComponentCall,\n },\n ],\n });\n }\n\n sourceFile.organizeImports();\n\n /**\n * Add the @ts-ignore comment to the clientComponents import after organizeImports()\n * to ensure the comment stays attached to the correct import.\n */\n if (hydrateModule && clientModule) {\n const clientComponentsImport = sourceFile\n .getImportDeclarations()\n .find((imp) => imp.getNamespaceImport()?.getText() === 'clientComponents');\n\n if (clientComponentsImport) {\n sourceFile.insertText(\n clientComponentsImport.getStart(),\n '// @ts-ignore - ignore potential type issues as the project is importing itself\\n'\n );\n }\n }\n\n sourceFile.formatText();\n\n return sourceFile.getFullText();\n};\n","export const createTagTransformer = ({\n stencilPackageName,\n customElementsDir,\n exportMaps,\n}: {\n stencilPackageName: string;\n customElementsDir: string;\n /** Import through the package's `exports` map (`<pkg>/standalone`) instead of a deep path. */\n exportMaps?: boolean;\n}) => {\n const standaloneModule = exportMaps\n ? `${stencilPackageName}/standalone`\n : `${stencilPackageName}/${customElementsDir}/index.js`;\n return `/* eslint-disable */\n/* tslint:disable */\nimport { setTagTransformer as clientSetTagTransformer } from '${standaloneModule}';\n\nlet tagTransformer: ((tagName: string) => string) | undefined;\n\nexport const setTagTransformer = (transformer: (tagName: string) => string) => {\n clientSetTagTransformer(transformer);\n tagTransformer = transformer;\n};\n\nexport const transformTag = (tag: string): string => {\n return tagTransformer ? tagTransformer(tag) : tag;\n};\n\nexport const getTagTransformer = () => tagTransformer;\n`;\n};\n","import type { ComponentCompilerMeta } from '@stencil/core/internal';\nimport path from 'node:path';\nimport { Project, SourceFile } from 'ts-morph';\nimport { createEsModulesComponentsFile } from './create-es-modules-components-file.js';\nimport { createStencilReactComponents } from './create-stencil-react-components.js';\nimport { createTagTransformer } from './create-tag-transformer.js';\nimport type { RenderToStringOptions } from './runtime/ssr.js';\n\nexport const createComponentWrappers = async ({\n stencilPackageName,\n components,\n outDir,\n esModules,\n customElementsDir,\n componentsTypesDir,\n excludeComponents,\n project,\n hydrateModule,\n clientModule,\n excludeServerSideRenderingFor,\n serializeShadowRoot,\n transformTag,\n exportMaps,\n typesFromComponentsFile,\n}: {\n stencilPackageName: string;\n components: ComponentCompilerMeta[];\n customElementsDir: string;\n componentsTypesDir: string;\n outDir: string;\n esModules?: boolean;\n excludeComponents?: string[];\n project: Project;\n hydrateModule?: string;\n clientModule?: string;\n excludeServerSideRenderingFor?: string[];\n serializeShadowRoot?: RenderToStringOptions['serializeShadowRoot'];\n transformTag?: boolean;\n exportMaps?: boolean;\n typesFromComponentsFile?: boolean;\n}) => {\n const sourceFiles: SourceFile[] = [];\n\n const filteredComponents = components.filter((c) => {\n if (c.internal === true) {\n /**\n * Skip internal components\n */\n return false;\n }\n if (excludeComponents?.includes(c.tagName)) {\n /**\n * Skip excluded components\n */\n return false;\n }\n\n return true;\n });\n\n if (filteredComponents.length === 0) {\n return [];\n }\n\n const fileContents: Record<string, string> = {};\n\n /**\n * create a single file with all components or a separate file for each component\n * @param components - the components to create the file for\n * @param filename - the filename of the file to create\n */\n function createComponentFile(components: ComponentCompilerMeta[], filename = 'components') {\n /**\n * create a single file with all components\n */\n const outputPath = path.join(outDir, `${filename}.ts`);\n\n /**\n * create a client side component\n */\n const stencilReactComponent = createStencilReactComponents({\n components,\n stencilPackageName,\n customElementsDir,\n componentsTypesDir,\n exportMaps,\n typesFromComponentsFile,\n transformTag,\n });\n fileContents[outputPath] = stencilReactComponent;\n\n /**\n * create tag-transformer file (for both client and server)\n */\n if (transformTag) {\n const tagTransformerPath = path.join(outDir, 'tag-transformer.ts');\n fileContents[tagTransformerPath] = createTagTransformer({ stencilPackageName, customElementsDir, exportMaps });\n }\n\n /**\n * create a server side component\n */\n if (hydrateModule) {\n const outputPath = path.join(outDir, `${filename}.server.ts`);\n const stencilReactComponent = createStencilReactComponents({\n components: components.filter(\n (c) => !excludeServerSideRenderingFor || !excludeServerSideRenderingFor.includes(c.tagName)\n ),\n stencilPackageName,\n customElementsDir,\n componentsTypesDir,\n exportMaps,\n typesFromComponentsFile,\n hydrateModule,\n clientModule,\n serializeShadowRoot,\n transformTag,\n });\n fileContents[outputPath] = stencilReactComponent;\n }\n }\n\n if (esModules) {\n /**\n * create a separate file for each component\n */\n for (const component of filteredComponents) {\n createComponentFile([component], component.tagName);\n }\n const componentsSource = await createEsModulesComponentsFile({ components: filteredComponents, project, outDir });\n sourceFiles.push(componentsSource);\n\n /**\n * Server barrel — mirrors the client barrel but points at `*.server.js` and\n * exposes a single shared `serializeShadowRoot` so SSR consumers can\n * tree-shake per-component imports.\n */\n if (hydrateModule) {\n const serverComponentsSource = await createEsModulesComponentsFile({\n components: filteredComponents.filter(\n (c) => !excludeServerSideRenderingFor || !excludeServerSideRenderingFor.includes(c.tagName)\n ),\n project,\n outDir,\n filename: 'components.server.ts',\n componentSuffix: '.server',\n serializeShadowRoot,\n });\n sourceFiles.push(serverComponentsSource);\n }\n } else {\n createComponentFile(filteredComponents);\n }\n\n await Promise.all(\n Object.entries(fileContents).map(async ([outputPath, content]) => {\n const sourceFile = project.createSourceFile(outputPath, content, { overwrite: true });\n await sourceFile.save();\n sourceFiles.push(sourceFile);\n })\n );\n\n return sourceFiles;\n};\n","import type { Config } from '@stencil/core';\nimport type { OutputTargetDistCustomElements } from '@stencil/core/internal';\nimport { isAbsolute, relative } from 'node:path';\nimport { Project } from 'ts-morph';\nimport { createComponentWrappers } from './create-component-wrappers.js';\nimport type { RenderToStringOptions } from './runtime/ssr.js';\n\nexport interface ReactOutputTargetOptions {\n /**\n * Specify the output directory or path where the generated React components will be saved.\n */\n outDir: string;\n /**\n * Specify the components that should be excluded from the React output target.\n */\n excludeComponents?: string[];\n /**\n * The package name of the Stencil project.\n *\n * This value is automatically detected from the package.json file of the Stencil project.\n * If the validation fails, you can manually assign the package name.\n */\n stencilPackageName?: string;\n /**\n * The directory where the custom elements are saved.\n *\n * This value is automatically detected from the Stencil configuration file for the dist-custom-elements output target.\n * If you are working in an environment that uses absolute paths, consider setting this value manually.\n */\n customElementsDir?: string;\n /**\n * To enable server side rendering, provide the path to the hydrate module, e.g. `my-component/hydrate`.\n * By default this value is undefined and server side rendering is disabled.\n */\n hydrateModule?: string;\n /**\n * The name of the package that exports all React wrapped Stencil components for client side rendering.\n * This options is required when `hydrateModule` is set for server side rendering to work.\n */\n clientModule?: string;\n /**\n * Specify the components that should be excluded from server side rendering.\n */\n excludeServerSideRenderingFor?: string[];\n /**\n * If `true`, the output target will generate a separate ES module for each React component wrapper (better for tree-shaking).\n * @default false\n */\n esModules?: boolean;\n /**\n * Configure how Stencil serializes the components shadow root.\n * - If set to `declarative-shadow-dom` the component will be rendered within a Declarative Shadow DOM.\n * - If set to `scoped` Stencil will render the contents of the shadow root as a `scoped: true` component\n * and the shadow DOM will be created during client-side hydration.\n * - Alternatively you can mix and match the two by providing an object with `declarative-shadow-dom` and `scoped` keys,\n * the value arrays containing the tag names of the components that should be rendered in that mode.\n *\n * Examples:\n * - `{ 'declarative-shadow-dom': ['my-component-1', 'another-component'], default: 'scoped' }`\n * Render all components as `scoped` apart from `my-component-1` and `another-component`\n * - `{ 'scoped': ['an-option-component'], default: 'declarative-shadow-dom' }`\n * Render all components within `declarative-shadow-dom` apart from `an-option-component`\n * - `'scoped'` Render all components as `scoped`\n * - `false` disables shadow root serialization\n *\n * *NOTE* `true` has been deprecated in favor of `declarative-shadow-dom` and `scoped`\n * @default 'declarative-shadow-dom'\n */\n serializeShadowRoot?: RenderToStringOptions['serializeShadowRoot'];\n /**\n * Use `transformTag` to enable runtime tag name transformation for your components.\n * When enabled, the output target will import `transformTag` from your component library\n * and apply it when rendering components.\n *\n * You must export `transformTag` from the root entry of your component library:\n * ```ts\n * // src/index.ts\n * export { transformTag } from '@stencil/core';\n * ```\n *\n * @default false\n */\n transformTag?: boolean;\n}\n\nconst PLUGIN_NAME = 'react-output-target';\n\nconst DIST_CUSTOM_ELEMENTS_DEFAULT_DIR = 'dist/components';\nconst DIST_CUSTOM_ELEMENTS = 'dist-custom-elements';\nconst STANDALONE = 'standalone';\nconst HYDRATE_OUTPUT_TARGET = 'dist-hydrate-script';\nconst SSR_OUTPUT_TARGET = 'ssr';\n// Stencil v5 removed the `@stencil/core/internal` entry point, so anything that ends up in\n// our public typings is derived from the root `Config` type, which v4 and v5 both export.\ntype OutputTargetCustom = Extract<NonNullable<Config['outputTargets']>[number], { type: 'custom' }>;\ntype BuildCtx = Parameters<OutputTargetCustom['generator']>[2];\n\nconst TYPES_OUTPUT_TARGET = 'types';\nconst TYPES_DEFAULT_DIR = 'dist/types';\n\n/**\n * Turn an output directory into the form used inside an import specifier: relative to the\n * project root, with forward slashes. `path.relative()` returns backslashes on Windows, which\n * would otherwise end up in the generated imports.\n */\nconst toImportPath = (rootDir: string, dir: string): string =>\n (isAbsolute(dir) ? relative(rootDir, dir) : dir).replace(/\\\\/g, '/');\n\ninterface ReactOutputTarget extends OutputTargetCustom {\n __internal_getCustomElementsDir: () => string;\n}\n\n/**\n * Creates an output target for binding Stencil components to be used in a React context\n * @public\n * @param outputTarget the user-defined output target defined in a Stencil configuration file\n * @returns an output target that can be used by the Stencil compiler\n */\nexport const reactOutputTarget = ({\n outDir,\n esModules,\n stencilPackageName,\n excludeComponents,\n customElementsDir: customElementsDirOverride,\n hydrateModule,\n clientModule,\n excludeServerSideRenderingFor,\n serializeShadowRoot,\n transformTag,\n}: ReactOutputTargetOptions): ReactOutputTarget => {\n let customElementsDir = DIST_CUSTOM_ELEMENTS_DEFAULT_DIR;\n let componentsTypesDir = DIST_CUSTOM_ELEMENTS_DEFAULT_DIR;\n let exportMaps = false;\n let typesFromComponentsFile = false;\n return {\n type: 'custom',\n name: PLUGIN_NAME,\n validate(config) {\n const isV5 = (config.outputTargets || []).some((o: any) =>\n ['loader-bundle', 'standalone', 'ssr', 'types'].includes(o.type)\n );\n\n /**\n * When the Stencil project generates a package.json `exports` map, deep `dist/` imports\n * are blocked for consumers, so the wrappers import through the map's entries instead.\n * Stencil v5 only: v4's map has no `./components`, `./standalone` or `./ssr` entry.\n */\n exportMaps = isV5 && (config as { generateExportMaps?: boolean }).generateExportMaps === true;\n\n /**\n * In Stencil v5 every component type lives in the `types` output's `components.d.ts`, so\n * event types are imported from there too. v4 keeps importing them from the package root.\n */\n typesFromComponentsFile = isV5;\n\n /**\n * Validate the configuration to ensure that the dist-custom-elements\n * output target is defined in the Stencil configuration.\n *\n * This context is used to detect a customized output path.\n */\n if (customElementsDirOverride) {\n customElementsDir = customElementsDirOverride;\n componentsTypesDir = customElementsDirOverride;\n } else {\n const customElementsOutputTarget = (config.outputTargets || []).find(\n (o: any) => o.type === DIST_CUSTOM_ELEMENTS || o.type === STANDALONE\n ) as OutputTargetDistCustomElements;\n if (customElementsOutputTarget == null) {\n const isV5 = (config.outputTargets || []).some((o: any) =>\n ['loader-bundle', 'standalone', 'ssr', 'types'].includes(o.type)\n );\n const requiredTarget = isV5 ? STANDALONE : DIST_CUSTOM_ELEMENTS;\n throw new Error(\n `The '${PLUGIN_NAME}' requires '${requiredTarget}' output target. Add { type: '${requiredTarget}' }, to the outputTargets config.`\n );\n }\n if ((customElementsOutputTarget as any).type === STANDALONE) {\n /**\n * In Stencil v5, `Components` types are emitted by the `types` output target\n * (not by `standalone`). Resolve the types dir independently of the JS output dir.\n */\n const typesTarget = (config.outputTargets || []).find((o: any) => o.type === TYPES_OUTPUT_TARGET) as any;\n const rawTypesDir = typesTarget?.dir ?? TYPES_DEFAULT_DIR;\n const typesDir = toImportPath(config.rootDir!, rawTypesDir);\n componentsTypesDir = `${typesDir}/components`;\n // customElementsDir stays as default (dist/components) unless standalone.dir is set\n if ((customElementsOutputTarget as any).dir !== undefined) {\n const dir = (customElementsOutputTarget as any).dir;\n customElementsDir = toImportPath(config.rootDir!, dir);\n }\n } else if (customElementsOutputTarget.dir !== undefined) {\n /**\n * If the developer has configured a custom output path for the Stencil components,\n * we need to use that path when importing the components in the React components.\n * In Stencil v4 the dir is normalised to an absolute path before validate runs,\n * so convert it back to a rootDir-relative path for use in import specifiers.\n */\n const dir = customElementsOutputTarget.dir;\n customElementsDir = toImportPath(config.rootDir!, dir);\n componentsTypesDir = customElementsDir;\n }\n\n /**\n * For the legacy `dist-custom-elements` output target, validate that externalRuntime is\n * disabled so the Stencil runtime includes hydration flags.\n */\n if (\n customElementsOutputTarget.type === DIST_CUSTOM_ELEMENTS &&\n customElementsOutputTarget.externalRuntime !== false\n ) {\n throw new Error(\n `The '${PLUGIN_NAME}' requires the '${DIST_CUSTOM_ELEMENTS}' output target to have 'externalRuntime: false' set in its configuration.`\n );\n }\n }\n\n /**\n * Validate the configuration to ensure that the dist-hydrate-script\n * output target is defined in the Stencil configuration if the hydrateModule is provided.\n */\n if (hydrateModule) {\n const hydrateOutputTarget = (config.outputTargets || []).find(\n (o: any) => o.type === HYDRATE_OUTPUT_TARGET || o.type === SSR_OUTPUT_TARGET\n );\n if (hydrateOutputTarget == null) {\n const isV5 = (config.outputTargets || []).some((o: any) =>\n ['loader-bundle', 'standalone', 'ssr', 'types'].includes(o.type)\n );\n const requiredTarget = isV5 ? SSR_OUTPUT_TARGET : HYDRATE_OUTPUT_TARGET;\n throw new Error(\n `The '${PLUGIN_NAME}' requires '${requiredTarget}' output target when the 'hydrateModule' option is set. Add { type: '${requiredTarget}' }, to the outputTargets config.`\n );\n }\n\n if (clientModule == null) {\n throw new Error(\n `The '${PLUGIN_NAME}' requires the 'clientModule' option when the 'hydrateModule' option is set. Please provide the clientModule manually to the ${PLUGIN_NAME} output target.`\n );\n }\n }\n\n /**\n * Validate the configuration to detect the package name of the Stencil project.\n */\n if (stencilPackageName === undefined) {\n if (config.sys && config.packageJsonFilePath) {\n const { name: packageName } = JSON.parse(config.sys.readFileSync(config.packageJsonFilePath, 'utf8'));\n stencilPackageName = packageName;\n }\n\n if (!stencilPackageName) {\n throw new Error(\n `Unable to find the package name in the package.json file: ${config.packageJsonFilePath}. Please provide the stencilPackageName manually to the ${PLUGIN_NAME} output target.`\n );\n }\n }\n },\n async generator(_config, compilerCtx, buildCtx: BuildCtx) {\n const timespan = buildCtx.createTimeSpan(`generate ${PLUGIN_NAME} started`, true);\n\n const components = buildCtx.components;\n const project = new Project();\n\n const sourceFiles = await createComponentWrappers({\n outDir,\n components,\n stencilPackageName: stencilPackageName!,\n customElementsDir,\n componentsTypesDir,\n excludeComponents,\n esModules: esModules === true,\n project,\n hydrateModule,\n clientModule,\n excludeServerSideRenderingFor,\n serializeShadowRoot,\n transformTag,\n exportMaps,\n typesFromComponentsFile,\n });\n\n await Promise.all(\n sourceFiles.map((sourceFile) => compilerCtx.fs.writeFile(sourceFile.getFilePath(), sourceFile.getFullText()))\n );\n\n timespan.finish(`generate ${PLUGIN_NAME} finished`);\n },\n __internal_getCustomElementsDir() {\n return customElementsDir;\n },\n };\n};\n"],"names":["kebabToPascalCase","str","segment","kebabToCamelCase","_","letter","slashesToCamelCase","eventListenerName","eventName","slashesConverted","normalizeTypeString","type","createEsModulesComponentsFile","components","project","outDir","filename","componentSuffix","serializeShadowRoot","tsProject","Project","disableEslint","autogeneratedComment","outFile","path","sourceFile","VariableDeclarationKind","component","tagName","reactTagName","fileName","createStencilReactComponents","stencilPackageName","customElementsDir","componentsTypesDir","hydrateModule","clientModule","transformTag","exportMaps","typesFromComponentsFile","componentsTypesModule","eventTypesModule","useClientDirective","createComponentImport","transformTagImport","componentElement","componentCustomEvent","publicEvents","e","events","importedEventDetailTypes","importedComponentCustomEvent","event","referenceKey","componentEventNamesType","requiredProps","p","requiredGeneric","transformTagParam","clientComponentCall","getTagTransformerParam","serverComponentCall","prop","clientComponentsImport","imp","_a","createTagTransformer","createComponentWrappers","esModules","excludeComponents","excludeServerSideRenderingFor","sourceFiles","filteredComponents","c","fileContents","createComponentFile","outputPath","stencilReactComponent","tagTransformerPath","componentsSource","serverComponentsSource","content","PLUGIN_NAME","DIST_CUSTOM_ELEMENTS_DEFAULT_DIR","DIST_CUSTOM_ELEMENTS","STANDALONE","HYDRATE_OUTPUT_TARGET","SSR_OUTPUT_TARGET","TYPES_OUTPUT_TARGET","TYPES_DEFAULT_DIR","toImportPath","rootDir","dir","isAbsolute","relative","reactOutputTarget","customElementsDirOverride","config","isV5","o","customElementsOutputTarget","requiredTarget","typesTarget","rawTypesDir","packageName","_config","compilerCtx","buildCtx","timespan"],"mappings":"mIAAaA,EAAqBC,GAChCA,EACG,YAAA,EACA,MAAM,GAAG,EACT,IAAKC,GAAYA,EAAQ,OAAO,CAAC,EAAE,cAAgBA,EAAQ,MAAM,CAAC,CAAC,EACnE,KAAK,EAAE,EAECC,EAAoBF,GAAgBA,EAAI,QAAQ,aAAc,CAACG,EAAGC,IAAWA,EAAO,aAAa,EAExGC,EAAsBL,GAAgBA,EAAI,QAAQ,aAAc,CAACG,EAAGC,IAAWA,EAAO,aAAa,EAE5FE,EAAqBC,GAAsB,CACtD,MAAMC,EAAmBH,EAAmBE,CAAS,EACrD,OAAOL,EAAiB,MAAMM,CAAgB,EAAE,CAClD,EAMaC,EAAuBC,GAClCA,EACG,QAAQ,YAAa,EAAE,EACvB,QAAQ,MAAO,GAAG,EAClB,QAAQ,UAAW,GAAG,EACtB,KAAA,ECnBQC,EAAgC,MAAO,CAClD,WAAAC,EACA,QAAAC,EACA,OAAAC,EACA,SAAAC,EAAW,gBACX,gBAAAC,EAAkB,GAClB,oBAAAC,CACF,IAOM,CACJ,MAAMC,EAAYL,GAAW,IAAIM,EAAAA,QAAQ,CAAE,sBAAuB,GAAM,EAClEC,EAAgB;AAAA,EAChBC,EAAuB;AAAA;AAAA;AAAA;AAAA;AAAA,EAIvBC,EAAUC,EAAK,KAAKT,GAAU,GAAIC,CAAQ,EAC1CS,EAAaN,EAAU,iBA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