babel-plugin-react-compiler 19.1.0-rc.1-76db730-20250421 → 19.1.0-rc.2

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +67 -27
  2. package/dist/index.js +62766 -108362
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -242,6 +242,7 @@ declare const EnvironmentConfigSchema: z.ZodObject<{
242
242
  validateNoCapitalizedCalls: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
243
243
  validateBlocklistedImports: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
244
244
  validateNoImpureFunctionsInRender: z.ZodDefault<z.ZodBoolean>;
245
+ validateNoFreezingKnownMutableFunctions: z.ZodDefault<z.ZodBoolean>;
245
246
  enableAssumeHooksFollowRulesOfReact: z.ZodDefault<z.ZodBoolean>;
246
247
  enableTransitivelyFreezeFunctionExpressions: z.ZodDefault<z.ZodBoolean>;
247
248
  enableEmitFreeze: z.ZodDefault<z.ZodNullable<z.ZodObject<{
@@ -402,6 +403,7 @@ declare const EnvironmentConfigSchema: z.ZodObject<{
402
403
  validateNoCapitalizedCalls: string[] | null;
403
404
  validateBlocklistedImports: string[] | null;
404
405
  validateNoImpureFunctionsInRender: boolean;
406
+ validateNoFreezingKnownMutableFunctions: boolean;
405
407
  enableAssumeHooksFollowRulesOfReact: boolean;
406
408
  enableTransitivelyFreezeFunctionExpressions: boolean;
407
409
  enableEmitFreeze: {
@@ -486,6 +488,7 @@ declare const EnvironmentConfigSchema: z.ZodObject<{
486
488
  validateNoCapitalizedCalls?: string[] | null | undefined;
487
489
  validateBlocklistedImports?: string[] | null | undefined;
488
490
  validateNoImpureFunctionsInRender?: boolean | undefined;
491
+ validateNoFreezingKnownMutableFunctions?: boolean | undefined;
489
492
  enableAssumeHooksFollowRulesOfReact?: boolean | undefined;
490
493
  enableTransitivelyFreezeFunctionExpressions?: boolean | undefined;
491
494
  enableEmitFreeze?: {
@@ -529,9 +532,6 @@ declare const EnvironmentConfigSchema: z.ZodObject<{
529
532
  } | null | undefined;
530
533
  }>;
531
534
  type EnvironmentConfig = z.infer<typeof EnvironmentConfigSchema>;
532
- declare function parseConfigPragmaForTests(pragma: string, defaults: {
533
- compilationMode: CompilationMode;
534
- }): PluginOptions;
535
535
  type PartialEnvironmentConfig = Partial<EnvironmentConfig>;
536
536
  type ReactFunctionType = 'Component' | 'Hook' | 'Other';
537
537
  declare class Environment {
@@ -1107,7 +1107,7 @@ type InstructionValue = LoadLocal | LoadContext | {
1107
1107
  } | StoreLocal | {
1108
1108
  kind: 'StoreContext';
1109
1109
  lvalue: {
1110
- kind: InstructionKind.Reassign;
1110
+ kind: InstructionKind.Reassign | InstructionKind.Const | InstructionKind.Let | InstructionKind.Function;
1111
1111
  place: Place;
1112
1112
  };
1113
1113
  value: Place;
@@ -1555,10 +1555,10 @@ type PluginOptions = {
1555
1555
  panicThreshold: PanicThresholdOptions;
1556
1556
  noEmit: boolean;
1557
1557
  compilationMode: CompilationMode;
1558
- eslintSuppressionRules?: Array<string> | null | undefined;
1558
+ eslintSuppressionRules: Array<string> | null | undefined;
1559
1559
  flowSuppressions: boolean;
1560
1560
  ignoreUseNoForget: boolean;
1561
- sources?: Array<string> | ((filename: string) => boolean) | null;
1561
+ sources: Array<string> | ((filename: string) => boolean) | null;
1562
1562
  enableReanimatedCheck: boolean;
1563
1563
  target: CompilerReactTarget;
1564
1564
  };
@@ -1575,7 +1575,7 @@ declare const CompilerReactTargetSchema: z.ZodUnion<[z.ZodLiteral<"17">, z.ZodLi
1575
1575
  type CompilerReactTarget = z.infer<typeof CompilerReactTargetSchema>;
1576
1576
  declare const CompilationModeSchema: z.ZodEnum<["infer", "syntax", "annotation", "all"]>;
1577
1577
  type CompilationMode = z.infer<typeof CompilationModeSchema>;
1578
- type LoggerEvent = CompileSuccessEvent | CompileErrorEvent | CompileDiagnosticEvent | CompileSkipEvent | PipelineErrorEvent | TimingEvent;
1578
+ type LoggerEvent = CompileSuccessEvent | CompileErrorEvent | CompileDiagnosticEvent | CompileSkipEvent | PipelineErrorEvent | TimingEvent | AutoDepsDecorationsEvent | AutoDepsEligibleEvent;
1579
1579
  type CompileErrorEvent = {
1580
1580
  kind: 'CompileError';
1581
1581
  fnLoc: t.SourceLocation | null;
@@ -1611,28 +1611,22 @@ type TimingEvent = {
1611
1611
  kind: 'Timing';
1612
1612
  measurement: PerformanceMeasure;
1613
1613
  };
1614
+ type AutoDepsDecorationsEvent = {
1615
+ kind: 'AutoDepsDecorations';
1616
+ fnLoc: t.SourceLocation;
1617
+ decorations: Array<t.SourceLocation>;
1618
+ };
1619
+ type AutoDepsEligibleEvent = {
1620
+ kind: 'AutoDepsEligible';
1621
+ fnLoc: t.SourceLocation;
1622
+ depArrayLoc: t.SourceLocation;
1623
+ };
1614
1624
  type Logger = {
1615
1625
  logEvent: (filename: string | null, event: LoggerEvent) => void;
1616
1626
  debugLogIRs?: (value: CompilerPipelineValue) => void;
1617
1627
  };
1618
1628
  declare function parsePluginOptions(obj: unknown): PluginOptions;
1619
1629
 
1620
- declare class ProgramContext {
1621
- scope: Scope;
1622
- reactRuntimeModule: string;
1623
- hookPattern: string | null;
1624
- knownReferencedNames: Set<string>;
1625
- imports: Map<string, Map<string, NonLocalImportSpecifier>>;
1626
- constructor(program: NodePath$1<t.Program>, reactRuntimeModule: CompilerReactTarget, hookPattern: string | null);
1627
- isHookName(name: string): boolean;
1628
- hasReference(name: string): boolean;
1629
- newUid(name: string): string;
1630
- addMemoCacheImport(): NonLocalImportSpecifier;
1631
- addImportSpecifier({ source: module, importSpecifierName: specifier }: ExternalFunction, nameHint?: string): NonLocalImportSpecifier;
1632
- addNewReference(name: string): void;
1633
- assertGlobalBinding(name: string, localScope?: Scope): Result<void, CompilerError>;
1634
- }
1635
-
1636
1630
  type CompilerPass = {
1637
1631
  opts: PluginOptions;
1638
1632
  filename: string | null;
@@ -1641,20 +1635,66 @@ type CompilerPass = {
1641
1635
  };
1642
1636
  declare const OPT_IN_DIRECTIVES: Set<string>;
1643
1637
  declare const OPT_OUT_DIRECTIVES: Set<string>;
1644
- declare function findDirectiveEnablingMemoization(directives: Array<t.Directive>): Array<t.Directive>;
1645
- declare function findDirectiveDisablingMemoization(directives: Array<t.Directive>): Array<t.Directive>;
1638
+ declare function findDirectiveEnablingMemoization(directives: Array<t.Directive>): t.Directive | null;
1639
+ declare function findDirectiveDisablingMemoization(directives: Array<t.Directive>): t.Directive | null;
1646
1640
  type BabelFn = NodePath$1<t.FunctionDeclaration> | NodePath$1<t.FunctionExpression> | NodePath$1<t.ArrowFunctionExpression>;
1647
- type CompileProgramResult = {
1641
+ type CompileProgramMetadata = {
1648
1642
  retryErrors: Array<{
1649
1643
  fn: BabelFn;
1650
1644
  error: CompilerError;
1651
1645
  }>;
1652
1646
  inferredEffectLocations: Set<t.SourceLocation>;
1653
1647
  };
1654
- declare function compileProgram(program: NodePath$1<t.Program>, pass: CompilerPass): CompileProgramResult | null;
1648
+ declare function compileProgram(program: NodePath$1<t.Program>, pass: CompilerPass): CompileProgramMetadata | null;
1649
+
1650
+ type SuppressionRange = {
1651
+ disableComment: t.Comment;
1652
+ enableComment: t.Comment | null;
1653
+ source: SuppressionSource;
1654
+ };
1655
+ type SuppressionSource = 'Eslint' | 'Flow';
1656
+
1657
+ type ProgramContextOptions = {
1658
+ program: NodePath$1<t.Program>;
1659
+ suppressions: Array<SuppressionRange>;
1660
+ opts: PluginOptions;
1661
+ filename: string | null;
1662
+ code: string | null;
1663
+ hasModuleScopeOptOut: boolean;
1664
+ };
1665
+ declare class ProgramContext {
1666
+ scope: Scope;
1667
+ opts: PluginOptions;
1668
+ filename: string | null;
1669
+ code: string | null;
1670
+ reactRuntimeModule: string;
1671
+ suppressions: Array<SuppressionRange>;
1672
+ hasModuleScopeOptOut: boolean;
1673
+ alreadyCompiled: WeakSet<object> | Set<object>;
1674
+ knownReferencedNames: Set<string>;
1675
+ imports: Map<string, Map<string, NonLocalImportSpecifier>>;
1676
+ retryErrors: Array<{
1677
+ fn: BabelFn;
1678
+ error: CompilerError;
1679
+ }>;
1680
+ inferredEffectLocations: Set<t.SourceLocation>;
1681
+ constructor({ program, suppressions, opts, filename, code, hasModuleScopeOptOut, }: ProgramContextOptions);
1682
+ isHookName(name: string): boolean;
1683
+ hasReference(name: string): boolean;
1684
+ newUid(name: string): string;
1685
+ addMemoCacheImport(): NonLocalImportSpecifier;
1686
+ addImportSpecifier({ source: module, importSpecifierName: specifier }: ExternalFunction, nameHint?: string): NonLocalImportSpecifier;
1687
+ addNewReference(name: string): void;
1688
+ assertGlobalBinding(name: string, localScope?: Scope): Result<void, CompilerError>;
1689
+ logEvent(event: LoggerEvent): void;
1690
+ }
1655
1691
 
1656
1692
  declare function runBabelPluginReactCompiler(text: string, file: string, language: 'flow' | 'typescript', options: Partial<PluginOptions> | null, includeAst?: boolean): BabelCore.BabelFileResult;
1657
1693
 
1694
+ declare function parseConfigPragmaForTests(pragma: string, defaults: {
1695
+ compilationMode: CompilationMode;
1696
+ }): PluginOptions;
1697
+
1658
1698
  declare function BabelPluginReactCompiler(_babel: typeof BabelCore): BabelCore.PluginObj;
1659
1699
 
1660
1700
  declare global {