@shuvi/error-overlay 1.0.16 → 1.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/package.json +3 -3
  2. package/umd/client.d.ts +15 -0
  3. package/umd/constants.d.ts +7 -0
  4. package/umd/iframeScript.d.ts +1 -0
  5. package/umd/index.d.ts +2 -0
  6. package/umd/middleware/helper/createOriginalStackFrame.d.ts +15 -0
  7. package/umd/middleware/helper/findOriginalSourcePositionAndContent.d.ts +7 -0
  8. package/umd/middleware/helper/getModuleById.d.ts +2 -0
  9. package/umd/middleware/helper/getOriginalStackFrame.d.ts +6 -0
  10. package/umd/middleware/helper/getSourceById.d.ts +6 -0
  11. package/umd/middleware/helper/getSourceMapUrl.d.ts +1 -0
  12. package/umd/middleware/helper/getSourcePath.d.ts +1 -0
  13. package/umd/middleware/index.d.ts +2 -0
  14. package/umd/middleware/launchEditorMiddleware.d.ts +2 -0
  15. package/umd/middleware/stackFrameMiddleware.d.ts +2 -0
  16. package/umd/view/ErrorOverlay.d.ts +2 -0
  17. package/umd/view/components/Dialog/Dialog.d.ts +10 -0
  18. package/umd/view/components/Dialog/DialogBody.d.ts +7 -0
  19. package/umd/view/components/Dialog/DialogContent.d.ts +7 -0
  20. package/umd/view/components/Dialog/DialogHeader.d.ts +7 -0
  21. package/umd/view/components/Dialog/index.d.ts +5 -0
  22. package/umd/view/components/Dialog/styles.d.ts +2 -0
  23. package/umd/view/components/Errors/CallStackFrame/CallStackFrame.d.ts +10 -0
  24. package/umd/view/components/Errors/CallStackFrame/index.d.ts +1 -0
  25. package/umd/view/components/Errors/CodeFrame/CodeFrame.d.ts +7 -0
  26. package/umd/view/components/Errors/CodeFrame/index.d.ts +1 -0
  27. package/umd/view/components/Errors/Errors.d.ts +7 -0
  28. package/umd/view/components/Errors/index.d.ts +2 -0
  29. package/umd/view/components/Errors/styles.d.ts +1 -0
  30. package/umd/view/components/Icons/ArrowLeftIcon.d.ts +3 -0
  31. package/umd/view/components/Icons/ArrowRightIcon.d.ts +3 -0
  32. package/umd/view/components/Icons/CloseIcon.d.ts +3 -0
  33. package/umd/view/components/Icons/ExternalLinkIcon.d.ts +3 -0
  34. package/umd/view/components/Icons/WarningIcon.d.ts +3 -0
  35. package/umd/view/components/Icons/index.d.ts +5 -0
  36. package/umd/view/components/NavigationBar/NavigationBar.d.ts +10 -0
  37. package/umd/view/components/NavigationBar/index.d.ts +2 -0
  38. package/umd/view/components/NavigationBar/styles.d.ts +2 -0
  39. package/umd/view/components/Overlay/Overlay.d.ts +8 -0
  40. package/umd/view/components/Overlay/body-locker.d.ts +2 -0
  41. package/umd/view/components/Overlay/index.d.ts +2 -0
  42. package/umd/view/components/Overlay/styles.d.ts +2 -0
  43. package/umd/view/components/ShadowPortal.d.ts +5 -0
  44. package/umd/view/components/Terminal/Terminal.d.ts +5 -0
  45. package/umd/view/components/Terminal/index.d.ts +2 -0
  46. package/umd/view/components/Terminal/styles.d.ts +2 -0
  47. package/umd/view/components/Toast/Toast.d.ts +7 -0
  48. package/umd/view/components/Toast/index.d.ts +2 -0
  49. package/umd/view/components/Toast/styles.d.ts +2 -0
  50. package/umd/view/container/BuildError.d.ts +6 -0
  51. package/umd/view/container/RuntimeError.d.ts +11 -0
  52. package/umd/view/container/index.d.ts +2 -0
  53. package/umd/view/errorTypeHandler.d.ts +27 -0
  54. package/umd/view/helpers/getErrorByType.d.ts +9 -0
  55. package/umd/view/helpers/nodeStackFrames.d.ts +7 -0
  56. package/umd/view/helpers/noop-template.d.ts +1 -0
  57. package/umd/view/helpers/parseStack.d.ts +3 -0
  58. package/umd/view/helpers/stack-frame.d.ts +12 -0
  59. package/umd/view/hooks/use-on-click-outside.d.ts +1 -0
  60. package/umd/view/styles/Base.d.ts +2 -0
  61. package/umd/view/styles/ComponentStyles.d.ts +2 -0
  62. package/umd/view/styles/CssReset.d.ts +2 -0
  63. package/umd/view/styles/index.d.ts +3 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuvi/error-overlay",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "main": "umd/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "files": [
@@ -23,8 +23,8 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@babel/code-frame": "7.14.5",
26
- "@shuvi/shared": "1.0.16",
27
- "@shuvi/toolpack": "1.0.16",
26
+ "@shuvi/shared": "1.0.18",
27
+ "@shuvi/toolpack": "1.0.18",
28
28
  "anser": "1.4.9",
29
29
  "data-uri-to-buffer": "3.0.1",
30
30
  "html-entities": "2.3.2",
@@ -0,0 +1,15 @@
1
+ declare global {
2
+ interface Window {
3
+ __SHUVI_ERROR_OVERLAY_GLOBAL_HOOK__: string | {};
4
+ }
5
+ }
6
+ declare function startReportingRuntimeErrors({ onError }: {
7
+ onError: () => void;
8
+ }): void;
9
+ declare function stopReportingRuntimeErrors(): void;
10
+ declare function onBuildOk(): void;
11
+ declare function onBuildError(message: string): void;
12
+ declare function onRefresh(): void;
13
+ export { getErrorByType } from './view/helpers/getErrorByType';
14
+ export { getServerError } from './view/helpers/nodeStackFrames';
15
+ export { onBuildError, onBuildOk, onRefresh, startReportingRuntimeErrors, stopReportingRuntimeErrors };
@@ -0,0 +1,7 @@
1
+ export declare const SERVER_TYPE_ERROR = "server";
2
+ export declare const TYPE_BUILD_OK = "build-ok";
3
+ export declare const TYPE_REFRESH = "fast-refresh";
4
+ export declare const TYPE_BUILD_ERROR = "build-error";
5
+ export declare const TYPE_UNHANDLED_ERROR = "unhandled-error";
6
+ export declare const TYPE_UNHANDLED_REJECTION = "unhandled-rejection";
7
+ export declare const STACK_TRACE_LIMIT = 50;
@@ -0,0 +1 @@
1
+ export {};
package/umd/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './client';
2
+ export { getServerError } from './view/helpers/nodeStackFrames';
@@ -0,0 +1,15 @@
1
+ import { StackFrame } from 'stacktrace-parser';
2
+ import type webpack from '@shuvi/toolpack/lib/webpack';
3
+ export declare type OriginalStackFrameResponse = {
4
+ originalStackFrame: StackFrame;
5
+ originalCodeFrame: string | null;
6
+ };
7
+ export declare function createOriginalStackFrame({ line, column, source, modulePath, frame, errorMessage, compilation }: {
8
+ line: number;
9
+ column: number | null;
10
+ source: any;
11
+ modulePath?: string;
12
+ frame: any;
13
+ errorMessage?: string;
14
+ compilation?: webpack.Compilation;
15
+ }): Promise<OriginalStackFrameResponse | null>;
@@ -0,0 +1,7 @@
1
+ export declare function findOriginalSourcePositionAndContent(webpackSource: any, position: {
2
+ line: number;
3
+ column: number | null;
4
+ }): Promise<{
5
+ sourcePosition: NullableMappedPosition;
6
+ sourceContent: string | null;
7
+ } | null>;
@@ -0,0 +1,2 @@
1
+ import type webpack from '@shuvi/toolpack/lib/webpack';
2
+ export declare function getModuleById(id: string | undefined, compilation: webpack.Compilation): webpack.Module | undefined;
@@ -0,0 +1,6 @@
1
+ import type { StackFrame } from 'stacktrace-parser';
2
+ import type webpack from '@shuvi/toolpack/lib/webpack';
3
+ import type { Source } from './getSourceById';
4
+ import type { OriginalStackFrame } from '../../view/helpers/stack-frame';
5
+ export { OriginalStackFrame };
6
+ export declare function getOriginalStackFrame(frame: StackFrame, cache: Map<string, Source | null>, resolveBuildFile: (...paths: string[]) => string, buildDir: string, errorMessage?: string, compilation?: webpack.Compilation): Promise<OriginalStackFrame>;
@@ -0,0 +1,6 @@
1
+ import { RawSourceMap } from 'source-map';
2
+ import type { webpack } from '@shuvi/toolpack/lib/webpack';
3
+ export declare type Source = {
4
+ map: () => RawSourceMap;
5
+ } | null;
6
+ export declare function getSourceById(isFile: boolean, id: string, compiler: webpack.Compiler, resolveBuildFile: (...paths: string[]) => string, buildDir: string, compilation?: webpack.Compilation): Promise<Source>;
@@ -0,0 +1 @@
1
+ export declare function getSourceMapUrl(fileContents: string): string | null;
@@ -0,0 +1 @@
1
+ export declare function getSourcePath(source: string): string;
@@ -0,0 +1,2 @@
1
+ export { launchEditorMiddleware } from './launchEditorMiddleware';
2
+ export { stackFrameMiddleware } from './stackFrameMiddleware';
@@ -0,0 +1,2 @@
1
+ import { IncomingMessage, ServerResponse } from 'http';
2
+ export declare function launchEditorMiddleware(launchEditorEndpoint: string, rootDir: string): (req: IncomingMessage, res: ServerResponse, next: Function) => void;
@@ -0,0 +1,2 @@
1
+ import { IncomingMessage, ServerResponse } from 'http';
2
+ export declare function stackFrameMiddleware(originalStackFrameEndpoint: string, bundler: any, resolveBuildFile: (...paths: string[]) => string, buildDefaultDir: string, buildServerDir: string): (req: IncomingMessage, res: ServerResponse, next: Function) => Promise<any>;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const ErrorOverlay: () => JSX.Element;
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ export declare type DialogProps = {
3
+ type: 'error' | 'warning';
4
+ 'aria-labelledby': string;
5
+ 'aria-describedby': string;
6
+ onClose?: (e: MouseEvent | TouchEvent) => void;
7
+ children: React.ReactNode;
8
+ };
9
+ declare const Dialog: React.FC<DialogProps>;
10
+ export { Dialog };
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ export declare type DialogBodyProps = {
3
+ className?: string;
4
+ children: React.ReactNode;
5
+ };
6
+ declare const DialogBody: React.FC<DialogBodyProps>;
7
+ export { DialogBody };
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ export declare type DialogContentProps = {
3
+ className?: string;
4
+ children: React.ReactNode;
5
+ };
6
+ declare const DialogContent: React.FC<DialogContentProps>;
7
+ export { DialogContent };
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ export declare type DialogHeaderProps = {
3
+ className?: string;
4
+ children: React.ReactNode;
5
+ };
6
+ declare const DialogHeader: React.FC<DialogHeaderProps>;
7
+ export { DialogHeader };
@@ -0,0 +1,5 @@
1
+ export { Dialog } from './Dialog';
2
+ export { DialogBody } from './DialogBody';
3
+ export { DialogContent } from './DialogContent';
4
+ export { DialogHeader } from './DialogHeader';
5
+ export { styles } from './styles';
@@ -0,0 +1,2 @@
1
+ declare const styles: string;
2
+ export { styles };
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { StackFrame } from 'stacktrace-parser';
3
+ import { OriginalStackFrame } from '../../../helpers/stack-frame';
4
+ export declare type CallStackFrameProps = {
5
+ stackFrame: StackFrame;
6
+ codeFrame: string;
7
+ };
8
+ export declare const CallStackFrame: React.FC<{
9
+ frame: OriginalStackFrame;
10
+ }>;
@@ -0,0 +1 @@
1
+ export { CallStackFrame } from './CallStackFrame';
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { StackFrame } from 'stacktrace-parser';
3
+ export declare type CodeFrameProps = {
4
+ stackFrame: StackFrame;
5
+ codeFrame: string;
6
+ };
7
+ export declare const CodeFrame: React.FC<CodeFrameProps>;
@@ -0,0 +1 @@
1
+ export { CodeFrame } from './CodeFrame';
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { ReadyRuntimeError } from '../../helpers/getErrorByType';
3
+ export declare type ErrorsProps = {
4
+ error: ReadyRuntimeError;
5
+ };
6
+ declare const Errors: React.FC<ErrorsProps>;
7
+ export { Errors };
@@ -0,0 +1,2 @@
1
+ export { Errors } from './Errors';
2
+ export { styles } from './styles';
@@ -0,0 +1 @@
1
+ export declare const styles: string;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const ArrowLeftIcon: () => JSX.Element;
3
+ export { ArrowLeftIcon };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const ArrowRightIcon: () => JSX.Element;
3
+ export { ArrowRightIcon };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const CloseIcon: () => JSX.Element;
3
+ export { CloseIcon };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const ExternalLinkIcon: () => JSX.Element;
3
+ export { ExternalLinkIcon };
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const WarningIcon: () => JSX.Element;
3
+ export { WarningIcon };
@@ -0,0 +1,5 @@
1
+ export { CloseIcon } from './CloseIcon';
2
+ export { WarningIcon } from './WarningIcon';
3
+ export { ExternalLinkIcon } from './ExternalLinkIcon';
4
+ export { ArrowLeftIcon } from './ArrowLeftIcon';
5
+ export { ArrowRightIcon } from './ArrowRightIcon';
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ export declare type NavigationBarProps = {
3
+ className?: string;
4
+ previous: (() => void) | null;
5
+ next: (() => void) | null;
6
+ close?: () => void;
7
+ children: React.ReactNode;
8
+ };
9
+ declare const NavigationBar: React.FC<NavigationBarProps>;
10
+ export { NavigationBar };
@@ -0,0 +1,2 @@
1
+ export { NavigationBar } from './NavigationBar';
2
+ export { styles } from './styles';
@@ -0,0 +1,2 @@
1
+ declare const styles: string;
2
+ export { styles };
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ export declare type OverlayProps = {
3
+ className?: string;
4
+ fixed?: boolean;
5
+ children?: React.ReactNode;
6
+ };
7
+ declare const Overlay: React.FC<OverlayProps>;
8
+ export { Overlay };
@@ -0,0 +1,2 @@
1
+ export declare function lock(): void;
2
+ export declare function unlock(): void;
@@ -0,0 +1,2 @@
1
+ export { Overlay } from './Overlay';
2
+ export { styles } from './styles';
@@ -0,0 +1,2 @@
1
+ declare const styles: string;
2
+ export { styles };
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export declare type ShadowPortalProps = {
3
+ children: React.ReactNode;
4
+ };
5
+ export declare const ShadowPortal: React.FC<ShadowPortalProps>;
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export declare type TerminalProps = {
3
+ content: string;
4
+ };
5
+ export declare const Terminal: React.FC<TerminalProps>;
@@ -0,0 +1,2 @@
1
+ export { Terminal } from './Terminal';
2
+ export { styles } from './styles';
@@ -0,0 +1,2 @@
1
+ declare const styles: string;
2
+ export { styles };
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ export declare type ToastProps = {
3
+ onClick?: (ev: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
4
+ className?: string;
5
+ children: React.ReactNode;
6
+ };
7
+ export declare const Toast: React.FC<ToastProps>;
@@ -0,0 +1,2 @@
1
+ export { Toast } from './Toast';
2
+ export { styles } from './styles';
@@ -0,0 +1,2 @@
1
+ declare const styles: string;
2
+ export { styles };
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ export declare type BuildErrorProps = {
3
+ error: string;
4
+ };
5
+ export declare const BuildError: React.FC<BuildErrorProps>;
6
+ export declare const styles: string;
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import { UnhandledError, UnhandledRejection } from '../errorTypeHandler';
3
+ export declare type SupportedErrorEvent = {
4
+ id: number;
5
+ event: UnhandledError | UnhandledRejection;
6
+ };
7
+ export declare type RuntimeErrorProps = {
8
+ errors: SupportedErrorEvent[];
9
+ };
10
+ export declare const RuntimeError: React.FC<RuntimeErrorProps>;
11
+ export declare const styles: string;
@@ -0,0 +1,2 @@
1
+ export { BuildError } from './BuildError';
2
+ export { RuntimeError } from './RuntimeError';
@@ -0,0 +1,27 @@
1
+ import { StackFrame } from 'stacktrace-parser';
2
+ import { TYPE_BUILD_OK, TYPE_REFRESH, TYPE_BUILD_ERROR, TYPE_UNHANDLED_ERROR, TYPE_UNHANDLED_REJECTION } from '../constants';
3
+ export declare type BuildOk = {
4
+ type: typeof TYPE_BUILD_OK;
5
+ };
6
+ export declare type FastRefresh = {
7
+ type: typeof TYPE_REFRESH;
8
+ };
9
+ export declare type BuildError = {
10
+ type: typeof TYPE_BUILD_ERROR;
11
+ message: string;
12
+ };
13
+ export declare type UnhandledError = {
14
+ type: typeof TYPE_UNHANDLED_ERROR;
15
+ reason: Error;
16
+ frames: StackFrame[];
17
+ };
18
+ export declare type UnhandledRejection = {
19
+ type: typeof TYPE_UNHANDLED_REJECTION;
20
+ reason: Error;
21
+ frames: StackFrame[];
22
+ };
23
+ export declare type ErrorTypeEvent = BuildOk | FastRefresh | BuildError | UnhandledError | UnhandledRejection;
24
+ export declare type ErrorTypeEventHandler = (ev: ErrorTypeEvent) => void;
25
+ export declare function emit(ev: ErrorTypeEvent): void;
26
+ export declare function on(fn: ErrorTypeEventHandler): boolean;
27
+ export declare function off(fn: ErrorTypeEventHandler): boolean;
@@ -0,0 +1,9 @@
1
+ import { SupportedErrorEvent } from '../container/RuntimeError';
2
+ import { OriginalStackFrame } from './stack-frame';
3
+ export declare type ReadyRuntimeError = {
4
+ id: number;
5
+ runtime: true;
6
+ error: Error;
7
+ frames: OriginalStackFrame[];
8
+ };
9
+ export declare function getErrorByType(ev: SupportedErrorEvent): Promise<ReadyRuntimeError>;
@@ -0,0 +1,7 @@
1
+ import { StackFrame } from 'stacktrace-parser';
2
+ declare type ErrorType = 'server';
3
+ export declare function getFilesystemFrame(frame: StackFrame): StackFrame;
4
+ export declare function decorateServerError(error: Error): void;
5
+ export declare function getServerError(error: Error): Error;
6
+ export declare function getErrorSource(error: Error): ErrorType | null;
7
+ export {};
@@ -0,0 +1 @@
1
+ export declare function noop(strings: TemplateStringsArray, ...keys: readonly string[]): string;
@@ -0,0 +1,3 @@
1
+ import { StackFrame } from 'stacktrace-parser';
2
+ export declare function parseError(stack: string): string;
3
+ export declare function parseStack(stack: string): StackFrame[];
@@ -0,0 +1,12 @@
1
+ import { StackFrame } from 'stacktrace-parser';
2
+ export declare type OriginalStackFrame = {
3
+ error: boolean;
4
+ reason: string | null;
5
+ external: boolean;
6
+ expanded: boolean;
7
+ sourceStackFrame: StackFrame;
8
+ originalStackFrame: StackFrame | null;
9
+ originalCodeFrame: string | null;
10
+ };
11
+ export declare function getOriginalStackFrames(frames: StackFrame[], type: 'server' | null, errorMessage: string): Promise<OriginalStackFrame[]>;
12
+ export declare function getFrameSource(frame: StackFrame): string;
@@ -0,0 +1 @@
1
+ export declare function useOnClickOutside(el: Node | null, handler: ((e: MouseEvent | TouchEvent) => void) | undefined): void;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function Base(): JSX.Element;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function ComponentStyles(): JSX.Element;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function CssReset(): JSX.Element;
@@ -0,0 +1,3 @@
1
+ export { Base } from './Base';
2
+ export { ComponentStyles } from './ComponentStyles';
3
+ export { CssReset } from './CssReset';