babel-plugin-react-compiler 0.0.0-experimental-3452ff1-20250321 → 0.0.0-experimental-3cea1f4-20250324

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 +39 -18
  2. package/dist/index.js +1376 -882
  3. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -72,6 +72,7 @@ type FunctionType = {
72
72
  kind: 'Function';
73
73
  shapeId: string | null;
74
74
  return: Type;
75
+ isConstructor: boolean;
75
76
  };
76
77
  type ObjectType = {
77
78
  kind: 'Object';
@@ -541,14 +542,15 @@ declare class Environment {
541
542
  config: EnvironmentConfig;
542
543
  fnType: ReactFunctionType;
543
544
  compilerMode: CompilerMode;
544
- useMemoCacheIdentifier: string;
545
- hasLoweredContextAccess: boolean;
545
+ programContext: ProgramContext;
546
546
  hasFireRewrite: boolean;
547
- 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
+ constructor(scope: Scope, fnType: ReactFunctionType, compilerMode: CompilerMode, config: EnvironmentConfig, contextIdentifiers: Set<t.Identifier>, logger: Logger | null, filename: string | null, code: string | null, programContext: ProgramContext);
548
549
  get isInferredMemoEnabled(): boolean;
549
550
  get nextIdentifierId(): IdentifierId;
550
551
  get nextBlockId(): BlockId;
551
552
  get nextScopeId(): ScopeId;
553
+ get scope(): Scope;
552
554
  logErrors(errors: Result<void, CompilerError>): void;
553
555
  isContextIdentifier(node: t.Identifier): boolean;
554
556
  isHoistedIdentifier(node: t.Identifier): boolean;
@@ -1073,6 +1075,12 @@ type CallExpression = {
1073
1075
  loc: SourceLocation;
1074
1076
  typeArguments?: Array<t.FlowType>;
1075
1077
  };
1078
+ type NewExpression = {
1079
+ kind: 'NewExpression';
1080
+ callee: Place;
1081
+ args: Array<Place | SpreadPattern>;
1082
+ loc: SourceLocation;
1083
+ };
1076
1084
  type LoadLocal = {
1077
1085
  kind: 'LoadLocal';
1078
1086
  place: Place;
@@ -1113,12 +1121,7 @@ type InstructionValue = LoadLocal | LoadContext | {
1113
1121
  left: Place;
1114
1122
  right: Place;
1115
1123
  loc: SourceLocation;
1116
- } | {
1117
- kind: 'NewExpression';
1118
- callee: Place;
1119
- args: Array<Place | SpreadPattern>;
1120
- loc: SourceLocation;
1121
- } | CallExpression | MethodCall | {
1124
+ } | NewExpression | CallExpression | MethodCall | {
1122
1125
  kind: 'UnaryExpression';
1123
1126
  operator: Exclude<t.UnaryExpression['operator'], 'throw' | 'delete'>;
1124
1127
  value: Place;
@@ -1302,6 +1305,12 @@ type MutableRange = {
1302
1305
  start: InstructionId;
1303
1306
  end: InstructionId;
1304
1307
  };
1308
+ type NonLocalImportSpecifier = {
1309
+ kind: 'ImportSpecifier';
1310
+ name: string;
1311
+ module: string;
1312
+ imported: string;
1313
+ };
1305
1314
  type NonLocalBinding = {
1306
1315
  kind: 'ImportDefault';
1307
1316
  name: string;
@@ -1310,12 +1319,7 @@ type NonLocalBinding = {
1310
1319
  kind: 'ImportNamespace';
1311
1320
  name: string;
1312
1321
  module: string;
1313
- } | {
1314
- kind: 'ImportSpecifier';
1315
- name: string;
1316
- module: string;
1317
- imported: string;
1318
- } | {
1322
+ } | NonLocalImportSpecifier | {
1319
1323
  kind: 'ModuleLocal';
1320
1324
  name: string;
1321
1325
  } | {
@@ -1367,6 +1371,7 @@ declare enum Effect {
1367
1371
  Freeze = "freeze",
1368
1372
  Read = "read",
1369
1373
  Capture = "capture",
1374
+ ConditionallyMutateIterator = "mutate-iterator?",
1370
1375
  ConditionallyMutate = "mutate?",
1371
1376
  Mutate = "mutate",
1372
1377
  Store = "store"
@@ -1507,7 +1512,7 @@ type CodegenFunction = {
1507
1512
  fn: CodegenFunction;
1508
1513
  type: ReactFunctionType | null;
1509
1514
  }>;
1510
- hasLoweredContextAccess: boolean;
1515
+ hasInferredEffect: boolean;
1511
1516
  hasFireRewrite: boolean;
1512
1517
  };
1513
1518
 
@@ -1530,7 +1535,7 @@ type CompilerPipelineValue = {
1530
1535
  name: string;
1531
1536
  value: string;
1532
1537
  };
1533
- 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;
1538
+ 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;
1534
1539
 
1535
1540
  declare const PanicThresholdOptionsSchema: z.ZodEnum<["all_errors", "critical_errors", "none"]>;
1536
1541
  type PanicThresholdOptions = z.infer<typeof PanicThresholdOptionsSchema>;
@@ -1603,6 +1608,22 @@ type Logger = {
1603
1608
  };
1604
1609
  declare function parsePluginOptions(obj: unknown): PluginOptions;
1605
1610
 
1611
+ declare class ProgramContext {
1612
+ scope: Scope;
1613
+ reactRuntimeModule: string;
1614
+ hookPattern: string | null;
1615
+ knownReferencedNames: Set<string>;
1616
+ imports: Map<string, Map<string, NonLocalImportSpecifier>>;
1617
+ constructor(program: NodePath$1<t.Program>, reactRuntimeModule: CompilerReactTarget, hookPattern: string | null);
1618
+ isHookName(name: string): boolean;
1619
+ hasReference(name: string): boolean;
1620
+ newUid(name: string): string;
1621
+ addMemoCacheImport(): NonLocalImportSpecifier;
1622
+ addImportSpecifier({ source: module, importSpecifierName: specifier }: ExternalFunction, nameHint?: string): NonLocalImportSpecifier;
1623
+ addNewReference(name: string): void;
1624
+ assertGlobalBinding(name: string, localScope?: Scope): Result<void, CompilerError>;
1625
+ }
1626
+
1606
1627
  type CompilerPass = {
1607
1628
  opts: PluginOptions;
1608
1629
  filename: string | null;
@@ -1630,4 +1651,4 @@ declare global {
1630
1651
  let __DEV__: boolean | null | undefined;
1631
1652
  }
1632
1653
 
1633
- 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 };
1654
+ 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, printHIR, printReactiveFunction, runBabelPluginReactCompiler, validateEnvironmentConfig };