Skip to content

Commit 0f6b4ce

Browse files
chore: dedupe license headers and narrow tool dependency type
1 parent 983d485 commit 0f6b4ce

1,935 files changed

Lines changed: 59358 additions & 47 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export type { AnalyticsServiceSetup, AnalyticsServiceStart, AnalyticsServicePreboot, } from './src/contracts';
2+
export type { AnalyticsClient, AnalyticsClientInitContext, ShipperClassConstructor, RegisterShipperOpts, OptInConfig, OptInConfigPerType, ShipperName, ContextProviderOpts, ContextProviderName, EventTypeOpts, Event, EventContext, EventType, TelemetryCounter, TelemetryCounterType, RootSchema, SchemaObject, SchemaArray, SchemaChildValue, SchemaMeta, SchemaValue, SchemaMetaOptional, PossibleSchemaTypes, AllowedSchemaBooleanTypes, AllowedSchemaNumberTypes, AllowedSchemaStringTypes, AllowedSchemaTypes, IShipper, } from '@elastic/ebt/client';
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { AnalyticsClient } from '@elastic/ebt/client';
2+
/**
3+
* Exposes the public APIs of the AnalyticsClient during the preboot phase
4+
* {@link AnalyticsClient}
5+
* @public
6+
*/
7+
export type AnalyticsServicePreboot = Omit<AnalyticsClient, 'flush' | 'shutdown'>;
8+
/**
9+
* Exposes the public APIs of the AnalyticsClient during the setup phase.
10+
* {@link AnalyticsClient}
11+
* @public
12+
*/
13+
export type AnalyticsServiceSetup = Omit<AnalyticsClient, 'flush' | 'shutdown'>;
14+
/**
15+
* Exposes the public APIs of the AnalyticsClient during the start phase
16+
* {@link AnalyticsClient}
17+
* @public
18+
*/
19+
export type AnalyticsServiceStart = Pick<AnalyticsClient, 'optIn' | 'reportEvent' | 'telemetryCounter$'>;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export { AppLeaveActionType } from './src/app_leave';
2+
export type { AppLeaveAction, AppLeaveActionFactory, AppLeaveConfirmAction, AppLeaveDefaultAction, AppLeaveHandler, } from './src/app_leave';
3+
export type { AppMount, AppMountParameters, AppUnmount } from './src/app_mount';
4+
export type { App, AppDeepLink, AppDeepLinkLocations, PublicAppInfo, AppNavOptions, PublicAppDeepLinkInfo, AppUpdater, AppUpdatableFields, } from './src/application';
5+
export { AppStatus } from './src/application';
6+
export type { ApplicationSetup, ApplicationStart, NavigateToAppOptions, NavigateToUrlOptions, } from './src/contracts';
7+
export type { ScopedHistory } from './src/scoped_history';
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import type { EuiButtonColor } from '@elastic/eui';
2+
/**
3+
* A handler that will be executed before leaving the application, either when
4+
* going to another application or when closing the browser tab or manually changing
5+
* the url.
6+
* Should return `confirm` to prompt a message to the user before leaving the page, or `default`
7+
* to keep the default behavior (doing nothing).
8+
*
9+
* See {@link AppMountParameters} for detailed usage examples.
10+
*
11+
* @remarks prefer {@link ScopedHistory.block} instead
12+
*
13+
* @public
14+
*/
15+
export type AppLeaveHandler = (factory: AppLeaveActionFactory, nextAppId?: string) => AppLeaveAction;
16+
/**
17+
* Possible type of actions on application leave.
18+
*
19+
* @public
20+
*/
21+
export declare enum AppLeaveActionType {
22+
confirm = "confirm",
23+
default = "default"
24+
}
25+
/**
26+
* Action to return from a {@link AppLeaveHandler} to execute the default
27+
* behaviour when leaving the application.
28+
*
29+
* See {@link AppLeaveActionFactory}
30+
*
31+
* @public
32+
*/
33+
export interface AppLeaveDefaultAction {
34+
type: AppLeaveActionType.default;
35+
}
36+
/**
37+
* Action to return from a {@link AppLeaveHandler} to show a confirmation
38+
* message when trying to leave an application.
39+
*
40+
* See {@link AppLeaveActionFactory}
41+
*
42+
* @public
43+
*/
44+
export interface AppLeaveConfirmAction {
45+
type: AppLeaveActionType.confirm;
46+
text: string;
47+
title?: string;
48+
confirmButtonText?: string;
49+
buttonColor?: EuiButtonColor;
50+
callback?: () => void;
51+
}
52+
/**
53+
* Possible actions to return from a {@link AppLeaveHandler}
54+
*
55+
* See {@link AppLeaveConfirmAction} and {@link AppLeaveDefaultAction}
56+
*
57+
* @public
58+
* */
59+
export type AppLeaveAction = AppLeaveDefaultAction | AppLeaveConfirmAction;
60+
/**
61+
* Factory provided when invoking a {@link AppLeaveHandler} to retrieve the {@link AppLeaveAction} to execute.
62+
*/
63+
export interface AppLeaveActionFactory {
64+
/**
65+
* Returns a confirm action, resulting on prompting a message to the user before leaving the
66+
* application, allowing him to choose if he wants to stay on the app or confirm that he
67+
* wants to leave.
68+
*
69+
* @param text The text to display in the confirmation message
70+
* @param title (optional) title to display in the confirmation message
71+
* @param callback (optional) to know that the user want to stay on the page
72+
* @param confirmButtonText (optional) text for the confirmation button
73+
* @param buttonColor (optional) color for the confirmation button
74+
* so we can show to the user the right UX for him to saved his/her/their changes
75+
*/
76+
confirm(text: string, title?: string, callback?: () => void, confirmButtonText?: string, buttonColor?: EuiButtonColor): AppLeaveConfirmAction;
77+
/**
78+
* Returns a default action, resulting on executing the default behavior when
79+
* the user tries to leave an application
80+
*/
81+
default(): AppLeaveDefaultAction;
82+
}
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
import type { Observable } from 'rxjs';
2+
import type { CoreTheme } from '@kbn/core-theme-browser';
3+
import type { MountPoint } from '@kbn/core-mount-utils-browser';
4+
import type { AppLeaveHandler } from './app_leave';
5+
import type { ScopedHistory } from './scoped_history';
6+
/**
7+
* A mount function called when the user navigates to this app's route.
8+
*
9+
* @param params {@link AppMountParameters}
10+
* @returns An unmounting function that will be called to unmount the application. See {@link AppUnmount}.
11+
*
12+
* @public
13+
*/
14+
export type AppMount<HistoryLocationState = unknown> = (params: AppMountParameters<HistoryLocationState>) => AppUnmount | Promise<AppUnmount>;
15+
/**
16+
* A function called when an application should be unmounted from the page. This function should be synchronous.
17+
* @public
18+
*/
19+
export type AppUnmount = () => void;
20+
/** @public */
21+
export interface AppMountParameters<HistoryLocationState = unknown> {
22+
/**
23+
* The container element to render the application into.
24+
*/
25+
element: HTMLElement;
26+
/**
27+
* A scoped history instance for your application. Should be used to wire up
28+
* your applications Router.
29+
*
30+
* @example
31+
* How to configure react-router with a base path:
32+
*
33+
* ```ts
34+
* // inside your plugin's setup function
35+
* export class MyPlugin implements Plugin {
36+
* setup({ application }) {
37+
* application.register({
38+
* id: 'my-app',
39+
* appRoute: '/my-app',
40+
* async mount(params) {
41+
* const { renderApp } = await import('./application');
42+
* return renderApp(params);
43+
* },
44+
* });
45+
* }
46+
* }
47+
* ```
48+
*
49+
* ```ts
50+
* // application.tsx
51+
* import React from 'react';
52+
* import ReactDOM from 'react-dom';
53+
* import { Router, Route } from 'react-router-dom';
54+
*
55+
* import { CoreStart, AppMountParameters } from 'src/core/public';
56+
* import { MyPluginDepsStart } from './plugin';
57+
*
58+
* export renderApp = ({ element, history }: AppMountParameters) => {
59+
* ReactDOM.render(
60+
* <Router history={history}>
61+
* <Route path="/" exact component={HomePage} />
62+
* </Router>,
63+
* element
64+
* );
65+
*
66+
* return () => ReactDOM.unmountComponentAtNode(element);
67+
* }
68+
* ```
69+
*/
70+
history: ScopedHistory<HistoryLocationState>;
71+
/**
72+
* The route path for configuring navigation to the application.
73+
* This string should not include the base path from HTTP.
74+
*
75+
* @deprecated Use {@link AppMountParameters.history} instead.
76+
* remove after https://github.com/elastic/kibana/issues/132600 is done
77+
*
78+
* @example
79+
*
80+
* How to configure react-router with a base path:
81+
*
82+
* ```ts
83+
* // inside your plugin's setup function
84+
* export class MyPlugin implements Plugin {
85+
* setup({ application }) {
86+
* application.register({
87+
* id: 'my-app',
88+
* appRoute: '/my-app',
89+
* async mount(params) {
90+
* const { renderApp } = await import('./application');
91+
* return renderApp(params);
92+
* },
93+
* });
94+
* }
95+
* }
96+
* ```
97+
*
98+
* ```ts
99+
* // application.tsx
100+
* import React from 'react';
101+
* import ReactDOM from 'react-dom';
102+
* import { BrowserRouter, Route } from 'react-router-dom';
103+
*
104+
* import { CoreStart, AppMountParameters } from 'src/core/public';
105+
* import { MyPluginDepsStart } from './plugin';
106+
*
107+
* export renderApp = ({ appBasePath, element }: AppMountParameters) => {
108+
* ReactDOM.render(
109+
* // pass `appBasePath` to `basename`
110+
* <BrowserRouter basename={appBasePath}>
111+
* <Route path="/" exact component={HomePage} />
112+
* </BrowserRouter>,
113+
* element
114+
* );
115+
*
116+
* return () => ReactDOM.unmountComponentAtNode(element);
117+
* }
118+
* ```
119+
*/
120+
appBasePath: string;
121+
/**
122+
* A function that can be used to register a handler that will be called
123+
* when the user is leaving the current application, allowing to
124+
* prompt a confirmation message before actually changing the page.
125+
*
126+
* This will be called either when the user goes to another application, or when
127+
* trying to close the tab or manually changing the url.
128+
*
129+
*
130+
* @example
131+
*
132+
* ```ts
133+
* // application.tsx
134+
* import React from 'react';
135+
* import ReactDOM from 'react-dom';
136+
* import { BrowserRouter, Route } from 'react-router-dom';
137+
*
138+
* import { CoreStart, AppMountParameters } from 'src/core/public';
139+
* import { MyPluginDepsStart } from './plugin';
140+
*
141+
* export renderApp = ({ element, history, onAppLeave }: AppMountParameters) => {
142+
* const { renderApp, hasUnsavedChanges } = await import('./application');
143+
* onAppLeave(actions => {
144+
* if(hasUnsavedChanges()) {
145+
* return actions.confirm('Some changes were not saved. Are you sure you want to leave?');
146+
* }
147+
* return actions.default();
148+
* });
149+
* return renderApp({ element, history });
150+
* }
151+
* ```
152+
*
153+
* @remarks prefer {@link ScopedHistory.block} instead
154+
* Resources with names containing percent sign with other special characters or
155+
* containing `%25` sequence can experience navigation issues. Refs https://github.com/elastic/kibana/issues/82440 and https://github.com/elastic/kibana/issues/132600
156+
157+
*/
158+
onAppLeave: (handler: AppLeaveHandler) => void;
159+
/**
160+
* @deprecated Pass `menu` to `AppHeader` from `@kbn/app-header`.
161+
*/
162+
setHeaderActionMenu: (menuMount: MountPoint | undefined) => void;
163+
/**
164+
* An observable emitting {@link CoreTheme | Core's theme}.
165+
* Should be used when mounting the application to include theme information.
166+
*
167+
* @example
168+
* When mounting a react application:
169+
* ```ts
170+
* // application.tsx
171+
* import React from 'react';
172+
* import ReactDOM from 'react-dom';
173+
*
174+
* import { AppMountParameters } from 'src/core/public';
175+
* import { wrapWithTheme } from 'src/platform/plugins/shared/kibana_react';
176+
* import { MyApp } from './app';
177+
*
178+
* export renderApp = ({ element, theme$ }: AppMountParameters) => {
179+
* ReactDOM.render(wrapWithTheme(<MyApp/>, theme$), element);
180+
* return () => ReactDOM.unmountComponentAtNode(element);
181+
* }
182+
* ```
183+
*/
184+
theme$: Observable<CoreTheme>;
185+
}

0 commit comments

Comments
 (0)