Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DevTools] Check in frontend.d.ts for react-devtools-fusebox, include in build output #28970

Merged
merged 3 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ packages/react-devtools-extensions/chrome/build
packages/react-devtools-extensions/firefox/build
packages/react-devtools-extensions/shared/build
packages/react-devtools-extensions/src/ErrorTesterCompiled.js
packages/react-devtools-fusebox/dist
packages/react-devtools-inline/dist
packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/
packages/react-devtools-shared/src/hooks/__tests__/__source__/__untransformed__/
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ packages/react-devtools-extensions/firefox/build
packages/react-devtools-extensions/edge/build
packages/react-devtools-extensions/shared/build
packages/react-devtools-extensions/src/ErrorTesterCompiled.js
packages/react-devtools-fusebox/dist
packages/react-devtools-inline/dist
packages/react-devtools-shared/src/hooks/__tests__/__source__/__compiled__/
packages/react-devtools-shared/src/hooks/__tests__/__source__/__untransformed__/
Expand Down
12 changes: 11 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
'use strict';

const {esNextPaths} = require('./scripts/shared/pathsByLanguageVersion');
const {
esNextPaths,
typescriptPaths,
} = require('./scripts/shared/pathsByLanguageVersion');

module.exports = {
bracketSpacing: false,
Expand All @@ -17,5 +20,12 @@ module.exports = {
trailingComma: 'all',
},
},
{
files: typescriptPaths,
options: {
trailingComma: 'all',
parser: 'typescript',
},
},
],
};
5 changes: 3 additions & 2 deletions packages/react-devtools-fusebox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"license": "MIT",
"files": ["dist"],
"scripts": {
"build:frontend:local": "cross-env NODE_ENV=development webpack --config webpack.config.frontend.js",
"build:frontend": "cross-env NODE_ENV=production webpack --config webpack.config.frontend.js",
"build:frontend:copy-types": "cp src/*.d.ts dist/",
"build:frontend:local": "cross-env NODE_ENV=development webpack --config webpack.config.frontend.js && yarn build:frontend:copy-types",
"build:frontend": "cross-env NODE_ENV=production webpack --config webpack.config.frontend.js && yarn build:frontend:copy-types",
"build": "yarn build:frontend"
},
"devDependencies": {
Expand Down
40 changes: 40 additions & 0 deletions packages/react-devtools-fusebox/src/frontend.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* 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 type MessagePayload =
| null
| string
| number
| boolean
| {[key: string]: MessagePayload}
| MessagePayload[];
export type Message = {event: string; payload?: MessagePayload};

export type WallListener = (message: Message) => void;
export type Wall = {
listen: (fn: WallListener) => Function;
send: (event: string, payload?: MessagePayload) => void;
};

export type Bridge = {
shutdown: () => void;
};
export type Store = Object;
export type BrowserTheme = 'dark' | 'light';

export function createBridge(wall: Wall): Bridge;
export function createStore(bridge: Bridge): Store;

export type InitializationOptions = {
bridge: Bridge;
store: Store;
theme?: BrowserTheme;
};
export function initialize(
node: Element | Document,
options: InitializationOptions,
): void;
3 changes: 3 additions & 0 deletions scripts/shared/pathsByLanguageVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ const esNextPaths = [
// Files that we distribute on npm that should be ES5-only.
const es5Paths = ['packages/*/npm/**/*.js'];

const typescriptPaths = ['packages/**/*.d.ts'];

module.exports = {
esNextPaths,
es5Paths,
typescriptPaths,
};