diff --git a/.i18nrc.json b/.i18nrc.json index 8c98fc415c91..88c1ecb5106b 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -7,7 +7,11 @@ "bfetch": "src/plugins/bfetch", "charts": "src/plugins/charts", "console": "src/plugins/console", - "core": ["src/core", "packages/core/i18n/core-i18n-browser-internal"], + "core": [ + "src/core", + "packages/core/i18n/core-i18n-browser-internal", + "packages/core/fatal-errors/core-fatal-errors-browser-internal" + ], "customIntegrations": "src/plugins/custom_integrations", "dashboard": "src/plugins/dashboard", "controls": "src/plugins/controls", diff --git a/package.json b/package.json index 717392523c95..d9e567e45bb8 100644 --- a/package.json +++ b/package.json @@ -167,6 +167,9 @@ "@kbn/core-doc-links-server": "link:bazel-bin/packages/core/doc-links/core-doc-links-server", "@kbn/core-doc-links-server-internal": "link:bazel-bin/packages/core/doc-links/core-doc-links-server-internal", "@kbn/core-doc-links-server-mocks": "link:bazel-bin/packages/core/doc-links/core-doc-links-server-mocks", + "@kbn/core-fatal-errors-browser": "link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser", + "@kbn/core-fatal-errors-browser-internal": "link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser-internal", + "@kbn/core-fatal-errors-browser-mocks": "link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser-mocks", "@kbn/core-i18n-browser": "link:bazel-bin/packages/core/i18n/core-i18n-browser", "@kbn/core-i18n-browser-internal": "link:bazel-bin/packages/core/i18n/core-i18n-browser-internal", "@kbn/core-i18n-browser-mocks": "link:bazel-bin/packages/core/i18n/core-i18n-browser-mocks", @@ -705,6 +708,9 @@ "@types/kbn__core-doc-links-server": "link:bazel-bin/packages/core/doc-links/core-doc-links-server/npm_module_types", "@types/kbn__core-doc-links-server-internal": "link:bazel-bin/packages/core/doc-links/core-doc-links-server-internal/npm_module_types", "@types/kbn__core-doc-links-server-mocks": "link:bazel-bin/packages/core/doc-links/core-doc-links-server-mocks/npm_module_types", + "@types/kbn__core-fatal-errors-browser": "link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser/npm_module_types", + "@types/kbn__core-fatal-errors-browser-internal": "link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser-internal/npm_module_types", + "@types/kbn__core-fatal-errors-browser-mocks": "link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser-mocks/npm_module_types", "@types/kbn__core-i18n-browser": "link:bazel-bin/packages/core/i18n/core-i18n-browser/npm_module_types", "@types/kbn__core-i18n-browser-internal": "link:bazel-bin/packages/core/i18n/core-i18n-browser-internal/npm_module_types", "@types/kbn__core-i18n-browser-mocks": "link:bazel-bin/packages/core/i18n/core-i18n-browser-mocks/npm_module_types", diff --git a/packages/BUILD.bazel b/packages/BUILD.bazel index 253c5cc2b4fb..a44ba9cd3a2d 100644 --- a/packages/BUILD.bazel +++ b/packages/BUILD.bazel @@ -33,6 +33,9 @@ filegroup( "//packages/core/doc-links/core-doc-links-server-internal:build", "//packages/core/doc-links/core-doc-links-server-mocks:build", "//packages/core/doc-links/core-doc-links-server:build", + "//packages/core/fatal-errors/core-fatal-errors-browser-internal:build", + "//packages/core/fatal-errors/core-fatal-errors-browser-mocks:build", + "//packages/core/fatal-errors/core-fatal-errors-browser:build", "//packages/core/i18n/core-i18n-browser-internal:build", "//packages/core/i18n/core-i18n-browser-mocks:build", "//packages/core/i18n/core-i18n-browser:build", @@ -193,6 +196,9 @@ filegroup( "//packages/core/doc-links/core-doc-links-server-internal:build_types", "//packages/core/doc-links/core-doc-links-server-mocks:build_types", "//packages/core/doc-links/core-doc-links-server:build_types", + "//packages/core/fatal-errors/core-fatal-errors-browser-internal:build_types", + "//packages/core/fatal-errors/core-fatal-errors-browser-mocks:build_types", + "//packages/core/fatal-errors/core-fatal-errors-browser:build_types", "//packages/core/i18n/core-i18n-browser-internal:build_types", "//packages/core/i18n/core-i18n-browser-mocks:build_types", "//packages/core/i18n/core-i18n-browser:build_types", diff --git a/packages/core/fatal-errors/core-fatal-errors-browser-internal/BUILD.bazel b/packages/core/fatal-errors/core-fatal-errors-browser-internal/BUILD.bazel new file mode 100644 index 000000000000..e79c856654b0 --- /dev/null +++ b/packages/core/fatal-errors/core-fatal-errors-browser-internal/BUILD.bazel @@ -0,0 +1,125 @@ +load("@npm//@bazel/typescript:index.bzl", "ts_config") +load("@build_bazel_rules_nodejs//:index.bzl", "js_library") +load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project") + +PKG_DIRNAME = "core-fatal-errors-browser-internal" +PKG_REQUIRE_NAME = "@kbn/core-fatal-errors-browser-internal" + +SOURCE_FILES = glob( + [ + "src/**/*.ts", + "src/**/*.tsx", + ], + exclude = [ + "**/*.test.*", + ], +) + +SRCS = SOURCE_FILES + +filegroup( + name = "srcs", + srcs = SRCS, +) + +NPM_MODULE_EXTRA_FILES = [ + "package.json", +] + +RUNTIME_DEPS = [ + "@npm//react", + "@npm//react-dom", + "@npm//rxjs", + "@npm//@elastic/eui", + "//packages/core/theme/core-theme-browser-internal", + "//packages/core/theme/core-theme-browser-mocks", + "//packages/core/injected-metadata/core-injected-metadata-browser-mocks", + "//packages/kbn-i18n-react", + "//packages/kbn-test-jest-helpers", + "//packages/kbn-test-subj-selector", +] + +TYPES_DEPS = [ + "@npm//@types/node", + "@npm//@types/jest", + "@npm//@types/react", + "@npm//@types/react-dom", + "@npm//rxjs", + "@npm//@elastic/eui", + "//packages/core/injected-metadata/core-injected-metadata-browser-internal:npm_module_types", + "//packages/core/theme/core-theme-browser:npm_module_types", + "//packages/core/theme/core-theme-browser-internal:npm_module_types", + "//packages/core/i18n/core-i18n-browser:npm_module_types", + "//packages/core/fatal-errors/core-fatal-errors-browser:npm_module_types", + "//packages/kbn-i18n-react:npm_module_types", + "//packages/kbn-test-jest-helpers", + "//packages/kbn-test-subj-selector", +] + +jsts_transpiler( + name = "target_node", + srcs = SRCS, + build_pkg_name = package_name(), +) + +jsts_transpiler( + name = "target_web", + srcs = SRCS, + build_pkg_name = package_name(), + web = True, +) + +ts_config( + name = "tsconfig", + src = "tsconfig.json", + deps = [ + "//:tsconfig.base.json", + "//:tsconfig.bazel.json", + ], +) + +ts_project( + name = "tsc_types", + args = ['--pretty'], + srcs = SRCS, + deps = TYPES_DEPS, + declaration = True, + emit_declaration_only = True, + out_dir = "target_types", + root_dir = "src", + tsconfig = ":tsconfig", +) + +js_library( + name = PKG_DIRNAME, + srcs = NPM_MODULE_EXTRA_FILES, + deps = RUNTIME_DEPS + [":target_node", ":target_web"], + package_name = PKG_REQUIRE_NAME, + visibility = ["//visibility:public"], +) + +pkg_npm( + name = "npm_module", + deps = [":" + PKG_DIRNAME], +) + +filegroup( + name = "build", + srcs = [":npm_module"], + visibility = ["//visibility:public"], +) + +pkg_npm_types( + name = "npm_module_types", + srcs = SRCS, + deps = [":tsc_types"], + package_name = PKG_REQUIRE_NAME, + tsconfig = ":tsconfig", + visibility = ["//visibility:public"], +) + +filegroup( + name = "build_types", + srcs = [":npm_module_types"], + visibility = ["//visibility:public"], +) diff --git a/packages/core/fatal-errors/core-fatal-errors-browser-internal/README.md b/packages/core/fatal-errors/core-fatal-errors-browser-internal/README.md new file mode 100644 index 000000000000..bc14a6611b73 --- /dev/null +++ b/packages/core/fatal-errors/core-fatal-errors-browser-internal/README.md @@ -0,0 +1,3 @@ +# @kbn/core-fatal-errors-browser-internal + +This package contains the implementation and internal types of the browser-side fatalErrors service. diff --git a/packages/core/fatal-errors/core-fatal-errors-browser-internal/jest.config.js b/packages/core/fatal-errors/core-fatal-errors-browser-internal/jest.config.js new file mode 100644 index 000000000000..4098eeba3bef --- /dev/null +++ b/packages/core/fatal-errors/core-fatal-errors-browser-internal/jest.config.js @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../..', + roots: ['/packages/core/fatal-errors/core-fatal-errors-browser-internal'], +}; diff --git a/packages/core/fatal-errors/core-fatal-errors-browser-internal/package.json b/packages/core/fatal-errors/core-fatal-errors-browser-internal/package.json new file mode 100644 index 000000000000..fc5c13485540 --- /dev/null +++ b/packages/core/fatal-errors/core-fatal-errors-browser-internal/package.json @@ -0,0 +1,8 @@ +{ + "name": "@kbn/core-fatal-errors-browser-internal", + "private": true, + "version": "1.0.0", + "main": "./target_node/index.js", + "browser": "./target_web/index.js", + "license": "SSPL-1.0 OR Elastic License 2.0" +} diff --git a/src/core/public/fatal_errors/__snapshots__/fatal_errors_screen.test.tsx.snap b/packages/core/fatal-errors/core-fatal-errors-browser-internal/src/__snapshots__/fatal_errors_screen.test.tsx.snap similarity index 100% rename from src/core/public/fatal_errors/__snapshots__/fatal_errors_screen.test.tsx.snap rename to packages/core/fatal-errors/core-fatal-errors-browser-internal/src/__snapshots__/fatal_errors_screen.test.tsx.snap diff --git a/src/core/public/fatal_errors/__snapshots__/fatal_errors_service.test.ts.snap b/packages/core/fatal-errors/core-fatal-errors-browser-internal/src/__snapshots__/fatal_errors_service.test.ts.snap similarity index 100% rename from src/core/public/fatal_errors/__snapshots__/fatal_errors_service.test.ts.snap rename to packages/core/fatal-errors/core-fatal-errors-browser-internal/src/__snapshots__/fatal_errors_service.test.ts.snap diff --git a/src/core/public/fatal_errors/fatal_errors_screen.test.tsx b/packages/core/fatal-errors/core-fatal-errors-browser-internal/src/fatal_errors_screen.test.tsx similarity index 96% rename from src/core/public/fatal_errors/fatal_errors_screen.test.tsx rename to packages/core/fatal-errors/core-fatal-errors-browser-internal/src/fatal_errors_screen.test.tsx index b460e62b1151..1849517c8cf3 100644 --- a/src/core/public/fatal_errors/fatal_errors_screen.test.tsx +++ b/packages/core/fatal-errors/core-fatal-errors-browser-internal/src/fatal_errors_screen.test.tsx @@ -9,7 +9,7 @@ import { EuiCallOut } from '@elastic/eui'; import testSubjSelector from '@kbn/test-subj-selector'; import React from 'react'; -import * as Rx from 'rxjs'; +import { of, ReplaySubject } from 'rxjs'; import { mountWithIntl, shallowWithIntl } from '@kbn/test-jest-helpers'; import { FatalErrorsScreen } from './fatal_errors_screen'; @@ -27,7 +27,7 @@ describe('FatalErrorsScreen', () => { const defaultProps = { buildNumber: 123, kibanaVersion: 'bar', - errorInfo$: Rx.of(errorInfoFoo, errorInfoBar), + errorInfo$: of(errorInfoFoo, errorInfoBar), }; const noop = () => { @@ -67,7 +67,7 @@ describe('FatalErrorsScreen', () => { }); it('rerenders when errorInfo$ emits more errors', () => { - const errorInfo$ = new Rx.ReplaySubject(); + const errorInfo$ = new ReplaySubject(); const el = shallowWithIntl(); diff --git a/src/core/public/fatal_errors/fatal_errors_screen.tsx b/packages/core/fatal-errors/core-fatal-errors-browser-internal/src/fatal_errors_screen.tsx similarity index 93% rename from src/core/public/fatal_errors/fatal_errors_screen.tsx rename to packages/core/fatal-errors/core-fatal-errors-browser-internal/src/fatal_errors_screen.tsx index b46fdf134d0b..6fbf6ab80aeb 100644 --- a/src/core/public/fatal_errors/fatal_errors_screen.tsx +++ b/packages/core/fatal-errors/core-fatal-errors-browser-internal/src/fatal_errors_screen.tsx @@ -17,17 +17,16 @@ import { EuiPageContent, } from '@elastic/eui'; import React from 'react'; -import * as Rx from 'rxjs'; -import { tap } from 'rxjs/operators'; +import { Observable, Subscription, merge, tap, fromEvent } from 'rxjs'; import { FormattedMessage } from '@kbn/i18n-react'; -import { FatalErrorInfo } from './get_error_info'; +import { FatalErrorInfo } from '@kbn/core-fatal-errors-browser'; interface Props { kibanaVersion: string; buildNumber: number; - errorInfo$: Rx.Observable; + errorInfo$: Observable; } interface State { @@ -39,12 +38,12 @@ export class FatalErrorsScreen extends React.Component { errors: [], }; - private subscription?: Rx.Subscription; + private subscription?: Subscription; public componentDidMount() { - this.subscription = Rx.merge( + this.subscription = merge( // reload the page if hash-based navigation is attempted - Rx.fromEvent(window, 'hashchange').pipe( + fromEvent(window, 'hashchange').pipe( tap(() => { window.location.reload(); }) diff --git a/src/core/public/fatal_errors/fatal_errors_service.test.mocks.ts b/packages/core/fatal-errors/core-fatal-errors-browser-internal/src/fatal_errors_service.test.mocks.ts similarity index 100% rename from src/core/public/fatal_errors/fatal_errors_service.test.mocks.ts rename to packages/core/fatal-errors/core-fatal-errors-browser-internal/src/fatal_errors_service.test.mocks.ts diff --git a/src/core/public/fatal_errors/fatal_errors_service.test.ts b/packages/core/fatal-errors/core-fatal-errors-browser-internal/src/fatal_errors_service.test.ts similarity index 97% rename from src/core/public/fatal_errors/fatal_errors_service.test.ts rename to packages/core/fatal-errors/core-fatal-errors-browser-internal/src/fatal_errors_service.test.ts index fe3e623b00f9..cc7da2e0eb35 100644 --- a/src/core/public/fatal_errors/fatal_errors_service.test.ts +++ b/packages/core/fatal-errors/core-fatal-errors-browser-internal/src/fatal_errors_service.test.ts @@ -6,10 +6,10 @@ * Side Public License, v 1. */ -import * as Rx from 'rxjs'; +import { Observable } from 'rxjs'; expect.addSnapshotSerializer({ - test: (val) => val instanceof Rx.Observable, + test: (val) => val instanceof Observable, print: () => `Rx.Observable`, }); diff --git a/src/core/public/fatal_errors/fatal_errors_service.tsx b/packages/core/fatal-errors/core-fatal-errors-browser-internal/src/fatal_errors_service.tsx similarity index 71% rename from src/core/public/fatal_errors/fatal_errors_service.tsx rename to packages/core/fatal-errors/core-fatal-errors-browser-internal/src/fatal_errors_service.tsx index 952740c41416..cefa6e7c0ecb 100644 --- a/src/core/public/fatal_errors/fatal_errors_service.tsx +++ b/packages/core/fatal-errors/core-fatal-errors-browser-internal/src/fatal_errors_service.tsx @@ -8,55 +8,26 @@ import React from 'react'; import { render } from 'react-dom'; -import * as Rx from 'rxjs'; -import { first, tap } from 'rxjs/operators'; +import { ReplaySubject, first, tap } from 'rxjs'; import type { InternalInjectedMetadataSetup } from '@kbn/core-injected-metadata-browser-internal'; import type { ThemeServiceSetup } from '@kbn/core-theme-browser'; import type { I18nStart } from '@kbn/core-i18n-browser'; -import { CoreContextProvider } from '../utils'; +import type { FatalErrorInfo, FatalErrorsSetup } from '@kbn/core-fatal-errors-browser'; +import { CoreContextProvider } from '@kbn/core-theme-browser-internal'; import { FatalErrorsScreen } from './fatal_errors_screen'; -import { FatalErrorInfo, getErrorInfo } from './get_error_info'; +import { getErrorInfo } from './get_error_info'; -export interface Deps { +/** @internal */ +export interface FatalErrorsServiceSetupDeps { i18n: I18nStart; theme: ThemeServiceSetup; injectedMetadata: InternalInjectedMetadataSetup; } -/** - * FatalErrors stop the Kibana Public Core and displays a fatal error screen - * with details about the Kibana build and the error. - * - * @public - */ -export interface FatalErrorsSetup { - /** - * Add a new fatal error. This will stop the Kibana Public Core and display - * a fatal error screen with details about the Kibana build and the error. - * - * @param error - The error to display - * @param source - Adds a prefix of the form `${source}: ` to the error message - */ - add: (error: string | Error, source?: string) => never; - - /** - * An Observable that will emit whenever a fatal error is added with `add()` - */ - get$: () => Rx.Observable; -} - -/** - * FatalErrors stop the Kibana Public Core and displays a fatal error screen - * with details about the Kibana build and the error. - * - * @public - */ -export type FatalErrorsStart = FatalErrorsSetup; - /** @internal */ export class FatalErrorsService { - private readonly errorInfo$ = new Rx.ReplaySubject(); + private readonly errorInfo$ = new ReplaySubject(); private fatalErrors?: FatalErrorsSetup; /** @@ -67,7 +38,7 @@ export class FatalErrorsService { */ constructor(private rootDomElement: HTMLElement, private onFirstErrorCb: () => void) {} - public setup(deps: Deps) { + public setup(deps: FatalErrorsServiceSetupDeps) { this.errorInfo$ .pipe( first(), @@ -115,7 +86,7 @@ export class FatalErrorsService { return fatalErrors; } - private renderError({ i18n, theme, injectedMetadata }: Deps) { + private renderError({ i18n, theme, injectedMetadata }: FatalErrorsServiceSetupDeps) { // delete all content in the rootDomElement this.rootDomElement.textContent = ''; diff --git a/src/core/public/fatal_errors/get_error_info.test.ts b/packages/core/fatal-errors/core-fatal-errors-browser-internal/src/get_error_info.test.ts similarity index 100% rename from src/core/public/fatal_errors/get_error_info.test.ts rename to packages/core/fatal-errors/core-fatal-errors-browser-internal/src/get_error_info.test.ts diff --git a/src/core/public/fatal_errors/get_error_info.ts b/packages/core/fatal-errors/core-fatal-errors-browser-internal/src/get_error_info.ts similarity index 92% rename from src/core/public/fatal_errors/get_error_info.ts rename to packages/core/fatal-errors/core-fatal-errors-browser-internal/src/get_error_info.ts index 89ecb3f4a918..186011b778ed 100644 --- a/src/core/public/fatal_errors/get_error_info.ts +++ b/packages/core/fatal-errors/core-fatal-errors-browser-internal/src/get_error_info.ts @@ -7,7 +7,7 @@ */ import { inspect } from 'util'; - +import type { FatalErrorInfo } from '@kbn/core-fatal-errors-browser'; /** * Produce a string version of an error, */ @@ -63,13 +63,3 @@ export function getErrorInfo(error: any, source?: string): FatalErrorInfo { stack: formatStack(error), }; } - -/** - * Represents the `message` and `stack` of a fatal Error - * - * @public - * */ -export interface FatalErrorInfo { - message: string; - stack: string | undefined; -} diff --git a/src/core/public/fatal_errors/index.ts b/packages/core/fatal-errors/core-fatal-errors-browser-internal/src/index.ts similarity index 75% rename from src/core/public/fatal_errors/index.ts rename to packages/core/fatal-errors/core-fatal-errors-browser-internal/src/index.ts index bb6590c69129..20bd9db4936d 100644 --- a/src/core/public/fatal_errors/index.ts +++ b/packages/core/fatal-errors/core-fatal-errors-browser-internal/src/index.ts @@ -7,5 +7,4 @@ */ export { FatalErrorsService } from './fatal_errors_service'; -export type { FatalErrorsSetup, FatalErrorsStart } from './fatal_errors_service'; -export type { FatalErrorInfo } from './get_error_info'; +export type { FatalErrorsServiceSetupDeps } from './fatal_errors_service'; diff --git a/packages/core/fatal-errors/core-fatal-errors-browser-internal/tsconfig.json b/packages/core/fatal-errors/core-fatal-errors-browser-internal/tsconfig.json new file mode 100644 index 000000000000..dc20b641b198 --- /dev/null +++ b/packages/core/fatal-errors/core-fatal-errors-browser-internal/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../../../../tsconfig.bazel.json", + "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "target_types", + "rootDir": "src", + "stripInternal": false, + "types": [ + "jest", + "node", + "react" + ] + }, + "include": [ + "src/**/*" + ] +} diff --git a/packages/core/fatal-errors/core-fatal-errors-browser-mocks/BUILD.bazel b/packages/core/fatal-errors/core-fatal-errors-browser-mocks/BUILD.bazel new file mode 100644 index 000000000000..647682e9f5b9 --- /dev/null +++ b/packages/core/fatal-errors/core-fatal-errors-browser-mocks/BUILD.bazel @@ -0,0 +1,109 @@ +load("@npm//@bazel/typescript:index.bzl", "ts_config") +load("@build_bazel_rules_nodejs//:index.bzl", "js_library") +load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project") + +PKG_DIRNAME = "core-fatal-errors-browser-mocks" +PKG_REQUIRE_NAME = "@kbn/core-fatal-errors-browser-mocks" + +SOURCE_FILES = glob( + [ + "src/**/*.ts", + "src/**/*.tsx", + ], + exclude = [ + "**/*.test.*", + ], +) + +SRCS = SOURCE_FILES + +filegroup( + name = "srcs", + srcs = SRCS, +) + +NPM_MODULE_EXTRA_FILES = [ + "package.json", +] + +RUNTIME_DEPS = [ + "@npm//react", + "//packages/core/fatal-errors/core-fatal-errors-browser-internal", +] + +TYPES_DEPS = [ + "@npm//@types/node", + "@npm//@types/jest", + "@npm//@types/react", + "//packages/core/fatal-errors/core-fatal-errors-browser:npm_module_types", + "//packages/core/fatal-errors/core-fatal-errors-browser-internal:npm_module_types", + "//packages/kbn-utility-types:npm_module_types" +] + +jsts_transpiler( + name = "target_node", + srcs = SRCS, + build_pkg_name = package_name(), +) + +jsts_transpiler( + name = "target_web", + srcs = SRCS, + build_pkg_name = package_name(), + web = True, +) + +ts_config( + name = "tsconfig", + src = "tsconfig.json", + deps = [ + "//:tsconfig.base.json", + "//:tsconfig.bazel.json", + ], +) + +ts_project( + name = "tsc_types", + args = ['--pretty'], + srcs = SRCS, + deps = TYPES_DEPS, + declaration = True, + emit_declaration_only = True, + out_dir = "target_types", + root_dir = "src", + tsconfig = ":tsconfig", +) + +js_library( + name = PKG_DIRNAME, + srcs = NPM_MODULE_EXTRA_FILES, + deps = RUNTIME_DEPS + [":target_node", ":target_web"], + package_name = PKG_REQUIRE_NAME, + visibility = ["//visibility:public"], +) + +pkg_npm( + name = "npm_module", + deps = [":" + PKG_DIRNAME], +) + +filegroup( + name = "build", + srcs = [":npm_module"], + visibility = ["//visibility:public"], +) + +pkg_npm_types( + name = "npm_module_types", + srcs = SRCS, + deps = [":tsc_types"], + package_name = PKG_REQUIRE_NAME, + tsconfig = ":tsconfig", + visibility = ["//visibility:public"], +) + +filegroup( + name = "build_types", + srcs = [":npm_module_types"], + visibility = ["//visibility:public"], +) diff --git a/packages/core/fatal-errors/core-fatal-errors-browser-mocks/README.md b/packages/core/fatal-errors/core-fatal-errors-browser-mocks/README.md new file mode 100644 index 000000000000..9f532282c553 --- /dev/null +++ b/packages/core/fatal-errors/core-fatal-errors-browser-mocks/README.md @@ -0,0 +1,3 @@ +# @kbn/core-fatal-errors-browser-mocks + +This package contains the mocks for Core's fatalErrors service. diff --git a/packages/core/fatal-errors/core-fatal-errors-browser-mocks/jest.config.js b/packages/core/fatal-errors/core-fatal-errors-browser-mocks/jest.config.js new file mode 100644 index 000000000000..2aebfcfd4f99 --- /dev/null +++ b/packages/core/fatal-errors/core-fatal-errors-browser-mocks/jest.config.js @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../..', + roots: ['/packages/core/fatal-errors/core-fatal-errors-browser-mocks'], +}; diff --git a/packages/core/fatal-errors/core-fatal-errors-browser-mocks/package.json b/packages/core/fatal-errors/core-fatal-errors-browser-mocks/package.json new file mode 100644 index 000000000000..208ee92ee836 --- /dev/null +++ b/packages/core/fatal-errors/core-fatal-errors-browser-mocks/package.json @@ -0,0 +1,8 @@ +{ + "name": "@kbn/core-fatal-errors-browser-mocks", + "private": true, + "version": "1.0.0", + "main": "./target_node/index.js", + "browser": "./target_web/index.js", + "license": "SSPL-1.0 OR Elastic License 2.0" +} diff --git a/src/core/public/fatal_errors/fatal_errors_service.mock.ts b/packages/core/fatal-errors/core-fatal-errors-browser-mocks/src/fatal_errors_service.mock.ts similarity index 88% rename from src/core/public/fatal_errors/fatal_errors_service.mock.ts rename to packages/core/fatal-errors/core-fatal-errors-browser-mocks/src/fatal_errors_service.mock.ts index 151164000bfb..222fb29ebc81 100644 --- a/src/core/public/fatal_errors/fatal_errors_service.mock.ts +++ b/packages/core/fatal-errors/core-fatal-errors-browser-mocks/src/fatal_errors_service.mock.ts @@ -7,7 +7,8 @@ */ import type { PublicMethodsOf } from '@kbn/utility-types'; -import { FatalErrorsService, FatalErrorsSetup } from './fatal_errors_service'; +import type { FatalErrorsSetup } from '@kbn/core-fatal-errors-browser'; +import { FatalErrorsService } from '@kbn/core-fatal-errors-browser-internal'; const createSetupContractMock = () => { const setupContract: jest.Mocked = { diff --git a/packages/core/fatal-errors/core-fatal-errors-browser-mocks/src/index.ts b/packages/core/fatal-errors/core-fatal-errors-browser-mocks/src/index.ts new file mode 100644 index 000000000000..a31ac652c885 --- /dev/null +++ b/packages/core/fatal-errors/core-fatal-errors-browser-mocks/src/index.ts @@ -0,0 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export { fatalErrorsServiceMock } from './fatal_errors_service.mock'; diff --git a/packages/core/fatal-errors/core-fatal-errors-browser-mocks/tsconfig.json b/packages/core/fatal-errors/core-fatal-errors-browser-mocks/tsconfig.json new file mode 100644 index 000000000000..dc20b641b198 --- /dev/null +++ b/packages/core/fatal-errors/core-fatal-errors-browser-mocks/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../../../../tsconfig.bazel.json", + "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "target_types", + "rootDir": "src", + "stripInternal": false, + "types": [ + "jest", + "node", + "react" + ] + }, + "include": [ + "src/**/*" + ] +} diff --git a/packages/core/fatal-errors/core-fatal-errors-browser/BUILD.bazel b/packages/core/fatal-errors/core-fatal-errors-browser/BUILD.bazel new file mode 100644 index 000000000000..5cd525836c32 --- /dev/null +++ b/packages/core/fatal-errors/core-fatal-errors-browser/BUILD.bazel @@ -0,0 +1,106 @@ +load("@npm//@bazel/typescript:index.bzl", "ts_config") +load("@build_bazel_rules_nodejs//:index.bzl", "js_library") +load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project") + +PKG_DIRNAME = "core-fatal-errors-browser" +PKG_REQUIRE_NAME = "@kbn/core-fatal-errors-browser" + +SOURCE_FILES = glob( + [ + "src/**/*.ts", + "src/**/*.tsx", + ], + exclude = [ + "**/*.test.*", + ], +) + +SRCS = SOURCE_FILES + +filegroup( + name = "srcs", + srcs = SRCS, +) + +NPM_MODULE_EXTRA_FILES = [ + "package.json", +] + +RUNTIME_DEPS = [ + "@npm//react" +] + +TYPES_DEPS = [ + "@npm//@types/node", + "@npm//@types/jest", + "@npm//@types/react", + "@npm//rxjs", +] + +jsts_transpiler( + name = "target_node", + srcs = SRCS, + build_pkg_name = package_name(), +) + +jsts_transpiler( + name = "target_web", + srcs = SRCS, + build_pkg_name = package_name(), + web = True, +) + +ts_config( + name = "tsconfig", + src = "tsconfig.json", + deps = [ + "//:tsconfig.base.json", + "//:tsconfig.bazel.json", + ], +) + +ts_project( + name = "tsc_types", + args = ['--pretty'], + srcs = SRCS, + deps = TYPES_DEPS, + declaration = True, + emit_declaration_only = True, + out_dir = "target_types", + root_dir = "src", + tsconfig = ":tsconfig", +) + +js_library( + name = PKG_DIRNAME, + srcs = NPM_MODULE_EXTRA_FILES, + deps = RUNTIME_DEPS + [":target_node", ":target_web"], + package_name = PKG_REQUIRE_NAME, + visibility = ["//visibility:public"], +) + +pkg_npm( + name = "npm_module", + deps = [":" + PKG_DIRNAME], +) + +filegroup( + name = "build", + srcs = [":npm_module"], + visibility = ["//visibility:public"], +) + +pkg_npm_types( + name = "npm_module_types", + srcs = SRCS, + deps = [":tsc_types"], + package_name = PKG_REQUIRE_NAME, + tsconfig = ":tsconfig", + visibility = ["//visibility:public"], +) + +filegroup( + name = "build_types", + srcs = [":npm_module_types"], + visibility = ["//visibility:public"], +) diff --git a/packages/core/fatal-errors/core-fatal-errors-browser/README.md b/packages/core/fatal-errors/core-fatal-errors-browser/README.md new file mode 100644 index 000000000000..a0d4ead4c483 --- /dev/null +++ b/packages/core/fatal-errors/core-fatal-errors-browser/README.md @@ -0,0 +1,3 @@ +# @kbn/core-fatal-errors-browser + +This package contains the browser public types for the fatalErrors core service. diff --git a/packages/core/fatal-errors/core-fatal-errors-browser/jest.config.js b/packages/core/fatal-errors/core-fatal-errors-browser/jest.config.js new file mode 100644 index 000000000000..aef7abddb0e6 --- /dev/null +++ b/packages/core/fatal-errors/core-fatal-errors-browser/jest.config.js @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../..', + roots: ['/packages/core/fatal-errors/core-fatal-errors-browser'], +}; diff --git a/packages/core/fatal-errors/core-fatal-errors-browser/package.json b/packages/core/fatal-errors/core-fatal-errors-browser/package.json new file mode 100644 index 000000000000..d45515d4d9f9 --- /dev/null +++ b/packages/core/fatal-errors/core-fatal-errors-browser/package.json @@ -0,0 +1,8 @@ +{ + "name": "@kbn/core-fatal-errors-browser", + "private": true, + "version": "1.0.0", + "main": "./target_node/index.js", + "browser": "./target_web/index.js", + "license": "SSPL-1.0 OR Elastic License 2.0" +} diff --git a/packages/core/fatal-errors/core-fatal-errors-browser/src/contract.ts b/packages/core/fatal-errors/core-fatal-errors-browser/src/contract.ts new file mode 100644 index 000000000000..2b6bc8ee0aba --- /dev/null +++ b/packages/core/fatal-errors/core-fatal-errors-browser/src/contract.ts @@ -0,0 +1,38 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ +import type { Observable } from 'rxjs'; +import type { FatalErrorInfo } from './get_error_info'; +/** + * FatalErrors stop the Kibana Public Core and displays a fatal error screen + * with details about the Kibana build and the error. + * + * @public + */ +export interface FatalErrorsSetup { + /** + * Add a new fatal error. This will stop the Kibana Public Core and display + * a fatal error screen with details about the Kibana build and the error. + * + * @param error - The error to display + * @param source - Adds a prefix of the form `${source}: ` to the error message + */ + add: (error: string | Error, source?: string) => never; + + /** + * An Observable that will emit whenever a fatal error is added with `add()` + */ + get$: () => Observable; +} + +/** + * FatalErrors stop the Kibana Public Core and displays a fatal error screen + * with details about the Kibana build and the error. + * + * @public + */ +export type FatalErrorsStart = FatalErrorsSetup; diff --git a/packages/core/fatal-errors/core-fatal-errors-browser/src/get_error_info.ts b/packages/core/fatal-errors/core-fatal-errors-browser/src/get_error_info.ts new file mode 100644 index 000000000000..a0e0b67b24d2 --- /dev/null +++ b/packages/core/fatal-errors/core-fatal-errors-browser/src/get_error_info.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +/** + * Represents the `message` and `stack` of a fatal Error + * + * @public + * */ +export interface FatalErrorInfo { + message: string; + stack: string | undefined; +} diff --git a/packages/core/fatal-errors/core-fatal-errors-browser/src/index.ts b/packages/core/fatal-errors/core-fatal-errors-browser/src/index.ts new file mode 100644 index 000000000000..365e8ab268df --- /dev/null +++ b/packages/core/fatal-errors/core-fatal-errors-browser/src/index.ts @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export type { FatalErrorsSetup, FatalErrorsStart } from './contract'; +export type { FatalErrorInfo } from './get_error_info'; diff --git a/packages/core/fatal-errors/core-fatal-errors-browser/tsconfig.json b/packages/core/fatal-errors/core-fatal-errors-browser/tsconfig.json new file mode 100644 index 000000000000..dc20b641b198 --- /dev/null +++ b/packages/core/fatal-errors/core-fatal-errors-browser/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../../../../tsconfig.bazel.json", + "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "target_types", + "rootDir": "src", + "stripInternal": false, + "types": [ + "jest", + "node", + "react" + ] + }, + "include": [ + "src/**/*" + ] +} diff --git a/packages/core/theme/core-theme-browser-internal/BUILD.bazel b/packages/core/theme/core-theme-browser-internal/BUILD.bazel index e4e56b6ef38f..4dc740ef5804 100644 --- a/packages/core/theme/core-theme-browser-internal/BUILD.bazel +++ b/packages/core/theme/core-theme-browser-internal/BUILD.bazel @@ -46,6 +46,7 @@ TYPES_DEPS = [ "//packages/core/base/core-base-common:npm_module_types", "//packages/core/injected-metadata/core-injected-metadata-browser-internal:npm_module_types", "//packages/core/theme/core-theme-browser:npm_module_types", + "//packages/core/i18n/core-i18n-browser:npm_module_types", ] jsts_transpiler( diff --git a/src/core/public/utils/core_context_provider.tsx b/packages/core/theme/core-theme-browser-internal/src/core_context_provider.tsx similarity index 95% rename from src/core/public/utils/core_context_provider.tsx rename to packages/core/theme/core-theme-browser-internal/src/core_context_provider.tsx index a400f8eae991..0c1f8aca9e2c 100644 --- a/src/core/public/utils/core_context_provider.tsx +++ b/packages/core/theme/core-theme-browser-internal/src/core_context_provider.tsx @@ -8,8 +8,8 @@ import React, { FC } from 'react'; import type { ThemeServiceStart } from '@kbn/core-theme-browser'; -import { CoreThemeProvider } from '@kbn/core-theme-browser-internal'; import type { I18nStart } from '@kbn/core-i18n-browser'; +import { CoreThemeProvider } from './core_theme_provider'; interface CoreContextProviderProps { theme: ThemeServiceStart; diff --git a/packages/core/theme/core-theme-browser-internal/src/index.ts b/packages/core/theme/core-theme-browser-internal/src/index.ts index 8e698a6bc226..48cbb5c6848d 100644 --- a/packages/core/theme/core-theme-browser-internal/src/index.ts +++ b/packages/core/theme/core-theme-browser-internal/src/index.ts @@ -9,3 +9,4 @@ export { ThemeService } from './theme_service'; export { CoreThemeProvider } from './core_theme_provider'; export type { ThemeServiceSetupDeps } from './theme_service'; +export { CoreContextProvider } from './core_context_provider'; diff --git a/src/core/public/core_system.test.mocks.ts b/src/core/public/core_system.test.mocks.ts index 25bbe39ddcc2..9899e6c345ab 100644 --- a/src/core/public/core_system.test.mocks.ts +++ b/src/core/public/core_system.test.mocks.ts @@ -12,7 +12,7 @@ import { themeServiceMock } from '@kbn/core-theme-browser-mocks'; import { analyticsServiceMock } from '@kbn/core-analytics-browser-mocks'; import { applicationServiceMock } from './application/application_service.mock'; import { chromeServiceMock } from './chrome/chrome_service.mock'; -import { fatalErrorsServiceMock } from './fatal_errors/fatal_errors_service.mock'; +import { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks'; import { httpServiceMock } from './http/http_service.mock'; import { i18nServiceMock } from '@kbn/core-i18n-browser-mocks'; import { notificationServiceMock } from './notifications/notifications_service.mock'; @@ -48,7 +48,7 @@ export const MockFatalErrorsService = fatalErrorsServiceMock.create(); export const FatalErrorsServiceConstructor = jest .fn() .mockImplementation(() => MockFatalErrorsService); -jest.doMock('./fatal_errors', () => ({ +jest.doMock('@kbn/core-fatal-errors-browser-internal', () => ({ FatalErrorsService: FatalErrorsServiceConstructor, })); diff --git a/src/core/public/core_system.ts b/src/core/public/core_system.ts index bdf94d953b65..1dbb16b274ff 100644 --- a/src/core/public/core_system.ts +++ b/src/core/public/core_system.ts @@ -18,9 +18,10 @@ import { ThemeService } from '@kbn/core-theme-browser-internal'; import type { AnalyticsServiceSetup, AnalyticsServiceStart } from '@kbn/core-analytics-browser'; import { AnalyticsService } from '@kbn/core-analytics-browser-internal'; import { I18nService } from '@kbn/core-i18n-browser-internal'; +import type { FatalErrorsSetup } from '@kbn/core-fatal-errors-browser'; +import { FatalErrorsService } from '@kbn/core-fatal-errors-browser-internal'; import { CoreSetup, CoreStart } from '.'; import { ChromeService } from './chrome'; -import { FatalErrorsService, FatalErrorsSetup } from './fatal_errors'; import { HttpService } from './http'; import { NotificationsService } from './notifications'; import { OverlayService } from './overlays'; diff --git a/src/core/public/http/http_service.test.ts b/src/core/public/http/http_service.test.ts index af6e2343d5f8..0a844dfe2f4b 100644 --- a/src/core/public/http/http_service.test.ts +++ b/src/core/public/http/http_service.test.ts @@ -10,7 +10,7 @@ import fetchMock from 'fetch-mock/es5/client'; import { loadingServiceMock } from './http_service.test.mocks'; -import { fatalErrorsServiceMock } from '../fatal_errors/fatal_errors_service.mock'; +import { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks'; import { injectedMetadataServiceMock } from '@kbn/core-injected-metadata-browser-mocks'; import { HttpService } from './http_service'; import { Observable } from 'rxjs'; diff --git a/src/core/public/http/http_service.ts b/src/core/public/http/http_service.ts index 4507b808e5a4..57e5bc7ef2d7 100644 --- a/src/core/public/http/http_service.ts +++ b/src/core/public/http/http_service.ts @@ -8,8 +8,8 @@ import type { CoreService } from '@kbn/core-base-browser-internal'; import type { InternalInjectedMetadataSetup } from '@kbn/core-injected-metadata-browser-internal'; +import type { FatalErrorsSetup } from '@kbn/core-fatal-errors-browser'; import { HttpSetup, HttpStart } from './types'; -import { FatalErrorsSetup } from '../fatal_errors'; import { BasePath } from './base_path'; import { AnonymousPathsService } from './anonymous_paths_service'; import { LoadingCountService } from './loading_count_service'; diff --git a/src/core/public/http/loading_count_service.test.ts b/src/core/public/http/loading_count_service.test.ts index e933e93b4bde..041af203c8b3 100644 --- a/src/core/public/http/loading_count_service.test.ts +++ b/src/core/public/http/loading_count_service.test.ts @@ -9,7 +9,7 @@ import { Observable, throwError, of, Subject } from 'rxjs'; import { toArray } from 'rxjs/operators'; -import { fatalErrorsServiceMock } from '../fatal_errors/fatal_errors_service.mock'; +import { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks'; import { LoadingCountService } from './loading_count_service'; describe('LoadingCountService', () => { diff --git a/src/core/public/http/loading_count_service.ts b/src/core/public/http/loading_count_service.ts index c2ae7433b82c..4df60e53f9c6 100644 --- a/src/core/public/http/loading_count_service.ts +++ b/src/core/public/http/loading_count_service.ts @@ -17,7 +17,7 @@ import { tap, } from 'rxjs/operators'; import type { CoreService } from '@kbn/core-base-browser-internal'; -import { FatalErrorsSetup } from '../fatal_errors'; +import type { FatalErrorsSetup } from '@kbn/core-fatal-errors-browser'; /** @public */ export interface LoadingCountSetup { diff --git a/src/core/public/index.ts b/src/core/public/index.ts index 5162cdac1024..e16aa3ec174c 100644 --- a/src/core/public/index.ts +++ b/src/core/public/index.ts @@ -35,6 +35,11 @@ import type { ThemeServiceSetup, ThemeServiceStart } from '@kbn/core-theme-brows import type { AnalyticsServiceSetup, AnalyticsServiceStart } from '@kbn/core-analytics-browser'; import type { I18nStart } from '@kbn/core-i18n-browser'; +import type { + FatalErrorsSetup, + FatalErrorsStart, + FatalErrorInfo, +} from '@kbn/core-fatal-errors-browser'; import { ChromeBadge, ChromeBreadcrumb, @@ -57,7 +62,6 @@ import { NavType, ChromeHelpMenuActions, } from './chrome'; -import { FatalErrorsSetup, FatalErrorsStart, FatalErrorInfo } from './fatal_errors'; import { HttpSetup, HttpStart } from './http'; import { NotificationsSetup, NotificationsStart } from './notifications'; import { OverlayStart } from './overlays'; diff --git a/src/core/public/kbn_bootstrap.test.mocks.ts b/src/core/public/kbn_bootstrap.test.mocks.ts index b1b48b1a21ab..0e3a9ca95d35 100644 --- a/src/core/public/kbn_bootstrap.test.mocks.ts +++ b/src/core/public/kbn_bootstrap.test.mocks.ts @@ -7,7 +7,7 @@ */ import { applicationServiceMock } from './application/application_service.mock'; -import { fatalErrorsServiceMock } from './fatal_errors/fatal_errors_service.mock'; +import { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks'; export const fatalErrorMock = fatalErrorsServiceMock.createSetupContract(); export const coreSystemMock = { setup: jest.fn().mockResolvedValue({ diff --git a/src/core/public/mocks.ts b/src/core/public/mocks.ts index 3a1f03f5ea78..c905526fc257 100644 --- a/src/core/public/mocks.ts +++ b/src/core/public/mocks.ts @@ -15,12 +15,12 @@ import { analyticsServiceMock } from '@kbn/core-analytics-browser-mocks'; // Only import types from '.' to avoid triggering default Jest mocks. import { i18nServiceMock } from '@kbn/core-i18n-browser-mocks'; +import { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks'; import { PluginInitializerContext, AppMountParameters } from '.'; // Import values from their individual modules instead. import { ScopedHistory } from './application'; import { applicationServiceMock } from './application/application_service.mock'; import { chromeServiceMock } from './chrome/chrome_service.mock'; -import { fatalErrorsServiceMock } from './fatal_errors/fatal_errors_service.mock'; import { httpServiceMock } from './http/http_service.mock'; import { notificationServiceMock } from './notifications/notifications_service.mock'; import { overlayServiceMock } from './overlays/overlay_service.mock'; @@ -35,7 +35,7 @@ export { themeServiceMock } from '@kbn/core-theme-browser-mocks'; export { analyticsServiceMock } from '@kbn/core-analytics-browser-mocks'; export { chromeServiceMock } from './chrome/chrome_service.mock'; export { executionContextServiceMock } from './execution_context/execution_context_service.mock'; -export { fatalErrorsServiceMock } from './fatal_errors/fatal_errors_service.mock'; +export { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks'; export { httpServiceMock } from './http/http_service.mock'; export { i18nServiceMock } from '@kbn/core-i18n-browser-mocks'; export { notificationServiceMock } from './notifications/notifications_service.mock'; diff --git a/src/core/public/notifications/toasts/toasts_service.tsx b/src/core/public/notifications/toasts/toasts_service.tsx index 045da1fc24d0..63edd5608579 100644 --- a/src/core/public/notifications/toasts/toasts_service.tsx +++ b/src/core/public/notifications/toasts/toasts_service.tsx @@ -11,11 +11,11 @@ import { render, unmountComponentAtNode } from 'react-dom'; import type { ThemeServiceStart } from '@kbn/core-theme-browser'; import type { I18nStart } from '@kbn/core-i18n-browser'; +import { CoreContextProvider } from '@kbn/core-theme-browser-internal'; import { IUiSettingsClient } from '../../ui_settings'; import { GlobalToastList } from './global_toast_list'; import { ToastsApi, IToasts } from './toasts_api'; import { OverlayStart } from '../../overlays'; -import { CoreContextProvider } from '../../utils'; interface SetupDeps { uiSettings: IUiSettingsClient; diff --git a/src/core/public/overlays/flyout/flyout_service.tsx b/src/core/public/overlays/flyout/flyout_service.tsx index 701915113bb5..186517890412 100644 --- a/src/core/public/overlays/flyout/flyout_service.tsx +++ b/src/core/public/overlays/flyout/flyout_service.tsx @@ -14,9 +14,10 @@ import { render, unmountComponentAtNode } from 'react-dom'; import { Subject } from 'rxjs'; import type { ThemeServiceStart } from '@kbn/core-theme-browser'; import type { I18nStart } from '@kbn/core-i18n-browser'; +import { CoreContextProvider } from '@kbn/core-theme-browser-internal'; import { MountPoint } from '../../types'; import { OverlayRef } from '../types'; -import { MountWrapper, CoreContextProvider } from '../../utils'; +import { MountWrapper } from '../../utils'; /** * A FlyoutRef is a reference to an opened flyout panel. It offers methods to diff --git a/src/core/public/overlays/modal/modal_service.tsx b/src/core/public/overlays/modal/modal_service.tsx index 0195fb2b5bf1..5645ed5c2b8a 100644 --- a/src/core/public/overlays/modal/modal_service.tsx +++ b/src/core/public/overlays/modal/modal_service.tsx @@ -15,9 +15,10 @@ import { render, unmountComponentAtNode } from 'react-dom'; import { Subject } from 'rxjs'; import type { ThemeServiceStart } from '@kbn/core-theme-browser'; import type { I18nStart } from '@kbn/core-i18n-browser'; +import { CoreContextProvider } from '@kbn/core-theme-browser-internal'; import { MountPoint } from '../../types'; import { OverlayRef } from '../types'; -import { MountWrapper, CoreContextProvider } from '../../utils'; +import { MountWrapper } from '../../utils'; /** * A ModalRef is a reference to an opened modal. It offers methods to diff --git a/src/core/public/plugins/plugins_service.test.ts b/src/core/public/plugins/plugins_service.test.ts index b3d0ab8f295a..98320dda7a3a 100644 --- a/src/core/public/plugins/plugins_service.test.ts +++ b/src/core/public/plugins/plugins_service.test.ts @@ -30,7 +30,7 @@ import { applicationServiceMock } from '../application/application_service.mock' import { i18nServiceMock } from '@kbn/core-i18n-browser-mocks'; import { overlayServiceMock } from '../overlays/overlay_service.mock'; import { chromeServiceMock } from '../chrome/chrome_service.mock'; -import { fatalErrorsServiceMock } from '../fatal_errors/fatal_errors_service.mock'; +import { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks'; import { uiSettingsServiceMock } from '../ui_settings/ui_settings_service.mock'; import { injectedMetadataServiceMock } from '@kbn/core-injected-metadata-browser-mocks'; import { httpServiceMock } from '../http/http_service.mock'; diff --git a/src/core/public/rendering/rendering_service.tsx b/src/core/public/rendering/rendering_service.tsx index 48031db64897..1a656877d924 100644 --- a/src/core/public/rendering/rendering_service.tsx +++ b/src/core/public/rendering/rendering_service.tsx @@ -12,10 +12,10 @@ import { pairwise, startWith } from 'rxjs/operators'; import type { ThemeServiceStart } from '@kbn/core-theme-browser'; import type { I18nStart } from '@kbn/core-i18n-browser'; +import { CoreContextProvider } from '@kbn/core-theme-browser-internal'; import type { InternalChromeStart } from '../chrome'; import type { InternalApplicationStart } from '../application'; import type { OverlayStart } from '../overlays'; -import { CoreContextProvider } from '../utils'; import { AppWrapper } from './app_containers'; export interface StartDeps { diff --git a/src/core/public/utils/index.ts b/src/core/public/utils/index.ts index 4fb9c50f715c..812862c499da 100644 --- a/src/core/public/utils/index.ts +++ b/src/core/public/utils/index.ts @@ -8,5 +8,4 @@ export { Sha256 } from './crypto'; export { MountWrapper, mountReactNode } from './mount'; -export { CoreContextProvider } from './core_context_provider'; export { KBN_LOAD_MARKS } from './consts'; diff --git a/src/core/test_helpers/http_test_setup.ts b/src/core/test_helpers/http_test_setup.ts index 2a7d6451319c..6adc0be8b744 100644 --- a/src/core/test_helpers/http_test_setup.ts +++ b/src/core/test_helpers/http_test_setup.ts @@ -7,8 +7,8 @@ */ import { injectedMetadataServiceMock } from '@kbn/core-injected-metadata-browser-mocks'; +import { fatalErrorsServiceMock } from '@kbn/core-fatal-errors-browser-mocks'; import { HttpService } from '../public/http'; -import { fatalErrorsServiceMock } from '../public/fatal_errors/fatal_errors_service.mock'; import { executionContextServiceMock } from '../public/execution_context/execution_context_service.mock'; export type SetupTap = ( diff --git a/yarn.lock b/yarn.lock index 5233110b1f99..fbbbbf9b85d6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3099,6 +3099,18 @@ version "0.0.0" uid "" +"@kbn/core-fatal-errors-browser-internal@link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser-internal": + version "0.0.0" + uid "" + +"@kbn/core-fatal-errors-browser-mocks@link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser-mocks": + version "0.0.0" + uid "" + +"@kbn/core-fatal-errors-browser@link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser": + version "0.0.0" + uid "" + "@kbn/core-i18n-browser-internal@link:bazel-bin/packages/core/i18n/core-i18n-browser-internal": version "0.0.0" uid "" @@ -6542,6 +6554,18 @@ version "0.0.0" uid "" +"@types/kbn__core-fatal-errors-browser-internal@link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser-internal/npm_module_types": + version "0.0.0" + uid "" + +"@types/kbn__core-fatal-errors-browser-mocks@link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser-mocks/npm_module_types": + version "0.0.0" + uid "" + +"@types/kbn__core-fatal-errors-browser@link:bazel-bin/packages/core/fatal-errors/core-fatal-errors-browser/npm_module_types": + version "0.0.0" + uid "" + "@types/kbn__core-i18n-browser-internal@link:bazel-bin/packages/core/i18n/core-i18n-browser-internal/npm_module_types": version "0.0.0" uid ""