From 3a5335676f7df4318e8e399f8f69e880db724f78 Mon Sep 17 00:00:00 2001 From: lauren Date: Wed, 23 Apr 2025 21:55:15 -0400 Subject: [PATCH 1/3] [forgive] Polish decorations (#33002) Polishes up decorations. Co-authored-by: Jordan Brown --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/33002). * #33004 * #33003 * __->__ #33002 Co-authored-by: Jordan Brown --- .../src/Inference/InferEffectDependencies.ts | 1 + .../react-forgive/client/src/autodeps.ts | 99 +++++++++++++++++++ .../react-forgive/client/src/extension.ts | 71 +++++-------- .../react-forgive/client/src/mapping.ts | 15 +++ .../react-forgive/server/src/index.ts | 53 +++++----- .../src/requests/autodepsdecorations.ts | 2 +- 6 files changed, 170 insertions(+), 71 deletions(-) create mode 100644 compiler/packages/react-forgive/client/src/autodeps.ts create mode 100644 compiler/packages/react-forgive/client/src/mapping.ts diff --git a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts index 472e4cfae3..a70f49dacd 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts @@ -261,6 +261,7 @@ export function inferEffectDependencies(fn: HIRFunction): void { } else if ( value.args.length >= 2 && value.args.length - 1 === autodepFnLoads.get(callee.identifier.id) && + value.args[0] != null && value.args[0].kind === 'Identifier' ) { const penultimateArg = value.args[value.args.length - 2]; diff --git a/compiler/packages/react-forgive/client/src/autodeps.ts b/compiler/packages/react-forgive/client/src/autodeps.ts new file mode 100644 index 0000000000..62cfc92a47 --- /dev/null +++ b/compiler/packages/react-forgive/client/src/autodeps.ts @@ -0,0 +1,99 @@ +import * as vscode from 'vscode'; +import { + LanguageClient, + RequestType, + type Position, +} from 'vscode-languageclient/node'; +import {positionLiteralToVSCodePosition, positionsToRange} from './mapping'; + +export type AutoDepsDecorationsLSPEvent = { + useEffectCallExpr: [Position, Position]; + decorations: Array<[Position, Position]>; +}; + +export interface AutoDepsDecorationsParams { + position: Position; +} + +export namespace AutoDepsDecorationsRequest { + export const type = new RequestType< + AutoDepsDecorationsParams, + AutoDepsDecorationsLSPEvent | null, + void + >('react/autodeps_decorations'); +} + +const inferredEffectDepDecoration = + vscode.window.createTextEditorDecorationType({ + // TODO: make configurable? + borderColor: new vscode.ThemeColor('diffEditor.move.border'), + borderStyle: 'solid', + borderWidth: '0 0 4px 0', + }); + +let currentlyDecoratedAutoDepFnLoc: vscode.Range | null = null; +export function getCurrentlyDecoratedAutoDepFnLoc(): vscode.Range | null { + return currentlyDecoratedAutoDepFnLoc; +} +export function setCurrentlyDecoratedAutoDepFnLoc(range: vscode.Range): void { + currentlyDecoratedAutoDepFnLoc = range; +} +export function clearCurrentlyDecoratedAutoDepFnLoc(): void { + currentlyDecoratedAutoDepFnLoc = null; +} + +let decorationRequestId = 0; +export type AutoDepsDecorationsOptions = { + shouldUpdateCurrent: boolean; +}; +export function requestAutoDepsDecorations( + client: LanguageClient, + position: vscode.Position, + options: AutoDepsDecorationsOptions, +) { + const id = ++decorationRequestId; + client + .sendRequest(AutoDepsDecorationsRequest.type, {position}) + .then(response => { + if (response !== null) { + const { + decorations, + useEffectCallExpr: [start, end], + } = response; + // Maintain ordering + if (decorationRequestId === id) { + if (options.shouldUpdateCurrent) { + setCurrentlyDecoratedAutoDepFnLoc(positionsToRange(start, end)); + } + drawInferredEffectDepDecorations(decorations); + } + } else { + clearCurrentlyDecoratedAutoDepFnLoc(); + clearDecorations(inferredEffectDepDecoration); + } + }); +} + +export function drawInferredEffectDepDecorations( + decorations: Array<[Position, Position]>, +): void { + const decorationOptions = decorations.map(([start, end]) => { + return { + range: new vscode.Range( + positionLiteralToVSCodePosition(start), + positionLiteralToVSCodePosition(end), + ), + hoverMessage: 'Inferred as an effect dependency', + }; + }); + vscode.window.activeTextEditor?.setDecorations( + inferredEffectDepDecoration, + decorationOptions, + ); +} + +export function clearDecorations( + decorationType: vscode.TextEditorDecorationType, +) { + vscode.window.activeTextEditor?.setDecorations(decorationType, []); +} diff --git a/compiler/packages/react-forgive/client/src/extension.ts b/compiler/packages/react-forgive/client/src/extension.ts index 01da3fa491..74ad541483 100644 --- a/compiler/packages/react-forgive/client/src/extension.ts +++ b/compiler/packages/react-forgive/client/src/extension.ts @@ -5,29 +5,16 @@ import { LanguageClient, LanguageClientOptions, type Position, - RequestType, ServerOptions, TransportKind, } from 'vscode-languageclient/node'; -import {WHITE} from './colors'; +import {positionLiteralToVSCodePosition} from './mapping'; +import { + getCurrentlyDecoratedAutoDepFnLoc, + requestAutoDepsDecorations, +} from './autodeps'; let client: LanguageClient; -const inferredEffectDepDecoration = - vscode.window.createTextEditorDecorationType({ - backgroundColor: WHITE.toAlphaString(0.3), - }); - -type Range = [Position, Position]; -interface AutoDepsDecorationsParams { - position: Position; -} -namespace AutoDepsDecorationsRequest { - export const type = new RequestType< - AutoDepsDecorationsParams, - Array | null, - void - >('react/autodeps_decorations'); -} export function activate(context: vscode.ExtensionContext) { const serverModule = context.asAbsolutePath(path.join('dist', 'server.js')); @@ -71,31 +58,31 @@ export function activate(context: vscode.ExtensionContext) { vscode.languages.registerHoverProvider(documentSelector, { provideHover(_document, position, _token) { - client - .sendRequest(AutoDepsDecorationsRequest.type, {position}) - .then(decorations => { - if (Array.isArray(decorations)) { - const decorationOptions = decorations.map(([start, end]) => { - return { - range: new vscode.Range( - new vscode.Position(start.line, start.character), - new vscode.Position(end.line, end.character), - ), - hoverMessage: 'Inferred as an effect dependency', - }; - }); - vscode.window.activeTextEditor?.setDecorations( - inferredEffectDepDecoration, - decorationOptions, - ); - } else { - clearDecorations(inferredEffectDepDecoration); - } - }); + requestAutoDepsDecorations(client, position, {shouldUpdateCurrent: true}); return null; }, }); + vscode.workspace.onDidChangeTextDocument(async _e => { + const currentlyDecoratedAutoDepFnLoc = getCurrentlyDecoratedAutoDepFnLoc(); + if (currentlyDecoratedAutoDepFnLoc !== null) { + requestAutoDepsDecorations(client, currentlyDecoratedAutoDepFnLoc.start, { + shouldUpdateCurrent: false, + }); + } + }); + + vscode.commands.registerCommand( + 'react.requestAutoDepsDecorations', + (position: Position) => { + requestAutoDepsDecorations( + client, + positionLiteralToVSCodePosition(position), + {shouldUpdateCurrent: true}, + ); + }, + ); + client.registerProposedFeatures(); client.start(); } @@ -106,9 +93,3 @@ export function deactivate(): Thenable | undefined { } return; } - -export function clearDecorations( - decorationType: vscode.TextEditorDecorationType, -) { - vscode.window.activeTextEditor?.setDecorations(decorationType, []); -} diff --git a/compiler/packages/react-forgive/client/src/mapping.ts b/compiler/packages/react-forgive/client/src/mapping.ts new file mode 100644 index 0000000000..0505011711 --- /dev/null +++ b/compiler/packages/react-forgive/client/src/mapping.ts @@ -0,0 +1,15 @@ +import * as vscode from 'vscode'; +import {Position} from 'vscode-languageclient/node'; + +export function positionLiteralToVSCodePosition( + position: Position, +): vscode.Position { + return new vscode.Position(position.line, position.character); +} + +export function positionsToRange(start: Position, end: Position): vscode.Range { + return new vscode.Range( + positionLiteralToVSCodePosition(start), + positionLiteralToVSCodePosition(end), + ); +} diff --git a/compiler/packages/react-forgive/server/src/index.ts b/compiler/packages/react-forgive/server/src/index.ts index edb6d63f02..0b43e9fcd2 100644 --- a/compiler/packages/react-forgive/server/src/index.ts +++ b/compiler/packages/react-forgive/server/src/index.ts @@ -10,6 +10,7 @@ import { CodeAction, CodeActionKind, CodeLens, + Command, createConnection, type InitializeParams, type InitializeResult, @@ -96,6 +97,7 @@ connection.onInitialize((_params: InitializeParams) => { logger: { logEvent(_filename: string | null, event: LoggerEvent) { connection.console.info(`Received event: ${event.kind}`); + connection.console.debug(JSON.stringify(event, null, 2)); if (event.kind === 'CompileSuccess') { compiledFns.add(event); } @@ -191,7 +193,6 @@ connection.onCodeLensResolve(lens => { connection.onCodeAction(params => { connection.console.log('onCodeAction'); - connection.console.log(JSON.stringify(params, null, 2)); const codeActions: Array = []; for (const codeActionEvent of codeActionEvents) { if ( @@ -200,39 +201,41 @@ connection.onCodeAction(params => { codeActionEvent.anchorRange, ) ) { - codeActions.push( - CodeAction.create( - codeActionEvent.title, - { - changes: { - [params.textDocument.uri]: [ - { - newText: codeActionEvent.newText, - range: codeActionEvent.editRange, - }, - ], - }, + const codeAction = CodeAction.create( + codeActionEvent.title, + { + changes: { + [params.textDocument.uri]: [ + { + newText: codeActionEvent.newText, + range: codeActionEvent.editRange, + }, + ], }, - codeActionEvent.kind, - ), + }, + codeActionEvent.kind, ); + // After executing a codeaction, we want to draw autodep decorations again + codeAction.command = Command.create( + 'Request autodeps decorations', + 'react.requestAutoDepsDecorations', + codeActionEvent.anchorRange[0], + ); + codeActions.push(codeAction); } } return codeActions; }); -connection.onCodeActionResolve(codeAction => { - connection.console.log('onCodeActionResolve'); - connection.console.log(JSON.stringify(codeAction, null, 2)); - return codeAction; -}); - +/** + * The client can request the server to compute autodeps decorations based on a currently selected + * position if the selected position is within an autodep eligible function call. + */ connection.onRequest(AutoDepsDecorationsRequest.type, async params => { const position = params.position; - connection.console.debug('Client hovering on: ' + JSON.stringify(position)); - for (const dec of autoDepsDecorations) { - if (isPositionWithinRange(position, dec.useEffectCallExpr)) { - return dec.decorations; + for (const decoration of autoDepsDecorations) { + if (isPositionWithinRange(position, decoration.useEffectCallExpr)) { + return decoration; } } return null; diff --git a/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts b/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts index 6f3a4051fb..1738bbcd8c 100644 --- a/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts +++ b/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts @@ -13,7 +13,7 @@ export interface AutoDepsDecorationsParams { export namespace AutoDepsDecorationsRequest { export const type = new RequestType< AutoDepsDecorationsParams, - Array | null, + AutoDepsDecorationsLSPEvent, void >('react/autodeps_decorations'); } From 8b9629c8106b55965ac6e4f078110b484b358101 Mon Sep 17 00:00:00 2001 From: lauren Date: Wed, 23 Apr 2025 21:55:24 -0400 Subject: [PATCH 2/3] [compiler] Fix copyright script (#33003) Don't try to open directories --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/33003). * #33004 * __->__ #33003 * #33002 --------- Co-authored-by: Jordan Brown --- compiler/scripts/copyright.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/scripts/copyright.js b/compiler/scripts/copyright.js index da3c39fe85..0a5ef2e29a 100644 --- a/compiler/scripts/copyright.js +++ b/compiler/scripts/copyright.js @@ -51,6 +51,9 @@ if (hasErrors) { } function processFile(file) { + if (fs.lstatSync(file).isDirectory()) { + return; + } let source = fs.readFileSync(file, 'utf8'); if (source.indexOf(META_COPYRIGHT_COMMENT_BLOCK) === 0) { From 44d7d0cfa72392c8030b1d06c1a70ded410ce355 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Wed, 23 Apr 2025 21:55:45 -0400 Subject: [PATCH 3/3] [compiler] Add missing copyrights `yarn copyright` --- .../src/Entrypoint/Reanimated.ts | 7 +++++++ .../src/Entrypoint/ValidateNoUntransformedReferences.ts | 7 +++++++ .../src/HIR/AssertValidBlockNesting.ts | 7 +++++++ .../src/HIR/BuildReactiveScopeTerminalsHIR.ts | 7 +++++++ .../src/HIR/CollectHoistablePropertyLoads.ts | 7 +++++++ .../src/HIR/CollectOptionalChainDependencies.ts | 7 +++++++ .../src/HIR/MergeOverlappingReactiveScopesHIR.ts | 7 +++++++ .../src/HIR/PropagateScopeDependenciesHIR.ts | 7 +++++++ .../src/HIR/PruneUnusedLabelsHIR.ts | 7 +++++++ .../src/ReactiveScopes/StabilizeBlockIds.ts | 7 +++++++ .../babel-plugin-react-compiler/src/Transform/index.ts | 1 + .../src/Validation/ValidateNoCapitalizedCalls.ts | 1 + .../packages/babel-plugin-react-compiler/tsup.config.ts | 7 +++++++ .../packages/eslint-plugin-react-compiler/tsup.config.ts | 7 +++++++ compiler/packages/make-read-only-util/tsup.config.ts | 7 +++++++ compiler/packages/react-compiler-healthcheck/src/config.ts | 7 +++++++ .../packages/react-compiler-healthcheck/tsup.config.ts | 7 +++++++ compiler/packages/react-compiler-runtime/tsup.config.ts | 7 +++++++ compiler/packages/react-forgive/client/src/autodeps.ts | 7 +++++++ compiler/packages/react-forgive/client/src/colors.ts | 7 +++++++ compiler/packages/react-forgive/client/src/extension.ts | 7 +++++++ compiler/packages/react-forgive/client/src/mapping.ts | 7 +++++++ .../packages/react-forgive/server/src/compiler/compat.ts | 7 +++++++ .../server/src/requests/autodepsdecorations.ts | 7 +++++++ compiler/packages/react-forgive/server/src/utils/range.ts | 7 +++++++ compiler/packages/react-mcp-server/src/types/algolia.ts | 7 +++++++ compiler/packages/react-mcp-server/tsup.config.ts | 7 +++++++ compiler/scripts/release/prompt-for-otp.js | 6 ++++++ compiler/scripts/release/publish.js | 6 ++++++ compiler/scripts/release/shared/build-packages.js | 7 +++++++ compiler/scripts/release/shared/packages.js | 7 +++++++ compiler/scripts/release/shared/utils.js | 7 +++++++ 32 files changed, 210 insertions(+) diff --git a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Reanimated.ts b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Reanimated.ts index e946d7aab8..4f8a3e709d 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Reanimated.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Reanimated.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import type * as BabelCore from '@babel/core'; import {hasOwnProperty} from '../Utils/utils'; import {PluginOptions} from './Options'; diff --git a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/ValidateNoUntransformedReferences.ts b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/ValidateNoUntransformedReferences.ts index a221b0485c..5f6c6986e0 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/ValidateNoUntransformedReferences.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/ValidateNoUntransformedReferences.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import {NodePath} from '@babel/core'; import * as t from '@babel/types'; diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/AssertValidBlockNesting.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/AssertValidBlockNesting.ts index cd2024e1e1..adfb051058 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/HIR/AssertValidBlockNesting.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/AssertValidBlockNesting.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import {CompilerError} from '..'; import { BlockId, diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/BuildReactiveScopeTerminalsHIR.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/BuildReactiveScopeTerminalsHIR.ts index 7c1fb54ea8..6f69af4b4f 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/HIR/BuildReactiveScopeTerminalsHIR.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/BuildReactiveScopeTerminalsHIR.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import {CompilerError} from '../CompilerError'; import {getScopes, recursivelyTraverseItems} from './AssertValidBlockNesting'; import {Environment} from './Environment'; diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/CollectHoistablePropertyLoads.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/CollectHoistablePropertyLoads.ts index cb6854d1b3..e29ef51ce0 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/HIR/CollectHoistablePropertyLoads.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/CollectHoistablePropertyLoads.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import {CompilerError} from '../CompilerError'; import {inRange} from '../ReactiveScopes/InferReactiveScopeVariables'; import {printDependency} from '../ReactiveScopes/PrintReactiveFunction'; diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/CollectOptionalChainDependencies.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/CollectOptionalChainDependencies.ts index 02a28b9f35..cb787d04d0 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/HIR/CollectOptionalChainDependencies.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/CollectOptionalChainDependencies.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import {CompilerError} from '..'; import {assertNonNull} from './CollectHoistablePropertyLoads'; import { diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/MergeOverlappingReactiveScopesHIR.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/MergeOverlappingReactiveScopesHIR.ts index 5b286e917d..96d20ea644 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/HIR/MergeOverlappingReactiveScopesHIR.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/MergeOverlappingReactiveScopesHIR.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import { HIRFunction, InstructionId, diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/PropagateScopeDependenciesHIR.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/PropagateScopeDependenciesHIR.ts index e12d10b406..934fd98f73 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/HIR/PropagateScopeDependenciesHIR.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/PropagateScopeDependenciesHIR.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import { ScopeId, HIRFunction, diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/PruneUnusedLabelsHIR.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/PruneUnusedLabelsHIR.ts index bf10e9f1f3..f0c488c3e1 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/HIR/PruneUnusedLabelsHIR.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/PruneUnusedLabelsHIR.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import {CompilerError} from '..'; import {BlockId, GotoVariant, HIRFunction} from './HIR'; diff --git a/compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/StabilizeBlockIds.ts b/compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/StabilizeBlockIds.ts index 26d83f9906..9ad1815474 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/StabilizeBlockIds.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/StabilizeBlockIds.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import { BlockId, ReactiveFunction, diff --git a/compiler/packages/babel-plugin-react-compiler/src/Transform/index.ts b/compiler/packages/babel-plugin-react-compiler/src/Transform/index.ts index 8665ead0b1..4f142104f2 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/Transform/index.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/Transform/index.ts @@ -4,4 +4,5 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ + export {transformFire} from './TransformFire'; diff --git a/compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoCapitalizedCalls.ts b/compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoCapitalizedCalls.ts index 4ba70b64a8..8989cb1ac2 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoCapitalizedCalls.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoCapitalizedCalls.ts @@ -4,6 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ + import {CompilerError, EnvironmentConfig, ErrorSeverity} from '..'; import {HIRFunction, IdentifierId} from '../HIR'; import {DEFAULT_GLOBALS} from '../HIR/Globals'; diff --git a/compiler/packages/babel-plugin-react-compiler/tsup.config.ts b/compiler/packages/babel-plugin-react-compiler/tsup.config.ts index 12c04ec8a2..dde9525256 100644 --- a/compiler/packages/babel-plugin-react-compiler/tsup.config.ts +++ b/compiler/packages/babel-plugin-react-compiler/tsup.config.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import {defineConfig} from 'tsup'; export default defineConfig({ diff --git a/compiler/packages/eslint-plugin-react-compiler/tsup.config.ts b/compiler/packages/eslint-plugin-react-compiler/tsup.config.ts index ac13d33bba..3e3b1b1313 100644 --- a/compiler/packages/eslint-plugin-react-compiler/tsup.config.ts +++ b/compiler/packages/eslint-plugin-react-compiler/tsup.config.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import {defineConfig} from 'tsup'; export default defineConfig({ diff --git a/compiler/packages/make-read-only-util/tsup.config.ts b/compiler/packages/make-read-only-util/tsup.config.ts index cb65a61aaa..ffef80abba 100644 --- a/compiler/packages/make-read-only-util/tsup.config.ts +++ b/compiler/packages/make-read-only-util/tsup.config.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import {defineConfig} from 'tsup'; export default defineConfig({ diff --git a/compiler/packages/react-compiler-healthcheck/src/config.ts b/compiler/packages/react-compiler-healthcheck/src/config.ts index 9655d2654b..f279bc5d22 100644 --- a/compiler/packages/react-compiler-healthcheck/src/config.ts +++ b/compiler/packages/react-compiler-healthcheck/src/config.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + export const config = { knownIncompatibleLibraries: [ 'mobx-react', diff --git a/compiler/packages/react-compiler-healthcheck/tsup.config.ts b/compiler/packages/react-compiler-healthcheck/tsup.config.ts index 9fe1e493db..7addc79bf9 100644 --- a/compiler/packages/react-compiler-healthcheck/tsup.config.ts +++ b/compiler/packages/react-compiler-healthcheck/tsup.config.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import {defineConfig} from 'tsup'; export default defineConfig({ diff --git a/compiler/packages/react-compiler-runtime/tsup.config.ts b/compiler/packages/react-compiler-runtime/tsup.config.ts index ebc8df6f14..30a7f9da96 100644 --- a/compiler/packages/react-compiler-runtime/tsup.config.ts +++ b/compiler/packages/react-compiler-runtime/tsup.config.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import {defineConfig} from 'tsup'; export default defineConfig({ diff --git a/compiler/packages/react-forgive/client/src/autodeps.ts b/compiler/packages/react-forgive/client/src/autodeps.ts index 62cfc92a47..ed41b34dcb 100644 --- a/compiler/packages/react-forgive/client/src/autodeps.ts +++ b/compiler/packages/react-forgive/client/src/autodeps.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import * as vscode from 'vscode'; import { LanguageClient, diff --git a/compiler/packages/react-forgive/client/src/colors.ts b/compiler/packages/react-forgive/client/src/colors.ts index 5d98b07808..8989aa1c62 100644 --- a/compiler/packages/react-forgive/client/src/colors.ts +++ b/compiler/packages/react-forgive/client/src/colors.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + type RGB = [number, number, number]; const int = Math.floor; diff --git a/compiler/packages/react-forgive/client/src/extension.ts b/compiler/packages/react-forgive/client/src/extension.ts index 74ad541483..e9938c388a 100644 --- a/compiler/packages/react-forgive/client/src/extension.ts +++ b/compiler/packages/react-forgive/client/src/extension.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import * as path from 'path'; import * as vscode from 'vscode'; diff --git a/compiler/packages/react-forgive/client/src/mapping.ts b/compiler/packages/react-forgive/client/src/mapping.ts index 0505011711..3ec01ef8f6 100644 --- a/compiler/packages/react-forgive/client/src/mapping.ts +++ b/compiler/packages/react-forgive/client/src/mapping.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import * as vscode from 'vscode'; import {Position} from 'vscode-languageclient/node'; diff --git a/compiler/packages/react-forgive/server/src/compiler/compat.ts b/compiler/packages/react-forgive/server/src/compiler/compat.ts index 8b13f1df88..10271cbdcd 100644 --- a/compiler/packages/react-forgive/server/src/compiler/compat.ts +++ b/compiler/packages/react-forgive/server/src/compiler/compat.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import {SourceLocation} from 'babel-plugin-react-compiler/src'; import {type Range} from 'vscode-languageserver'; diff --git a/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts b/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts index 1738bbcd8c..77a568662e 100644 --- a/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts +++ b/compiler/packages/react-forgive/server/src/requests/autodepsdecorations.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import {type AutoDepsDecorationsEvent} from 'babel-plugin-react-compiler/src/Entrypoint'; import {type Position} from 'vscode-languageserver-textdocument'; import {RequestType} from 'vscode-languageserver/node'; diff --git a/compiler/packages/react-forgive/server/src/utils/range.ts b/compiler/packages/react-forgive/server/src/utils/range.ts index 8a16f1bc09..5c164667c4 100644 --- a/compiler/packages/react-forgive/server/src/utils/range.ts +++ b/compiler/packages/react-forgive/server/src/utils/range.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import * as t from '@babel/types'; import {type Position} from 'vscode-languageserver/node'; diff --git a/compiler/packages/react-mcp-server/src/types/algolia.ts b/compiler/packages/react-mcp-server/src/types/algolia.ts index 68914076a3..1921dd3f71 100644 --- a/compiler/packages/react-mcp-server/src/types/algolia.ts +++ b/compiler/packages/react-mcp-server/src/types/algolia.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + // https://github.com/algolia/docsearch/blob/15ebcba606b281aa0dddc4ccb8feb19d396bf79e/packages/docsearch-react/src/types/DocSearchHit.ts type ContentType = | 'content' diff --git a/compiler/packages/react-mcp-server/tsup.config.ts b/compiler/packages/react-mcp-server/tsup.config.ts index eefc6ee0ce..820410e20f 100644 --- a/compiler/packages/react-mcp-server/tsup.config.ts +++ b/compiler/packages/react-mcp-server/tsup.config.ts @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import {defineConfig} from 'tsup'; export default defineConfig({ diff --git a/compiler/scripts/release/prompt-for-otp.js b/compiler/scripts/release/prompt-for-otp.js index e69e4f1604..3cb1e419c7 100644 --- a/compiler/scripts/release/prompt-for-otp.js +++ b/compiler/scripts/release/prompt-for-otp.js @@ -1,4 +1,10 @@ #!/usr/bin/env node +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ const prompt = require('prompt-promise'); diff --git a/compiler/scripts/release/publish.js b/compiler/scripts/release/publish.js index d367e331e3..99c4738425 100755 --- a/compiler/scripts/release/publish.js +++ b/compiler/scripts/release/publish.js @@ -1,4 +1,10 @@ #!/usr/bin/env node +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ 'use strict'; diff --git a/compiler/scripts/release/shared/build-packages.js b/compiler/scripts/release/shared/build-packages.js index 21c88e3aae..0a5ac1f5c2 100644 --- a/compiler/scripts/release/shared/build-packages.js +++ b/compiler/scripts/release/shared/build-packages.js @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + const ora = require('ora'); const {execHelper} = require('./utils'); diff --git a/compiler/scripts/release/shared/packages.js b/compiler/scripts/release/shared/packages.js index 533041d119..39970bdde6 100644 --- a/compiler/scripts/release/shared/packages.js +++ b/compiler/scripts/release/shared/packages.js @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + const PUBLISHABLE_PACKAGES = [ 'babel-plugin-react-compiler', 'eslint-plugin-react-compiler', diff --git a/compiler/scripts/release/shared/utils.js b/compiler/scripts/release/shared/utils.js index 8406e56330..bda2d28c03 100644 --- a/compiler/scripts/release/shared/utils.js +++ b/compiler/scripts/release/shared/utils.js @@ -1,3 +1,10 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + const cp = require('child_process'); const util = require('util');