@adonisjs/inertia 1.0.0-1 → 1.0.0-11
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/build/app.css.stub +39 -0
- package/build/{chunk-TO74VVAR.js → chunk-CXICUKHN.js} +49 -7
- package/build/{stubs/config.stub → config.stub} +9 -1
- package/build/index.d.ts +2 -2
- package/build/index.js +150 -35
- package/build/providers/inertia_provider.d.ts +10 -3
- package/build/providers/inertia_provider.js +25 -18
- package/build/react/app.tsx.stub +25 -0
- package/build/react/home.tsx.stub +21 -0
- package/build/react/root.edge.stub +22 -0
- package/build/react/ssr.tsx.stub +17 -0
- package/build/react/tsconfig.json.stub +25 -0
- package/build/solid/app.tsx.stub +24 -0
- package/build/solid/home.tsx.stub +21 -0
- package/build/solid/root.edge.stub +21 -0
- package/build/solid/ssr.tsx.stub +19 -0
- package/build/solid/tsconfig.json.stub +26 -0
- package/build/src/helpers.d.ts +12 -0
- package/build/src/helpers.js +14 -0
- package/build/src/inertia_middleware.d.ts +13 -4
- package/build/src/inertia_middleware.js +1 -1
- package/build/src/plugins/edge/plugin.js +85 -0
- package/build/src/plugins/{api_client.d.ts → japa/api_client.d.ts} +1 -1
- package/build/src/plugins/{api_client.js → japa/api_client.js} +1 -1
- package/build/src/plugins/vite.d.ts +26 -0
- package/build/src/plugins/vite.js +33 -0
- package/build/src/types.d.ts +27 -0
- package/build/vue/app.ts.stub +27 -0
- package/build/vue/home.vue.stub +21 -0
- package/build/vue/root.edge.stub +21 -0
- package/build/vue/ssr.ts.stub +22 -0
- package/build/vue/tsconfig.json.stub +26 -0
- package/package.json +48 -40
- package/build/src/plugins/edge.js +0 -41
- /package/build/src/plugins/{edge.d.ts → edge/plugin.d.ts} +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.makePath('resources/ssr.tsx') })
|
|
3
|
+
}}}
|
|
4
|
+
|
|
5
|
+
import { hydrate } from 'solid-js/web'
|
|
6
|
+
import { createInertiaApp } from 'inertia-adapter-solid'
|
|
7
|
+
|
|
8
|
+
export default function render(page: any) {
|
|
9
|
+
return createInertiaApp({
|
|
10
|
+
page,
|
|
11
|
+
resolve: (name) => {
|
|
12
|
+
const pages = import.meta.glob('./pages/**/*.tsx', { eager: true })
|
|
13
|
+
{{ 'return pages[`./pages/${name}.tsx`]' }}
|
|
14
|
+
},
|
|
15
|
+
setup({ el, App, props }) {
|
|
16
|
+
hydrate(() => <App {...props} />, el)
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.makePath('resources/tsconfig.json') })
|
|
3
|
+
}}}
|
|
4
|
+
{
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"target": "ESNext",
|
|
7
|
+
"jsx": "preserve",
|
|
8
|
+
"jsxImportSource": "solid-js",
|
|
9
|
+
"lib": ["DOM", "ESNext", "DOM.Iterable", "ES2020"],
|
|
10
|
+
"useDefineForClassFields": true,
|
|
11
|
+
"baseUrl": ".",
|
|
12
|
+
"module": "ESNext",
|
|
13
|
+
"moduleResolution": "Bundler",
|
|
14
|
+
"paths": {
|
|
15
|
+
"@/*": ["./*"],
|
|
16
|
+
"~/*": ["../*"],
|
|
17
|
+
},
|
|
18
|
+
"resolveJsonModule": true,
|
|
19
|
+
"types": ["vite/client"],
|
|
20
|
+
"allowSyntheticDefaultImports": true,
|
|
21
|
+
"esModuleInterop": true,
|
|
22
|
+
"verbatimModuleSyntax": true,
|
|
23
|
+
"skipLibCheck": true,
|
|
24
|
+
},
|
|
25
|
+
"include": ["./**/*.ts", "./**/*.tsx"],
|
|
26
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility function to resolve a page component
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* return resolvePageComponent(
|
|
6
|
+
* `./pages/${name}.vue`,
|
|
7
|
+
* import.meta.glob<DefineComponent>("./pages/**\/*.vue")
|
|
8
|
+
* )
|
|
9
|
+
*/
|
|
10
|
+
declare function resolvePageComponent<T>(path: string | string[], pages: Record<string, Promise<T> | (() => Promise<T>)>): Promise<T>;
|
|
11
|
+
|
|
12
|
+
export { resolvePageComponent };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/helpers.ts
|
|
2
|
+
async function resolvePageComponent(path, pages) {
|
|
3
|
+
for (const p of Array.isArray(path) ? path : [path]) {
|
|
4
|
+
const page = pages[p];
|
|
5
|
+
if (typeof page === "undefined") {
|
|
6
|
+
continue;
|
|
7
|
+
}
|
|
8
|
+
return typeof page === "function" ? page() : page;
|
|
9
|
+
}
|
|
10
|
+
throw new Error(`Page not found: ${path}`);
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
resolvePageComponent
|
|
14
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { Vite } from '@adonisjs/vite';
|
|
1
2
|
import { HttpContext } from '@adonisjs/core/http';
|
|
2
3
|
import { NextFn } from '@adonisjs/core/types/http';
|
|
3
|
-
import {
|
|
4
|
+
import { ViteRuntime } from 'vite/runtime';
|
|
5
|
+
import { ResolvedConfig, Data, PageProps, MaybePromise } from './types.js';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Symbol used to identify lazy props
|
|
@@ -13,11 +15,17 @@ declare class Inertia {
|
|
|
13
15
|
#private;
|
|
14
16
|
protected ctx: HttpContext;
|
|
15
17
|
protected config: ResolvedConfig;
|
|
16
|
-
|
|
18
|
+
protected viteRuntime?: ViteRuntime | undefined;
|
|
19
|
+
constructor(ctx: HttpContext, config: ResolvedConfig, viteRuntime?: ViteRuntime | undefined);
|
|
20
|
+
/**
|
|
21
|
+
* Share data for the current request.
|
|
22
|
+
* This data will override any shared data defined in the config.
|
|
23
|
+
*/
|
|
24
|
+
share(data: Record<string, Data>): void;
|
|
17
25
|
/**
|
|
18
26
|
* Render a page using Inertia
|
|
19
27
|
*/
|
|
20
|
-
render<
|
|
28
|
+
render<TPageProps extends Record<string, any> = PageProps, TViewProps extends Record<string, any> = PageProps>(component: string, pageProps?: TPageProps, viewProps?: TViewProps): Promise<string | {
|
|
21
29
|
component: string;
|
|
22
30
|
version: string | number;
|
|
23
31
|
props: any;
|
|
@@ -56,8 +64,9 @@ declare module '@adonisjs/core/http' {
|
|
|
56
64
|
* set appropriate headers/status
|
|
57
65
|
*/
|
|
58
66
|
declare class InertiaMiddleware {
|
|
67
|
+
#private;
|
|
59
68
|
protected config: ResolvedConfig;
|
|
60
|
-
constructor(config: ResolvedConfig);
|
|
69
|
+
constructor(config: ResolvedConfig, vite?: Vite);
|
|
61
70
|
handle(ctx: HttpContext, next: NextFn): Promise<void>;
|
|
62
71
|
}
|
|
63
72
|
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// src/plugins/edge/plugin.ts
|
|
2
|
+
import { encode } from "html-entities";
|
|
3
|
+
|
|
4
|
+
// src/debug.ts
|
|
5
|
+
import { debuglog } from "node:util";
|
|
6
|
+
var debug_default = debuglog("adonisjs:inertia");
|
|
7
|
+
|
|
8
|
+
// src/plugins/edge/tags.ts
|
|
9
|
+
import { EdgeError } from "edge-error";
|
|
10
|
+
|
|
11
|
+
// src/plugins/edge/utils.ts
|
|
12
|
+
function isSubsetOf(expression, expressions, errorCallback) {
|
|
13
|
+
if (!expressions.includes(expression.type)) {
|
|
14
|
+
errorCallback();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// src/plugins/edge/tags.ts
|
|
19
|
+
var inertiaTag = {
|
|
20
|
+
block: false,
|
|
21
|
+
tagName: "inertia",
|
|
22
|
+
seekable: true,
|
|
23
|
+
compile(parser, buffer, { filename, loc, properties }) {
|
|
24
|
+
if (properties.jsArg.trim() === "") {
|
|
25
|
+
buffer.writeExpression(`out += state.inertia(state.page)`, filename, loc.start.line);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
properties.jsArg = `(${properties.jsArg})`;
|
|
29
|
+
const parsed = parser.utils.transformAst(
|
|
30
|
+
parser.utils.generateAST(properties.jsArg, loc, filename),
|
|
31
|
+
filename,
|
|
32
|
+
parser
|
|
33
|
+
);
|
|
34
|
+
isSubsetOf(parsed, ["ObjectExpression"], () => {
|
|
35
|
+
const { line, col } = parser.utils.getExpressionLoc(parsed);
|
|
36
|
+
throw new EdgeError(
|
|
37
|
+
`"${properties.jsArg}" is not a valid argument for @inertia`,
|
|
38
|
+
"E_UNALLOWED_EXPRESSION",
|
|
39
|
+
{ line, col, filename }
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
const attributes = parser.utils.stringify(parsed);
|
|
43
|
+
buffer.writeExpression(
|
|
44
|
+
`out += state.inertia(state.page, ${attributes})`,
|
|
45
|
+
filename,
|
|
46
|
+
loc.start.line
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var inertiaHeadTag = {
|
|
51
|
+
block: false,
|
|
52
|
+
tagName: "inertiaHead",
|
|
53
|
+
seekable: false,
|
|
54
|
+
compile(_, buffer, { filename, loc }) {
|
|
55
|
+
buffer.writeExpression(`out += state.inertiaHead(state.page)`, filename, loc.start.line);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// src/plugins/edge/plugin.ts
|
|
60
|
+
var edgePluginInertia = () => {
|
|
61
|
+
return (edge) => {
|
|
62
|
+
debug_default("sharing globals and inertia tags with edge");
|
|
63
|
+
edge.global(
|
|
64
|
+
"inertia",
|
|
65
|
+
(page = {}, attributes = {}) => {
|
|
66
|
+
if (page.ssrBody)
|
|
67
|
+
return page.ssrBody;
|
|
68
|
+
const className = attributes?.class ? ` class="${attributes.class}"` : "";
|
|
69
|
+
const id = attributes?.id ? ` id="${attributes.id}"` : ' id="app"';
|
|
70
|
+
const tag = attributes?.as || "div";
|
|
71
|
+
const dataPage = encode(JSON.stringify(page));
|
|
72
|
+
return `<${tag}${id}${className} data-page="${dataPage}"></${tag}>`;
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
edge.global("inertiaHead", (page) => {
|
|
76
|
+
const { ssrHead = [] } = page || {};
|
|
77
|
+
return ssrHead.join("\n");
|
|
78
|
+
});
|
|
79
|
+
edge.registerTag(inertiaHeadTag);
|
|
80
|
+
edge.registerTag(inertiaTag);
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
export {
|
|
84
|
+
edgePluginInertia
|
|
85
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PluginFn } from '@japa/runner/types';
|
|
2
|
-
import { PageProps } from '../types.js';
|
|
3
2
|
import { ApplicationService } from '@adonisjs/core/types';
|
|
3
|
+
import { PageProps } from '../../types.js';
|
|
4
4
|
import '@adonisjs/core/http';
|
|
5
5
|
|
|
6
6
|
declare module '@japa/api-client' {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PluginOption } from 'vite';
|
|
2
|
+
|
|
3
|
+
type InertiaPluginOptions = {
|
|
4
|
+
ssr?: {
|
|
5
|
+
/**
|
|
6
|
+
* Whether or not to enable server-side rendering
|
|
7
|
+
*/
|
|
8
|
+
enabled: true;
|
|
9
|
+
/**
|
|
10
|
+
* The entrypoint for the server-side rendering
|
|
11
|
+
*/
|
|
12
|
+
entrypoint: string;
|
|
13
|
+
/**
|
|
14
|
+
* The output directory for the server-side rendering bundle
|
|
15
|
+
*/
|
|
16
|
+
output?: string;
|
|
17
|
+
} | {
|
|
18
|
+
enabled: false;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Inertia plugin for Vite that is tailored for AdonisJS
|
|
23
|
+
*/
|
|
24
|
+
declare function inertia(options?: InertiaPluginOptions): PluginOption;
|
|
25
|
+
|
|
26
|
+
export { type InertiaPluginOptions, inertia as default };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/plugins/vite.ts
|
|
2
|
+
function inertia(options) {
|
|
3
|
+
return {
|
|
4
|
+
name: "vite-plugin-inertia",
|
|
5
|
+
config: () => {
|
|
6
|
+
if (!options?.ssr?.enabled)
|
|
7
|
+
return {};
|
|
8
|
+
return {
|
|
9
|
+
buildSteps: [
|
|
10
|
+
{
|
|
11
|
+
name: "build-client",
|
|
12
|
+
description: "build inertia client bundle",
|
|
13
|
+
config: { build: { outDir: "build/public/assets/" } }
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "build-ssr",
|
|
17
|
+
description: "build inertia server bundle",
|
|
18
|
+
config: {
|
|
19
|
+
build: {
|
|
20
|
+
ssr: true,
|
|
21
|
+
outDir: options.ssr.output || "build/ssr",
|
|
22
|
+
rollupOptions: { input: options.ssr.entrypoint }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
inertia as default
|
|
33
|
+
};
|
package/build/src/types.d.ts
CHANGED
|
@@ -56,6 +56,27 @@ interface InertiaConfig {
|
|
|
56
56
|
* Data that should be shared with all rendered pages
|
|
57
57
|
*/
|
|
58
58
|
sharedData?: SharedData;
|
|
59
|
+
/**
|
|
60
|
+
* Options to configure SSR
|
|
61
|
+
*/
|
|
62
|
+
ssr?: {
|
|
63
|
+
/**
|
|
64
|
+
* Enable or disable SSR
|
|
65
|
+
*/
|
|
66
|
+
enabled: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* List of components that should be rendered on the server
|
|
69
|
+
*/
|
|
70
|
+
pages?: string[];
|
|
71
|
+
/**
|
|
72
|
+
* Path to the SSR entrypoint file
|
|
73
|
+
*/
|
|
74
|
+
entrypoint?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Path to the SSR bundled file that will be used in production
|
|
77
|
+
*/
|
|
78
|
+
bundle?: string;
|
|
79
|
+
};
|
|
59
80
|
}
|
|
60
81
|
/**
|
|
61
82
|
* Resolved inertia configuration
|
|
@@ -64,6 +85,12 @@ interface ResolvedConfig {
|
|
|
64
85
|
rootView: string;
|
|
65
86
|
versionCache: VersionCache;
|
|
66
87
|
sharedData: SharedData;
|
|
88
|
+
ssr: {
|
|
89
|
+
enabled: boolean;
|
|
90
|
+
entrypoint: string;
|
|
91
|
+
pages?: string[];
|
|
92
|
+
bundle: string;
|
|
93
|
+
};
|
|
67
94
|
}
|
|
68
95
|
|
|
69
96
|
export type { AssetsVersion, Data, InertiaConfig, MaybePromise, PageProps, ResolvedConfig, SharedData, SharedDatumFactory };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.makePath('resources/app.ts') })
|
|
3
|
+
}}}
|
|
4
|
+
import './css/app.css';
|
|
5
|
+
|
|
6
|
+
import { createApp, h } from 'vue'
|
|
7
|
+
import type { DefineComponent } from 'vue'
|
|
8
|
+
import { createInertiaApp } from '@inertiajs/vue3'
|
|
9
|
+
|
|
10
|
+
const appName = import.meta.env.VITE_APP_NAME || 'AdonisJS'
|
|
11
|
+
|
|
12
|
+
createInertiaApp({
|
|
13
|
+
progress: { color: '#5468FF' },
|
|
14
|
+
|
|
15
|
+
title: (title) => {{ '`${title} - ${appName}`' }},
|
|
16
|
+
|
|
17
|
+
resolve: (name) => {
|
|
18
|
+
const pages = import.meta.glob<DefineComponent>('./pages/**/*.vue', { eager: true })
|
|
19
|
+
{{ 'return pages[`./pages/${name}.vue`]' }}
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
setup({ el, App, props, plugin }) {
|
|
23
|
+
createApp({ render: () => h(App, props) })
|
|
24
|
+
.use(plugin)
|
|
25
|
+
.mount(el)
|
|
26
|
+
},
|
|
27
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.makePath('resources/pages/home.vue') })
|
|
3
|
+
}}}
|
|
4
|
+
<script setup lang="ts">
|
|
5
|
+
import { Head } from '@inertiajs/vue3'
|
|
6
|
+
|
|
7
|
+
defineProps<{ version: number }>()
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<Head title="Homepage" />
|
|
12
|
+
|
|
13
|
+
<div className="container">
|
|
14
|
+
<div className="title">AdonisJS \{\{ version \}\} x Inertia x Vue.js</div>
|
|
15
|
+
|
|
16
|
+
<span>
|
|
17
|
+
Learn more about AdonisJS and Inertia.js by visiting the
|
|
18
|
+
<a href="https://docs.adonisjs.com/inertia">AdonisJS documentation</a>.
|
|
19
|
+
</span>
|
|
20
|
+
</div>
|
|
21
|
+
</template>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.makePath('resources/views/root.edge') })
|
|
3
|
+
}}}
|
|
4
|
+
<!DOCTYPE html>
|
|
5
|
+
<html>
|
|
6
|
+
|
|
7
|
+
<head>
|
|
8
|
+
<meta charset="utf-8">
|
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
10
|
+
|
|
11
|
+
<title inertia>AdonisJS x Inertia x VueJS</title>
|
|
12
|
+
|
|
13
|
+
@vite(['resources/app.ts'])
|
|
14
|
+
@inertiaHead()
|
|
15
|
+
</head>
|
|
16
|
+
|
|
17
|
+
<body>
|
|
18
|
+
@inertia()
|
|
19
|
+
</body>
|
|
20
|
+
|
|
21
|
+
</html>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.makePath('resources/ssr.ts') })
|
|
3
|
+
}}}
|
|
4
|
+
|
|
5
|
+
import { createInertiaApp } from '@inertiajs/vue3'
|
|
6
|
+
import { renderToString } from '@vue/server-renderer'
|
|
7
|
+
import { createSSRApp, h, type DefineComponent } from 'vue'
|
|
8
|
+
|
|
9
|
+
export default function render(page: any) {
|
|
10
|
+
return createInertiaApp({
|
|
11
|
+
page,
|
|
12
|
+
render: renderToString,
|
|
13
|
+
resolve: (name) => {
|
|
14
|
+
const pages = import.meta.glob<DefineComponent>('./pages/**/*.vue', { eager: true })
|
|
15
|
+
{{ 'return pages[`./pages/${name}.vue`]' }}
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
setup({ App, props, plugin }) {
|
|
19
|
+
return createSSRApp({ render: () => h(App, props) }).use(plugin)
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.makePath('resources/tsconfig.json') })
|
|
3
|
+
}}}
|
|
4
|
+
{
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"target": "ESNext",
|
|
7
|
+
"jsx": "preserve",
|
|
8
|
+
"jsxImportSource": "vue",
|
|
9
|
+
"lib": ["DOM", "ESNext", "DOM.Iterable", "ES2020"],
|
|
10
|
+
"useDefineForClassFields": true,
|
|
11
|
+
"baseUrl": ".",
|
|
12
|
+
"module": "ESNext",
|
|
13
|
+
"moduleResolution": "Bundler",
|
|
14
|
+
"paths": {
|
|
15
|
+
"@/*": ["./*"],
|
|
16
|
+
"~/*": ["../*"],
|
|
17
|
+
},
|
|
18
|
+
"resolveJsonModule": true,
|
|
19
|
+
"types": ["vite/client"],
|
|
20
|
+
"allowSyntheticDefaultImports": true,
|
|
21
|
+
"esModuleInterop": true,
|
|
22
|
+
"verbatimModuleSyntax": true,
|
|
23
|
+
"skipLibCheck": true,
|
|
24
|
+
},
|
|
25
|
+
"include": ["./**/*.ts", "./**/*.vue"],
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/inertia",
|
|
3
3
|
"description": "Official Inertia.js adapter for AdonisJS",
|
|
4
|
-
"version": "1.0.0-
|
|
4
|
+
"version": "1.0.0-11",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.16.0"
|
|
7
7
|
},
|
|
@@ -16,12 +16,14 @@
|
|
|
16
16
|
"./services/main": "./build/services/inertia.js",
|
|
17
17
|
"./inertia_middleware": "./build/src/inertia_middleware.js",
|
|
18
18
|
"./inertia_provider": "./build/providers/inertia_provider.js",
|
|
19
|
-
"./plugins/edge": "./build/src/plugins/edge.js",
|
|
20
|
-
"./plugins/api_client": "./build/src/plugins/api_client.js"
|
|
19
|
+
"./plugins/edge": "./build/src/plugins/edge/plugin.js",
|
|
20
|
+
"./plugins/api_client": "./build/src/plugins/japa/api_client.js",
|
|
21
|
+
"./client": "./build/src/plugins/vite.js",
|
|
22
|
+
"./helpers": "./build/src/helpers.js"
|
|
21
23
|
},
|
|
22
24
|
"scripts": {
|
|
23
25
|
"clean": "del-cli build",
|
|
24
|
-
"copy:templates": "copyfiles \"stubs/**/*.stub\" build",
|
|
26
|
+
"copy:templates": "copyfiles --up 1 \"stubs/**/*.stub\" build",
|
|
25
27
|
"typecheck": "tsc --noEmit",
|
|
26
28
|
"lint": "eslint . --ext=.ts",
|
|
27
29
|
"format": "prettier --write .",
|
|
@@ -36,54 +38,58 @@
|
|
|
36
38
|
"prepublishOnly": "npm run build"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
|
-
"@adonisjs/assembler": "
|
|
40
|
-
"@adonisjs/core": "6.1
|
|
41
|
-
"@adonisjs/eslint-config": "^1.
|
|
42
|
-
"@adonisjs/prettier-config": "^1.
|
|
43
|
-
"@adonisjs/session": "7.
|
|
44
|
-
"@adonisjs/tsconfig": "^1.
|
|
45
|
-
"@
|
|
46
|
-
"@japa/
|
|
47
|
-
"@japa/
|
|
48
|
-
"@japa/
|
|
49
|
-
"@japa/
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"@
|
|
54
|
-
"
|
|
41
|
+
"@adonisjs/assembler": "^7.2.3",
|
|
42
|
+
"@adonisjs/core": "6.3.1",
|
|
43
|
+
"@adonisjs/eslint-config": "^1.2.2",
|
|
44
|
+
"@adonisjs/prettier-config": "^1.2.2",
|
|
45
|
+
"@adonisjs/session": "7.1.1",
|
|
46
|
+
"@adonisjs/tsconfig": "^1.2.2",
|
|
47
|
+
"@adonisjs/vite": "^3.0.0-2",
|
|
48
|
+
"@japa/api-client": "^2.0.2",
|
|
49
|
+
"@japa/assert": "2.1.0",
|
|
50
|
+
"@japa/expect-type": "^2.0.1",
|
|
51
|
+
"@japa/file-system": "^2.2.0",
|
|
52
|
+
"@japa/plugin-adonisjs": "^3.0.0",
|
|
53
|
+
"@japa/runner": "3.1.1",
|
|
54
|
+
"@japa/snapshot": "^2.0.4",
|
|
55
|
+
"@swc/core": "^1.4.2",
|
|
56
|
+
"@types/node": "^20.11.24",
|
|
57
|
+
"@types/qs": "^6.9.12",
|
|
58
|
+
"@types/supertest": "^6.0.2",
|
|
59
|
+
"@vavite/multibuild": "^4.1.1",
|
|
60
|
+
"c8": "^9.1.0",
|
|
55
61
|
"copyfiles": "^2.4.1",
|
|
56
62
|
"del-cli": "^5.1.0",
|
|
57
|
-
"edge
|
|
58
|
-
"
|
|
63
|
+
"edge-parser": "^9.0.1",
|
|
64
|
+
"edge.js": "^6.0.1",
|
|
65
|
+
"eslint": "^8.57.0",
|
|
59
66
|
"get-port": "^7.0.0",
|
|
60
|
-
"np": "^
|
|
61
|
-
"prettier": "^3.
|
|
62
|
-
"supertest": "^6.3.
|
|
63
|
-
"tinybench": "^2.
|
|
64
|
-
"ts-node": "^10.9.
|
|
65
|
-
"tsup": "^
|
|
66
|
-
"typescript": "
|
|
67
|
+
"np": "^10.0.0",
|
|
68
|
+
"prettier": "^3.2.5",
|
|
69
|
+
"supertest": "^6.3.4",
|
|
70
|
+
"tinybench": "^2.6.0",
|
|
71
|
+
"ts-node": "^10.9.2",
|
|
72
|
+
"tsup": "^8.0.2",
|
|
73
|
+
"typescript": "~5.3.3",
|
|
74
|
+
"vite": "^5.1.4"
|
|
67
75
|
},
|
|
68
76
|
"dependencies": {
|
|
69
|
-
"@poppinss/utils": "^6.
|
|
77
|
+
"@poppinss/utils": "^6.7.2",
|
|
70
78
|
"crc-32": "^1.2.2",
|
|
79
|
+
"edge-error": "^4.0.1",
|
|
71
80
|
"html-entities": "^2.4.0",
|
|
72
81
|
"qs": "^6.11.2"
|
|
73
82
|
},
|
|
74
83
|
"peerDependencies": {
|
|
75
|
-
"@adonisjs/
|
|
76
|
-
"@adonisjs/
|
|
77
|
-
"@adonisjs/
|
|
78
|
-
"@japa/api-client": "^2.0.
|
|
84
|
+
"@adonisjs/core": "^6.2.0",
|
|
85
|
+
"@adonisjs/session": "^7.0.0",
|
|
86
|
+
"@adonisjs/vite": "^3.0.0-2",
|
|
87
|
+
"@japa/api-client": "^2.0.0",
|
|
79
88
|
"edge.js": "^6.0.0"
|
|
80
89
|
},
|
|
81
90
|
"peerDependenciesMeta": {
|
|
82
|
-
"@adonisjs/assembler": {
|
|
83
|
-
"optional": false
|
|
84
|
-
},
|
|
85
91
|
"@japa/api-client": {
|
|
86
|
-
"optional":
|
|
92
|
+
"optional": true
|
|
87
93
|
}
|
|
88
94
|
},
|
|
89
95
|
"author": "Julien Ripouteau <julien@ripouteau.com>,adonisjs",
|
|
@@ -120,11 +126,13 @@
|
|
|
120
126
|
"entry": [
|
|
121
127
|
"./index.ts",
|
|
122
128
|
"./src/types.ts",
|
|
129
|
+
"./src/helpers.ts",
|
|
130
|
+
"./src/plugins/vite.ts",
|
|
123
131
|
"./services/inertia.ts",
|
|
124
132
|
"./src/inertia_middleware.ts",
|
|
125
133
|
"./providers/inertia_provider.ts",
|
|
126
|
-
"./src/plugins/edge.ts",
|
|
127
|
-
"./src/plugins/api_client.ts"
|
|
134
|
+
"./src/plugins/edge/plugin.ts",
|
|
135
|
+
"./src/plugins/japa/api_client.ts"
|
|
128
136
|
],
|
|
129
137
|
"outDir": "./build",
|
|
130
138
|
"clean": true,
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// src/plugins/edge.ts
|
|
2
|
-
import { encode } from "html-entities";
|
|
3
|
-
|
|
4
|
-
// src/debug.ts
|
|
5
|
-
import { debuglog } from "node:util";
|
|
6
|
-
var debug_default = debuglog("adonisjs:inertia");
|
|
7
|
-
|
|
8
|
-
// src/plugins/edge.ts
|
|
9
|
-
var edgePluginInertia = () => {
|
|
10
|
-
return (edge) => {
|
|
11
|
-
debug_default("sharing globals and inertia tags with edge");
|
|
12
|
-
edge.global("inertia", (page = {}) => {
|
|
13
|
-
if (page.ssrBody)
|
|
14
|
-
return page.ssrBody;
|
|
15
|
-
return `<div id="app" data-page="${encode(JSON.stringify(page))}"></div>`;
|
|
16
|
-
});
|
|
17
|
-
edge.global("inertiaHead", (page) => {
|
|
18
|
-
const { ssrHead = [] } = page || {};
|
|
19
|
-
return ssrHead.join("\n");
|
|
20
|
-
});
|
|
21
|
-
edge.registerTag({
|
|
22
|
-
block: false,
|
|
23
|
-
tagName: "inertia",
|
|
24
|
-
seekable: false,
|
|
25
|
-
compile(_, buffer, { filename, loc }) {
|
|
26
|
-
buffer.writeExpression(`out += state.inertia(state.page)`, filename, loc.start.line);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
edge.registerTag({
|
|
30
|
-
block: false,
|
|
31
|
-
tagName: "inertiaHead",
|
|
32
|
-
seekable: false,
|
|
33
|
-
compile(_, buffer, { filename, loc }) {
|
|
34
|
-
buffer.writeExpression(`out += state.inertiaHead(state.page)`, filename, loc.start.line);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
export {
|
|
40
|
-
edgePluginInertia
|
|
41
|
-
};
|
|
File without changes
|