@ubean/build 0.3.5 → 0.3.7

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.
@@ -141,8 +141,12 @@ interface GenerateOpenApiTypesOptions {
141
141
  declare function generateOpenApiTypes(schema: unknown, options: GenerateOpenApiTypesOptions): Promise<string>;
142
142
  /**
143
143
  * 从 dev server 的 `/_openapi.json` 路由获取 schema 并生成类型声明文件。
144
+ *
145
+ * SSG / SPA 等无后端模式访问 `/_openapi.json` 时,dev server 会以 200 返回
146
+ * HTML(页面 fallback)而非 JSON。此时跳过生成并返回 `null`,避免抛出
147
+ * `Unexpected token '<'` 之类的误导性错误。
144
148
  */
145
- declare function generateOpenApiTypesFromServer(baseUrl: string, options: GenerateOpenApiTypesOptions): Promise<string>;
149
+ declare function generateOpenApiTypesFromServer(baseUrl: string, options: GenerateOpenApiTypesOptions): Promise<string | null>;
146
150
  //#endregion
147
151
  //#region src/codegen/index.d.ts
148
152
  declare const CODEGEN_CONTRACT_VERSION: 1;
@@ -1,2 +1,2 @@
1
- import { _ as generateImportsTransform, a as generateOpenApiTypesFromServer, b as getUbeanComponentsConfig, c as generateI18nTypes, d as HONO_OPENAPI_PRESET, f as UBEAN_CLIENT_PRESET, g as generateAutoImports, h as VUE_PRESET, i as generateOpenApiTypes, l as messagesToTsType, m as VUE_MACROS_PRESET, n as CODEGEN_FILES, o as generatePageTypes, p as UBEAN_SERVER_PRESET, r as generateTypes, s as generateRouteTypes, t as CODEGEN_CONTRACT_VERSION, u as BUILTIN_PRESETS, v as getBuiltinComposables, y as getUbeanAutoImportConfig } from "../codegen-C4Y0V3iD.js";
1
+ import { _ as generateImportsTransform, a as generateOpenApiTypesFromServer, b as getUbeanComponentsConfig, c as generateI18nTypes, d as HONO_OPENAPI_PRESET, f as UBEAN_CLIENT_PRESET, g as generateAutoImports, h as VUE_PRESET, i as generateOpenApiTypes, l as messagesToTsType, m as VUE_MACROS_PRESET, n as CODEGEN_FILES, o as generatePageTypes, p as UBEAN_SERVER_PRESET, r as generateTypes, s as generateRouteTypes, t as CODEGEN_CONTRACT_VERSION, u as BUILTIN_PRESETS, v as getBuiltinComposables, y as getUbeanAutoImportConfig } from "../codegen-DX7zMgPZ.js";
2
2
  export { BUILTIN_PRESETS, CODEGEN_CONTRACT_VERSION, CODEGEN_FILES, HONO_OPENAPI_PRESET, UBEAN_CLIENT_PRESET, UBEAN_SERVER_PRESET, VUE_MACROS_PRESET, VUE_PRESET, generateAutoImports, generateI18nTypes, generateImportsTransform, generateOpenApiTypes, generateOpenApiTypesFromServer, generatePageTypes, generateRouteTypes, generateTypes, getBuiltinComposables, getUbeanAutoImportConfig, getUbeanComponentsConfig, messagesToTsType };
@@ -605,11 +605,16 @@ async function generateOpenApiTypes(schema, options) {
605
605
  }
606
606
  /**
607
607
  * 从 dev server 的 `/_openapi.json` 路由获取 schema 并生成类型声明文件。
608
+ *
609
+ * SSG / SPA 等无后端模式访问 `/_openapi.json` 时,dev server 会以 200 返回
610
+ * HTML(页面 fallback)而非 JSON。此时跳过生成并返回 `null`,避免抛出
611
+ * `Unexpected token '<'` 之类的误导性错误。
608
612
  */
609
613
  async function generateOpenApiTypesFromServer(baseUrl, options) {
610
614
  const url = `${baseUrl.replace(/\/$/, "")}/_openapi.json`;
611
615
  const response = await fetch(url);
612
616
  if (!response.ok) throw new Error(`[openapi-types] Failed to fetch OpenAPI schema from ${url}: ${response.status} ${response.statusText}`);
617
+ if (!(response.headers.get("content-type") || "").includes("json")) return null;
613
618
  return generateOpenApiTypes(await response.json(), options);
614
619
  }
615
620
  //#endregion
@@ -2,7 +2,7 @@ import { a as useVirtualRegistry } from "./virtual-registry-BWkaQHXN.js";
2
2
  import { a as createRoutingVirtualModule, i as createPagesVirtualModule, n as createLocalesVirtualModule, r as createMetaVirtualModule, t as createAppVirtualModule } from "./virtual-modules-D5WBA3u7.js";
3
3
  import { a as ssrSingletonProdOptimizeExclude, o as ssrSingletonProdSsr } from "./ssr-singleton-CEQi_H6-.js";
4
4
  import { n as localeVueParamFromI18n, r as serializeI18nConfig, t as ubeanPlugin } from "./vite-B3y8Qoan.js";
5
- import { a as createVueAppEntryVirtualModule, i as createServerEntryVirtualModule, n as ubeanVite, o as createVuePagesVirtualModule, r as createClientEntryVirtualModule, t as VUE_PLUGIN_INCLUDE } from "./vue-DtV9bO4I.js";
5
+ import { a as createVueAppEntryVirtualModule, i as createServerEntryVirtualModule, n as ubeanVite, o as createVuePagesVirtualModule, r as createClientEntryVirtualModule, t as VUE_PLUGIN_INCLUDE } from "./vue-JEYc4beF.js";
6
6
  import { join, relative, resolve } from "pathe";
7
7
  import { resolveModules } from "@ubean/config";
8
8
  import { build } from "vite";
@@ -1,6 +1,6 @@
1
1
  import { a as useVirtualRegistry, n as defineVirtualModule } from "./virtual-registry-BWkaQHXN.js";
2
2
  import { c as getCssImports, i as ssrSingletonDevPolicy, s as getComponentResolvers } from "./ssr-singleton-CEQi_H6-.js";
3
- import { f as UBEAN_CLIENT_PRESET, p as UBEAN_SERVER_PRESET } from "./codegen-C4Y0V3iD.js";
3
+ import { f as UBEAN_CLIENT_PRESET, p as UBEAN_SERVER_PRESET } from "./codegen-DX7zMgPZ.js";
4
4
  import { createRequire } from "node:module";
5
5
  import { join, resolve } from "pathe";
6
6
  import { scanProject } from "@ubean/scan";
package/dist/vue.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as createVueAppEntryVirtualModule, i as createServerEntryVirtualModule, n as ubeanVite, o as createVuePagesVirtualModule, r as createClientEntryVirtualModule, t as VUE_PLUGIN_INCLUDE } from "./vue-DtV9bO4I.js";
1
+ import { a as createVueAppEntryVirtualModule, i as createServerEntryVirtualModule, n as ubeanVite, o as createVuePagesVirtualModule, r as createClientEntryVirtualModule, t as VUE_PLUGIN_INCLUDE } from "./vue-JEYc4beF.js";
2
2
  export { VUE_PLUGIN_INCLUDE, createClientEntryVirtualModule, createServerEntryVirtualModule, createVueAppEntryVirtualModule, createVuePagesVirtualModule, ubeanVite as default, ubeanVite };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubean/build",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "Vite plugins, production build, SSG prerender, type codegen, and Server Actions plugin for ubean",
5
5
  "files": [
6
6
  "dist"
@@ -41,17 +41,17 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@intlify/unplugin-vue-i18n": "11.2.5",
44
- "@ubean/client": "0.3.5",
45
- "@ubean/config": "0.3.5",
46
- "@ubean/i18n": "0.3.5",
47
- "@ubean/islands": "0.3.5",
48
- "@ubean/markdown": "0.3.5",
49
- "@ubean/pages": "0.3.5",
50
- "@ubean/preset": "0.3.5",
51
- "@ubean/routes": "0.3.5",
52
- "@ubean/scan": "0.3.5",
53
- "@ubean/shared": "0.3.5",
54
- "@ubean/vue": "0.3.5",
44
+ "@ubean/client": "0.3.7",
45
+ "@ubean/config": "0.3.7",
46
+ "@ubean/i18n": "0.3.7",
47
+ "@ubean/islands": "0.3.7",
48
+ "@ubean/markdown": "0.3.7",
49
+ "@ubean/pages": "0.3.7",
50
+ "@ubean/preset": "0.3.7",
51
+ "@ubean/routes": "0.3.7",
52
+ "@ubean/scan": "0.3.7",
53
+ "@ubean/shared": "0.3.7",
54
+ "@ubean/vue": "0.3.7",
55
55
  "@vitejs/plugin-vue": "^6.0.8",
56
56
  "openapi-typescript": "^7.13.0",
57
57
  "oxc-transform": "^0.147.0",