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

Remove the window.AppBoot function #98543

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
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
4 changes: 1 addition & 3 deletions client/boot/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ import { bootApp } from './common';

import 'calypso/assets/stylesheets/style.scss';

window.AppBoot = () => {
bootApp( 'Calypso' );
};
bootApp( 'Calypso' );
3 changes: 0 additions & 3 deletions client/document/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,6 @@ class Document extends Component {
{ chunkFiles.js.map( ( chunk ) => (
<script key={ chunk } src={ chunk } />
) ) }
<script nonce={ inlineScriptNonce } type="text/javascript">
window.AppBoot();
</script>
<script
nonce={ inlineScriptNonce }
dangerouslySetInnerHTML={ {
Expand Down
10 changes: 4 additions & 6 deletions client/landing/login/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import 'calypso/assets/stylesheets/style.scss';
// goofy import for environment badge, which is SSR'd
import 'calypso/components/environment-badge/style.scss';

const boot = ( currentUser ) => {
async function main() {
const currentUser = await initializeCurrentUser();
const store = createStore();
setStore( store, getStateFromCache( currentUser?.ID ) );
configureReduxStore( currentUser, store );
Expand All @@ -36,9 +37,6 @@ const boot = ( currentUser ) => {

initLoginSection( ( route, ...handlers ) => page( route, ...handlers, render ) );
page.start();
};
}

window.AppBoot = async () => {
const user = await initializeCurrentUser();
boot( user );
};
main();
6 changes: 4 additions & 2 deletions client/landing/stepper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const initializeHotJar = ( flowName: string ) => {
}
};

window.AppBoot = async () => {
async function main() {
const { pathname, search } = window.location;

// Before proceeding we redirect the user if necessary.
Expand Down Expand Up @@ -184,4 +184,6 @@ window.AppBoot = async () => {
</Provider>
</CalypsoI18nProvider>
);
};
}

main();
10 changes: 4 additions & 6 deletions client/landing/subscriptions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ const setupReduxStore = ( user: CurrentUser ) => {
return reduxStore;
};

declare const window: Window & {
AppBoot?: () => void;
};

window.AppBoot = async () => {
async function main() {
const user = ( await initializeCurrentUser() ) as unknown as CurrentUser;
const { queryClient } = await createQueryClient( user.ID );
const reduxStore = setupReduxStore( user );
Expand Down Expand Up @@ -86,4 +82,6 @@ window.AppBoot = async () => {
</CalypsoI18nProvider>,
document.getElementById( 'wpcom' )
);
};
}

main();
1 change: 0 additions & 1 deletion client/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ Output is built on the server side by the following `modules` (corresponding to
- render content by passing that to `404.jsx`, `500.jsx`, `browsehappy.jsx`, `support-user.jsx`, `index.jsx` or `desktop.jsx` template files, respectively.
- `index.jsx`
- builds an HTML skeleton, including `<script>` tags to load relevant JavaScript files (minified unless in debug mode or in the `development` environment) that contain client-side (React) rendering code
- lastly, it runs `window.AppBoot()`, which is defined in `client/boot`.
5 changes: 1 addition & 4 deletions client/server/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,7 @@ function setUpCSP( req, res, next ) {
// and calculating SHA256 hash on it, encoded in base64, example:
// `sha256-${ base64( sha256( 'window.AppBoot();' ) ) }` === sha256-3yiQswl88knA3EhjrG5tj5gmV6EUdLYFvn2dygc0xUQ
// you can also just run it in Chrome, chrome will give you the hash of the violating scripts
const inlineScripts = [
'sha256-3yiQswl88knA3EhjrG5tj5gmV6EUdLYFvn2dygc0xUQ=',
'sha256-ZKTuGaoyrLu2lwYpcyzib+xE4/2mCN8PKv31uXS3Eg4=',
];
const inlineScripts = [ 'sha256-ZKTuGaoyrLu2lwYpcyzib+xE4/2mCN8PKv31uXS3Eg4=' ];

req.context.inlineScriptNonce = crypto.randomBytes( 48 ).toString( 'hex' );

Expand Down
1 change: 0 additions & 1 deletion client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ export type __TodoAny__ = any; /* eslint-disable-line @typescript-eslint/no-expl
// Properties added to the `window` object:
declare global {
interface Window {
AppBoot: () => void;
COMMIT_SHA: string; // Added by an inline script in <head> via SSR context + webpack.
app?: {
isDebug?: boolean;
Expand Down
Loading