@inertiajs/core 2.3.17 → 3.0.0-beta.1
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/dist/index.js +1016 -298
- package/dist/index.js.map +4 -4
- package/dist/server.js +277 -56
- package/dist/server.js.map +4 -4
- package/dist/ssrErrors.js +197 -0
- package/dist/ssrErrors.js.map +7 -0
- package/package.json +28 -14
- package/types/axiosHttpClient.d.ts +16 -0
- package/types/dialog.d.ts +4 -0
- package/types/domUtils.d.ts +1 -1
- package/types/events.d.ts +2 -2
- package/types/http.d.ts +38 -0
- package/types/httpErrors.d.ts +16 -0
- package/types/httpHandlers.d.ts +15 -0
- package/types/index.d.ts +9 -2
- package/types/layout.d.ts +38 -0
- package/types/page.d.ts +4 -1
- package/types/progress.d.ts +2 -8
- package/types/queryString.d.ts +13 -0
- package/types/request.d.ts +12 -5
- package/types/requestParams.d.ts +2 -3
- package/types/requestStream.d.ts +3 -1
- package/types/response.d.ts +17 -5
- package/types/router.d.ts +8 -3
- package/types/server.d.ts +2 -1
- package/types/ssrErrors.d.ts +29 -0
- package/types/ssrUtils.d.ts +2 -0
- package/types/types.d.ts +131 -54
- package/types/url.d.ts +1 -0
- package/types/xhrHttpClient.d.ts +12 -0
- package/dist/index.esm.js +0 -4119
- package/dist/index.esm.js.map +0 -7
- package/dist/server.esm.js +0 -61
- package/dist/server.esm.js.map +0 -7
- package/types/modal.d.ts +0 -12
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/ssrErrors.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * SSR Error Classification\n *\n * This module detects common SSR errors and provides helpful hints\n * to developers on how to fix them. The most common issue is using\n * browser-specific APIs (like window, document) that don't exist\n * in the Node.js server environment.\n */\n\nexport type SSRErrorType = 'browser-api' | 'component-resolution' | 'render' | 'unknown'\n\ntype SourceMapResolver = (\n file: string,\n line: number,\n column: number,\n) => { file: string; line: number; column: number } | null\n\nlet sourceMapResolver: SourceMapResolver | null = null\n\nexport function setSourceMapResolver(resolver: SourceMapResolver | null): void {\n sourceMapResolver = resolver\n}\n\nexport interface ClassifiedSSRError {\n error: string\n type: SSRErrorType\n component?: string\n url?: string\n browserApi?: string\n hint: string\n stack?: string\n sourceLocation?: string\n timestamp: string\n}\n\nconst BROWSER_APIS: Record<string, string> = {\n // Global objects\n window: 'The global window object',\n document: 'The DOM document object',\n navigator: 'The navigator object',\n location: 'The location object',\n history: 'The browser history API',\n screen: 'The screen object',\n localStorage: 'Browser local storage',\n sessionStorage: 'Browser session storage',\n\n // Viewport properties (accessed via window.X)\n innerWidth: 'Browser viewport width',\n innerHeight: 'Browser viewport height',\n outerWidth: 'Browser window width',\n outerHeight: 'Browser window height',\n scrollX: 'Horizontal scroll position',\n scrollY: 'Vertical scroll position',\n devicePixelRatio: 'The device pixel ratio',\n matchMedia: 'The matchMedia function',\n\n // Observers (commonly instantiated at module level)\n IntersectionObserver: 'The IntersectionObserver API',\n ResizeObserver: 'The ResizeObserver API',\n MutationObserver: 'The MutationObserver API',\n\n // Timing functions (commonly called at module level)\n requestAnimationFrame: 'The requestAnimationFrame function',\n requestIdleCallback: 'The requestIdleCallback function',\n\n // Constructors that might be used at module level\n Image: 'The Image constructor',\n Audio: 'The Audio constructor',\n Worker: 'The Worker constructor',\n BroadcastChannel: 'The BroadcastChannel constructor',\n\n // Network (older Node.js versions)\n fetch: 'The fetch API',\n XMLHttpRequest: 'The XMLHttpRequest API',\n}\n\nfunction detectBrowserApi(error: Error): string | null {\n const message = error.message.toLowerCase()\n\n for (const api of Object.keys(BROWSER_APIS)) {\n const patterns = [\n `${api.toLowerCase()} is not defined`,\n `'${api.toLowerCase()}' is not defined`,\n `\"${api.toLowerCase()}\" is not defined`,\n `cannot read properties of undefined (reading '${api.toLowerCase()}')`,\n `cannot read property '${api.toLowerCase()}'`,\n ]\n\n if (patterns.some((pattern) => message.includes(pattern))) {\n return api\n }\n }\n\n return null\n}\n\nfunction isComponentResolutionError(error: Error): boolean {\n const message = error.message.toLowerCase()\n\n return (\n message.includes('cannot find module') ||\n message.includes('failed to resolve') ||\n message.includes('module not found') ||\n message.includes('could not resolve')\n )\n}\n\nconst LIFECYCLE_HOOKS = 'onMounted/useEffect/onMount'\n\nfunction getBrowserApiHint(api: string): string {\n const apiDescription = BROWSER_APIS[api] || `The \"${api}\" object`\n\n if (['localStorage', 'sessionStorage'].includes(api)) {\n return (\n `${apiDescription} doesn't exist in Node.js. ` +\n `Check \"typeof ${api} !== 'undefined'\" before using it, ` +\n `or move the code to a ${LIFECYCLE_HOOKS} lifecycle hook.`\n )\n }\n\n if (['window', 'document'].includes(api)) {\n return (\n `${apiDescription} doesn't exist in Node.js. ` +\n `Wrap browser-specific code in a ${LIFECYCLE_HOOKS} lifecycle hook, ` +\n `or check \"typeof ${api} !== 'undefined'\" before using it.`\n )\n }\n\n if (['IntersectionObserver', 'ResizeObserver', 'MutationObserver'].includes(api)) {\n return (\n `${apiDescription} doesn't exist in Node.js. ` +\n `Create observers inside a ${LIFECYCLE_HOOKS} lifecycle hook, not at the module level.`\n )\n }\n\n if (['fetch', 'XMLHttpRequest'].includes(api)) {\n return (\n `${apiDescription} may not be available in all Node.js versions. ` +\n `For SSR, ensure data fetching happens on the server (in your controller) ` +\n `and is passed as props, or use a ${LIFECYCLE_HOOKS} hook for client-side fetching.`\n )\n }\n\n return (\n `${apiDescription} doesn't exist in Node.js. ` +\n `Move this code to a ${LIFECYCLE_HOOKS} lifecycle hook, or guard it with ` +\n `\"typeof ${api} !== 'undefined'\".`\n )\n}\n\nfunction getComponentResolutionHint(component?: string): string {\n const componentPart = component ? ` \"${component}\"` : ''\n\n return (\n `Could not resolve component${componentPart}. ` +\n `Check that the file exists and the path is correct. ` +\n `Ensure the component name matches the file name exactly (case-sensitive).`\n )\n}\n\nfunction getRenderErrorHint(): string {\n return (\n 'An error occurred while rendering the component. ' +\n 'Check the component for browser-specific code that runs during initialization. ' +\n 'Move any code that accesses browser APIs to a lifecycle hook.'\n )\n}\n\nfunction extractSourceLocation(stack?: string): string | undefined {\n if (!stack) {\n return undefined\n }\n\n for (const line of stack.split('\\n')) {\n if (!line.includes('at ')) {\n continue\n }\n\n if (line.includes('node_modules') || line.includes('node:')) {\n continue\n }\n\n let match = line.match(/\\(([^)]+):(\\d+):(\\d+)\\)/)\n\n if (!match) {\n match = line.match(/at\\s+(?:file:\\/\\/)?(.+):(\\d+):(\\d+)\\s*$/)\n }\n\n if (match) {\n const file = match[1].replace(/^file:\\/\\//, '')\n const lineNum = parseInt(match[2], 10)\n const colNum = parseInt(match[3], 10)\n\n if (sourceMapResolver) {\n const resolved = sourceMapResolver(file, lineNum, colNum)\n\n if (resolved) {\n return `${resolved.file}:${resolved.line}:${resolved.column}`\n }\n }\n\n return `${file}:${lineNum}:${colNum}`\n }\n }\n\n return undefined\n}\n\nexport function classifySSRError(error: Error, component?: string, url?: string): ClassifiedSSRError {\n const timestamp = new Date().toISOString()\n const base = {\n error: error.message,\n component,\n url,\n stack: error.stack,\n sourceLocation: extractSourceLocation(error.stack),\n timestamp,\n }\n\n const browserApi = detectBrowserApi(error)\n\n if (browserApi) {\n return {\n ...base,\n type: 'browser-api',\n browserApi,\n hint: getBrowserApiHint(browserApi),\n }\n }\n\n if (isComponentResolutionError(error)) {\n return {\n ...base,\n type: 'component-resolution',\n hint: getComponentResolutionHint(component),\n }\n }\n\n return {\n ...base,\n type: 'render',\n hint: getRenderErrorHint(),\n }\n}\n\nconst colors = {\n reset: '\\x1b[0m',\n red: '\\x1b[31m',\n yellow: '\\x1b[33m',\n cyan: '\\x1b[36m',\n dim: '\\x1b[2m',\n bold: '\\x1b[1m',\n bgRed: '\\x1b[41m',\n white: '\\x1b[37m',\n}\n\nfunction makeRelative(path: string, root?: string): string {\n const base = root ?? process.cwd()\n\n if (path.startsWith(base + '/')) {\n return path.slice(base.length + 1)\n }\n\n return path\n}\n\nexport function formatConsoleError(\n classified: ClassifiedSSRError,\n root?: string,\n handleErrors: boolean = true,\n suppressedWarnings: string[] = [],\n): string {\n if (!handleErrors) {\n const component = classified.component ? `[${classified.component}]` : ''\n return `SSR Error ${component}: ${classified.error}`\n }\n\n const componentPart = classified.component ? ` ${colors.cyan}${classified.component}${colors.reset}` : ''\n\n const lines = [\n '',\n ` ${colors.bgRed}${colors.white}${colors.bold} SSR ERROR ${colors.reset}${componentPart}`,\n '',\n ` ${classified.error}`,\n ]\n\n if (classified.sourceLocation) {\n const relativePath = makeRelative(classified.sourceLocation, root)\n lines.push(` ${colors.dim}Source: ${relativePath}${colors.reset}`)\n }\n\n if (classified.url) {\n lines.push(` ${colors.dim}URL: ${classified.url}${colors.reset}`)\n }\n\n lines.push('', ` ${colors.yellow}Hint${colors.reset} ${classified.hint}`, '')\n\n if (classified.stack) {\n lines.push(` ${colors.dim}${classified.stack.split('\\n').join('\\n ')}${colors.reset}`, '')\n }\n\n if (suppressedWarnings.length > 0) {\n lines.push(` ${colors.dim}Suppressed ${suppressedWarnings.length} framework warning(s).${colors.reset}`, '')\n }\n\n return lines.join('\\n')\n}\n"],
|
|
5
|
+
"mappings": ";AAiBA,IAAI,oBAA8C;AAE3C,SAAS,qBAAqB,UAA0C;AAC7E,sBAAoB;AACtB;AAcA,IAAM,eAAuC;AAAA;AAAA,EAE3C,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,WAAW;AAAA,EACX,UAAU;AAAA,EACV,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,gBAAgB;AAAA;AAAA,EAGhB,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,SAAS;AAAA,EACT,SAAS;AAAA,EACT,kBAAkB;AAAA,EAClB,YAAY;AAAA;AAAA,EAGZ,sBAAsB;AAAA,EACtB,gBAAgB;AAAA,EAChB,kBAAkB;AAAA;AAAA,EAGlB,uBAAuB;AAAA,EACvB,qBAAqB;AAAA;AAA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AAAA,IACA,KAAK,WAAW,KAAK;AAAA,EACvB;AAEA,MAAI,WAAW,gBAAgB;AAC7B,UAAM,eAAe,aAAa,WAAW,gBAAgB,IAAI;AACjE,UAAM,KAAK,KAAK,OAAO,GAAG,WAAW,YAAY,GAAG,OAAO,KAAK,EAAE;AAAA,EACpE;AAEA,MAAI,WAAW,KAAK;AAClB,UAAM,KAAK,KAAK,OAAO,GAAG,QAAQ,WAAW,GAAG,GAAG,OAAO,KAAK,EAAE;AAAA,EACnE;AAEA,QAAM,KAAK,IAAI,KAAK,OAAO,MAAM,OAAO,OAAO,KAAK,KAAK,WAAW,IAAI,IAAI,EAAE;AAE9E,MAAI,WAAW,OAAO;AACpB,UAAM,KAAK,KAAK,OAAO,GAAG,GAAG,WAAW,MAAM,MAAM,IAAI,EAAE,KAAK,MAAM,CAAC,GAAG,OAAO,KAAK,IAAI,EAAE;AAAA,EAC7F;AAEA,MAAI,mBAAmB,SAAS,GAAG;AACjC,UAAM,KAAK,KAAK,OAAO,GAAG,cAAc,mBAAmB,MAAM,yBAAyB,OAAO,KAAK,IAAI,EAAE;AAAA,EAC9G;AAEA,SAAO,MAAM,KAAK,IAAI;AACxB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inertiajs/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "A framework for creating server-driven single page apps.",
|
|
6
6
|
"contributors": [
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"homepage": "https://inertiajs.com/",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "https://github.com/inertiajs/inertia.git",
|
|
14
|
+
"url": "git+https://github.com/inertiajs/inertia.git",
|
|
15
15
|
"directory": "packages/inertia"
|
|
16
16
|
},
|
|
17
17
|
"bugs": {
|
|
@@ -27,36 +27,49 @@
|
|
|
27
27
|
"exports": {
|
|
28
28
|
".": {
|
|
29
29
|
"types": "./types/index.d.ts",
|
|
30
|
-
"import": "./dist/index.
|
|
31
|
-
"require": "./dist/index.js"
|
|
30
|
+
"import": "./dist/index.js"
|
|
32
31
|
},
|
|
33
32
|
"./server": {
|
|
34
33
|
"types": "./types/server.d.ts",
|
|
35
|
-
"import": "./dist/server.
|
|
36
|
-
|
|
34
|
+
"import": "./dist/server.js"
|
|
35
|
+
},
|
|
36
|
+
"./ssrErrors": {
|
|
37
|
+
"types": "./types/ssrErrors.d.ts",
|
|
38
|
+
"import": "./dist/ssrErrors.js"
|
|
37
39
|
}
|
|
38
40
|
},
|
|
39
41
|
"typesVersions": {
|
|
40
42
|
"*": {
|
|
41
43
|
"server": [
|
|
42
44
|
"types/server.d.ts"
|
|
45
|
+
],
|
|
46
|
+
"ssrErrors": [
|
|
47
|
+
"types/ssrErrors.d.ts"
|
|
43
48
|
]
|
|
44
49
|
}
|
|
45
50
|
},
|
|
46
51
|
"dependencies": {
|
|
52
|
+
"@jridgewell/trace-mapping": "^0.3.31",
|
|
47
53
|
"@types/lodash-es": "^4.17.12",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
"laravel-precognition": "2.0.0-beta.2",
|
|
55
|
+
"lodash-es": "^4.17.23"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"axios": "^1.13.2"
|
|
59
|
+
},
|
|
60
|
+
"peerDependenciesMeta": {
|
|
61
|
+
"axios": {
|
|
62
|
+
"optional": true
|
|
63
|
+
}
|
|
52
64
|
},
|
|
53
65
|
"devDependencies": {
|
|
54
|
-
"@types/node": "^
|
|
55
|
-
"
|
|
66
|
+
"@types/node": "^24.10.13",
|
|
67
|
+
"axios": "^1.13.5",
|
|
56
68
|
"es-check": "^9.6.1",
|
|
57
69
|
"esbuild": "^0.27.3",
|
|
58
70
|
"esbuild-node-externals": "^1.20.1",
|
|
59
|
-
"typescript": "^5.9.3"
|
|
71
|
+
"typescript": "^5.9.3",
|
|
72
|
+
"vitest": "^3.2.4"
|
|
60
73
|
},
|
|
61
74
|
"scripts": {
|
|
62
75
|
"build": "pnpm clean && ./build.js && tsc",
|
|
@@ -65,6 +78,7 @@
|
|
|
65
78
|
"dev": "pnpx concurrently -c \"#ffcf00,#3178c6\" \"pnpm dev:build\" \"pnpm dev:types\" --names build,types",
|
|
66
79
|
"dev:build": "./build.js --watch",
|
|
67
80
|
"dev:types": "tsc --watch --preserveWatchOutput",
|
|
68
|
-
"es2020-check": "pnpm build:with-deps && es-check es2020 \"dist/index.
|
|
81
|
+
"es2020-check": "pnpm build:with-deps && es-check es2020 \"dist/index.js\" --checkFeatures --module --noCache --verbose",
|
|
82
|
+
"test": "vitest run"
|
|
69
83
|
}
|
|
70
84
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AxiosInstance } from 'axios';
|
|
2
|
+
import { HttpClient, HttpRequestConfig, HttpResponse } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* HTTP client implementation using Axios
|
|
5
|
+
*/
|
|
6
|
+
export declare class AxiosHttpClient implements HttpClient {
|
|
7
|
+
private axios?;
|
|
8
|
+
constructor(instance?: AxiosInstance);
|
|
9
|
+
private getAxios;
|
|
10
|
+
request(config: HttpRequestConfig): Promise<HttpResponse>;
|
|
11
|
+
protected doRequest(config: HttpRequestConfig): Promise<HttpResponse>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create an Axios HTTP client adapter
|
|
15
|
+
*/
|
|
16
|
+
export declare function axiosAdapter(instance?: AxiosInstance): HttpClient;
|
package/types/dialog.d.ts
CHANGED
package/types/domUtils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const getScrollableParent: (element: HTMLElement | null) => HTMLElement | null;
|
|
2
2
|
export declare const getElementsInViewportFromCollection: (elements: HTMLElement[], referenceElement?: HTMLElement) => HTMLElement[];
|
|
3
3
|
export declare const requestAnimationFrame: (cb: () => void, times?: number) => void;
|
|
4
|
-
export declare const getInitialPageFromDOM: <T>(id: string
|
|
4
|
+
export declare const getInitialPageFromDOM: <T>(id: string) => T | null;
|
package/types/events.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { GlobalEventTrigger } from './types';
|
|
2
2
|
export declare const fireBeforeEvent: GlobalEventTrigger<'before'>;
|
|
3
3
|
export declare const fireErrorEvent: GlobalEventTrigger<'error'>;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const fireNetworkErrorEvent: GlobalEventTrigger<'networkError'>;
|
|
5
5
|
export declare const fireFinishEvent: GlobalEventTrigger<'finish'>;
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const fireHttpExceptionEvent: GlobalEventTrigger<'httpException'>;
|
|
7
7
|
export declare const fireBeforeUpdateEvent: GlobalEventTrigger<'beforeUpdate'>;
|
|
8
8
|
export declare const fireNavigateEvent: GlobalEventTrigger<'navigate'>;
|
|
9
9
|
export declare const fireProgressEvent: GlobalEventTrigger<'progress'>;
|
package/types/http.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { HttpClient, HttpClientOptions } from './types';
|
|
2
|
+
export declare const http: {
|
|
3
|
+
/**
|
|
4
|
+
* Get the current HTTP client
|
|
5
|
+
*/
|
|
6
|
+
getClient(): HttpClient;
|
|
7
|
+
/**
|
|
8
|
+
* Set the HTTP client to use for all Inertia requests
|
|
9
|
+
*/
|
|
10
|
+
setClient(clientOrOptions: HttpClient | HttpClientOptions): void;
|
|
11
|
+
/**
|
|
12
|
+
* Register a request handler that runs before each request
|
|
13
|
+
*/
|
|
14
|
+
onRequest: (handler: import("./types").HttpRequestHandler) => () => void;
|
|
15
|
+
/**
|
|
16
|
+
* Register a response handler that runs after each successful response
|
|
17
|
+
*/
|
|
18
|
+
onResponse: (handler: import("./types").HttpResponseHandler) => () => void;
|
|
19
|
+
/**
|
|
20
|
+
* Register an error handler that runs when a request fails
|
|
21
|
+
*/
|
|
22
|
+
onError: (handler: import("./types").HttpErrorHandler) => () => void;
|
|
23
|
+
/**
|
|
24
|
+
* Process a request config through all registered request handlers.
|
|
25
|
+
* For use by custom HttpClient implementations.
|
|
26
|
+
*/
|
|
27
|
+
processRequest: (config: import("./types").HttpRequestConfig) => Promise<import("./types").HttpRequestConfig>;
|
|
28
|
+
/**
|
|
29
|
+
* Process a response through all registered response handlers.
|
|
30
|
+
* For use by custom HttpClient implementations.
|
|
31
|
+
*/
|
|
32
|
+
processResponse: (response: import("./types").HttpResponse) => Promise<import("./types").HttpResponse>;
|
|
33
|
+
/**
|
|
34
|
+
* Process an error through all registered error handlers.
|
|
35
|
+
* For use by custom HttpClient implementations.
|
|
36
|
+
*/
|
|
37
|
+
processError: (error: import("./httpErrors").HttpResponseError | import("./httpErrors").HttpNetworkError | import("./httpErrors").HttpCancelledError) => Promise<void>;
|
|
38
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HttpResponse } from './types';
|
|
2
|
+
export declare class HttpResponseError extends Error {
|
|
3
|
+
readonly response: HttpResponse;
|
|
4
|
+
readonly url?: string;
|
|
5
|
+
constructor(message: string, response: HttpResponse, url?: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class HttpCancelledError extends Error {
|
|
8
|
+
readonly url?: string;
|
|
9
|
+
constructor(message?: string, url?: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class HttpNetworkError extends Error {
|
|
12
|
+
readonly cause?: Error;
|
|
13
|
+
readonly code = "ERR_NETWORK";
|
|
14
|
+
readonly url?: string;
|
|
15
|
+
constructor(message: string, url?: string, cause?: Error);
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HttpCancelledError, HttpNetworkError, HttpResponseError } from './httpErrors';
|
|
2
|
+
import { HttpErrorHandler, HttpRequestConfig, HttpRequestHandler, HttpResponse, HttpResponseHandler } from './types';
|
|
3
|
+
declare class HttpHandlers {
|
|
4
|
+
protected requestHandlers: HttpRequestHandler[];
|
|
5
|
+
protected responseHandlers: HttpResponseHandler[];
|
|
6
|
+
protected errorHandlers: HttpErrorHandler[];
|
|
7
|
+
onRequest(handler: HttpRequestHandler): () => void;
|
|
8
|
+
onResponse(handler: HttpResponseHandler): () => void;
|
|
9
|
+
onError(handler: HttpErrorHandler): () => void;
|
|
10
|
+
processRequest(config: HttpRequestConfig): Promise<HttpRequestConfig>;
|
|
11
|
+
processResponse(response: HttpResponse): Promise<HttpResponse>;
|
|
12
|
+
processError(error: HttpResponseError | HttpNetworkError | HttpCancelledError): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export declare const httpHandlers: HttpHandlers;
|
|
15
|
+
export {};
|
package/types/index.d.ts
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { Config } from './config';
|
|
2
2
|
import { Router } from './router';
|
|
3
3
|
export { UseFormUtils } from './useFormUtils';
|
|
4
|
+
export { axiosAdapter } from './axiosHttpClient';
|
|
4
5
|
export { config } from './config';
|
|
5
6
|
export { getInitialPageFromDOM, getScrollableParent } from './domUtils';
|
|
7
|
+
export { hasFiles } from './files';
|
|
6
8
|
export { objectToFormData } from './formData';
|
|
7
9
|
export { formDataToObject } from './formObject';
|
|
8
10
|
export { default as createHeadManager } from './head';
|
|
11
|
+
export { http } from './http';
|
|
12
|
+
export { HttpCancelledError, HttpNetworkError, HttpResponseError } from './httpErrors';
|
|
9
13
|
export { default as useInfiniteScroll } from './infiniteScroll';
|
|
14
|
+
export { createLayoutPropsStore, mergeLayoutProps, normalizeLayouts, type LayoutDefinition, type LayoutPropsStore, } from './layout';
|
|
10
15
|
export { shouldIntercept, shouldNavigate } from './navigationEvents';
|
|
11
|
-
export {
|
|
16
|
+
export { progress, default as setupProgress } from './progress';
|
|
12
17
|
export { FormComponentResetSymbol, resetFormFields } from './resetFormFields';
|
|
18
|
+
export { buildSSRBody } from './ssrUtils';
|
|
13
19
|
export * from './types';
|
|
14
|
-
export { hrefToUrl, isUrlMethodPair, mergeDataIntoQueryString, urlHasProtocol, urlToString, urlWithoutHash, } from './url';
|
|
20
|
+
export { hrefToUrl, isSameUrlWithoutQueryOrHash, isUrlMethodPair, mergeDataIntoQueryString, resolveUrlMethodPairComponent, urlHasProtocol, urlToString, urlWithoutHash, } from './url';
|
|
21
|
+
export { XhrHttpClient, xhrHttpClient } from './xhrHttpClient';
|
|
15
22
|
export { type Config, type Router };
|
|
16
23
|
export declare const router: Router;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface LayoutDefinition<Component> {
|
|
2
|
+
component: Component;
|
|
3
|
+
props: Record<string, unknown>;
|
|
4
|
+
name?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface LayoutPropsStore {
|
|
7
|
+
set(props: Record<string, unknown>): void;
|
|
8
|
+
setFor(name: string, props: Record<string, unknown>): void;
|
|
9
|
+
get(): {
|
|
10
|
+
shared: Record<string, unknown>;
|
|
11
|
+
named: Record<string, Record<string, unknown>>;
|
|
12
|
+
};
|
|
13
|
+
reset(): void;
|
|
14
|
+
subscribe(callback: () => void): () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function createLayoutPropsStore(): LayoutPropsStore;
|
|
17
|
+
/**
|
|
18
|
+
* Merges layout props from three sources with priority: dynamic > static > defaults.
|
|
19
|
+
* Only keys present in `defaults` are included in the result.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* mergeLayoutProps(
|
|
24
|
+
* { title: 'Default', showSidebar: true }, // defaults declared in useLayoutProps()
|
|
25
|
+
* { title: 'My Page', color: 'blue' }, // static props from layout definition
|
|
26
|
+
* { showSidebar: false, fontSize: 16 }, // dynamic props from setLayoutProps()
|
|
27
|
+
* )
|
|
28
|
+
* // => { title: 'My Page', showSidebar: false }
|
|
29
|
+
* // 'color' and 'fontSize' are excluded because they're not declared in defaults
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function mergeLayoutProps<T extends Record<string, unknown>>(defaults: T, staticProps: Record<string, unknown>, dynamicProps: Record<string, unknown>): T;
|
|
33
|
+
type ComponentCheck<T> = (value: unknown) => value is T;
|
|
34
|
+
/**
|
|
35
|
+
* Normalizes layout definitions into a consistent structure.
|
|
36
|
+
*/
|
|
37
|
+
export declare function normalizeLayouts<T>(layout: unknown, isComponent: ComponentCheck<T>, isRenderFunction?: (value: unknown) => boolean): LayoutDefinition<T>[];
|
|
38
|
+
export {};
|
package/types/page.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ declare class CurrentPage {
|
|
|
29
29
|
getWithoutFlashData(): Page;
|
|
30
30
|
hasOnceProps(): boolean;
|
|
31
31
|
merge(data: Partial<Page>): void;
|
|
32
|
+
setPropsQuietly(props: Page['props']): Promise<unknown>;
|
|
32
33
|
setFlash(flash: FlashData): void;
|
|
33
34
|
setUrlHash(hash: string): void;
|
|
34
35
|
remember(data: Page['rememberedState']): void;
|
|
@@ -38,7 +39,9 @@ declare class CurrentPage {
|
|
|
38
39
|
preserveState: boolean;
|
|
39
40
|
viewTransition: Visit['viewTransition'];
|
|
40
41
|
}): Promise<unknown>;
|
|
41
|
-
resolve(component: string): Promise<Component>;
|
|
42
|
+
resolve(component: string, page?: Page): Promise<Component>;
|
|
43
|
+
recordOptimisticUpdate(keys: string[], updatedAt: number): void;
|
|
44
|
+
shouldPreserveOptimistic(key: string, updatedAt: number): boolean;
|
|
42
45
|
isTheSame(page: Page): boolean;
|
|
43
46
|
on(event: PageEvent, callback: VoidFunction): VoidFunction;
|
|
44
47
|
fireEventsFor(event: PageEvent): void;
|
package/types/progress.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ProgressOptions } from './types';
|
|
1
2
|
declare class Progress {
|
|
2
3
|
hideCount: number;
|
|
3
4
|
start(): void;
|
|
@@ -11,12 +12,5 @@ declare class Progress {
|
|
|
11
12
|
getStatus(): number | null;
|
|
12
13
|
}
|
|
13
14
|
export declare const progress: Progress;
|
|
14
|
-
export
|
|
15
|
-
export declare const hide: () => void;
|
|
16
|
-
export default function setupProgress({ delay, color, includeCSS, showSpinner, }?: {
|
|
17
|
-
delay?: number | undefined;
|
|
18
|
-
color?: string | undefined;
|
|
19
|
-
includeCSS?: boolean | undefined;
|
|
20
|
-
showSpinner?: boolean | undefined;
|
|
21
|
-
}): void;
|
|
15
|
+
export default function setupProgress({ delay, color, includeCSS, showSpinner, popover, }?: ProgressOptions): void;
|
|
22
16
|
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { QueryStringArrayFormatOption } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if the given URL query string contains indexed array parameters.
|
|
4
|
+
*/
|
|
5
|
+
export declare function hasIndices(url: URL): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Parse a query string into a nested object.
|
|
8
|
+
*/
|
|
9
|
+
export declare function parse(query: string): Record<string, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* Convert an object to a query string.
|
|
12
|
+
*/
|
|
13
|
+
export declare function stringify(data: Record<string, unknown>, arrayFormat: QueryStringArrayFormatOption): string;
|
package/types/request.d.ts
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import { type AxiosProgressEvent, type AxiosRequestConfig } from 'axios';
|
|
2
1
|
import { RequestParams } from './requestParams';
|
|
3
2
|
import { Response } from './response';
|
|
4
3
|
import type { ActiveVisit, Page } from './types';
|
|
4
|
+
import { HttpProgressEvent, HttpRequestHeaders } from './types';
|
|
5
5
|
export declare class Request {
|
|
6
6
|
protected page: Page;
|
|
7
7
|
protected response: Response;
|
|
8
8
|
protected cancelToken: AbortController;
|
|
9
9
|
protected requestParams: RequestParams;
|
|
10
10
|
protected requestHasFinished: boolean;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
protected optimistic: boolean;
|
|
12
|
+
constructor(params: ActiveVisit, page: Page, { optimistic }?: {
|
|
13
|
+
optimistic?: boolean;
|
|
14
|
+
});
|
|
15
|
+
static create(params: ActiveVisit, page: Page, options?: {
|
|
16
|
+
optimistic?: boolean;
|
|
17
|
+
}): Request;
|
|
13
18
|
isPrefetch(): boolean;
|
|
19
|
+
isOptimistic(): boolean;
|
|
20
|
+
isPendingOptimistic(): boolean;
|
|
14
21
|
send(): Promise<void | undefined>;
|
|
15
22
|
protected finish(): void;
|
|
16
23
|
protected fireFinishEvents(): void;
|
|
@@ -18,6 +25,6 @@ export declare class Request {
|
|
|
18
25
|
cancelled?: boolean;
|
|
19
26
|
interrupted?: boolean;
|
|
20
27
|
}): void;
|
|
21
|
-
protected onProgress(progress:
|
|
22
|
-
protected getHeaders():
|
|
28
|
+
protected onProgress(progress: HttpProgressEvent): void;
|
|
29
|
+
protected getHeaders(): HttpRequestHeaders;
|
|
23
30
|
}
|
package/types/requestParams.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from 'axios';
|
|
2
1
|
import { Response } from './response';
|
|
3
|
-
import { ActiveVisit, InternalActiveVisit, Page, PreserveStateOption, VisitCallbacks } from './types';
|
|
2
|
+
import { ActiveVisit, HttpRequestHeaders, InternalActiveVisit, Page, PreserveStateOption, VisitCallbacks } from './types';
|
|
4
3
|
export declare class RequestParams {
|
|
5
4
|
protected callbacks: {
|
|
6
5
|
name: keyof VisitCallbacks;
|
|
@@ -27,7 +26,7 @@ export declare class RequestParams {
|
|
|
27
26
|
onPrefetchResponse(response: Response): void;
|
|
28
27
|
onPrefetchError(error: Error): void;
|
|
29
28
|
all(): InternalActiveVisit;
|
|
30
|
-
headers():
|
|
29
|
+
headers(): HttpRequestHeaders;
|
|
31
30
|
setPreserveOptions(page: Page): void;
|
|
32
31
|
runCallbacks(): void;
|
|
33
32
|
merge(toMerge: Partial<ActiveVisit>): void;
|
package/types/requestStream.d.ts
CHANGED
|
@@ -9,12 +9,14 @@ export declare class RequestStream {
|
|
|
9
9
|
});
|
|
10
10
|
send(request: Request): void;
|
|
11
11
|
interruptInFlight(): void;
|
|
12
|
-
cancelInFlight({ prefetch }?: {
|
|
12
|
+
cancelInFlight({ prefetch, optimistic }?: {
|
|
13
13
|
prefetch?: boolean | undefined;
|
|
14
|
+
optimistic?: boolean | undefined;
|
|
14
15
|
}): void;
|
|
15
16
|
protected cancel({ cancelled, interrupted }?: {
|
|
16
17
|
cancelled?: boolean | undefined;
|
|
17
18
|
interrupted?: boolean | undefined;
|
|
18
19
|
}, force?: boolean): void;
|
|
19
20
|
protected shouldCancel(): boolean;
|
|
21
|
+
hasPendingOptimistic(): boolean;
|
|
20
22
|
}
|
package/types/response.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { AxiosResponse } from 'axios';
|
|
2
1
|
import { RequestParams } from './requestParams';
|
|
3
|
-
import { ActiveVisit, ErrorBag, Errors, Page } from './types';
|
|
2
|
+
import { ActiveVisit, ErrorBag, Errors, HttpResponse, Page, PageProps } from './types';
|
|
4
3
|
export declare class Response {
|
|
5
4
|
protected requestParams: RequestParams;
|
|
6
|
-
protected response:
|
|
5
|
+
protected response: HttpResponse;
|
|
7
6
|
protected originatingPage: Page;
|
|
8
7
|
protected wasPrefetched: boolean;
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
protected processed: boolean;
|
|
9
|
+
constructor(requestParams: RequestParams, response: HttpResponse, originatingPage: Page);
|
|
10
|
+
static create(params: RequestParams, response: HttpResponse, originatingPage: Page): Response;
|
|
11
|
+
isProcessed(): boolean;
|
|
11
12
|
handlePrefetch(): Promise<void>;
|
|
12
13
|
handle(): Promise<void>;
|
|
13
14
|
process(): Promise<boolean | void>;
|
|
@@ -18,6 +19,7 @@ export declare class Response {
|
|
|
18
19
|
protected hasStatus(status: number): boolean;
|
|
19
20
|
protected getHeader(header: string): string;
|
|
20
21
|
protected hasHeader(header: string): boolean;
|
|
22
|
+
protected isInertiaRedirect(): boolean;
|
|
21
23
|
protected isLocationVisit(): boolean;
|
|
22
24
|
/**
|
|
23
25
|
* @link https://inertiajs.com/redirects#external-redirects
|
|
@@ -27,8 +29,18 @@ export declare class Response {
|
|
|
27
29
|
protected getDataFromResponse(response: any): any;
|
|
28
30
|
protected shouldSetPage(pageResponse: Page): boolean;
|
|
29
31
|
protected pageUrl(pageResponse: Page): string;
|
|
32
|
+
protected preserveOptimisticProps(pageResponse: Page): void;
|
|
30
33
|
protected preserveEqualProps(pageResponse: Page): void;
|
|
31
34
|
protected mergeProps(pageResponse: Page): void;
|
|
35
|
+
/**
|
|
36
|
+
* By default, the Laravel adapter shares validation errors via Inertia::always(),
|
|
37
|
+
* so responses always include errors, even when empty. Components like
|
|
38
|
+
* InfiniteScroll and WhenVisible, as well as loading deferred props,
|
|
39
|
+
* perform async requests that should practically never reset errors.
|
|
40
|
+
*/
|
|
41
|
+
protected shouldPreserveErrors(pageResponse: Page): boolean;
|
|
42
|
+
protected isObject(item: any): boolean;
|
|
43
|
+
protected deepMergeObjects(target: PageProps, source: PageProps): PageProps;
|
|
32
44
|
protected mergeOrMatchItems(existingItems: any[], newItems: any[], matchProp: string, matchPropsOn: string[], shouldAppend?: boolean): any[];
|
|
33
45
|
protected appendWithMatching(existingItems: any[], newItems: any[], newItemsMap: Map<any, any>, uniqueProperty: string): any[];
|
|
34
46
|
protected prependWithMatching(existingItems: any[], newItems: any[], newItemsMap: Map<any, any>, uniqueProperty: string): any[];
|
package/types/router.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import Queue from './queue';
|
|
2
2
|
import { RequestStream } from './requestStream';
|
|
3
|
-
import { ActiveVisit, ClientSideVisitOptions, Component, FlashData, GlobalEvent, GlobalEventNames, GlobalEventResult, InFlightPrefetch, Page, PageFlashData, PendingVisit,
|
|
3
|
+
import { ActiveVisit, ClientSideVisitOptions, Component, FlashData, GlobalEvent, GlobalEventNames, GlobalEventResult, InFlightPrefetch, OptimisticCallback, Page, PageFlashData, PendingVisit, PollOptions, PrefetchedResponse, PrefetchOptions, ReloadOptions, RequestPayload, RouterInitParams, UrlMethodPair, VisitCallbacks, VisitHelperOptions, VisitOptions } from './types';
|
|
4
4
|
export declare class Router {
|
|
5
5
|
protected syncRequestStream: RequestStream;
|
|
6
6
|
protected asyncRequestStream: RequestStream;
|
|
7
7
|
protected clientVisitQueue: Queue<Promise<void>>;
|
|
8
|
+
protected pendingOptimisticCallback: OptimisticCallback | undefined;
|
|
8
9
|
init<ComponentType = Component>({ initialPage, resolveComponent, swapComponent, onFlash, }: RouterInitParams<ComponentType>): void;
|
|
10
|
+
optimistic<TProps>(callback: OptimisticCallback<TProps>): this;
|
|
9
11
|
get<T extends RequestPayload = RequestPayload>(url: URL | string | UrlMethodPair, data?: T, options?: VisitHelperOptions<T>): void;
|
|
10
12
|
post<T extends RequestPayload = RequestPayload>(url: URL | string | UrlMethodPair, data?: T, options?: VisitHelperOptions<T>): void;
|
|
11
13
|
put<T extends RequestPayload = RequestPayload>(url: URL | string | UrlMethodPair, data?: T, options?: VisitHelperOptions<T>): void;
|
|
@@ -22,6 +24,7 @@ export declare class Router {
|
|
|
22
24
|
* @deprecated Use cancelAll() instead.
|
|
23
25
|
*/
|
|
24
26
|
cancel(): void;
|
|
27
|
+
hasPendingOptimistic(): boolean;
|
|
25
28
|
cancelAll({ async, prefetch, sync }?: {
|
|
26
29
|
async?: boolean | undefined;
|
|
27
30
|
prefetch?: boolean | undefined;
|
|
@@ -40,7 +43,7 @@ export declare class Router {
|
|
|
40
43
|
prefetch(href: string | URL | UrlMethodPair, options?: VisitOptions, prefetchOptions?: Partial<PrefetchOptions>): void;
|
|
41
44
|
clearHistory(): void;
|
|
42
45
|
decryptHistory(): Promise<Page>;
|
|
43
|
-
resolveComponent(component: string): Promise<Component>;
|
|
46
|
+
resolveComponent(component: string, page?: Page): Promise<Component>;
|
|
44
47
|
replace<TProps = Page['props']>(params: ClientSideVisitOptions<TProps>): void;
|
|
45
48
|
replaceProp<TProps = Page['props']>(name: string, value: unknown | ((oldValue: unknown, props: TProps) => unknown), options?: Pick<ClientSideVisitOptions, 'onError' | 'onFinish' | 'onSuccess'>): void;
|
|
46
49
|
appendToProp<TProps = Page['props']>(name: string, value: unknown | unknown[] | ((oldValue: unknown, props: TProps) => unknown | unknown[]), options?: Pick<ClientSideVisitOptions, 'onError' | 'onFinish' | 'onSuccess'>): void;
|
|
@@ -53,8 +56,10 @@ export declare class Router {
|
|
|
53
56
|
protected performClientVisit<TProps = Page['props']>(params: ClientSideVisitOptions<TProps>, { replace }?: {
|
|
54
57
|
replace?: boolean;
|
|
55
58
|
}): Promise<void>;
|
|
59
|
+
protected performInstantSwap(visit: PendingVisit): Promise<void>;
|
|
56
60
|
protected getPrefetchParams(href: string | URL | UrlMethodPair, options: VisitOptions): ActiveVisit;
|
|
57
|
-
protected getPendingVisit(href: string | URL | UrlMethodPair, options: VisitOptions
|
|
61
|
+
protected getPendingVisit(href: string | URL | UrlMethodPair, options: VisitOptions): PendingVisit;
|
|
58
62
|
protected getVisitEvents(options: VisitOptions): VisitCallbacks;
|
|
63
|
+
protected applyOptimisticUpdate(optimistic: OptimisticCallback, events: VisitCallbacks): void;
|
|
59
64
|
protected loadDeferredProps(deferred: Page['deferredProps']): void;
|
|
60
65
|
}
|
package/types/server.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ type AppCallback = (page: Page) => InertiaAppResponse;
|
|
|
3
3
|
type ServerOptions = {
|
|
4
4
|
port?: number;
|
|
5
5
|
cluster?: boolean;
|
|
6
|
+
handleErrors?: boolean;
|
|
6
7
|
};
|
|
7
8
|
type Port = number;
|
|
8
|
-
declare const _default: (render: AppCallback, options?: Port | ServerOptions) =>
|
|
9
|
+
declare const _default: (render: AppCallback, options?: Port | ServerOptions) => AppCallback;
|
|
9
10
|
export default _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SSR Error Classification
|
|
3
|
+
*
|
|
4
|
+
* This module detects common SSR errors and provides helpful hints
|
|
5
|
+
* to developers on how to fix them. The most common issue is using
|
|
6
|
+
* browser-specific APIs (like window, document) that don't exist
|
|
7
|
+
* in the Node.js server environment.
|
|
8
|
+
*/
|
|
9
|
+
export type SSRErrorType = 'browser-api' | 'component-resolution' | 'render' | 'unknown';
|
|
10
|
+
type SourceMapResolver = (file: string, line: number, column: number) => {
|
|
11
|
+
file: string;
|
|
12
|
+
line: number;
|
|
13
|
+
column: number;
|
|
14
|
+
} | null;
|
|
15
|
+
export declare function setSourceMapResolver(resolver: SourceMapResolver | null): void;
|
|
16
|
+
export interface ClassifiedSSRError {
|
|
17
|
+
error: string;
|
|
18
|
+
type: SSRErrorType;
|
|
19
|
+
component?: string;
|
|
20
|
+
url?: string;
|
|
21
|
+
browserApi?: string;
|
|
22
|
+
hint: string;
|
|
23
|
+
stack?: string;
|
|
24
|
+
sourceLocation?: string;
|
|
25
|
+
timestamp: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function classifySSRError(error: Error, component?: string, url?: string): ClassifiedSSRError;
|
|
28
|
+
export declare function formatConsoleError(classified: ClassifiedSSRError, root?: string, handleErrors?: boolean, suppressedWarnings?: string[]): string;
|
|
29
|
+
export {};
|