@visulima/ono 2.0.0-alpha.14 → 2.0.0-alpha.16

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 (35) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/error-inspector/page/create-request-context.d.ts +41 -3
  3. package/dist/index.d.ts +34 -18
  4. package/dist/index.js +114 -114
  5. package/dist/packem_shared/types.d-CDlBu_Vx.d.ts +50 -0
  6. package/dist/server/open-in-editor.d.ts +22 -22
  7. package/package.json +22 -22
  8. package/dist/error-inspector/components/causes-viewer/index.d.ts +0 -7
  9. package/dist/error-inspector/components/copy-button.d.ts +0 -8
  10. package/dist/error-inspector/components/copy-dropdown.d.ts +0 -10
  11. package/dist/error-inspector/components/error-card/index.d.ts +0 -13
  12. package/dist/error-inspector/components/error-card/solutions.d.ts +0 -7
  13. package/dist/error-inspector/components/error-card/sticky-header.d.ts +0 -5
  14. package/dist/error-inspector/components/header-bar/editor-selector.d.ts +0 -3
  15. package/dist/error-inspector/components/header-bar/index.d.ts +0 -11
  16. package/dist/error-inspector/components/header-bar/theme-toggle.d.ts +0 -6
  17. package/dist/error-inspector/components/header-tabs.d.ts +0 -10
  18. package/dist/error-inspector/components/raw-stack-trace.d.ts +0 -2
  19. package/dist/error-inspector/components/shortcuts-button.d.ts +0 -5
  20. package/dist/error-inspector/components/stack-trace-viewer/index.d.ts +0 -7
  21. package/dist/error-inspector/components/stack-trace-viewer/types.d.ts +0 -5
  22. package/dist/error-inspector/components/stack-trace-viewer/utils/get-type.d.ts +0 -3
  23. package/dist/error-inspector/components/stack-trace-viewer/utils/group-similar-types.d.ts +0 -4
  24. package/dist/error-inspector/components/tooltip.d.ts +0 -4
  25. package/dist/error-inspector/index.d.ts +0 -6
  26. package/dist/error-inspector/layout.d.ts +0 -12
  27. package/dist/error-inspector/page/stack.d.ts +0 -15
  28. package/dist/error-inspector/page/types.d.ts +0 -62
  29. package/dist/error-inspector/types.d.ts +0 -43
  30. package/dist/error-inspector/utils/cn.d.ts +0 -2
  31. package/dist/error-inspector/utils/sanitize.d.ts +0 -7
  32. package/dist/types.d.ts +0 -1
  33. package/dist/utils/process.d.ts +0 -7
  34. package/dist/utils/revision-hash.d.ts +0 -2
  35. package/dist/utils/runtimes.d.ts +0 -3
@@ -0,0 +1,50 @@
1
+ declare enum Editors {
2
+ appcode = "AppCode",
3
+ "android-studio" = "Android Studio",
4
+ atom = "Atom",
5
+ "atom-beta" = "Atom Beta",
6
+ brackets = "Brackets",
7
+ clion = "CLion",
8
+ code = "Visual Studio Code",
9
+ "code-insiders" = "Visual Studio Code Insiders",
10
+ codium = "VSCodium",
11
+ cursor = "Cursor",
12
+ emacs = "GNU Emacs",
13
+ emacsforosx = "GNU Emacs for Mac OS X",
14
+ intellij = "IntelliJ IDEA",
15
+ idea = "IntelliJ IDEA",
16
+ nano = "GNU nano",
17
+ neovim = "NeoVim",
18
+ "notepad++" = "Notepad++",
19
+ phpstorm = "PhpStorm",
20
+ pycharm = "PyCharm",
21
+ rider = "Rider",
22
+ rubymine = "RubyMine",
23
+ sublime = "SublimeText",
24
+ textmate = "TextMate",
25
+ vim = "Vim",
26
+ visualstudio = "Visual Studio",
27
+ vscode = "Visual Studio Code",
28
+ vscodium = "VSCodium",
29
+ webstorm = "WebStorm",
30
+ xcode = "Xcode",
31
+ zed = "Zed",
32
+ }
33
+ type Theme = "dark" | "light" | "auto";
34
+ type ContentPage = {
35
+ code: {
36
+ html: string;
37
+ script?: string;
38
+ };
39
+ defaultSelected?: boolean;
40
+ id: string;
41
+ name: string;
42
+ };
43
+ type TemplateOptions = {
44
+ content?: ContentPage[];
45
+ cspNonce?: string;
46
+ editor?: Editors;
47
+ openInEditorUrl?: string;
48
+ theme?: Theme;
49
+ };
50
+ export { ContentPage as C, TemplateOptions as T };
@@ -1,29 +1,29 @@
1
- import type { IncomingMessage, ServerResponse } from "node:http";
1
+ import { IncomingMessage, ServerResponse } from 'node:http';
2
2
  type RequestBody = Record<string, unknown>;
3
3
  type UniversalHandler = (request: IncomingMessage & {
4
- body?: RequestBody;
4
+ body?: RequestBody;
5
5
  }, response: ServerResponse, next?: (error?: unknown) => void) => Promise<void>;
6
6
  type NodeHttpHandler = (request: IncomingMessage & {
7
- body?: RequestBody;
7
+ body?: RequestBody;
8
8
  }, response: ServerResponse) => Promise<void>;
9
- export type OpenInEditorOptions = {
10
- allowOutsideProject?: boolean;
11
- projectRoot?: string;
9
+ type OpenInEditorOptions = {
10
+ allowOutsideProject?: boolean;
11
+ projectRoot?: string;
12
12
  };
13
13
  /**
14
- * Single universal handler factory for Node HTTP and Connect/Express.
15
- * Accepts POST JSON or GET query (?file&amp;line&amp;column&amp;editor).
16
- * Enforces projectRoot unless allowOutsideProject is true.
17
- * @example
18
- * ```typescript
19
- * const openInEditor = createOpenInEditorMiddleware({ projectRoot: process.cwd() })
20
- * // Node http
21
- * if (url.pathname === '/__open-in-editor') return openInEditor(req, res)
22
- * // Express/Connect
23
- * app.post('/__open-in-editor', openInEditor)
24
- * ```
25
- */
26
- export declare const createOpenInEditorMiddleware: (options?: OpenInEditorOptions) => UniversalHandler;
27
- export declare const createNodeHttpHandler: (options?: OpenInEditorOptions) => NodeHttpHandler;
28
- export declare const createExpressHandler: (options?: OpenInEditorOptions) => UniversalHandler;
29
- export {};
14
+ * Single universal handler factory for Node HTTP and Connect/Express.
15
+ * Accepts POST JSON or GET query (?file&amp;line&amp;column&amp;editor).
16
+ * Enforces projectRoot unless allowOutsideProject is true.
17
+ * @example
18
+ * ```typescript
19
+ * const openInEditor = createOpenInEditorMiddleware({ projectRoot: process.cwd() })
20
+ * // Node http
21
+ * if (url.pathname === '/__open-in-editor') return openInEditor(req, res)
22
+ * // Express/Connect
23
+ * app.post('/__open-in-editor', openInEditor)
24
+ * ```
25
+ */
26
+ declare const createOpenInEditorMiddleware: (options?: OpenInEditorOptions) => UniversalHandler;
27
+ declare const createNodeHttpHandler: (options?: OpenInEditorOptions) => NodeHttpHandler;
28
+ declare const createExpressHandler: (options?: OpenInEditorOptions) => UniversalHandler;
29
+ export { OpenInEditorOptions, createExpressHandler, createNodeHttpHandler, createOpenInEditorMiddleware };
package/package.json CHANGED
@@ -1,34 +1,34 @@
1
1
  {
2
2
  "name": "@visulima/ono",
3
- "version": "2.0.0-alpha.14",
3
+ "version": "2.0.0-alpha.16",
4
4
  "description": "Ono is an error-parsing library that pretty prints JavaScript errors on a web page or the terminal.",
5
5
  "keywords": [
6
- "visulima",
7
- "error",
8
- "exception",
9
- "error-inspector",
10
- "diagnostics",
11
- "debugging",
12
- "stacktrace",
6
+ "anolilab",
7
+ "browser",
8
+ "cli",
13
9
  "code-frame",
14
10
  "codeframe",
15
- "source-code-preview",
11
+ "connect",
12
+ "debugging",
13
+ "devtools",
14
+ "diagnostics",
15
+ "error",
16
+ "error-inspector",
17
+ "error-reporting",
18
+ "exception",
19
+ "express",
16
20
  "html-error",
21
+ "http-errors",
22
+ "node",
17
23
  "open-in-editor",
18
- "cli",
24
+ "source-code-preview",
25
+ "stacktrace",
19
26
  "terminal",
20
- "node",
27
+ "visulima",
21
28
  "web",
22
- "browser",
23
- "express",
24
- "connect",
25
- "http-errors",
26
- "devtools",
27
- "error-reporting",
29
+ "webpack",
28
30
  "whoops",
29
- "youch",
30
- "anolilab",
31
- "webpack"
31
+ "youch"
32
32
  ],
33
33
  "homepage": "https://visulima.com/packages/ono/",
34
34
  "repository": {
@@ -94,7 +94,7 @@
94
94
  },
95
95
  "dependencies": {
96
96
  "@shikijs/langs": "catalog:prod",
97
- "@visulima/error": "6.0.0-alpha.12",
97
+ "@visulima/error": "6.0.0-alpha.13",
98
98
  "isomorphic-dompurify": "catalog:prod",
99
99
  "launch-editor-middleware": "catalog:prod",
100
100
  "shiki": "catalog:syntax"
@@ -114,7 +114,7 @@
114
114
  "@types/http-errors": "catalog:types",
115
115
  "@types/node": "catalog:types",
116
116
  "@visulima/packem": "catalog:dev",
117
- "@visulima/path": "3.0.0-alpha.9",
117
+ "@visulima/path": "3.0.0-alpha.10",
118
118
  "@vitest/coverage-v8": "catalog:test",
119
119
  "cssnano": "catalog:dev",
120
120
  "esbuild": "catalog:build",
@@ -1,7 +0,0 @@
1
- declare const causes: (causeList: unknown[], options?: {
2
- openInEditorUrl?: string;
3
- }) => Promise<{
4
- html: string;
5
- script: string;
6
- }>;
7
- export default causes;
@@ -1,8 +0,0 @@
1
- declare const copyButton: ({ label, successText, targetId }: {
2
- label?: string;
3
- successText?: string;
4
- targetId: string;
5
- }) => {
6
- html: string;
7
- };
8
- export default copyButton;
@@ -1,10 +0,0 @@
1
- declare const copyDropdown: ({ label, secondaryLabel, secondaryText, successText, targetId, }: {
2
- label?: string;
3
- secondaryLabel?: string;
4
- secondaryText: string;
5
- successText?: string;
6
- targetId: string;
7
- }) => {
8
- html: string;
9
- };
10
- export default copyDropdown;
@@ -1,13 +0,0 @@
1
- import type { VisulimaError } from "@visulima/error/error";
2
- import type { SolutionError, SolutionFinder } from "@visulima/error/solution";
3
- import type { RuntimeName } from "../../../utils/runtimes.d.ts";
4
- declare const errorCard: ({ error, runtimeName, solutionFinders, version, }: {
5
- error: Error | SolutionError | VisulimaError;
6
- runtimeName: RuntimeName | undefined;
7
- solutionFinders: SolutionFinder[];
8
- version: string | undefined;
9
- }) => Promise<{
10
- html: string;
11
- scripts: string[];
12
- }>;
13
- export default errorCard;
@@ -1,7 +0,0 @@
1
- import type { VisulimaError } from "@visulima/error/error";
2
- import type { SolutionError, SolutionFinder } from "@visulima/error/solution";
3
- declare const solutions: (error: Error | SolutionError | VisulimaError, solutionFinders?: SolutionFinder[]) => Promise<{
4
- html: string;
5
- script: string;
6
- }>;
7
- export default solutions;
@@ -1,5 +0,0 @@
1
- declare const stickyHeader: (error: Error) => Promise<{
2
- html: string;
3
- script: string;
4
- }>;
5
- export default stickyHeader;
@@ -1,3 +0,0 @@
1
- import Editors from "../../../../../../../shared/utils/editors.d.ts";
2
- declare const editorSelector: (editor?: Editors) => string;
3
- export default editorSelector;
@@ -1,11 +0,0 @@
1
- import type Editors from "../../../../../../../shared/utils/editors.d.ts";
2
- import type { Theme } from "../../../types.d.ts";
3
- declare const headerBar: (options: Partial<{
4
- editor: Editors;
5
- openInEditorUrl?: string;
6
- theme: Theme;
7
- }>, hasContextTab?: boolean) => {
8
- html: string;
9
- script: string;
10
- };
11
- export default headerBar;
@@ -1,6 +0,0 @@
1
- import type { Theme } from "../../../types.d.ts";
2
- declare const themeToggle: (theme?: Theme) => {
3
- html: string;
4
- script: string;
5
- };
6
- export default themeToggle;
@@ -1,10 +0,0 @@
1
- export type HeaderTab = {
2
- icon?: string;
3
- id: string;
4
- name: string;
5
- selected?: boolean;
6
- };
7
- export declare const headerTabs: (tabs: HeaderTab[]) => {
8
- html: string;
9
- script: string;
10
- };
@@ -1,2 +0,0 @@
1
- declare const rawStackTrace: (stack?: string) => string;
2
- export default rawStackTrace;
@@ -1,5 +0,0 @@
1
- declare const shortcutsButton: () => {
2
- html: string;
3
- script: string;
4
- };
5
- export default shortcutsButton;
@@ -1,7 +0,0 @@
1
- declare const stackTraceViewer: (error: Error, options?: {
2
- openInEditorUrl?: string;
3
- }) => Promise<{
4
- html: string;
5
- script: string;
6
- }>;
7
- export default stackTraceViewer;
@@ -1,5 +0,0 @@
1
- export type GroupType = "internal" | "node_modules" | "webpack" | "native" | "bun" | undefined;
2
- export type Item = {
3
- html: string;
4
- type: GroupType;
5
- };
@@ -1,3 +0,0 @@
1
- import type { GroupType } from "../types.d.ts";
2
- declare const getType: (filePath: string) => GroupType;
3
- export default getType;
@@ -1,4 +0,0 @@
1
- import type { Item } from "../types.d.ts";
2
- type Grouped = Item | Item[];
3
- declare const groupSimilarTypes: (list: Item[]) => Grouped[];
4
- export default groupSimilarTypes;
@@ -1,4 +0,0 @@
1
- declare const tooltip: ({ message }?: {
2
- message?: string;
3
- }) => string;
4
- export default tooltip;
@@ -1,6 +0,0 @@
1
- import type { VisulimaError } from "@visulima/error/error";
2
- import type { SolutionError, SolutionFinder } from "@visulima/error/solution";
3
- import type { TemplateOptions } from "./types.d.ts";
4
- type ErrorType = Error | SolutionError | VisulimaError;
5
- declare const template: (error: ErrorType, solutionFinders?: SolutionFinder[], options?: TemplateOptions) => Promise<string>;
6
- export default template;
@@ -1,12 +0,0 @@
1
- import type { Theme } from "../types.d.ts";
2
- declare const layout: ({ content, cspNonce, css, description, error, scripts, theme, title, }: {
3
- content: string;
4
- cspNonce?: string;
5
- css: string;
6
- description: string;
7
- error: Error;
8
- scripts: string[];
9
- theme?: Theme;
10
- title: string;
11
- }) => string;
12
- export default layout;
@@ -1,15 +0,0 @@
1
- import type { VisulimaError } from "@visulima/error/error";
2
- import type { SolutionError, SolutionFinder } from "@visulima/error/solution";
3
- import type { ContentPage, TemplateOptions } from "../types.d.ts";
4
- type ErrorType = Error | SolutionError | VisulimaError;
5
- /**
6
- * Generates the stack page content for the error inspector
7
- * This page displays error details, stack traces, and related causes
8
- * @param error The main error to display
9
- * @param solutionFinders Array of solution finder functions
10
- * @param options Template options including sanitization settings
11
- * @returns Promise resolving to content page data
12
- * @throws TypeError if input validation fails
13
- */
14
- declare const stack: (error: ErrorType, solutionFinders?: SolutionFinder[], options?: TemplateOptions) => Promise<ContentPage>;
15
- export default stack;
@@ -1,62 +0,0 @@
1
- import type { IncomingMessage } from "node:http";
2
- type NativeRequest = typeof globalThis.Request;
3
- type NativeHeaders = typeof globalThis.Headers;
4
- interface CustomHeaders {
5
- entries: () => IterableIterator<[string, string]>;
6
- forEach: (callback: (value: string, key: string) => void) => void;
7
- get: (name: string) => string | null;
8
- }
9
- interface CustomRequest {
10
- clone?: () => CustomRequest;
11
- headers?: Record<string, string | string[]> | CustomHeaders;
12
- json?: () => Promise<unknown>;
13
- method?: string;
14
- text?: () => Promise<string>;
15
- url?: string;
16
- }
17
- type HeadersLike = NativeHeaders | CustomHeaders;
18
- type RequestLikeType = NativeRequest | CustomRequest;
19
- type RequestLike = NativeRequest | (IncomingMessage & {
20
- body?: unknown;
21
- clone?: () => RequestLike;
22
- json?: () => Promise<unknown>;
23
- text?: () => Promise<string>;
24
- }) | CustomRequest | {
25
- body?: unknown;
26
- headers?: Record<string, string | string[]> | HeadersLike;
27
- method?: string;
28
- off?: (event: string, handler: (chunk: unknown) => void) => void;
29
- on?: (event: string, handler: (chunk: unknown) => void) => void;
30
- setEncoding?: (encoding: string) => void;
31
- url?: string;
32
- };
33
- type ExpressRequest = {
34
- body?: unknown;
35
- headers?: Record<string, string | string[]> | HeadersLike;
36
- method?: string;
37
- url?: string;
38
- };
39
- export declare const isNativeRequest: (request: RequestLike) => request is NativeRequest;
40
- export declare const isIncomingMessage: (request: RequestLike) => request is IncomingMessage;
41
- export declare const isExpressRequest: (request: RequestLike) => request is ExpressRequest;
42
- export declare const isHeadersObject: (object: unknown) => object is HeadersLike;
43
- export type HeaderValue = string | string[] | undefined;
44
- export type HeadersRecord = Record<string, HeaderValue>;
45
- export type HeadersInput = HeadersRecord | HeadersLike | undefined;
46
- export type HeadersOutput = Record<string, string | string[]> | undefined;
47
- export type ContextContentOptions = {
48
- context?: Record<string, unknown>;
49
- headerAllowlist?: string[];
50
- headerDenylist?: string[];
51
- maskValue?: string;
52
- previewBytes?: number;
53
- totalCapBytes?: number;
54
- };
55
- export type { HeadersLike, RequestLike, RequestLikeType };
56
- export declare const runtime: {
57
- hasNativeHeaders: boolean;
58
- hasNativeRequest: boolean;
59
- isBun: boolean;
60
- isDeno: boolean;
61
- isNodeJS: string | false;
62
- };
@@ -1,43 +0,0 @@
1
- import type Editors from "../../../../../shared/utils/editors.d.ts";
2
- import type { Theme } from "../types.d.ts";
3
- export type RequestTimings = {
4
- elapsedMs?: number;
5
- end?: number;
6
- start?: number;
7
- };
8
- export type AppContext = {
9
- routing?: {
10
- params?: Record<string, string>;
11
- query?: Record<string, string | string[]>;
12
- route?: string;
13
- };
14
- };
15
- export type UserContext = {
16
- client?: {
17
- geo?: unknown;
18
- ip?: string;
19
- userAgent?: string;
20
- };
21
- };
22
- export type GitContext = {
23
- branch?: string;
24
- commit?: string;
25
- dirty?: boolean;
26
- tag?: string;
27
- };
28
- export type ContentPage = {
29
- code: {
30
- html: string;
31
- script?: string;
32
- };
33
- defaultSelected?: boolean;
34
- id: string;
35
- name: string;
36
- };
37
- export type TemplateOptions = {
38
- content?: ContentPage[];
39
- cspNonce?: string;
40
- editor?: Editors;
41
- openInEditorUrl?: string;
42
- theme?: Theme;
43
- };
@@ -1,2 +0,0 @@
1
- export declare const cn: (...inputs: (string | false | null | undefined)[]) => string;
2
- export default cn;
@@ -1,7 +0,0 @@
1
- import type { TemplateOptions } from "../types.d.ts";
2
- export declare const sanitizeHtml: (value: unknown) => string;
3
- export declare const sanitizeAttribute: (value: unknown) => string;
4
- export declare const sanitizeUrlAttribute: (value: unknown) => string;
5
- export declare const sanitizeCodeHtml: (value: unknown) => string;
6
- export declare const sanitizeCspNonce: (value: unknown) => string | undefined;
7
- export declare const sanitizeOptions: (options?: TemplateOptions) => TemplateOptions;
package/dist/types.d.ts DELETED
@@ -1 +0,0 @@
1
- export type Theme = "dark" | "light" | "auto";
@@ -1,7 +0,0 @@
1
- interface Process extends Partial<Omit<typeof globalThis.process, "versions">> {
2
- versions: Record<string, string>;
3
- }
4
- declare const process: Process;
5
- export declare const getProcessVersion: () => string;
6
- export declare const getProcessPlatform: () => string;
7
- export default process;
@@ -1,2 +0,0 @@
1
- declare const revisionHash: (data: string) => string;
2
- export default revisionHash;
@@ -1,3 +0,0 @@
1
- declare const runtime: RuntimeName | undefined;
2
- export type RuntimeName = "bun" | "deno" | "edge-light" | "fastly" | "lagon" | "netlify" | "node" | "workerd";
3
- export default runtime;