@pubinfo/module-auth 2.0.0-rc.3 → 2.0.0-rc.5

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pubinfo/module-auth",
3
3
  "type": "module",
4
- "version": "2.0.0-rc.3",
4
+ "version": "2.0.0-rc.5",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
@@ -19,11 +19,14 @@
19
19
  "dist",
20
20
  "src"
21
21
  ],
22
+ "engines": {
23
+ "node": "^20.19.0 || >=22.12.0"
24
+ },
22
25
  "peerDependencies": {
23
- "pubinfo": "2.0.0-rc.3"
26
+ "pubinfo": "2.0.0-rc.5"
24
27
  },
25
28
  "devDependencies": {
26
- "pubinfo": "2.0.0-rc.3"
29
+ "pubinfo": "2.0.0-rc.5"
27
30
  },
28
31
  "scripts": {
29
32
  "dev": "pubinfo build --watch",
package/src/context.ts CHANGED
@@ -1,20 +1,4 @@
1
1
  import type { InternalContext } from './interface';
2
2
  import { createContext } from 'pubinfo';
3
3
 
4
- // 持久化 auth 模块上下文,避免 HMR 后丢失 baseURL/providers
5
- const g = globalThis as any;
6
- g.__PUBINFO__ = g.__PUBINFO__ || {};
7
- if (!g.__PUBINFO__.authCtx) {
8
- g.__PUBINFO__.authCtx = createContext<InternalContext>();
9
- }
10
- export const ctx = g.__PUBINFO__.authCtx as ReturnType<typeof createContext<InternalContext>>;
11
-
12
- // HMR 恢复
13
- if (g.__PUBINFO__.authState) {
14
- try {
15
- ctx.set(g.__PUBINFO__.authState);
16
- }
17
- catch {
18
- // ignore
19
- }
20
- }
4
+ export const ctx = createContext<InternalContext>('auth');
package/src/index.ts CHANGED
@@ -16,8 +16,7 @@ export function auth(options: AuthOptions): ModuleOptions {
16
16
  const { signIn = '/login' } = pages;
17
17
 
18
18
  ctx.set({ baseURL, providers });
19
- // 缓存以便 HMR 恢复
20
- (globalThis as any).__PUBINFO__.authState = { baseURL, providers };
19
+ // ctx.set 会自动缓存以便 HMR 恢复
21
20
 
22
21
  return {
23
22
  name: 'pubinfo:auth',