babel-plugin-react-compiler 19.0.0-beta-aeaed83-20250323 → 19.0.0-beta-e993439-20250405

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 +43 -15
  2. package/dist/index.js +844 -700
  3. package/package.json +3 -3
package/dist/index.d.ts CHANGED
@@ -542,14 +542,16 @@ declare class Environment {
542
542
  config: EnvironmentConfig;
543
543
  fnType: ReactFunctionType;
544
544
  compilerMode: CompilerMode;
545
- useMemoCacheIdentifier: string;
546
- hasLoweredContextAccess: boolean;
545
+ programContext: ProgramContext;
547
546
  hasFireRewrite: boolean;
548
- constructor(scope: Scope, fnType: ReactFunctionType, compilerMode: CompilerMode, config: EnvironmentConfig, contextIdentifiers: Set<t.Identifier>, logger: Logger | null, filename: string | null, code: string | null, useMemoCacheIdentifier: string);
547
+ hasInferredEffect: boolean;
548
+ inferredEffectLocations: Set<SourceLocation>;
549
+ constructor(scope: Scope, fnType: ReactFunctionType, compilerMode: CompilerMode, config: EnvironmentConfig, contextIdentifiers: Set<t.Identifier>, logger: Logger | null, filename: string | null, code: string | null, programContext: ProgramContext);
549
550
  get isInferredMemoEnabled(): boolean;
550
551
  get nextIdentifierId(): IdentifierId;
551
552
  get nextBlockId(): BlockId;
552
553
  get nextScopeId(): ScopeId;
554
+ get scope(): Scope;
553
555
  logErrors(errors: Result<void, CompilerError>): void;
554
556
  isContextIdentifier(node: t.Identifier): boolean;
555
557
  isHoistedIdentifier(node: t.Identifier): boolean;
@@ -1125,13 +1127,18 @@ type InstructionValue = LoadLocal | LoadContext | {
1125
1127
  operator: Exclude<t.UnaryExpression['operator'], 'throw' | 'delete'>;
1126
1128
  value: Place;
1127
1129
  loc: SourceLocation;
1128
- } | {
1130
+ } | ({
1129
1131
  kind: 'TypeCastExpression';
1130
1132
  value: Place;
1131
- typeAnnotation: t.FlowType | t.TSType;
1132
1133
  type: Type;
1133
1134
  loc: SourceLocation;
1134
- } | JsxExpression | {
1135
+ } & ({
1136
+ typeAnnotation: t.FlowType;
1137
+ typeAnnotationKind: 'cast';
1138
+ } | {
1139
+ typeAnnotation: t.TSType;
1140
+ typeAnnotationKind: 'as' | 'satisfies';
1141
+ })) | JsxExpression | {
1135
1142
  kind: 'ObjectExpression';
1136
1143
  properties: Array<ObjectProperty | SpreadPattern>;
1137
1144
  loc: SourceLocation;
@@ -1304,6 +1311,12 @@ type MutableRange = {
1304
1311
  start: InstructionId;
1305
1312
  end: InstructionId;
1306
1313
  };
1314
+ type NonLocalImportSpecifier = {
1315
+ kind: 'ImportSpecifier';
1316
+ name: string;
1317
+ module: string;
1318
+ imported: string;
1319
+ };
1307
1320
  type NonLocalBinding = {
1308
1321
  kind: 'ImportDefault';
1309
1322
  name: string;
@@ -1312,12 +1325,7 @@ type NonLocalBinding = {
1312
1325
  kind: 'ImportNamespace';
1313
1326
  name: string;
1314
1327
  module: string;
1315
- } | {
1316
- kind: 'ImportSpecifier';
1317
- name: string;
1318
- module: string;
1319
- imported: string;
1320
- } | {
1328
+ } | NonLocalImportSpecifier | {
1321
1329
  kind: 'ModuleLocal';
1322
1330
  name: string;
1323
1331
  } | {
@@ -1430,6 +1438,7 @@ type InstructionId = number & {
1430
1438
  type Options = {
1431
1439
  indent: number;
1432
1440
  };
1441
+ declare function printFunctionWithOutlined(fn: HIRFunction): string;
1433
1442
  declare function printHIR(ir: HIR, options?: Options | null): string;
1434
1443
 
1435
1444
  declare enum ErrorSeverity {
@@ -1510,10 +1519,12 @@ type CodegenFunction = {
1510
1519
  fn: CodegenFunction;
1511
1520
  type: ReactFunctionType | null;
1512
1521
  }>;
1513
- hasLoweredContextAccess: boolean;
1522
+ hasInferredEffect: boolean;
1523
+ inferredEffectLocations: Set<SourceLocation>;
1514
1524
  hasFireRewrite: boolean;
1515
1525
  };
1516
1526
 
1527
+ declare function printReactiveFunctionWithOutlined(fn: ReactiveFunction): string;
1517
1528
  declare function printReactiveFunction(fn: ReactiveFunction): string;
1518
1529
 
1519
1530
  type CompilerPipelineValue = {
@@ -1533,7 +1544,7 @@ type CompilerPipelineValue = {
1533
1544
  name: string;
1534
1545
  value: string;
1535
1546
  };
1536
- declare function compileFn(func: NodePath<t.FunctionDeclaration | t.ArrowFunctionExpression | t.FunctionExpression>, config: EnvironmentConfig, fnType: ReactFunctionType, mode: CompilerMode, useMemoCacheIdentifier: string, logger: Logger | null, filename: string | null, code: string | null): CodegenFunction;
1547
+ declare function compileFn(func: NodePath<t.FunctionDeclaration | t.ArrowFunctionExpression | t.FunctionExpression>, config: EnvironmentConfig, fnType: ReactFunctionType, mode: CompilerMode, programContext: ProgramContext, logger: Logger | null, filename: string | null, code: string | null): CodegenFunction;
1537
1548
 
1538
1549
  declare const PanicThresholdOptionsSchema: z.ZodEnum<["all_errors", "critical_errors", "none"]>;
1539
1550
  type PanicThresholdOptions = z.infer<typeof PanicThresholdOptionsSchema>;
@@ -1606,6 +1617,22 @@ type Logger = {
1606
1617
  };
1607
1618
  declare function parsePluginOptions(obj: unknown): PluginOptions;
1608
1619
 
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
+
1609
1636
  type CompilerPass = {
1610
1637
  opts: PluginOptions;
1611
1638
  filename: string | null;
@@ -1622,6 +1649,7 @@ type CompileProgramResult = {
1622
1649
  fn: BabelFn;
1623
1650
  error: CompilerError;
1624
1651
  }>;
1652
+ inferredEffectLocations: Set<t.SourceLocation>;
1625
1653
  };
1626
1654
  declare function compileProgram(program: NodePath$1<t.Program>, pass: CompilerPass): CompileProgramResult | null;
1627
1655
 
@@ -1633,4 +1661,4 @@ declare global {
1633
1661
  let __DEV__: boolean | null | undefined;
1634
1662
  }
1635
1663
 
1636
- export { CompilerError, CompilerErrorDetail, type CompilerErrorDetailOptions, type CompilerPipelineValue, CompilerSuggestionOperation, Effect, type EnvironmentConfig, ErrorSeverity, type ExternalFunction, type Hook, type Logger, type LoggerEvent, OPT_IN_DIRECTIVES, OPT_OUT_DIRECTIVES, type PluginOptions, type SourceLocation, ValueKind, compileFn as compile, compileProgram, BabelPluginReactCompiler as default, findDirectiveDisablingMemoization, findDirectiveEnablingMemoization, parseConfigPragmaForTests, parsePluginOptions, printHIR, printReactiveFunction, runBabelPluginReactCompiler, validateEnvironmentConfig };
1664
+ export { CompilerError, CompilerErrorDetail, type CompilerErrorDetailOptions, type CompilerPipelineValue, CompilerSuggestionOperation, Effect, type EnvironmentConfig, ErrorSeverity, type ExternalFunction, type Hook, type Logger, type LoggerEvent, OPT_IN_DIRECTIVES, OPT_OUT_DIRECTIVES, type PluginOptions, ProgramContext, type SourceLocation, ValueKind, compileFn as compile, compileProgram, BabelPluginReactCompiler as default, findDirectiveDisablingMemoization, findDirectiveEnablingMemoization, parseConfigPragmaForTests, parsePluginOptions, printFunctionWithOutlined, printHIR, printReactiveFunction, printReactiveFunctionWithOutlined, runBabelPluginReactCompiler, validateEnvironmentConfig };