@stacksjs/error-handling 0.70.86 → 0.70.88

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/error-handling",
3
3
  "type": "module",
4
- "version": "0.70.86",
4
+ "version": "0.70.88",
5
5
  "description": "Type safe error handling.",
6
6
  "author": "Chris Breuer",
7
7
  "contributors": [
@@ -57,12 +57,12 @@
57
57
  "ts-syntax-highlighter": "^0.2.1"
58
58
  },
59
59
  "devDependencies": {
60
- "@stacksjs/cli": "0.70.86",
61
- "@stacksjs/config": "0.70.86",
60
+ "@stacksjs/cli": "0.70.88",
61
+ "@stacksjs/config": "0.70.88",
62
62
  "better-dx": "^0.2.16",
63
- "@stacksjs/path": "0.70.86",
64
- "@stacksjs/types": "0.70.86",
65
- "@stacksjs/validation": "0.70.86"
63
+ "@stacksjs/path": "0.70.88",
64
+ "@stacksjs/types": "0.70.88",
65
+ "@stacksjs/validation": "0.70.88"
66
66
  },
67
67
  "sideEffects": false
68
68
  }
@@ -1,4 +0,0 @@
1
- export declare function languageForFile(file: string): string;
2
- export declare function highlightSnippet(code: string, file: string, highlightLine: number, startingLine: number): Promise<{ html: string, css: string }>;
3
- export declare function getSharedHighlighterCss(): string;
4
- export declare function resetHighlighterCache(): void;
@@ -1,39 +0,0 @@
1
- import { createHighlighter, detectLanguageFromExtension, getLanguageByExtension } from "ts-syntax-highlighter";
2
- let sharedHighlighter = null, sharedCss = null;
3
- async function getHighlighter() {
4
- if (!sharedHighlighter)
5
- sharedHighlighter = await createHighlighter({
6
- theme: "github-light",
7
- cache: !0
8
- });
9
- return sharedHighlighter;
10
- }
11
- export function languageForFile(file) {
12
- const ext = file.includes(".") ? `.${file.split(".").pop()}` : file, byExt = detectLanguageFromExtension(file) ?? getLanguageByExtension(ext);
13
- if (byExt)
14
- return byExt.id;
15
- if (ext === ".php")
16
- return "php";
17
- if (ext === ".sql")
18
- return "sql";
19
- return "text";
20
- }
21
- export async function highlightSnippet(code, file, highlightLine, startingLine) {
22
- const highlighter = await getHighlighter(), lang = languageForFile(file), relativeHighlight = Math.max(1, highlightLine - startingLine + 1), result = await highlighter.highlight(code, lang, {
23
- lineNumbers: !0,
24
- highlightLines: [relativeHighlight]
25
- });
26
- if (result.css && !sharedCss)
27
- sharedCss = result.css;
28
- return {
29
- html: result.html,
30
- css: sharedCss ?? result.css ?? ""
31
- };
32
- }
33
- export function getSharedHighlighterCss() {
34
- return sharedCss ?? "";
35
- }
36
- export function resetHighlighterCache() {
37
- sharedHighlighter = null;
38
- sharedCss = null;
39
- }
@@ -1,11 +0,0 @@
1
- import type { ErrorPageConfig, QueryInfo, RequestContext, RoutingContext, UserContext } from './error-page';
2
- export declare function renderDevErrorPage(opts: {
3
- error: Error
4
- status: number
5
- config: ErrorPageConfig
6
- framework?: { name: string, version?: string }
7
- request?: RequestContext
8
- routing?: RoutingContext
9
- user?: UserContext
10
- queries?: QueryInfo[]
11
- }): Promise<string>;
@@ -1,21 +0,0 @@
1
- import { dirname, join } from "node:path";
2
- import { fileURLToPath } from "node:url";
3
- import { buildErrorPageViewModel } from "./error-page-view-model";
4
- const VIEWS_DIR = join(dirname(fileURLToPath(import.meta.url)), "views/errors");
5
- let renderTemplateFn = null;
6
- async function getRenderTemplate() {
7
- if (!renderTemplateFn)
8
- renderTemplateFn = (await import("@stacksjs/stx")).renderTemplate;
9
- return renderTemplateFn;
10
- }
11
- export async function renderDevErrorPage(opts) {
12
- const viewModel = await buildErrorPageViewModel(opts);
13
- return (await getRenderTemplate())(join(VIEWS_DIR, "show.stx"), {
14
- context: viewModel,
15
- layout: join(VIEWS_DIR, "layout.stx"),
16
- injectCSS: !0,
17
- templateOnly: !0,
18
- processClientScripts: !1,
19
- title: viewModel.pageTitle
20
- });
21
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Laravel-style error page styles (v12.29+ local debug page).
3
- * Inline CSS — no external dependencies.
4
- */
5
- export declare const ERROR_PAGE_CSS: string;