123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- import {exportedGlobals} from 'sentry/bootstrap/exportGlobals';
- import {OnSentryInitConfiguration, SentryInitRenderReactComponent} from 'sentry/types';
- import {renderDom} from './renderDom';
- import {renderOnDomReady} from './renderOnDomReady';
- const COMPONENT_MAP = {
- [SentryInitRenderReactComponent.INDICATORS]: () =>
- import( 'sentry/components/indicators'),
- [SentryInitRenderReactComponent.SYSTEM_ALERTS]: () =>
- import( 'sentry/views/app/systemAlerts'),
- [SentryInitRenderReactComponent.SETUP_WIZARD]: () =>
- import( 'sentry/views/setupWizard'),
- [SentryInitRenderReactComponent.U2F_SIGN]: () =>
- import( 'sentry/components/u2f/u2fsign'),
- [SentryInitRenderReactComponent.SU_STAFF_ACCESS_FORM]: () =>
- import(
- 'sentry/components/superuserStaffAccessForm'
- ),
- };
- async function processItem(initConfig: OnSentryInitConfiguration) {
-
- if (initConfig.name === 'passwordStrength') {
- const {input, element} = initConfig;
- if (!input || !element) {
- return;
- }
- const passwordStrength = await import(
- 'sentry/components/passwordStrength'
- );
- passwordStrength.attachTo({
- input: document.querySelector(input),
- element: document.querySelector(element),
- });
- return;
- }
-
- if (initConfig.name === 'renderReact') {
- if (!COMPONENT_MAP.hasOwnProperty(initConfig.component)) {
- return;
- }
- const {default: Component} = await COMPONENT_MAP[initConfig.component]();
- renderOnDomReady(() =>
-
- renderDom(Component as any, initConfig.container, initConfig.props)
- );
- }
-
- if (initConfig.name === 'onReady' && typeof initConfig.onReady === 'function') {
- initConfig.onReady(exportedGlobals);
- }
- }
- export async function processInitQueue() {
-
-
-
-
-
- if (
- typeof window.__onSentryInit !== 'undefined' &&
- !Array.isArray(window.__onSentryInit)
- ) {
- return;
- }
- const queued = window.__onSentryInit;
-
-
-
-
- window.__onSentryInit = {
- push: processItem,
- };
- if (Array.isArray(queued)) {
-
-
- await Promise.all(queued.map(processItem));
- }
- }
|