@dokebi/template-inertia 0.4.19 → 0.4.20
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/AI.md +21 -0
- package/README.md +4 -0
- package/dist/errors.d.ts +2 -2
- package/dist/errors.js +3 -0
- package/dist/index.js +1 -1
- package/dist/template-build.d.ts +43 -0
- package/dist/template-build.js +335 -0
- package/dist/template-bundle.d.ts +102 -0
- package/dist/template-bundle.js +344 -0
- package/dist/template-shared.d.ts +93 -0
- package/dist/template-shared.js +197 -0
- package/dist/template.d.ts +3 -0
- package/dist/template.js +5 -0
- package/dist/vite-plugin.d.ts +20 -2
- package/dist/vite-plugin.js +24 -0
- package/package.json +6 -2
package/dist/vite-plugin.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type Logger } from '@dokebi/core';
|
|
2
2
|
import { type PagesDevServer } from './module-pages.js';
|
|
3
|
+
import { type DokebiInertiaTemplateOptions, type InputOptionsShape } from './template-shared.js';
|
|
3
4
|
import { type DevFilesOptions, type DevFilesPatch, type DevMiddleware, type ResolvedFilesShape } from './vite-files.js';
|
|
4
5
|
export { MODULE_PAGES_ID } from './module-pages.js';
|
|
6
|
+
export { type DokebiInertiaTemplateOptions, SHARED_FILE, type SharedFile, } from './template-shared.js';
|
|
5
7
|
export { DEV_FILES_DENY, type DevFilesOptions, type DokebiDevFilesPlugin, dokebiDevFiles, } from './vite-files.js';
|
|
6
8
|
/** Specifier → the URL the app serves it at (@dokebi/seal, `GET /dokebi/seal/*`). */
|
|
7
9
|
export declare const SERVED_MODULES: Readonly<Record<string, string>>;
|
|
@@ -13,9 +15,21 @@ export interface DokebiInertiaViteOptions extends DevFilesOptions {
|
|
|
13
15
|
* `DOKEBI_LOG_LEVEL` (`info` when unset), the level `dokebi dev` passes to its processes.
|
|
14
16
|
*/
|
|
15
17
|
readonly logger?: Logger;
|
|
18
|
+
/**
|
|
19
|
+
* D-0291: provide the shared modules of template bundles (vue, @inertiajs/vue3,
|
|
20
|
+
* @dokebi/template-inertia/{i18n,pages} and `shared`, the app's SDK) as entries of this build,
|
|
21
|
+
* listed in `<outDir>/.vite/dokebi-shared.json`. Give the same value in the browser and the
|
|
22
|
+
* server vite config. Without it the build is as before.
|
|
23
|
+
*/
|
|
24
|
+
readonly templates?: DokebiInertiaTemplateOptions;
|
|
16
25
|
}
|
|
17
26
|
/** The part of Vite's resolved config this plugin reads. */
|
|
18
|
-
type ResolvedConfigShape = ResolvedFilesShape
|
|
27
|
+
type ResolvedConfigShape = ResolvedFilesShape & {
|
|
28
|
+
readonly build?: {
|
|
29
|
+
readonly ssr?: unknown;
|
|
30
|
+
readonly outDir?: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
19
33
|
/** The part of Vite's dev server this plugin uses (connect middlewares). */
|
|
20
34
|
interface DevServerShape extends PagesDevServer {
|
|
21
35
|
readonly middlewares: {
|
|
@@ -60,7 +74,11 @@ export interface DokebiInertiaVitePlugin {
|
|
|
60
74
|
id: string;
|
|
61
75
|
external: true | 'absolute';
|
|
62
76
|
} | string | null;
|
|
63
|
-
load(id: string): string | null | Promise<string | null>;
|
|
77
|
+
load(this: unknown, id: string): string | null | Promise<string | null>;
|
|
78
|
+
/** Rollup's input options (D-0291: the shared entries join the inputs). */
|
|
79
|
+
options(input: InputOptionsShape): InputOptionsShape | null;
|
|
80
|
+
/** D-0291: writes dokebi-shared.json after a build. */
|
|
81
|
+
writeBundle(output: unknown, bundle: Readonly<Record<string, never>>): Promise<void>;
|
|
64
82
|
configureServer(server: DevServerShape): void;
|
|
65
83
|
/** Vite calls it when the dev server closes (or restarts) and after a build. */
|
|
66
84
|
closeBundle(): void;
|
package/dist/vite-plugin.js
CHANGED
|
@@ -29,8 +29,10 @@
|
|
|
29
29
|
// remote hosts), so an upgrade of this package secures every vite.config that uses it.
|
|
30
30
|
import { ConsoleLogger } from '@dokebi/core';
|
|
31
31
|
import { MODULE_PAGES_ID, ModulePagesSource } from './module-pages.js';
|
|
32
|
+
import { SharedEntries, } from './template-shared.js';
|
|
32
33
|
import { DevFilesPolicy, } from './vite-files.js';
|
|
33
34
|
export { MODULE_PAGES_ID } from './module-pages.js';
|
|
35
|
+
export { SHARED_FILE, } from './template-shared.js';
|
|
34
36
|
export { DEV_FILES_DENY, dokebiDevFiles, } from './vite-files.js';
|
|
35
37
|
/** Specifier → the URL the app serves it at (@dokebi/seal, `GET /dokebi/seal/*`). */
|
|
36
38
|
export const SERVED_MODULES = Object.freeze({
|
|
@@ -92,6 +94,8 @@ export function dokebiInertia(options = {}) {
|
|
|
92
94
|
const dev = new Map(Object.values(SERVED_MODULES).map((served) => [devId(served), served]));
|
|
93
95
|
/** Request path (with and without `base`) → the module text the dev server answers. */
|
|
94
96
|
const answers = new Map();
|
|
97
|
+
// D-0291: the shared modules of template bundles, when the app opts in.
|
|
98
|
+
const shared = options.templates ? new SharedEntries(logger, options.templates) : undefined;
|
|
95
99
|
return {
|
|
96
100
|
name: 'dokebi-inertia',
|
|
97
101
|
enforce: 'pre',
|
|
@@ -111,6 +115,15 @@ export function dokebiInertia(options = {}) {
|
|
|
111
115
|
},
|
|
112
116
|
configResolved(config) {
|
|
113
117
|
files.configResolved(config);
|
|
118
|
+
shared?.configResolved({
|
|
119
|
+
root: config.root ?? process.cwd(),
|
|
120
|
+
command: config.command,
|
|
121
|
+
base: config.base,
|
|
122
|
+
build: {
|
|
123
|
+
ssr: config.build?.ssr,
|
|
124
|
+
outDir: config.build?.outDir ?? 'dist',
|
|
125
|
+
},
|
|
126
|
+
});
|
|
114
127
|
command = config.command;
|
|
115
128
|
pages.command = command;
|
|
116
129
|
base = config.base || '/';
|
|
@@ -126,9 +139,18 @@ export function dokebiInertia(options = {}) {
|
|
|
126
139
|
modules: SERVED_MODULES,
|
|
127
140
|
});
|
|
128
141
|
},
|
|
142
|
+
options(input) {
|
|
143
|
+
return shared ? shared.options(input) : null;
|
|
144
|
+
},
|
|
145
|
+
async writeBundle(_output, bundle) {
|
|
146
|
+
await shared?.writeBundle(bundle);
|
|
147
|
+
},
|
|
129
148
|
resolveId(source, importer, resolveOptions) {
|
|
130
149
|
if (source === MODULE_PAGES_ID)
|
|
131
150
|
return pages.resolve(source, importer);
|
|
151
|
+
const entry = shared?.resolveId(source);
|
|
152
|
+
if (entry)
|
|
153
|
+
return entry;
|
|
132
154
|
const served = SERVED_MODULES[source];
|
|
133
155
|
if (served === undefined)
|
|
134
156
|
return null;
|
|
@@ -148,6 +170,8 @@ export function dokebiInertia(options = {}) {
|
|
|
148
170
|
load(id) {
|
|
149
171
|
if (id.startsWith('\0dokebi-module-pages:'))
|
|
150
172
|
return pages.load(id);
|
|
173
|
+
if (shared && id.startsWith('\0dokebi-shared:'))
|
|
174
|
+
return shared.load(this, id);
|
|
151
175
|
// Vite pre-transforms the imports it sees, the dev re-export too. The middleware below
|
|
152
176
|
// answers its URL before Vite does, so this text only fills Vite's module graph; were it
|
|
153
177
|
// ever served, the page would fail loudly instead of running without the served module.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dokebi/template-inertia",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.20",
|
|
4
4
|
"description": "Inertia v3 server adapter for Dokebi: page JSON, Vite manifest assets and optional server-side rendering.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dokebi",
|
|
@@ -38,6 +38,10 @@
|
|
|
38
38
|
"types": "./dist/pages.d.ts",
|
|
39
39
|
"import": "./dist/pages.js"
|
|
40
40
|
},
|
|
41
|
+
"./template": {
|
|
42
|
+
"types": "./dist/template.d.ts",
|
|
43
|
+
"default": "./dist/template.js"
|
|
44
|
+
},
|
|
41
45
|
"./module-pages": {
|
|
42
46
|
"types": "./module-pages.d.ts"
|
|
43
47
|
}
|
|
@@ -145,7 +149,7 @@
|
|
|
145
149
|
"devDependencies": {
|
|
146
150
|
"@dokebi/i18n": "0.2.9",
|
|
147
151
|
"@dokebi/session": "0.4.11",
|
|
148
|
-
"@dokebi/web": "0.4.
|
|
152
|
+
"@dokebi/web": "0.4.27",
|
|
149
153
|
"@dokebi/websocket": "0.4.10",
|
|
150
154
|
"@dokebi/websocket-hub": "0.4.5",
|
|
151
155
|
"@inertiajs/vue3": "3.9.1",
|