/* tslint:disable */ /* eslint-disable */ /* auto-generated by NAPI-RS */ export interface TransformNodiffBundleOptions { filename: string pluginName: string sourceFileName?: string sourcemap: boolean | string extractStr: boolean | ExtractStrConfig minify?: boolean } export interface TransformNodiffBundleOutput { code: string map?: string selectStrVec?: Array useWorklet?: boolean errors: Array warnings: Array } /** * This is esbuild's PartialMessage definition. * https://github.com/evanw/esbuild/blob/043ab306c490f692c68e8d254bbf00b6468be87d/lib/shared/types.ts#L421 */ export interface PartialMessage { id?: string pluginName?: string text?: string location?: PartialLocation notes?: Array detail?: string } export interface PartialNote { text?: string location?: PartialLocation } export interface PartialLocation { file?: string namespace?: string line?: number column?: number length?: number lineText?: string suggestion?: string } export interface DarkModeConfig { /** * @public * Theme expression to be used for dark mode */ themeExpr: string } /** * {@inheritdoc CompatVisitorConfig.addComponentElement} * @public */ export interface AddComponentElementConfig { /** * @public * Whether to only add component element during compilation * * @example * * Note that this only take effects on `Component` imported from {@link CompatVisitorConfig.oldRuntimePkg}. * * ```js * import { defineConfig } from '@lynx-js/rspeedy' * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin' * * export default defineConfig({ * plugins: [ * pluginReactLynx({ * compat: { * addComponentElement: { compilerOnly: true } * }, * }) * ], * }) * ``` */ compilerOnly: boolean } /** * {@inheritdoc PluginReactLynxOptions.compat} * @public */ export interface CompatVisitorConfig { /** @internal */ target: 'LEPUS' | 'JS' | 'MIXED' /** * @public * Specifies the list of component package names that need compatibility processing * * @remarks * Default value: `['@lynx-js/react-components']` * * @example * * ```js * import { defineConfig } from '@lynx-js/rspeedy' * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin' * * export default defineConfig({ * plugins: [ * pluginReactLynx({ * compat: { * componentsPkg: ['@my-org/components', '@legacy/ui-kit'] * }, * }) * ], * }) * ``` */ componentsPkg: Array /** * @public * Specifies the list of old runtime package names that need compatibility processing * * @remarks * Default value: `['@lynx-js/react-runtime']` * * @example * * ```js * import { defineConfig } from '@lynx-js/rspeedy' * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin' * * export default defineConfig({ * plugins: [ * pluginReactLynx({ * compat: { * oldRuntimePkg: ['@my-org/runtime', '@legacy/runtime'] * }, * }) * ], * }) * ``` */ oldRuntimePkg: Array /** * @public * Specifies the new runtime package name * * @remarks * Default value: `'@lynx-js/react'` * * @example * * ```js * import { defineConfig } from '@lynx-js/rspeedy' * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin' * * export default defineConfig({ * plugins: [ * pluginReactLynx({ * compat: { * newRuntimePkg: '@my-org/react' * }, * }) * ], * }) * ``` */ newRuntimePkg: string /** * @public * Specifies additional component attributes list, these attributes will be passed to the wrapped `` instead of the component. * * @remarks * This only takes effect when {@link CompatVisitorConfig.addComponentElement} is enabled. * * Default value: `[]` * * @example * * ```js * import { defineConfig } from '@lynx-js/rspeedy' * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin' * * export default defineConfig({ * plugins: [ * pluginReactLynx({ * compat: { * additionalComponentAttributes: ['custom-attr', 'data-special'] * }, * }) * ], * }) * ``` */ additionalComponentAttributes: Array /** * @public * Controls whether to add wrapper elements for components * * @remarks * Default value: `false` * * @example * * Add a `` wrapper element for all components during runtime. * * ```js * import { defineConfig } from '@lynx-js/rspeedy' * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin' * * export default defineConfig({ * plugins: [ * pluginReactLynx({ * compat: { * addComponentElement: true * }, * }) * ], * }) * ``` * * @example * * Only add component element during compilation. * Note that this only take effects on `Component` imported from {@link CompatVisitorConfig.oldRuntimePkg}. * * ```js * import { defineConfig } from '@lynx-js/rspeedy' * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin' * * export default defineConfig({ * plugins: [ * pluginReactLynx({ * compat: { * addComponentElement: { compilerOnly: true } * }, * }) * ], * }) * ``` */ addComponentElement: boolean | AddComponentElementConfig /** * @public * Whether to simplify constructor calls like ReactLynx 2 * * @deprecated * Using `simplifyCtorLikeReactLynx2` is not recommended as it introduces implicit behaviors that can: * * - Make code harder to understand and maintain * * - Create hidden dependencies between components * * - Complicate debugging and testing processes * * Instead, use `background-only` on class methods for explicit and maintainable behavior * * @remarks * Default value: `false` * * @example * * ```js * import { defineConfig } from '@lynx-js/rspeedy' * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin' * * export default defineConfig({ * plugins: [ * pluginReactLynx({ * compat: { * simplifyCtorLikeReactLynx2: true * }, * }) * ], * }) * ``` */ simplifyCtorLikeReactLynx2: boolean /** * @public * Regular expression used to remove component attributes * * @deprecated It's recommended to use `background-only`. * * If your code depends on this switch, when distributing it to other projects through npm packages or other means, you'll also need to enable this switch. This will lead to the proliferation of switches, which is not conducive to code reuse between different projects. * * @remarks * Default value: `None` * * @example * * ```js * import { defineConfig } from '@lynx-js/rspeedy' * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin' * * export default defineConfig({ * plugins: [ * pluginReactLynx({ * compat: { * removeComponentAttrRegex: '^data-test-' * }, * }) * ], * }) * ``` */ removeComponentAttrRegex?: string /** * @public * Whether to disable deprecated warnings * * @remarks * Default value: `false` * * @example * * Disable all the `DEPRECATED:` warnings. * * ```js * import { defineConfig } from '@lynx-js/rspeedy' * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin' * * export default defineConfig({ * plugins: [ * pluginReactLynx({ * compat: { * disableDeprecatedWarning: true * }, * }) * ], * }) * ``` */ disableDeprecatedWarning: boolean /** * @public * @deprecated * Dark mode configuration * * @remarks * Default value: `None` * * @example * * ```js * import { defineConfig } from '@lynx-js/rspeedy' * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin' * * export default defineConfig({ * plugins: [ * pluginReactLynx({ * compat: { * darkMode: true * }, * }) * ], * }) * ``` */ darkMode?: boolean | DarkModeConfig } export interface CssScopeVisitorConfig { /** @public */ mode: 'all' | 'none' | 'modules' /** @public */ filename: string } /** * {@inheritdoc PluginReactLynxOptions.defineDCE} * @public */ export interface DefineDceVisitorConfig { /** * @public * Replaces variables in your code with other values or expressions at compile time. * * @remarks * Caveat: differences between `source.define` * * `defineDCE` happens before transforming `background-only` directives. * So it's useful for eliminating code that is only used in the background from main-thread. * * @example * * ```js * import { defineConfig } from '@lynx-js/rspeedy' * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin' * * export default defineConfig({ * plugins: [ * pluginReactLynx({ * defineDCE: { * define: { * __FOO__: 'false', * 'process.env.PLATFORM': '"lynx"', * }, * }, * }) * ], * }) * ``` * * Then, `__FOO__` and `process.env.PLATFORM` could be used in source code. * * ``` * if (process.env.PLATFORM === 'lynx') { * console.log('lynx') * } * * function FooOrBar() { * if (__FOO__) { * return foo * } else { * return bar * } * } * ``` */ define: Record } export interface DirectiveDceVisitorConfig { /** @internal */ target: 'LEPUS' | 'JS' | 'MIXED' } export interface DynamicImportVisitorConfig { /** @internal */ runtimePkg: string /** @internal */ layer: string /** @internal */ injectLazyBundle?: boolean } /** * {@inheritdoc PluginReactLynxOptions.extractStr} * @public */ export interface ExtractStrConfig { /** * @public * The minimum length of string literals to be extracted. * * @remarks * Default value: `20`. * * @example * * ```js * import { defineConfig } from '@lynx-js/rspeedy' * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin' * * export default defineConfig({ * plugins: [ * pluginReactLynx({ * extractStr: { * strLength: 10, * }, * }) * ], * }) * ``` */ strLength: number /** @internal */ extractedStrArr?: Array } export interface InjectVisitorConfig { inject: Record } export interface RefreshVisitorConfig { library?: Array } /** * {@inheritdoc PluginReactLynxOptions.shake} * @public */ export interface ShakeVisitorConfig { /** * Package names to identify runtime imports that need to be processed * * @example * ```js * import { defineConfig } from '@lynx-js/rspeedy' * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin' * * export default defineConfig({ * plugins: [ * pluginReactLynx({ * shake: { * pkgName: ['@lynx-js/react-runtime'] * } * }) * ] * }) * ``` * * @remarks * Default value: `['@lynx-js/react-runtime']` * The provided values will be merged with the default values instead of replacing them. * @public */ pkgName: Array /** * Properties that should be retained in the component class * * @example * ```js * import { defineConfig } from '@lynx-js/rspeedy' * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin' * * export default defineConfig({ * plugins: [ * pluginReactLynx({ * shake: { * retainProp: ['myCustomMethod'] * } * }) * ] * }) * ``` * * @remarks * Default value: `['constructor', 'render', 'getDerivedStateFromProps', 'state', 'defaultDataProcessor', 'dataProcessors', 'contextType', 'defaultProps']` * The provided values will be merged with the default values instead of replacing them. * * @public */ retainProp: Array /** * Function names whose calls should be replaced with `undefined` during transformation * * @example * ```js * import { defineConfig } from '@lynx-js/rspeedy' * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin' * * export default defineConfig({ * plugins: [ * pluginReactLynx({ * shake: { * removeCall: ['useMyCustomEffect'] * } * }) * ] * }) * ``` * * @remarks * Default value: `['useEffect', 'useLayoutEffect', '__runInJS', 'useLynxGlobalEventListener', 'useImperativeHandle']` * The provided values will be merged with the default values instead of replacing them. * * @public */ removeCall: Array /** * Function names whose parameters should be removed during transformation * * @example * ```js * import { defineConfig } from '@lynx-js/rspeedy' * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin' * * export default defineConfig({ * plugins: [ * pluginReactLynx({ * shake: { * removeCallParams: ['useMyCustomEffect'] * } * }) * ] * }) * ``` * * @remarks * Default value: `[]` * The provided values will be merged with the default values instead of replacing them. * * @public */ removeCallParams: Array } /** @internal */ export interface JsxTransformerConfig { /** @internal */ preserveJsx: boolean /** @internal */ runtimePkg: string /** @internal */ jsxImportSource?: string /** @internal */ filename: string /** @internal */ target: 'LEPUS' | 'JS' | 'MIXED' /** @internal */ isDynamicComponent?: boolean } export interface WorkletVisitorConfig { /** * @public * During the compilation of worklet, when extracting external variable identifiers, * global identifiers available in lepus context need to be ignored. * In addition to the default lepus global identifier list provided by the compiler, * users can customize the global identifier list through this option. * This configuration will take effect together with the default lepus global identifier list. */ customGlobalIdentNames?: Array /** @internal */ filename: string /** @internal */ target: 'LEPUS' | 'JS' | 'MIXED' runtimePkg: string } export interface TransformNodiffOptions { /** * @internal * This is used internally to make sure the test output is consistent. */ mode?: 'production' | 'development' | 'test' pluginName: string filename: string sourceFileName?: string sourcemap: boolean | string sourceMapColumns?: boolean inlineSourcesContent?: boolean /** * @public * This is swc syntax config in JSON format */ syntaxConfig?: string isModule?: boolean | 'unknown' cssScope: boolean | CssScopeVisitorConfig snapshot?: boolean | JsxTransformerConfig engineVersion?: string shake: boolean | ShakeVisitorConfig compat: boolean | CompatVisitorConfig refresh: boolean | RefreshVisitorConfig defineDCE: boolean | DefineDceVisitorConfig directiveDCE: boolean | DirectiveDceVisitorConfig worklet: boolean | WorkletVisitorConfig dynamicImport?: boolean | DynamicImportVisitorConfig /** @internal */ inject?: boolean | InjectVisitorConfig inputSourceMap?: string } export interface TransformNodiffOutput { code: string map?: string errors: Array warnings: Array } export function transformReactLynxSync(code: string, options?: TransformNodiffOptions | undefined | null): TransformNodiffOutput export function transformReactLynx(code: string, options?: TransformNodiffOptions | undefined | null): Promise export function transformBundleResultSync(code: string, options?: TransformNodiffBundleOptions | undefined | null): TransformNodiffBundleOutput export function transformBundleResult(code: string, options?: TransformNodiffBundleOptions | undefined | null): Promise