@adonisjs/inertia 4.0.0-next.0 → 4.0.0-next.10
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/README.md +8 -5
- package/build/bin/test.d.ts +1 -0
- package/build/chunk-4EZ2J6OA.js +7 -0
- package/build/chunk-5QRJHXXQ.js +91 -0
- package/build/chunk-DISC5OYC.js +46 -0
- package/build/chunk-MLKGABMK.js +9 -0
- package/build/chunk-YQ72YL64.js +813 -0
- package/build/factories/inertia_factory.d.ts +137 -0
- package/build/factories/main.d.ts +1 -0
- package/build/factories/main.js +175 -0
- package/build/index.d.ts +7 -19
- package/build/index.js +21 -307
- package/build/providers/inertia_provider.d.ts +86 -13
- package/build/providers/inertia_provider.js +48 -18
- package/build/src/client/helpers.d.ts +27 -0
- package/build/src/client/helpers.js +30 -0
- package/build/src/client/react/context.d.ts +24 -0
- package/build/src/client/react/index.d.ts +3 -0
- package/build/src/client/react/index.js +72 -0
- package/build/src/client/react/link.d.ts +64 -0
- package/build/src/client/react/router.d.ts +33 -0
- package/build/src/client/vite.d.ts +65 -0
- package/build/src/{plugins → client}/vite.js +6 -2
- package/build/src/debug.d.ts +22 -0
- package/build/src/define_config.d.ts +30 -0
- package/build/src/headers.d.ts +61 -0
- package/build/src/index_pages.d.ts +32 -0
- package/build/src/inertia.d.ts +261 -0
- package/build/src/inertia_manager.d.ts +47 -0
- package/build/src/inertia_middleware.d.ts +76 -86
- package/build/src/inertia_middleware.js +110 -3
- package/build/src/plugins/edge/plugin.d.ts +30 -6
- package/build/src/plugins/edge/plugin.js +13 -9
- package/build/src/plugins/edge/tags.d.ts +47 -0
- package/build/src/plugins/edge/utils.d.ts +26 -0
- package/build/src/plugins/japa/api_client.d.ts +136 -22
- package/build/src/plugins/japa/api_client.js +36 -48
- package/build/src/props.d.ts +276 -0
- package/build/src/server_renderer.d.ts +54 -0
- package/build/src/symbols.d.ts +25 -0
- package/build/src/types.d.ts +400 -4
- package/build/tests/helpers.d.ts +35 -0
- package/build/tests/index_pages.spec.d.ts +1 -0
- package/build/tests/inertia.spec.d.ts +1 -0
- package/build/tests/inertia_page.spec.d.ts +1 -0
- package/build/tests/middleware.spec.d.ts +1 -0
- package/build/tests/plugins/api_client.spec.d.ts +1 -0
- package/build/tests/plugins/edge.plugin.spec.d.ts +1 -0
- package/build/tests/provider.spec.d.ts +1 -0
- package/build/tests/types/react.spec.d.ts +65 -0
- package/build/tests/types/shared_props.spec.d.ts +1 -0
- package/build/tests/types/to_component_props.spec.d.ts +1 -0
- package/build/tests/types/to_page_props.spec.d.ts +1 -0
- package/package.json +99 -71
- package/build/app.css.stub +0 -13
- package/build/chunk-AWCR2NAY.js +0 -412
- package/build/config.stub +0 -33
- package/build/react/app.tsx.stub +0 -38
- package/build/react/errors/not_found.tsx.stub +0 -14
- package/build/react/errors/server_error.tsx.stub +0 -14
- package/build/react/home.tsx.stub +0 -349
- package/build/react/root.edge.stub +0 -76
- package/build/react/ssr.tsx.stub +0 -17
- package/build/react/tsconfig.json.stub +0 -15
- package/build/solid/app.tsx.stub +0 -38
- package/build/solid/errors/not_found.tsx.stub +0 -14
- package/build/solid/errors/server_error.tsx.stub +0 -14
- package/build/solid/home.tsx.stub +0 -358
- package/build/solid/root.edge.stub +0 -73
- package/build/solid/ssr.tsx.stub +0 -19
- package/build/solid/tsconfig.json.stub +0 -16
- package/build/src/helpers.d.ts +0 -12
- package/build/src/helpers.js +0 -14
- package/build/src/plugins/vite.d.ts +0 -26
- package/build/svelte/app.ts.stub +0 -32
- package/build/svelte/errors/not_found.svelte.stub +0 -10
- package/build/svelte/errors/server_error.svelte.stub +0 -14
- package/build/svelte/home.svelte.stub +0 -339
- package/build/svelte/root.edge.stub +0 -75
- package/build/svelte/ssr.ts.stub +0 -19
- package/build/svelte/tsconfig.json.stub +0 -14
- package/build/types-DVqEHBD1.d.ts +0 -240
- package/build/vue/app.ts.stub +0 -41
- package/build/vue/errors/not_found.vue.stub +0 -10
- package/build/vue/errors/server_error.vue.stub +0 -14
- package/build/vue/home.vue.stub +0 -343
- package/build/vue/root.edge.stub +0 -75
- package/build/vue/ssr.ts.stub +0 -22
- package/build/vue/tsconfig.json.stub +0 -16
package/README.md
CHANGED
|
@@ -5,34 +5,37 @@
|
|
|
5
5
|
[![gh-workflow-image]][gh-workflow-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url]
|
|
6
6
|
|
|
7
7
|
## Introduction
|
|
8
|
+
|
|
8
9
|
Official [Inertia.js](https://inertiajs.com/) adapter for AdonisJS.
|
|
9
10
|
|
|
10
11
|
## Official Documentation
|
|
12
|
+
|
|
11
13
|
The documentation is available on the [AdonisJS website](https://docs.adonisjs.com/guides/views-and-templates/inertia).
|
|
12
14
|
|
|
13
15
|
## Starter Kit
|
|
16
|
+
|
|
14
17
|
The AdonisJS team maintains an Inertia starter kit. This starter kit provides a configurable base application using AdonisJS with Inertia and your favorite frontend framework (e.g. React, Vue.js, Svelte).
|
|
15
18
|
|
|
16
19
|
- [adonisjs/inertia-starter-kit](https://github.com/adonisjs/inertia-starter-kit)
|
|
17
20
|
|
|
18
21
|
## Contributing
|
|
22
|
+
|
|
19
23
|
One of the primary goals of AdonisJS is to have a vibrant community of users and contributors who believes in the principles of the framework.
|
|
20
24
|
|
|
21
25
|
We encourage you to read the [contribution guide](https://github.com/adonisjs/.github/blob/main/docs/CONTRIBUTING.md) before contributing to the framework.
|
|
22
26
|
|
|
23
27
|
## Code of Conduct
|
|
28
|
+
|
|
24
29
|
In order to ensure that the AdonisJS community is welcoming to all, please review and abide by the [Code of Conduct](https://github.com/adonisjs/.github/blob/main/docs/CODE_OF_CONDUCT.md).
|
|
25
30
|
|
|
26
31
|
## License
|
|
32
|
+
|
|
27
33
|
AdonisJS Inertia is open-sourced software licensed under the [MIT license](LICENSE.md).
|
|
28
34
|
|
|
29
35
|
[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/adonisjs/inertia/checks.yml?style=for-the-badge
|
|
30
|
-
[gh-workflow-url]: https://github.com/adonisjs/inertia/actions/workflows/checks.yml
|
|
31
|
-
|
|
36
|
+
[gh-workflow-url]: https://github.com/adonisjs/inertia/actions/workflows/checks.yml 'Github action'
|
|
32
37
|
[npm-image]: https://img.shields.io/npm/v/@adonisjs/inertia/latest.svg?style=for-the-badge&logo=npm
|
|
33
|
-
[npm-url]: https://www.npmjs.com/package/@adonisjs/inertia/v/latest
|
|
34
|
-
|
|
38
|
+
[npm-url]: https://www.npmjs.com/package/@adonisjs/inertia/v/latest 'npm'
|
|
35
39
|
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
|
|
36
|
-
|
|
37
40
|
[license-url]: LICENSE.md
|
|
38
41
|
[license-image]: https://img.shields.io/github/license/adonisjs/inertia?style=for-the-badge
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// src/index_pages.ts
|
|
2
|
+
var GLOB = {
|
|
3
|
+
vue3: ["**/*.vue"],
|
|
4
|
+
react: ["**/*.ts", "**/*.tsx"]
|
|
5
|
+
};
|
|
6
|
+
var SUPPORTED_FRAMEWORKS = Object.keys(GLOB);
|
|
7
|
+
var TYPES_EXTRACTION_HELPER = {
|
|
8
|
+
vue3: `import type { VNodeProps, AllowedComponentProps, ComponentInstance } from 'vue'
|
|
9
|
+
|
|
10
|
+
type ExtractProps<T> = Omit<
|
|
11
|
+
ComponentInstance<T>['$props'],
|
|
12
|
+
keyof VNodeProps | keyof AllowedComponentProps
|
|
13
|
+
>`,
|
|
14
|
+
react: `import type React from 'react'
|
|
15
|
+
import type { Prettify } from '@adonisjs/core/types/common'
|
|
16
|
+
|
|
17
|
+
type ExtractProps<T> =
|
|
18
|
+
T extends React.FC<infer Props>
|
|
19
|
+
? Prettify<Omit<Props, 'children'>>
|
|
20
|
+
: T extends React.Component<infer Props>
|
|
21
|
+
? Prettify<Omit<Props, 'children'>>
|
|
22
|
+
: never`
|
|
23
|
+
};
|
|
24
|
+
var indexPages = function(config) {
|
|
25
|
+
if (!SUPPORTED_FRAMEWORKS.includes(config.framework)) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`Unsupported framework "${config.framework}". Types generation is available only for ${SUPPORTED_FRAMEWORKS.join(",")}`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
/**
|
|
32
|
+
* Executes the page indexing process to generate TypeScript definitions.
|
|
33
|
+
*
|
|
34
|
+
* @param _ - Unused first parameter (assembler context)
|
|
35
|
+
* @param indexGenerator - The index generator instance used to register the pages type generation
|
|
36
|
+
*/
|
|
37
|
+
run(_, indexGenerator) {
|
|
38
|
+
indexGenerator.add("inertiaPages", {
|
|
39
|
+
source: "inertia/pages",
|
|
40
|
+
glob: GLOB[config.framework],
|
|
41
|
+
output: ".adonisjs/server/pages.d.ts",
|
|
42
|
+
/**
|
|
43
|
+
* Generates the TypeScript module declaration for Inertia pages.
|
|
44
|
+
*
|
|
45
|
+
* @param vfs - Virtual file system containing the scanned page files
|
|
46
|
+
* @param buffer - Buffer instance for writing the generated TypeScript code
|
|
47
|
+
* @param __ - Unused third parameter
|
|
48
|
+
* @param helpers - Helper utilities for path manipulation and imports
|
|
49
|
+
*/
|
|
50
|
+
as(vfs, buffer, __, helpers) {
|
|
51
|
+
const filesList = vfs.asList();
|
|
52
|
+
buffer.writeLine(`import '@adonisjs/inertia/types'`);
|
|
53
|
+
buffer.writeLine(TYPES_EXTRACTION_HELPER[config.framework]);
|
|
54
|
+
buffer.write(`declare module '@adonisjs/inertia/types' {`).indent();
|
|
55
|
+
buffer.write(`export interface InertiaPages {`).indent();
|
|
56
|
+
Object.keys(filesList).forEach((key) => {
|
|
57
|
+
buffer.write(
|
|
58
|
+
`'${key}': ExtractProps<(typeof import('${helpers.toImportPath(filesList[key])}'))['default']>`
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
buffer.dedent().write(`}`);
|
|
62
|
+
buffer.dedent().write(`}`);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// src/define_config.ts
|
|
70
|
+
import lodash from "@poppinss/utils/lodash";
|
|
71
|
+
function defineConfig(config) {
|
|
72
|
+
return lodash.merge(
|
|
73
|
+
{
|
|
74
|
+
rootView: "inertia_layout",
|
|
75
|
+
history: {
|
|
76
|
+
encrypt: false
|
|
77
|
+
},
|
|
78
|
+
ssr: {
|
|
79
|
+
enabled: false,
|
|
80
|
+
bundle: "ssr/ssr.js",
|
|
81
|
+
entrypoint: "inertia/ssr.tsx"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
config
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export {
|
|
89
|
+
indexPages,
|
|
90
|
+
defineConfig
|
|
91
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// src/headers.ts
|
|
2
|
+
var InertiaHeaders = {
|
|
3
|
+
/**
|
|
4
|
+
* Header to identify Inertia.js requests.
|
|
5
|
+
* Set to 'true' by Inertia.js client to indicate an Inertia request.
|
|
6
|
+
*/
|
|
7
|
+
Inertia: "x-inertia",
|
|
8
|
+
/**
|
|
9
|
+
* Header to drop a prop from the merge and deep merge object.
|
|
10
|
+
*/
|
|
11
|
+
Reset: "x-inertia-reset",
|
|
12
|
+
/**
|
|
13
|
+
* Header containing the current asset version.
|
|
14
|
+
* Used for cache busting - if versions don't match, Inertia performs a full page reload.
|
|
15
|
+
*/
|
|
16
|
+
Version: "x-inertia-version",
|
|
17
|
+
/**
|
|
18
|
+
* Header containing the target URL for redirects.
|
|
19
|
+
* Used when the server wants to redirect to a different URL than the current request.
|
|
20
|
+
*/
|
|
21
|
+
Location: "x-inertia-location",
|
|
22
|
+
/**
|
|
23
|
+
* Header specifying the error bag name for validation errors.
|
|
24
|
+
* Allows multiple forms on the same page to have separate error handling.
|
|
25
|
+
*/
|
|
26
|
+
ErrorBag: "x-inertia-error-bag",
|
|
27
|
+
/**
|
|
28
|
+
* Header containing comma-separated list of props to include in partial data requests.
|
|
29
|
+
* Only the specified props will be returned in the response.
|
|
30
|
+
*/
|
|
31
|
+
PartialOnly: "x-inertia-partial-data",
|
|
32
|
+
/**
|
|
33
|
+
* Header containing comma-separated list of props to exclude in partial data requests.
|
|
34
|
+
* All props except the specified ones will be returned in the response.
|
|
35
|
+
*/
|
|
36
|
+
PartialExcept: "x-inertia-partial-except",
|
|
37
|
+
/**
|
|
38
|
+
* Header specifying the component name for partial reloads.
|
|
39
|
+
* Used to identify which component is being partially reloaded.
|
|
40
|
+
*/
|
|
41
|
+
PartialComponent: "x-inertia-partial-component"
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
InertiaHeaders
|
|
46
|
+
};
|