@vertesia/build-tools 1.5.0-dev.20260807.073259Z → 1.5.0-dev.20260901.005903Z
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/lib/vite/api-server.d.ts
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
27
|
import type { Plugin } from 'vite';
|
|
28
|
+
export declare function injectRuntimeConfigMarker(html: string): string;
|
|
28
29
|
export interface ApiServerPluginOptions {
|
|
29
30
|
/**
|
|
30
31
|
* Tool server entry point (TypeScript source). Resolved by Vite from the
|
|
@@ -35,7 +36,10 @@ export interface ApiServerPluginOptions {
|
|
|
35
36
|
/**
|
|
36
37
|
* Compiled server module path used in preview mode. Resolved relative to
|
|
37
38
|
* `process.cwd()` (the consuming project's root when running `vite preview`).
|
|
38
|
-
*
|
|
39
|
+
*
|
|
40
|
+
* Defaults to `entry` with `src/` swapped for `lib/` and the `.ts`
|
|
41
|
+
* extension dropped, which is where a `rootDir: src` / `outDir: lib`
|
|
42
|
+
* tsconfig emits it. Set this explicitly for any other output layout.
|
|
39
43
|
*/
|
|
40
44
|
compiledEntry?: string;
|
|
41
45
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-server.d.ts","sourceRoot":"","sources":["../../src/vite/api-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"api-server.d.ts","sourceRoot":"","sources":["../../src/vite/api-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAC;AAUlD,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO9D;AAID,MAAM,WAAW,sBAAsB;IACnC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAUD,wBAAgB,eAAe,CAAC,OAAO,GAAE,sBAA2B,GAAG,MAAM,EAAE,CAkC9E"}
|
package/lib/vite/api-server.js
CHANGED
|
@@ -27,12 +27,33 @@
|
|
|
27
27
|
import path from 'node:path';
|
|
28
28
|
import { getRequestListener } from '@hono/node-server';
|
|
29
29
|
import { vertesiaDevServerPlugin } from './dev-server.js';
|
|
30
|
+
const RUNTIME_CONFIG_MARKER = 'vertesia-runtime-config';
|
|
31
|
+
const RUNTIME_CONFIG_VERSION = 'v1';
|
|
32
|
+
export function injectRuntimeConfigMarker(html) {
|
|
33
|
+
const metaTags = html.match(/<meta\b[^>]*>/gi) || [];
|
|
34
|
+
const markerName = new RegExp(`\\bname\\s*=\\s*(["'])${RUNTIME_CONFIG_MARKER}\\1`, 'i');
|
|
35
|
+
if (metaTags.some((tag) => markerName.test(tag)))
|
|
36
|
+
return html;
|
|
37
|
+
const marker = `<meta name="${RUNTIME_CONFIG_MARKER}" content="${RUNTIME_CONFIG_VERSION}" />`;
|
|
38
|
+
return html.replace(/<\/head>/i, ` ${marker}\n</head>`);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Maps a TypeScript source entry to the JavaScript file tsc emits for it under a
|
|
42
|
+
* `rootDir: src` / `outDir: lib` layout, so the dev and preview entries cannot drift apart.
|
|
43
|
+
*/
|
|
44
|
+
function compiledEntryFor(entry) {
|
|
45
|
+
return entry.replace(/(^|\/)src\//, '$1lib/').replace(/\.tsx?$/, '.js');
|
|
46
|
+
}
|
|
30
47
|
export function apiServerPlugin(options = {}) {
|
|
31
|
-
const { entry = './src/tool-server/server.ts', compiledEntry =
|
|
48
|
+
const { entry = './src/tool-server/server.ts', compiledEntry = compiledEntryFor(entry), apiPrefix = '/api', transformers, } = options;
|
|
32
49
|
// Resolve compiled entry relative to the consumer's cwd. Vite is run from
|
|
33
50
|
// the project root by convention, so this lands at the right file.
|
|
34
51
|
const absoluteCompiledEntry = path.resolve(process.cwd(), compiledEntry);
|
|
35
52
|
return [
|
|
53
|
+
{
|
|
54
|
+
name: 'vertesia-runtime-config-marker',
|
|
55
|
+
transformIndexHtml: injectRuntimeConfigMarker,
|
|
56
|
+
},
|
|
36
57
|
// Vertesia query-import transformer (skill / raw / prompt / template etc.).
|
|
37
58
|
vertesiaDevServerPlugin(transformers ? { transformers } : undefined),
|
|
38
59
|
// Hono middleware bridge for dev + preview.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-server.js","sourceRoot":"","sources":["../../src/vite/api-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"api-server.js","sourceRoot":"","sources":["../../src/vite/api-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAM1D,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AACxD,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAEpC,MAAM,UAAU,yBAAyB,CAAC,IAAY;IAClD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC;IACrD,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CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAClE,CAAC;YACD,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC;YAC7B,MAAM,eAAe,GAAG,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACtD,KAAK,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,IAAI,CAAC,CAAC,CAAC,CAAC;QACZ,CAAC;IACL,CAAC,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vertesia/build-tools",
|
|
3
|
-
"version": "1.5.0-dev.
|
|
3
|
+
"version": "1.5.0-dev.20260901.005903Z",
|
|
4
4
|
"description": "Build tools for Vertesia projects - import transformers (skill / template / prompt / raw), esbuild widget bundler, vertesia-build CLI, and a Vite dev plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@hono/node-server": "^2.0
|
|
27
|
+
"@hono/node-server": "^2.1.0",
|
|
28
28
|
"@types/js-yaml": "^4.0.9",
|
|
29
29
|
"@types/node": "^24.13.3",
|
|
30
30
|
"typescript": "7.0.2",
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"ajv": "^8.20.0",
|
|
37
37
|
"es-module-lexer": "^2.3.1",
|
|
38
|
-
"esbuild": "^0.28.
|
|
39
|
-
"js-yaml": "^5.2.
|
|
38
|
+
"esbuild": "^0.28.2",
|
|
39
|
+
"js-yaml": "^5.2.3",
|
|
40
40
|
"zod": "^4.4.3",
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@vertesia/studio-utils": "1.5.0-dev.
|
|
41
|
+
"@llumiverse/common": "1.5.0-dev.20260831.235912Z",
|
|
42
|
+
"@vertesia/common": "1.5.0-dev.20260901.005903Z",
|
|
43
|
+
"@vertesia/studio-utils": "1.5.0-dev.20260901.005903Z"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@hono/node-server": "^2.0
|
|
46
|
+
"@hono/node-server": "^2.1.0",
|
|
47
47
|
"vite": "^8.1.4"
|
|
48
48
|
},
|
|
49
49
|
"peerDependenciesMeta": {
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"zod",
|
|
76
76
|
"validation"
|
|
77
77
|
],
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "73de8716696201bda20b5ec0d0134bafd597387e",
|
|
79
79
|
"scripts": {
|
|
80
80
|
"lint": "biome lint src",
|
|
81
81
|
"test": "vitest run",
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { apiServerPlugin, injectRuntimeConfigMarker } from './api-server.js';
|
|
3
|
+
|
|
4
|
+
describe('apiServerPlugin runtime configuration marker', () => {
|
|
5
|
+
it('injects the versioned marker into application HTML', () => {
|
|
6
|
+
expect(injectRuntimeConfigMarker('<html><head><title>App</title></head></html>')).toContain(
|
|
7
|
+
'<meta name="vertesia-runtime-config" content="v1" />',
|
|
8
|
+
);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('does not duplicate an existing runtime configuration marker', () => {
|
|
12
|
+
const html = '<html><head><meta content="v1" name="vertesia-runtime-config"><title>App</title></head></html>';
|
|
13
|
+
|
|
14
|
+
expect(injectRuntimeConfigMarker(html)).toBe(html);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('includes marker emission in the existing API server plugin set', () => {
|
|
18
|
+
expect(apiServerPlugin().map((plugin) => plugin.name)).toContain('vertesia-runtime-config-marker');
|
|
19
|
+
});
|
|
20
|
+
});
|
package/src/vite/api-server.ts
CHANGED
|
@@ -35,6 +35,18 @@ interface HonoApp {
|
|
|
35
35
|
fetch: (request: Request, env?: unknown, executionCtx?: unknown) => Response | Promise<Response>;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
const RUNTIME_CONFIG_MARKER = 'vertesia-runtime-config';
|
|
39
|
+
const RUNTIME_CONFIG_VERSION = 'v1';
|
|
40
|
+
|
|
41
|
+
export function injectRuntimeConfigMarker(html: string): string {
|
|
42
|
+
const metaTags = html.match(/<meta\b[^>]*>/gi) || [];
|
|
43
|
+
const markerName = new RegExp(`\\bname\\s*=\\s*(["'])${RUNTIME_CONFIG_MARKER}\\1`, 'i');
|
|
44
|
+
if (metaTags.some((tag) => markerName.test(tag))) return html;
|
|
45
|
+
|
|
46
|
+
const marker = `<meta name="${RUNTIME_CONFIG_MARKER}" content="${RUNTIME_CONFIG_VERSION}" />`;
|
|
47
|
+
return html.replace(/<\/head>/i, ` ${marker}\n</head>`);
|
|
48
|
+
}
|
|
49
|
+
|
|
38
50
|
type NextHandleFunction = (req: IncomingMessage, res: ServerResponse, next: (err?: unknown) => void) => void;
|
|
39
51
|
|
|
40
52
|
export interface ApiServerPluginOptions {
|
|
@@ -48,7 +60,10 @@ export interface ApiServerPluginOptions {
|
|
|
48
60
|
/**
|
|
49
61
|
* Compiled server module path used in preview mode. Resolved relative to
|
|
50
62
|
* `process.cwd()` (the consuming project's root when running `vite preview`).
|
|
51
|
-
*
|
|
63
|
+
*
|
|
64
|
+
* Defaults to `entry` with `src/` swapped for `lib/` and the `.ts`
|
|
65
|
+
* extension dropped, which is where a `rootDir: src` / `outDir: lib`
|
|
66
|
+
* tsconfig emits it. Set this explicitly for any other output layout.
|
|
52
67
|
*/
|
|
53
68
|
compiledEntry?: string;
|
|
54
69
|
|
|
@@ -66,10 +81,18 @@ export interface ApiServerPluginOptions {
|
|
|
66
81
|
transformers?: readonly string[];
|
|
67
82
|
}
|
|
68
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Maps a TypeScript source entry to the JavaScript file tsc emits for it under a
|
|
86
|
+
* `rootDir: src` / `outDir: lib` layout, so the dev and preview entries cannot drift apart.
|
|
87
|
+
*/
|
|
88
|
+
function compiledEntryFor(entry: string): string {
|
|
89
|
+
return entry.replace(/(^|\/)src\//, '$1lib/').replace(/\.tsx?$/, '.js');
|
|
90
|
+
}
|
|
91
|
+
|
|
69
92
|
export function apiServerPlugin(options: ApiServerPluginOptions = {}): Plugin[] {
|
|
70
93
|
const {
|
|
71
94
|
entry = './src/tool-server/server.ts',
|
|
72
|
-
compiledEntry =
|
|
95
|
+
compiledEntry = compiledEntryFor(entry),
|
|
73
96
|
apiPrefix = '/api',
|
|
74
97
|
transformers,
|
|
75
98
|
} = options;
|
|
@@ -79,6 +102,11 @@ export function apiServerPlugin(options: ApiServerPluginOptions = {}): Plugin[]
|
|
|
79
102
|
const absoluteCompiledEntry = path.resolve(process.cwd(), compiledEntry);
|
|
80
103
|
|
|
81
104
|
return [
|
|
105
|
+
{
|
|
106
|
+
name: 'vertesia-runtime-config-marker',
|
|
107
|
+
transformIndexHtml: injectRuntimeConfigMarker,
|
|
108
|
+
},
|
|
109
|
+
|
|
82
110
|
// Vertesia query-import transformer (skill / raw / prompt / template etc.).
|
|
83
111
|
vertesiaDevServerPlugin(transformers ? { transformers } : undefined),
|
|
84
112
|
|