@pracht/vite-plugin 0.11.0 → 0.12.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 CHANGED
@@ -1,5 +1,6 @@
1
1
  import { PreactSsrPrecompileOptions } from "@pracht/preact-ssr-precompile";
2
- import { Plugin } from "vite";
2
+ import { InlineConfig, Plugin } from "vite";
3
+ import { EnvLeakReference, EnvLeakReference as EnvLeakReference$1, PUBLIC_ENV_PREFIX, VITE_BUILTIN_ENV_VARS, scanCodeForEnvLeaks } from "@pracht/capabilities/static";
3
4
  import { RenderMode, RenderMode as RenderMode$1 } from "@pracht/core";
4
5
 
5
6
  //#region src/plugin-assets.d.ts
@@ -10,29 +11,11 @@ declare const PRACHT_CAPABILITIES_MODULE_ID = "virtual:pracht/capabilities";
10
11
  declare const PRACHT_WEBMCP_MODULE_ID = "virtual:pracht/webmcp";
11
12
  //#endregion
12
13
  //#region src/env-safety.d.ts
13
- /**
14
- * Env vars Vite defines on `import.meta.env` in every bundle, plus NODE_ENV
15
- * which Vite's define pass statically replaces at build time (so it can never
16
- * leak and is referenced by countless dependencies).
17
- */
18
- declare const VITE_BUILTIN_ENV_VARS: Set<string>;
19
- /** Prefix that marks an env var as intentionally public. */
20
- declare const PUBLIC_ENV_PREFIX = "PRACHT_PUBLIC_";
21
14
  interface EnvSafetyOptions {
22
15
  /** Env var names allowed to appear in client bundles despite not being public. */
23
16
  allow?: string[];
24
17
  }
25
- interface EnvLeakReference {
26
- accessor: "process.env" | "import.meta.env";
27
- name: string;
28
- }
29
- /**
30
- * Scans JavaScript source for references to environment variables that are
31
- * neither public-prefixed, Vite built-ins, nor explicitly allowed, plus reads
32
- * that pull in the whole `import.meta.env` object.
33
- */
34
- declare function scanCodeForEnvLeaks(code: string, allow?: ReadonlySet<string>): EnvLeakReference[];
35
- interface EnvLeakProblem extends EnvLeakReference {
18
+ interface EnvLeakProblem extends EnvLeakReference$1 {
36
19
  chunk: string;
37
20
  sources: string[];
38
21
  }
@@ -165,6 +148,12 @@ interface PrachtClientOptions {
165
148
  * `prefetch()` export a no-op.
166
149
  */
167
150
  prefetch?: boolean;
151
+ /**
152
+ * `useBlocker()` navigation guards. Off also drops the per-history-entry
153
+ * index the router stamps so a refused back/forward traversal can be put
154
+ * back, and makes `useBlocker()` never block (it warns in development).
155
+ */
156
+ navigationGuards?: boolean;
168
157
  }
169
158
  interface PrachtPluginOptions {
170
159
  /**
@@ -182,6 +171,12 @@ interface PrachtPluginOptions {
182
171
  * Preact merged into its own chunks.
183
172
  */
184
173
  vendorChunk?: boolean;
174
+ /**
175
+ * Inline the matched route and shell's emitted production CSS in the HTML
176
+ * head instead of linking those assets. Defaults to `false`; enable it for
177
+ * small critical stylesheets after accounting for HTML/cache duplication.
178
+ */
179
+ inlineCss?: boolean;
185
180
  appFile?: string;
186
181
  routesDir?: string;
187
182
  shellsDir?: string;
@@ -319,12 +314,13 @@ interface ExtractedCapability {
319
314
  httpPath: string | null;
320
315
  webmcp: boolean;
321
316
  webmcpUntrustedContent: boolean;
317
+ /** Inline input schema, or `null` when WebMCP codegen loads the server module to derive it. */
322
318
  inputSchema: Record<string, unknown> | null;
323
319
  }
324
320
  /**
325
- * Extract capability registrations (name → module path) from the app
326
- * manifest source and their exposure metadata from each capability source.
327
- * Pages-router apps have no manifest, so capabilities are manifest-mode only.
321
+ * Extract capability registrations (name → module path) from a manifest app
322
+ * or the pages router's generated manifest, then read exposure metadata from
323
+ * each capability source.
328
324
  */
329
325
  declare function extractCapabilities(options?: PrachtPluginOptions, root?: string): ExtractedCapability[];
330
326
  /**
@@ -341,29 +337,33 @@ declare function createPrachtCapabilitiesClientModuleSource(options?: PrachtPlug
341
337
  root?: string;
342
338
  }): string;
343
339
  /**
344
- * Generate `virtual:pracht/webmcp` — the disposable WebMCP registration shim.
345
- * One page tool per `expose.webmcp` capability; `execute` dispatches through
340
+ * Generate `virtual:pracht/webmcp` — the WebMCP registration shim.
341
+ * One page tool per `expose.webmcp` capability; dispatch goes through
346
342
  * `callCapability`, so the user's session authenticates the call and all
347
343
  * validation/middleware/policy stays server-side. Each dispatch carries the
348
344
  * transport marker header so audit events can attribute it to WebMCP.
349
345
  *
350
- * Targets the WebMCP CG draft API: `document.modelContext.registerTool()`
351
- * (ChatGPT desktop's built-in browser; Chromium 150+ within the 149–156
352
- * origin trial — the `document` getter landed in 150 and the deprecated
353
- * `navigator.modelContext` alias was removed in 152, so trial builds before
354
- * 150 are not targeted and no fallback is kept; current polyfills install the
355
- * `document` shape). No-ops silently when the API is absent.
356
- *
357
- * `execute()` returns the capability envelope (`{ ok, data }` /
358
- * `{ ok: false, error }`) as a plain object: per the spec the host serializes
359
- * the returned value itself, so wrapping it in MCP-style content blocks would
360
- * reach the agent double-encoded.
346
+ * The registration runtime feature detection, `registerTool()` calls, and
347
+ * the WebMCP annotation policy lives in
348
+ * `@pracht/capabilities/webmcp` (published, so non-pracht sites register tools
349
+ * with identical semantics); this module only
350
+ * contributes the statically extracted tool metadata and the app-specific
351
+ * dispatch. The registrar import is resolved from *this plugin's* copy of
352
+ * `@pracht/capabilities` at codegen time: the virtual module has no importer
353
+ * on disk, so a bare specifier would resolve against the app root — where an
354
+ * older installed copy may predate the `./webmcp` entry point. The registrar
355
+ * is stateless, so using the plugin's copy cannot split state.
361
356
  */
362
357
  declare function createPrachtWebmcpModuleSource(options?: PrachtPluginOptions, buildOptions?: {
363
358
  root?: string;
364
359
  }): string;
360
+ declare function createPrachtWebmcpModuleSourceAsync(options?: PrachtPluginOptions, buildOptions?: {
361
+ root?: string;
362
+ loadCapability?: (file: string) => Promise<unknown>;
363
+ runnerConfig?: InlineConfig;
364
+ }): Promise<string>;
365
365
  //#endregion
366
366
  //#region src/index.d.ts
367
367
  declare function pracht(options?: PrachtPluginOptions): Plugin[];
368
368
  //#endregion
369
- export { type ChunkGroup, type EnvLeakReference, type EnvSafetyOptions, FRAMEWORK_VENDOR_CHUNK, 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, frameworkChunkGroups, pracht, scanCodeForEnvLeaks };
369
+ export { type ChunkGroup, type EnvLeakReference, type EnvSafetyOptions, FRAMEWORK_VENDOR_CHUNK, 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, createPrachtWebmcpModuleSourceAsync, extractCapabilities, formatEnvLeakError, frameworkChunkGroups, pracht, scanCodeForEnvLeaks };