@pracht/vite-plugin 0.9.0 → 0.10.0
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/dist/index.d.mts +21 -1
- package/dist/index.mjs +23 -3
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -136,7 +136,27 @@ interface PrachtLlmsTxtOptions {
|
|
|
136
136
|
*/
|
|
137
137
|
exclude?: string[];
|
|
138
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Optional client-router features, compiled out of the client bundle when
|
|
141
|
+
* disabled. Every one defaults to `true`. Turn a feature off only when the app
|
|
142
|
+
* really does not use it: the router silently stops honouring the
|
|
143
|
+
* corresponding route options and `<Link>` props.
|
|
144
|
+
*/
|
|
145
|
+
interface PrachtClientOptions {
|
|
146
|
+
/**
|
|
147
|
+
* JS prefetching of route-state JSON and route/shell chunks, driven by
|
|
148
|
+
* `route({ prefetch })` and `<Link prefetch>`. Off also drops the separate
|
|
149
|
+
* prefetch chunk the router loads on every page, and makes the imperative
|
|
150
|
+
* `prefetch()` export a no-op.
|
|
151
|
+
*/
|
|
152
|
+
prefetch?: boolean;
|
|
153
|
+
}
|
|
139
154
|
interface PrachtPluginOptions {
|
|
155
|
+
/**
|
|
156
|
+
* Switch off client-router features the app does not use, so they are
|
|
157
|
+
* compiled out of the client bundle. See {@link PrachtClientOptions}.
|
|
158
|
+
*/
|
|
159
|
+
client?: PrachtClientOptions;
|
|
140
160
|
appFile?: string;
|
|
141
161
|
routesDir?: string;
|
|
142
162
|
shellsDir?: string;
|
|
@@ -267,4 +287,4 @@ declare function createPrachtWebmcpModuleSource(options?: PrachtPluginOptions, b
|
|
|
267
287
|
//#region src/index.d.ts
|
|
268
288
|
declare function pracht(options?: PrachtPluginOptions): Plugin[];
|
|
269
289
|
//#endregion
|
|
270
|
-
export { type EnvLeakReference, type EnvSafetyOptions, type LlmsTxtSection, PRACHT_CAPABILITIES_MODULE_ID, PRACHT_CLIENT_MODULE_ID, PRACHT_ISLANDS_CLIENT_MODULE_ID, PRACHT_SERVER_MODULE_ID, PRACHT_WEBMCP_MODULE_ID, PUBLIC_ENV_PREFIX, type PrachtAdapter, type PrachtLlmsTxtOptions, type PrachtPluginOptions, type RenderMode, VITE_BUILTIN_ENV_VARS, createEnvSafetyPlugin, createPrachtCapabilitiesClientModuleSource, createPrachtClientModuleSource, createPrachtIslandsClientModuleSource, createPrachtRegistryModuleSource, createPrachtServerModuleSource, createPrachtWebmcpModuleSource, extractCapabilities, formatEnvLeakError, pracht, scanCodeForEnvLeaks };
|
|
290
|
+
export { type EnvLeakReference, type EnvSafetyOptions, type LlmsTxtSection, PRACHT_CAPABILITIES_MODULE_ID, PRACHT_CLIENT_MODULE_ID, PRACHT_ISLANDS_CLIENT_MODULE_ID, PRACHT_SERVER_MODULE_ID, PRACHT_WEBMCP_MODULE_ID, PUBLIC_ENV_PREFIX, type PrachtAdapter, type PrachtClientOptions, type PrachtLlmsTxtOptions, type PrachtPluginOptions, type RenderMode, VITE_BUILTIN_ENV_VARS, createEnvSafetyPlugin, createPrachtCapabilitiesClientModuleSource, createPrachtClientModuleSource, createPrachtIslandsClientModuleSource, createPrachtRegistryModuleSource, createPrachtServerModuleSource, createPrachtWebmcpModuleSource, extractCapabilities, formatEnvLeakError, pracht, scanCodeForEnvLeaks };
|
package/dist/index.mjs
CHANGED
|
@@ -1351,7 +1351,9 @@ function createDefaultNodeAdapter() {
|
|
|
1351
1351
|
}
|
|
1352
1352
|
//#endregion
|
|
1353
1353
|
//#region src/plugin-options.ts
|
|
1354
|
+
const CLIENT_FEATURE_DEFAULTS = { prefetch: true };
|
|
1354
1355
|
const DEFAULTS = {
|
|
1356
|
+
client: CLIENT_FEATURE_DEFAULTS,
|
|
1355
1357
|
appFile: "/src/routes.ts",
|
|
1356
1358
|
middlewareDir: "/src/middleware",
|
|
1357
1359
|
routesDir: "/src/routes",
|
|
@@ -1377,6 +1379,7 @@ function resolveOptions(options) {
|
|
|
1377
1379
|
...options
|
|
1378
1380
|
};
|
|
1379
1381
|
if (resolved.llmsTxt === void 0) resolved.llmsTxt = false;
|
|
1382
|
+
resolved.client = resolveClientOptions(options.client);
|
|
1380
1383
|
resolved.additionalExtensions = normalizeAdditionalExtensions(resolved.additionalExtensions);
|
|
1381
1384
|
if (!new Set([
|
|
1382
1385
|
"spa",
|
|
@@ -1390,6 +1393,20 @@ function resolveOptions(options) {
|
|
|
1390
1393
|
validateLlmsTxt(resolved.llmsTxt);
|
|
1391
1394
|
return resolved;
|
|
1392
1395
|
}
|
|
1396
|
+
function resolveClientOptions(client) {
|
|
1397
|
+
if (client === void 0) return CLIENT_FEATURE_DEFAULTS;
|
|
1398
|
+
if (typeof client !== "object" || client === null) throw new Error("pracht({ client }) expects an options object.");
|
|
1399
|
+
const resolved = { ...CLIENT_FEATURE_DEFAULTS };
|
|
1400
|
+
for (const key of Object.keys(CLIENT_FEATURE_DEFAULTS)) {
|
|
1401
|
+
const value = client[key];
|
|
1402
|
+
if (value === void 0) continue;
|
|
1403
|
+
if (typeof value !== "boolean") throw new Error(`pracht({ client: { ${key} } }) expects a boolean, got ${JSON.stringify(value)}.`);
|
|
1404
|
+
resolved[key] = value;
|
|
1405
|
+
}
|
|
1406
|
+
const unknown = Object.keys(client).filter((key) => !(key in CLIENT_FEATURE_DEFAULTS));
|
|
1407
|
+
if (unknown.length > 0) throw new Error(`pracht({ client }) does not accept ${unknown.map((key) => JSON.stringify(key)).join(", ")}. Known features: ${Object.keys(CLIENT_FEATURE_DEFAULTS).join(", ")}.`);
|
|
1408
|
+
return resolved;
|
|
1409
|
+
}
|
|
1393
1410
|
const LLMS_TXT_SECTIONS = new Set([
|
|
1394
1411
|
"pages",
|
|
1395
1412
|
"api",
|
|
@@ -1592,7 +1609,7 @@ function createPrachtCapabilitiesClientModuleSource(options = {}, buildOptions =
|
|
|
1592
1609
|
"// Generated by @pracht/vite-plugin from the app manifest capability registrations.",
|
|
1593
1610
|
"// Contains only http-exposed capability names, endpoints, and effects —",
|
|
1594
1611
|
"// capability modules themselves are server-only and never reach the client graph.",
|
|
1595
|
-
"import { createUseCapability, withBase } from \"@pracht/core\";",
|
|
1612
|
+
"import { createUseCapability, ensureCapabilityRevalidation, withBase } from \"@pracht/core\";",
|
|
1596
1613
|
"",
|
|
1597
1614
|
`const endpoints = Object.assign(Object.create(null), JSON.parse(${JSON.stringify(JSON.stringify(endpoints))}));`,
|
|
1598
1615
|
"",
|
|
@@ -1653,6 +1670,7 @@ function createPrachtCapabilitiesClientModuleSource(options = {}, buildOptions =
|
|
|
1653
1670
|
"}",
|
|
1654
1671
|
"",
|
|
1655
1672
|
"export async function callCapability(name, input, opts) {",
|
|
1673
|
+
" ensureCapabilityRevalidation();",
|
|
1656
1674
|
" const endpoint = endpoints[name];",
|
|
1657
1675
|
" if (!endpoint) {",
|
|
1658
1676
|
" return {",
|
|
@@ -2854,6 +2872,7 @@ function pracht(options = {}) {
|
|
|
2854
2872
|
const publicEnvDefine = JSON.stringify(loadEnv(env.mode, envDir, PUBLIC_ENV_PREFIX));
|
|
2855
2873
|
const agentSurfaceDefine = env.command === "build" ? String(hasAgentSurface(resolved, configRoot)) : "true";
|
|
2856
2874
|
const staticTargetDefine = String(env.command === "build" && resolved.adapter.staticTarget === true);
|
|
2875
|
+
const clientFeatureDefines = { __PRACHT_CLIENT_PREFETCH__: String(resolved.client.prefetch) };
|
|
2857
2876
|
return {
|
|
2858
2877
|
appType: "custom",
|
|
2859
2878
|
envPrefix: ["VITE_", PUBLIC_ENV_PREFIX],
|
|
@@ -2861,7 +2880,8 @@ function pracht(options = {}) {
|
|
|
2861
2880
|
define: {
|
|
2862
2881
|
__PRACHT_PUBLIC_ENV__: publicEnvDefine,
|
|
2863
2882
|
__PRACHT_AGENT_SURFACE__: agentSurfaceDefine,
|
|
2864
|
-
__PRACHT_STATIC_TARGET__: staticTargetDefine
|
|
2883
|
+
__PRACHT_STATIC_TARGET__: staticTargetDefine,
|
|
2884
|
+
...clientFeatureDefines
|
|
2865
2885
|
},
|
|
2866
2886
|
...isSSRBuild ? {} : { build: { rollupOptions: {
|
|
2867
2887
|
...wantsIslandsEntry ? { input: [PRACHT_ISLANDS_CLIENT_MODULE_ID] } : {},
|
|
@@ -2885,7 +2905,7 @@ function pracht(options = {}) {
|
|
|
2885
2905
|
} } },
|
|
2886
2906
|
build: { rollupOptions: { external: [/^cloudflare:/] } }
|
|
2887
2907
|
} : {},
|
|
2888
|
-
...!isEdge && isSSRBuild ? { ssr: { noExternal: [PRACHT_SSR_NO_EXTERNAL] } } : {}
|
|
2908
|
+
...!isEdge && isSSRBuild || env.command === "serve" ? { ssr: { noExternal: [PRACHT_SSR_NO_EXTERNAL] } } : {}
|
|
2889
2909
|
};
|
|
2890
2910
|
},
|
|
2891
2911
|
configResolved(config) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pracht/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Vite plugin for Pracht apps with virtual modules, dev SSR, prerendering, route inspection, and multi-adapter builds.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pracht",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"@preact/preset-vite": "^2.10.5",
|
|
47
47
|
"@prefresh/vite": "^2.0.0",
|
|
48
48
|
"es-module-lexer": "^1.7.0",
|
|
49
|
-
"@pracht/adapter-node": "0.4.
|
|
49
|
+
"@pracht/adapter-node": "0.4.1",
|
|
50
50
|
"@pracht/capabilities": "0.2.0",
|
|
51
|
-
"@pracht/
|
|
52
|
-
"@pracht/
|
|
51
|
+
"@pracht/core": "0.15.0",
|
|
52
|
+
"@pracht/preact-ssr-precompile": "0.1.3"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"vite": "^8.0.0"
|