@ubean/build 0.6.2 → 0.6.4

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.
@@ -1,5 +1,5 @@
1
1
  import { c as getComponentResolvers, h as defineVirtualModule, i as ssrSingletonDevPolicy, l as getCssImports, m as createVirtualRegistry } from "./ssr-singleton-Bbds29jS.js";
2
- import { D as toArray, E as resolveComponentsConfig, T as resolveAutoImportsConfig, d as COMPONENT_HALF_GLOBS, x as getAutoImportPresets } from "./codegen-DNUCCW3C.js";
2
+ import { D as resolveComponentsConfig, E as resolveAutoImportsConfig, O as toArray, S as getAutoImportPresets, f as COMPONENT_HALF_GLOBS } from "./codegen-BL0s5Pyq.js";
3
3
  import { createRequire } from "node:module";
4
4
  import { isAbsolute, join, normalize, relative, resolve } from "pathe";
5
5
  import { existsSync } from "node:fs";
@@ -874,24 +874,42 @@ function toDevCssHref(url) {
874
874
  return url.includes("\0") ? `${VALID_ID_PREFIX}${url.replace(/\0/g, NULL_BYTE_PLACEHOLDER)}` : url;
875
875
  }
876
876
  /**
877
- * 从客户端模块图收集 render-blocking CSS 链接。
877
+ * 收集 render-blocking CSS 链接。
878
878
  *
879
- * dev 下由 JS 引入的 CSS(虚拟 uno.css 入口、全局样式、字体 css)要等客户端模块图执行完才生效,
880
- * SSR HTML 在这段间隙是**无样式**的(FOUC)。把同一批 CSS 以阻塞 `<link>` 注入,浏览器可与 JS
881
- * 并行抓取,首屏即有样式。
879
+ * dev 下由 JS 引入的 CSS 要等模块图执行完才生效,SSR HTML 在这段间隙是**无样式**的(FOUC)。
880
+ * 把同一批 CSS 以阻塞 `<link>` 注入,浏览器可与 JS 并行抓取,首屏即有样式。
881
+ *
882
+ * 数据源是 **ssr + client 两个模块图**,缺一不可:
883
+ * - `client` 提供客户端入口 import 的全局样式(虚拟 uno.css、`@vean/ui/styles.css`);
884
+ * - `ssr` 提供 SFC `<style>` 块,且**首次页面请求时 client 图是空的**(它由浏览器后续请求
885
+ * 客户端入口才填充)—— 只读 client 图等于首个请求永远注入 0 个链接,正是 FOUC 的来源。
882
886
  *
883
887
  * `?direct` 让 Vite 的 transform 中间件返回原始 CSS(`Content-Type: text/css`)而不是注入式 JS
884
- * 包装;URL 自带查询串的模块(SFC `<style>` 块形如 `*.vue?vue&type=style`)无法这样服务,跳过。
888
+ * 包装。它必须紧跟路径(`?direct&vue&…`):Vite 的 `CSS_LANGS_RE` 只认 `.css` 结尾或紧跟
889
+ * `?`,写成 `&lang.css&direct` 会落到 JS 分支,浏览器拒绝把 JS 当样式表。
885
890
  */
886
- function collectDevCssLinks(moduleGraph) {
891
+ function collectDevCssLinks(server) {
887
892
  const links = /* @__PURE__ */ new Set();
888
- for (const mod of moduleGraph.idToModuleMap.values()) {
889
- const { url, id } = mod;
890
- if (!url || url.includes("?")) continue;
891
- if (id?.endsWith(".css") || url.endsWith(".css")) links.add(`${toDevCssHref(url)}?direct`);
893
+ for (const name of ["ssr", "client"]) {
894
+ const moduleGraph = server.environments[name]?.moduleGraph;
895
+ if (!moduleGraph) continue;
896
+ for (const mod of moduleGraph.idToModuleMap.values()) {
897
+ const { url, id } = mod;
898
+ if (!url) continue;
899
+ if (!isCssModuleUrl(url) && !isCssModuleUrl(String(id ?? ""))) continue;
900
+ const [pathname, query = ""] = toDevCssHref(url).split(/(?=\?)/);
901
+ const search = (query.slice(1) ? query.slice(1).split("&") : []).filter((part) => part !== "direct" && !part.startsWith("direct="));
902
+ links.add(search.length ? `${pathname}?direct&${search.join("&")}` : `${pathname}?direct`);
903
+ }
892
904
  }
893
905
  return [...links];
894
906
  }
907
+ /** CSS 模块判据:`.css` 结尾,或 SFC 的 `<style>` 块(`?vue&type=style&…`)。 */
908
+ function isCssModuleUrl(url) {
909
+ const [pathname, search = ""] = url.split(/(?=\?)/);
910
+ if (pathname.endsWith(".css")) return true;
911
+ return search.includes("type=style");
912
+ }
895
913
  /** 在 `</head>` 前插入阻塞样式链接。 */
896
914
  function injectStylesheetLinks(html, hrefs) {
897
915
  if (!hrefs.length || !html.includes("</head>")) return html;
@@ -1000,7 +1018,7 @@ function createUbeanRequestHandlers(server, options) {
1000
1018
  const isPage = !isFrameworkHtmlPage(url);
1001
1019
  if (contentType.includes("text/html") && webRes.body && !skipTransform && isPage) {
1002
1020
  const html = await webRes.text();
1003
- const cssLinks = collectDevCssLinks(server.environments.client.moduleGraph);
1021
+ const cssLinks = collectDevCssLinks(server);
1004
1022
  const transformed = await server.transformIndexHtml(url, injectStylesheetLinks(html, cssLinks));
1005
1023
  res.statusCode = webRes.status;
1006
1024
  res.statusMessage = webRes.statusText;
package/dist/vue.js CHANGED
@@ -1,2 +1 @@
1
- import { a as createVueAppEntryVirtualModule, i as createServerEntryVirtualModule, n as ubeanVite, o as createVuePagesVirtualModule, r as createClientEntryVirtualModule, t as VUE_PLUGIN_INCLUDE } from "./vue-DTMMMa4v.js";
2
- export { VUE_PLUGIN_INCLUDE, createClientEntryVirtualModule, createServerEntryVirtualModule, createVueAppEntryVirtualModule, createVuePagesVirtualModule, ubeanVite as default, ubeanVite };
1
+ export { t as VUE_PLUGIN_INCLUDE, r as createClientEntryVirtualModule, i as createServerEntryVirtualModule, a as createVueAppEntryVirtualModule, o as createVuePagesVirtualModule, n as default, n as ubeanVite } from "./vue-MyIMqUw0.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubean/build",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "Vite plugins, production build, SSG prerender, type codegen, and Server Actions plugin for ubean",
5
5
  "files": [
6
6
  "dist"
@@ -41,23 +41,27 @@
41
41
  "./actions": {
42
42
  "types": "./dist/actions-plugin.d.ts",
43
43
  "import": "./dist/actions-plugin.js"
44
+ },
45
+ "./env": {
46
+ "types": "./dist/env/plugin.d.ts",
47
+ "import": "./dist/env/plugin.js"
44
48
  }
45
49
  },
46
50
  "dependencies": {
47
- "@intlify/unplugin-vue-i18n": "11.2.5",
48
- "@ubean/app": "0.6.2",
49
- "@ubean/client": "0.6.2",
50
- "@ubean/config": "0.6.2",
51
- "@ubean/i18n": "0.6.2",
52
- "@ubean/islands": "0.6.2",
53
- "@ubean/markdown": "0.6.2",
54
- "@ubean/pages": "0.6.2",
55
- "@ubean/preset": "0.6.2",
56
- "@ubean/routes": "0.6.2",
57
- "@ubean/scan": "0.6.2",
58
- "@ubean/server": "0.6.2",
59
- "@ubean/shared": "0.6.2",
60
- "@ubean/vue": "0.6.2",
51
+ "@intlify/unplugin-vue-i18n": "11.2.6",
52
+ "@ubean/app": "0.6.4",
53
+ "@ubean/client": "0.6.4",
54
+ "@ubean/config": "0.6.4",
55
+ "@ubean/i18n": "0.6.4",
56
+ "@ubean/islands": "0.6.4",
57
+ "@ubean/markdown": "0.6.4",
58
+ "@ubean/pages": "0.6.4",
59
+ "@ubean/preset": "0.6.4",
60
+ "@ubean/routes": "0.6.4",
61
+ "@ubean/scan": "0.6.4",
62
+ "@ubean/server": "0.6.4",
63
+ "@ubean/shared": "0.6.4",
64
+ "@ubean/vue": "0.6.4",
61
65
  "@vitejs/plugin-vue": "^6.0.10",
62
66
  "openapi-typescript": "^7.13.0",
63
67
  "pathe": "^2.0.3",
@@ -70,14 +74,14 @@
70
74
  },
71
75
  "devDependencies": {
72
76
  "@types/node": "^26.6.5",
73
- "@vue/compiler-sfc": "^3.5.43",
77
+ "@vue/compiler-sfc": "^3.5.44",
74
78
  "hono": "4.13.13",
75
79
  "typescript": "npm:typescript-native-bridge@latest",
76
- "vite": "npm:@voidzero-dev/vite-plus-core@1.1.0",
77
- "vite-plus": "1.1.0"
80
+ "vite": "npm:@voidzero-dev/vite-plus-core@1.3.0",
81
+ "vite-plus": "1.3.0"
78
82
  },
79
83
  "peerDependencies": {
80
- "vite": "npm:@voidzero-dev/vite-plus-core@1.1.0"
84
+ "vite": "npm:@voidzero-dev/vite-plus-core@1.3.0"
81
85
  },
82
86
  "peerDependenciesMeta": {
83
87
  "vite": {