@ubean/vite 0.1.6 → 0.1.8

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.
Files changed (2) hide show
  1. package/dist/index.js +13 -0
  2. package/package.json +10 -10
package/dist/index.js CHANGED
@@ -160,6 +160,7 @@ import {
160
160
  Link,
161
161
  Head,
162
162
  getInitialPageData,
163
+ getInitialState,
163
164
  defineApp,
164
165
  applyAppConfig,
165
166
  createDefaultAppConfig,
@@ -177,6 +178,7 @@ export {
177
178
  Link,
178
179
  Head,
179
180
  getInitialPageData,
181
+ getInitialState,
180
182
  defineApp,
181
183
  applyAppConfig,
182
184
  createDefaultAppConfig
@@ -215,6 +217,8 @@ function _mergeAppConfig(base, ...configs) {
215
217
  if (cfg.errorComponent) result.errorComponent = cfg.errorComponent;
216
218
  if (cfg.loadingComponent) result.loadingComponent = cfg.loadingComponent;
217
219
  if (cfg.viewTransitions !== undefined) result.viewTransitions = cfg.viewTransitions;
220
+ if (cfg.serializeState) result.serializeState = cfg.serializeState;
221
+ if (cfg.hydrateState) result.hydrateState = cfg.hydrateState;
218
222
  }
219
223
  // router.setup:累加语义 — shared 和 client/server 各自定义的 setup 都会执行
220
224
  // (顺序:shared 先,client/server 后)。这样 shared 可放通用守卫(如埋点),
@@ -285,6 +289,15 @@ export function createApp() {
285
289
 
286
290
  if (config.onAppCreated) config.onAppCreated(instance.app);
287
291
 
292
+ // SSR 状态水合:在 applyAppConfig(注册插件)之后、mount 之前调用。
293
+ // getInitialState() 从 DOM 的 __UBEAN_STATE__ script 读取服务端
294
+ // serializeState 产生的状态对象(如 Pinia 的 state)。
295
+ // 必须在 mount 前执行,否则 store 已初始化为默认值,水合无效。
296
+ if (config.hydrateState) {
297
+ const state = getInitialState();
298
+ config.hydrateState(instance.app, state);
299
+ }
300
+
288
301
  const mountApp = () => {
289
302
  instance.app.mount('#' + (config.rootId || 'app'));
290
303
  if (config.onClientReady) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubean/vite",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Vue-specific Vite plugin for ubean (ubeanVuePlugin, virtual modules: pages, app, server, client-entry)",
5
5
  "files": [
6
6
  "dist"
@@ -16,21 +16,21 @@
16
16
  }
17
17
  },
18
18
  "dependencies": {
19
- "oxc-transform": "^0.141.0",
19
+ "oxc-transform": "^0.142.0",
20
20
  "pathe": "^2.0.3",
21
21
  "unplugin-auto-import": "21.0.0",
22
22
  "unplugin-vue-components": "^32.1.0",
23
23
  "unplugin-vue-markdown": "^32.0.0",
24
- "@ubean/build": "0.1.6",
25
- "@ubean/config": "0.1.6",
26
- "@ubean/routing": "0.1.6",
27
- "@ubean/markdown": "0.1.6",
28
- "@ubean/runtime": "0.1.6",
29
- "@ubean/auto-imports": "0.1.6"
24
+ "@ubean/auto-imports": "0.1.8",
25
+ "@ubean/config": "0.1.8",
26
+ "@ubean/build": "0.1.8",
27
+ "@ubean/markdown": "0.1.8",
28
+ "@ubean/runtime": "0.1.8",
29
+ "@ubean/routing": "0.1.8"
30
30
  },
31
31
  "devDependencies": {
32
- "@types/node": "^26.1.1",
33
- "typescript": "6.0.3",
32
+ "@types/node": "^26.1.2",
33
+ "typescript": "7.0.2",
34
34
  "vite": "npm:@voidzero-dev/vite-plus-core@0.2.6",
35
35
  "vite-plus": "0.2.6"
36
36
  },