@dokebi/template-inertia 0.2.0 → 0.4.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/AI.md +147 -91
- package/README.md +52 -42
- package/dist/errors.d.ts +19 -0
- package/dist/errors.js +43 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.js +123 -67
- package/dist/options.d.ts +22 -0
- package/dist/options.js +84 -0
- package/dist/props.js +6 -5
- package/dist/responder.d.ts +30 -2
- package/dist/responder.js +174 -37
- package/dist/vite-dev.d.ts +50 -12
- package/dist/vite-dev.js +460 -27
- package/dist/vite-host.d.ts +1 -0
- package/dist/vite-host.js +62 -0
- package/options.schema.json +44 -17
- package/package.json +66 -11
- package/dist/repeats.d.ts +0 -18
- package/dist/repeats.js +0 -52
package/options.schema.json
CHANGED
|
@@ -4,34 +4,37 @@
|
|
|
4
4
|
"additionalProperties": false,
|
|
5
5
|
"properties": {
|
|
6
6
|
"version": {
|
|
7
|
-
"type": "string"
|
|
7
|
+
"type": "string",
|
|
8
|
+
"description": "Asset version sent with every page; a client with another one reloads (409). Unset: development (and a warning)."
|
|
8
9
|
},
|
|
9
10
|
"rootId": {
|
|
10
11
|
"type": "string",
|
|
11
|
-
"pattern": "^[A-Za-z][A-Za-z0-9_-]*$"
|
|
12
|
+
"pattern": "^[A-Za-z][A-Za-z0-9_-]*$",
|
|
13
|
+
"description": "Id of the element the client app mounts on (default app)."
|
|
12
14
|
},
|
|
13
15
|
"title": {
|
|
14
|
-
"type": "string"
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "Document title of the first HTML."
|
|
15
18
|
},
|
|
16
19
|
"scripts": {
|
|
17
20
|
"type": "array",
|
|
18
21
|
"items": {
|
|
19
22
|
"type": "string",
|
|
20
|
-
"pattern": "
|
|
21
|
-
}
|
|
23
|
+
"pattern": "^\\/[^/]"
|
|
24
|
+
},
|
|
25
|
+
"description": "Module scripts of the first HTML."
|
|
22
26
|
},
|
|
23
27
|
"styles": {
|
|
24
28
|
"type": "array",
|
|
25
29
|
"items": {
|
|
26
30
|
"type": "string",
|
|
27
|
-
"pattern": "
|
|
28
|
-
}
|
|
31
|
+
"pattern": "^\\/[^/]"
|
|
32
|
+
},
|
|
33
|
+
"description": "Stylesheets of the first HTML."
|
|
29
34
|
},
|
|
30
35
|
"vite": {
|
|
31
36
|
"type": "object",
|
|
32
37
|
"additionalProperties": false,
|
|
33
|
-
"required": ["manifest", "entry"],
|
|
34
|
-
"description": "Read scripts, styles and version from a Vite build manifest at startup. Replaces version, scripts and styles.",
|
|
35
38
|
"properties": {
|
|
36
39
|
"manifest": {
|
|
37
40
|
"type": "string",
|
|
@@ -45,16 +48,20 @@
|
|
|
45
48
|
},
|
|
46
49
|
"base": {
|
|
47
50
|
"type": "string",
|
|
48
|
-
"pattern": "
|
|
51
|
+
"pattern": "^\\/(?:[^/\\\\\\s]+\\/)*$",
|
|
52
|
+
"default": "/",
|
|
49
53
|
"description": "URL prefix of the built files (default /)"
|
|
50
54
|
}
|
|
51
|
-
}
|
|
55
|
+
},
|
|
56
|
+
"required": [
|
|
57
|
+
"manifest",
|
|
58
|
+
"entry"
|
|
59
|
+
],
|
|
60
|
+
"description": "Read scripts, styles and version from a Vite build manifest at startup. Replaces version, scripts and styles."
|
|
52
61
|
},
|
|
53
62
|
"ssr": {
|
|
54
63
|
"type": "object",
|
|
55
64
|
"additionalProperties": false,
|
|
56
|
-
"required": ["bundle"],
|
|
57
|
-
"description": "Render the first HTML of each page on the server (D-0039) with the SSR build output, imported once at start. A missing bundle stops the start.",
|
|
58
65
|
"properties": {
|
|
59
66
|
"bundle": {
|
|
60
67
|
"type": "string",
|
|
@@ -62,14 +69,28 @@
|
|
|
62
69
|
"description": "SSR build output that exports render(page), relative to the working directory, e.g. dist/ssr/<app>/ssr.js"
|
|
63
70
|
},
|
|
64
71
|
"failure": {
|
|
65
|
-
"
|
|
72
|
+
"type": "string",
|
|
73
|
+
"enum": [
|
|
74
|
+
"fallback",
|
|
75
|
+
"error"
|
|
76
|
+
],
|
|
77
|
+
"default": "fallback",
|
|
66
78
|
"description": "When render throws: answer the client-rendered page and log (fallback, default) or fail the request (error)"
|
|
79
|
+
},
|
|
80
|
+
"entry": {
|
|
81
|
+
"type": "string",
|
|
82
|
+
"minLength": 1,
|
|
83
|
+
"pattern": "^(?!.*\\.\\.)",
|
|
84
|
+
"description": "Development (D-0045): source module of the bundle rendered through Vite, e.g. src/apps/admin/views/ssr.js. Default: ssr.js beside vite.entry"
|
|
67
85
|
}
|
|
68
|
-
}
|
|
86
|
+
},
|
|
87
|
+
"required": [
|
|
88
|
+
"bundle"
|
|
89
|
+
],
|
|
90
|
+
"description": "Render the first HTML of each page on the server (D-0039) with the SSR build output, imported once at start. A missing bundle stops the start."
|
|
69
91
|
},
|
|
70
92
|
"encryptHistory": {
|
|
71
|
-
"
|
|
72
|
-
"oneOf": [
|
|
93
|
+
"anyOf": [
|
|
73
94
|
{
|
|
74
95
|
"type": "boolean"
|
|
75
96
|
},
|
|
@@ -77,7 +98,13 @@
|
|
|
77
98
|
"const": "sealed"
|
|
78
99
|
}
|
|
79
100
|
],
|
|
101
|
+
"default": "sealed",
|
|
80
102
|
"description": "Inertia history encryption (D-0062): true, false, or sealed (default) = on for requests of seal hosts"
|
|
103
|
+
},
|
|
104
|
+
"errorPage": {
|
|
105
|
+
"type": "string",
|
|
106
|
+
"pattern": "^[A-Za-z0-9][A-Za-z0-9_-]*(?:\\/[A-Za-z0-9][A-Za-z0-9_-]*)*$",
|
|
107
|
+
"description": "Page component (for example Error) rendered with { status, error, message, hint } for error answers of Inertia visits and full page loads (D-0074). Unset: JSON for visits, a small HTML page for page loads."
|
|
81
108
|
}
|
|
82
109
|
}
|
|
83
110
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dokebi/template-inertia",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "Inertia v3 server adapter for Dokebi: page JSON, Vite manifest assets and optional server-side rendering.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"dokebi",
|
|
7
|
+
"dokebi-plugin",
|
|
8
|
+
"web",
|
|
9
|
+
"views",
|
|
10
|
+
"inertia",
|
|
11
|
+
"vue",
|
|
12
|
+
"ssr"
|
|
13
|
+
],
|
|
4
14
|
"private": false,
|
|
5
15
|
"type": "module",
|
|
6
16
|
"license": "MIT",
|
|
@@ -10,7 +20,8 @@
|
|
|
10
20
|
".": {
|
|
11
21
|
"types": "./dist/index.d.ts",
|
|
12
22
|
"import": "./dist/index.js"
|
|
13
|
-
}
|
|
23
|
+
},
|
|
24
|
+
"./vite-host": "./dist/vite-host.js"
|
|
14
25
|
},
|
|
15
26
|
"files": [
|
|
16
27
|
"dist",
|
|
@@ -24,30 +35,33 @@
|
|
|
24
35
|
"node": ">=24.0.0"
|
|
25
36
|
},
|
|
26
37
|
"scripts": {
|
|
27
|
-
"build": "tsc -p tsconfig.json",
|
|
38
|
+
"build": "tsc -p tsconfig.json && node -e \"import('./dist/options.js').then(async (m) => { const { renderOptionsSchema } = await import('@dokebi/core'); process.stdout.write(renderOptionsSchema(m.options)); })\" > options.schema.json",
|
|
28
39
|
"typecheck": "tsc -p tsconfig.test.json --noEmit",
|
|
29
|
-
"test": "tsc -p tsconfig.test.json && node --test .tmp/tests/tests/*.test.js"
|
|
40
|
+
"test": "node -e \"require('node:fs').rmSync('.tmp/tests',{recursive:true,force:true})\" && tsc -p tsconfig.test.json && node --test .tmp/tests/tests/*.test.js"
|
|
30
41
|
},
|
|
31
42
|
"peerDependencies": {
|
|
32
|
-
"@dokebi/core": "^0.
|
|
33
|
-
"@dokebi/web": "^0.
|
|
43
|
+
"@dokebi/core": "^0.4.0",
|
|
44
|
+
"@dokebi/web": "^0.4.1",
|
|
34
45
|
"fastify": "^5.12.7"
|
|
35
46
|
},
|
|
36
47
|
"dokebi": {
|
|
37
48
|
"schemaVersion": 2,
|
|
38
49
|
"id": "dokebi-template-inertia",
|
|
39
|
-
"core": "^0.
|
|
50
|
+
"core": "^0.4.0",
|
|
40
51
|
"dependencies": [
|
|
41
52
|
{
|
|
42
53
|
"name": "dokebi-web",
|
|
43
|
-
"version": "^0.
|
|
54
|
+
"version": "^0.4.1"
|
|
44
55
|
},
|
|
45
56
|
{
|
|
46
57
|
"name": "dokebi-session",
|
|
47
|
-
"version": "^0.
|
|
58
|
+
"version": "^0.4.0",
|
|
48
59
|
"optional": true
|
|
49
60
|
}
|
|
50
61
|
],
|
|
62
|
+
"contributes": [
|
|
63
|
+
"dokebi-web:view-engine"
|
|
64
|
+
],
|
|
51
65
|
"install": {
|
|
52
66
|
"entry": {
|
|
53
67
|
"source": "templates/shared.ts",
|
|
@@ -57,9 +71,50 @@
|
|
|
57
71
|
"optionsSchema": "options.schema.json",
|
|
58
72
|
"documentation": "AI.md"
|
|
59
73
|
},
|
|
74
|
+
"dokebiCatalog": {
|
|
75
|
+
"kind": "plugin",
|
|
76
|
+
"summary": "Inertia (v3) server adapter: Vue 3 views, Vite build files and optional server-side rendering (SSR)",
|
|
77
|
+
"maturity": "preview",
|
|
78
|
+
"provides": [],
|
|
79
|
+
"variants": [
|
|
80
|
+
{
|
|
81
|
+
"name": "vue",
|
|
82
|
+
"capability": "view.inertia-vue",
|
|
83
|
+
"alsoInstalls": [
|
|
84
|
+
"vite",
|
|
85
|
+
"vue",
|
|
86
|
+
"@inertiajs/vue3",
|
|
87
|
+
"@vitejs/plugin-vue"
|
|
88
|
+
],
|
|
89
|
+
"needs": [
|
|
90
|
+
"vite-build"
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"name": "vue-ssr",
|
|
95
|
+
"capability": "view.inertia-vue-ssr",
|
|
96
|
+
"alsoInstalls": [
|
|
97
|
+
"vite",
|
|
98
|
+
"vue",
|
|
99
|
+
"@inertiajs/vue3",
|
|
100
|
+
"@vitejs/plugin-vue"
|
|
101
|
+
],
|
|
102
|
+
"needs": [
|
|
103
|
+
"vite-build"
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
"doesNot": [
|
|
108
|
+
"No React skeleton",
|
|
109
|
+
"Vue and Vite are not server dependencies (they are dev dependencies of the app)"
|
|
110
|
+
],
|
|
111
|
+
"recipes": [
|
|
112
|
+
"blog"
|
|
113
|
+
]
|
|
114
|
+
},
|
|
60
115
|
"devDependencies": {
|
|
61
|
-
"@dokebi/session": "0.
|
|
62
|
-
"@dokebi/web": "0.
|
|
116
|
+
"@dokebi/session": "0.4.0",
|
|
117
|
+
"@dokebi/web": "0.4.1"
|
|
63
118
|
},
|
|
64
119
|
"publishConfig": {
|
|
65
120
|
"access": "public",
|
package/dist/repeats.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The full text of a caught value for the `error` log field (D-0047): name, whole message and
|
|
3
|
-
* stack, then each `cause` the same way. Only credentials in URLs (`//user:password@`) are
|
|
4
|
-
* removed; a text over 16 KB is cut and marked.
|
|
5
|
-
*/
|
|
6
|
-
export declare function errorText(error: unknown): string;
|
|
7
|
-
/** How often a repeating error of the same kind is logged; repeats in between are counted. */
|
|
8
|
-
export declare const REPEAT_INTERVAL_MS = 10000;
|
|
9
|
-
/**
|
|
10
|
-
* Counts repeats of the same error key so a per-request path logs it once per interval (D-0047).
|
|
11
|
-
* The first occurrence is logged; later ones inside the interval are only counted and reported
|
|
12
|
-
* with the next logged occurrence of that key.
|
|
13
|
-
*/
|
|
14
|
-
export declare class Repeats {
|
|
15
|
-
#private;
|
|
16
|
-
/** The repeats to report with this occurrence, or undefined when it is only counted. */
|
|
17
|
-
take(key: string, now?: number): number | undefined;
|
|
18
|
-
}
|
package/dist/repeats.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The full text of a caught value for the `error` log field (D-0047): name, whole message and
|
|
3
|
-
* stack, then each `cause` the same way. Only credentials in URLs (`//user:password@`) are
|
|
4
|
-
* removed; a text over 16 KB is cut and marked.
|
|
5
|
-
*/
|
|
6
|
-
export function errorText(error) {
|
|
7
|
-
const parts = [];
|
|
8
|
-
let current = error;
|
|
9
|
-
for (let depth = 0; current !== undefined && depth < 5; depth++) {
|
|
10
|
-
let text;
|
|
11
|
-
if (current instanceof Error)
|
|
12
|
-
text = current.stack ?? `${current.name}: ${current.message}`;
|
|
13
|
-
else if (typeof current === 'string')
|
|
14
|
-
text = current;
|
|
15
|
-
else {
|
|
16
|
-
try {
|
|
17
|
-
text = `NonError: ${JSON.stringify(current)}`;
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
text = `NonError: ${String(current)}`; // not serialisable (cycle, BigInt): its string form
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
parts.push(depth ? `Caused by: ${text}` : text);
|
|
24
|
-
current = current instanceof Error ? current.cause : undefined;
|
|
25
|
-
}
|
|
26
|
-
const text = parts.join('\n').replace(/\/\/[^\s/@]*@/g, '//***@');
|
|
27
|
-
return text.length > 16_384
|
|
28
|
-
? `${text.slice(0, 16_384)}… [truncated ${text.length - 16_384} characters]`
|
|
29
|
-
: text;
|
|
30
|
-
}
|
|
31
|
-
/** How often a repeating error of the same kind is logged; repeats in between are counted. */
|
|
32
|
-
export const REPEAT_INTERVAL_MS = 10_000;
|
|
33
|
-
/**
|
|
34
|
-
* Counts repeats of the same error key so a per-request path logs it once per interval (D-0047).
|
|
35
|
-
* The first occurrence is logged; later ones inside the interval are only counted and reported
|
|
36
|
-
* with the next logged occurrence of that key.
|
|
37
|
-
*/
|
|
38
|
-
export class Repeats {
|
|
39
|
-
#keys = new Map();
|
|
40
|
-
/** The repeats to report with this occurrence, or undefined when it is only counted. */
|
|
41
|
-
take(key, now = Date.now()) {
|
|
42
|
-
const entry = this.#keys.get(key);
|
|
43
|
-
if (entry && now < entry.until) {
|
|
44
|
-
entry.repeated++;
|
|
45
|
-
return undefined;
|
|
46
|
-
}
|
|
47
|
-
if (!entry && this.#keys.size >= 256)
|
|
48
|
-
this.#keys.clear();
|
|
49
|
-
this.#keys.set(key, { until: now + REPEAT_INTERVAL_MS, repeated: 0 });
|
|
50
|
-
return entry?.repeated ?? 0;
|
|
51
|
-
}
|
|
52
|
-
}
|