@vizejs/vite-plugin 0.312.0 → 0.315.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,4 +1,4 @@
1
- import { a as VizeVueVersion, c as ResolvedVizeConfig, i as VizeOptions, l as UserConfigExport, n as MacroArtifact, o as ConfigEnv, r as VizeCompatibilityOptions, s as LoadConfigOptions, t as CompiledModule, u as VizeConfig } from "./types-Cm3dJq25.mjs";
1
+ import { a as VizeVueVersion, c as VizeInspectorOptions, d as ResolvedVizeConfig, f as UserConfigExport, i as VizeOptions, l as ConfigEnv, n as MacroArtifact, o as VizeInspectorLintPlanProvider, p as VizeConfig, r as VizeCompatibilityOptions, s as VizeInspectorLintPlanRequest, t as CompiledModule, u as LoadConfigOptions } from "./types-BU_B_kFs.mjs";
2
2
  import { Plugin } from "vite";
3
3
 
4
4
  //#region src/virtual.d.ts
@@ -40,4 +40,4 @@ declare const __internal: {
40
40
  rewriteStaticAssetUrls: typeof rewriteStaticAssetUrls;
41
41
  };
42
42
  //#endregion
43
- export { type CompiledModule, type LoadConfigOptions, type MacroArtifact, type ResolvedVizeConfig, type UserConfigExport, VIZE_CONFIG_FILE_ENV, type VizeCompatibilityOptions, type VizeConfig, type VizeOptions, type VizeVueVersion, __internal, rewriteStaticAssetUrls as __internal_rewriteStaticAssetUrls, vize as default, vize, defineConfig, loadConfig, resolveConfigExport, vizeConfigStore };
43
+ export { type CompiledModule, type LoadConfigOptions, type MacroArtifact, type ResolvedVizeConfig, type UserConfigExport, VIZE_CONFIG_FILE_ENV, type VizeCompatibilityOptions, type VizeConfig, type VizeInspectorLintPlanProvider, type VizeInspectorLintPlanRequest, type VizeInspectorOptions, type VizeOptions, type VizeVueVersion, __internal, rewriteStaticAssetUrls as __internal_rewriteStaticAssetUrls, vize as default, vize, defineConfig, loadConfig, resolveConfigExport, vizeConfigStore };
package/dist/index.mjs CHANGED
@@ -3096,6 +3096,114 @@ function normalizeCssModuleFilename(filename) {
3096
3096
  return normalized;
3097
3097
  }
3098
3098
  //#endregion
3099
+ //#region src/plugin/inspector-lint-plan.ts
3100
+ const VIZE_INSPECTOR_LINT_PLAN_ENDPOINT = "/__vize/inspector/lint-plan";
3101
+ const MAX_REQUEST_URL_BYTES = 8 * 1024;
3102
+ const MAX_FILE_COUNT = 128;
3103
+ const MAX_FILE_BYTES = 4 * 1024;
3104
+ const MAX_RESPONSE_BYTES = 4 * 1024 * 1024;
3105
+ const ALLOWED_QUERY_KEYS = new Set(["file", "fresh"]);
3106
+ function installInspectorLintPlanMiddleware(devServer, state) {
3107
+ const provider = state.mergedOptions.inspector?.lintPlan;
3108
+ if (!provider) return;
3109
+ devServer.middlewares.use((req, res, next) => {
3110
+ if (!isInspectorLintPlanRequest(req.url, state.clientViteBase)) {
3111
+ next();
3112
+ return;
3113
+ }
3114
+ handleInspectorLintPlanRequest(req, res, provider, state.logger, state.clientViteBase);
3115
+ });
3116
+ }
3117
+ function isInspectorLintPlanRequest(reqUrl, base = "/") {
3118
+ if (!reqUrl) return false;
3119
+ try {
3120
+ return new URL(reqUrl, "http://localhost").pathname === resolveInspectorEndpoint(base);
3121
+ } catch {
3122
+ return false;
3123
+ }
3124
+ }
3125
+ function parseInspectorLintPlanRequest(reqUrl, base = "/") {
3126
+ if (!reqUrl || !isInspectorLintPlanRequest(reqUrl, base)) return null;
3127
+ if (Buffer.byteLength(reqUrl) > MAX_REQUEST_URL_BYTES) return {
3128
+ statusCode: 414,
3129
+ error: "request_uri_too_long"
3130
+ };
3131
+ const url = new URL(reqUrl, "http://localhost");
3132
+ for (const key of url.searchParams.keys()) if (!ALLOWED_QUERY_KEYS.has(key)) return {
3133
+ statusCode: 400,
3134
+ error: "invalid_query"
3135
+ };
3136
+ const freshValues = url.searchParams.getAll("fresh");
3137
+ if (freshValues.length > 1 || freshValues[0] !== void 0 && freshValues[0] !== "1") return {
3138
+ statusCode: 400,
3139
+ error: "invalid_fresh"
3140
+ };
3141
+ const rawFiles = url.searchParams.getAll("file");
3142
+ if (rawFiles.length > MAX_FILE_COUNT) return {
3143
+ statusCode: 413,
3144
+ error: "too_many_files"
3145
+ };
3146
+ const files = [];
3147
+ const seen = /* @__PURE__ */ new Set();
3148
+ for (const file of rawFiles) {
3149
+ if (!isSafeInspectorFile(file)) return {
3150
+ statusCode: 400,
3151
+ error: "invalid_file"
3152
+ };
3153
+ if (!seen.has(file)) {
3154
+ seen.add(file);
3155
+ files.push(file);
3156
+ }
3157
+ }
3158
+ return { request: {
3159
+ files,
3160
+ fresh: freshValues[0] === "1"
3161
+ } };
3162
+ }
3163
+ async function handleInspectorLintPlanRequest(req, res, provider, logger, base = "/") {
3164
+ if (req.method !== "GET" && req.method !== "HEAD") {
3165
+ res.setHeader("allow", "GET, HEAD");
3166
+ sendJson$1(res, 405, { error: "method_not_allowed" });
3167
+ return;
3168
+ }
3169
+ const parsed = parseInspectorLintPlanRequest(req.url, base);
3170
+ if (!parsed) {
3171
+ sendJson$1(res, 404, { error: "not_found" });
3172
+ return;
3173
+ }
3174
+ if ("error" in parsed) {
3175
+ sendJson$1(res, parsed.statusCode, { error: parsed.error }, req.method === "HEAD");
3176
+ return;
3177
+ }
3178
+ try {
3179
+ sendJson$1(res, 200, await provider(parsed.request), req.method === "HEAD");
3180
+ } catch (error) {
3181
+ logger.error("Failed to build inspector lint plan:", error);
3182
+ sendJson$1(res, 500, { error: "inspector_lint_plan_failed" }, req.method === "HEAD");
3183
+ }
3184
+ }
3185
+ function resolveInspectorEndpoint(base) {
3186
+ return `${new URL(base, "http://localhost").pathname.replace(/\/+$/, "")}${VIZE_INSPECTOR_LINT_PLAN_ENDPOINT}`;
3187
+ }
3188
+ function isSafeInspectorFile(file) {
3189
+ if (file.length === 0 || Buffer.byteLength(file) > MAX_FILE_BYTES || file.includes("\0") || file.includes("\\") || path.posix.isAbsolute(file)) return false;
3190
+ return !file.split("/").some((segment) => segment === ".." || segment.length === 0);
3191
+ }
3192
+ function sendJson$1(res, statusCode, payload, headOnly = false) {
3193
+ let body = JSON.stringify(payload);
3194
+ if (body === void 0) throw new TypeError("Inspector payload is not JSON serializable");
3195
+ if (Buffer.byteLength(body) > MAX_RESPONSE_BYTES) {
3196
+ statusCode = 413;
3197
+ body = JSON.stringify({ error: "inspector_response_too_large" });
3198
+ }
3199
+ res.statusCode = statusCode;
3200
+ res.setHeader("cache-control", "no-store");
3201
+ res.setHeader("content-type", "application/json; charset=utf-8");
3202
+ res.setHeader("content-length", Buffer.byteLength(body));
3203
+ res.setHeader("x-content-type-options", "nosniff");
3204
+ res.end(headOnly ? void 0 : body);
3205
+ }
3206
+ //#endregion
3099
3207
  //#region src/plugin/dev-middleware.ts
3100
3208
  const VIZE_INSPECTOR_GRAPH_ENDPOINT = "/__vize/inspector/graph";
3101
3209
  const INSPECTOR_SCRIPT_PATTERNS = ["**/*.{js,jsx,ts,tsx}"];
@@ -3104,6 +3212,7 @@ const INSPECTOR_FILE_EXTENSION_RE = /\.(?:vue|[jt]sx?)$/;
3104
3212
  function installDevMiddleware(devServer, state) {
3105
3213
  installVirtualAssetMiddleware(devServer, state);
3106
3214
  installInspectorGraphMiddleware(devServer, state);
3215
+ installInspectorLintPlanMiddleware(devServer, state);
3107
3216
  }
3108
3217
  function installVirtualAssetMiddleware(devServer, state) {
3109
3218
  devServer.middlewares.use((req, _res, next) => {
@@ -1,4 +1,4 @@
1
- import { c as ResolvedVizeConfig } from "../types-Cm3dJq25.mjs";
1
+ import { d as ResolvedVizeConfig } from "../types-BU_B_kFs.mjs";
2
2
  import { ResolvedConfig } from "vite";
3
3
 
4
4
  //#region src/internal/config-bridge.d.ts
@@ -660,6 +660,19 @@ interface ExperimentalPluginOptions extends ExperimentalCompileFlags {
660
660
  experimentals?: ExperimentalOptions;
661
661
  }
662
662
  //#endregion
663
+ //#region src/inspector-types.d.ts
664
+ interface VizeInspectorLintPlanRequest {
665
+ /** Project-relative files whose effective lint rules should be explained. */
666
+ files: string[];
667
+ /** Ask the integration to rebuild its plan before resolving the files. */
668
+ fresh: boolean;
669
+ }
670
+ type VizeInspectorLintPlanProvider = (request: VizeInspectorLintPlanRequest) => unknown;
671
+ interface VizeInspectorOptions {
672
+ /** Optional development-only lint-plan payload provider. */
673
+ lintPlan?: VizeInspectorLintPlanProvider;
674
+ }
675
+ //#endregion
663
676
  //#region src/utils/module-output.d.ts
664
677
  type ModuleOutputInfo = {
665
678
  hasDefaultExport: boolean;
@@ -726,6 +739,8 @@ interface VizeOptions extends ExperimentalPluginOptions {
726
739
  * Direct plugin options still take precedence over these values.
727
740
  */
728
741
  config?: UserConfigExport;
742
+ /** Development inspector integrations exposed through Vite's dev server. */
743
+ inspector?: VizeInspectorOptions;
729
744
  /**
730
745
  * Vue major version for the host project.
731
746
  *
@@ -898,4 +913,4 @@ interface CompiledModule {
898
913
  moduleShape?: ModuleOutputInfo;
899
914
  }
900
915
  //#endregion
901
- export { VizeVueVersion as a, ResolvedVizeConfig as c, VizeOptions as i, UserConfigExport as l, MacroArtifact as n, ConfigEnv as o, VizeCompatibilityOptions as r, LoadConfigOptions as s, CompiledModule as t, VizeConfig as u };
916
+ export { VizeVueVersion as a, VizeInspectorOptions as c, ResolvedVizeConfig as d, UserConfigExport as f, VizeOptions as i, ConfigEnv as l, MacroArtifact as n, VizeInspectorLintPlanProvider as o, VizeConfig as p, VizeCompatibilityOptions as r, VizeInspectorLintPlanRequest as s, CompiledModule as t, LoadConfigOptions as u };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/vite-plugin",
3
- "version": "0.312.0",
3
+ "version": "0.315.0",
4
4
  "description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
5
5
  "keywords": [
6
6
  "compiler",
@@ -45,10 +45,10 @@
45
45
  "access": "public"
46
46
  },
47
47
  "dependencies": {
48
- "@vizejs/native": "0.312.0",
48
+ "@vizejs/native": "0.315.0",
49
49
  "oxc-parser": "0.133.0",
50
50
  "tinyglobby": "0.2.16",
51
- "vize": "0.312.0"
51
+ "vize": "0.315.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/node": "25.9.2",