@metagptx/web-sdk 0.0.52-beta.12 → 0.0.52-beta.13

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/plugins.d.ts CHANGED
@@ -1,13 +1,11 @@
1
1
  import { Plugin } from "vite";
2
2
 
3
- //#region src/plugins/vite-plugin-404.d.ts
3
+ //#region src/types/plugins.d.ts
4
4
 
5
5
  /**
6
- * Vite plugin to create a virtual 404 React component and automatically add a 404 route
6
+ * Vite 插件相关类型定义
7
7
  */
8
- declare function vitePlugin404(): Plugin;
9
- //#endregion
10
- //#region src/plugins/vite-plugin-routes.d.ts
8
+ // ==================== vite-plugin-routes 类型 ====================
11
9
  interface RouteInfo {
12
10
  /** 完整路由路径 */
13
11
  path: string;
@@ -37,23 +35,107 @@ interface RoutesManifest {
37
35
  /** 生成时间戳 */
38
36
  generatedAt: string;
39
37
  }
40
- interface PluginOptions {
41
- /** 路由文件路径,默认 'src/App.tsx' */
38
+ interface PluginRoutesOptions {
39
+ /**
40
+ * 路由文件路径
41
+ * @default 'src/App.tsx'
42
+ */
42
43
  routeFile?: string;
43
- /** 入口文件路径,用于自动注入,默认 'src/main.tsx' */
44
+
45
+ /**
46
+ * 入口文件路径,用于自动注入
47
+ * @default 'src/main.tsx'
48
+ */
44
49
  entryFile?: string;
45
- /** 虚拟模块 ID */
50
+
51
+ /**
52
+ * 虚拟模块 ID
53
+ * @default 'virtual:routes-manifest'
54
+ */
46
55
  moduleId?: string;
47
- /** 是否自动向父级 iframe 发送路由信息,默认 true */
56
+
57
+ /**
58
+ * 是否自动向父级 iframe 发送路由信息
59
+ * @default true
60
+ */
48
61
  notifyParent?: boolean;
49
- /** 发送给父级的消息类型标识 */
62
+
63
+ /**
64
+ * 发送给父级的消息类型标识
65
+ * @default 'ROUTES_MANIFEST'
66
+ */
50
67
  messageType?: string;
51
- /** 要排除的路由路径模式 */
68
+
69
+ /**
70
+ * 要排除的路由路径模式
71
+ * @default ['*']
72
+ */
52
73
  excludePaths?: string[];
53
74
  }
75
+
76
+ // ==================== vite-plugin-404 类型 ====================
77
+
78
+ // vite-plugin-404 目前不需要配置选项
79
+
80
+ // ==================== atomsPlugins 容器类型 ====================
81
+
82
+ interface Plugin404Options {
83
+ /**
84
+ * 是否启用 404 插件
85
+ * @default true
86
+ */
87
+ enable?: boolean;
88
+ }
89
+ interface AtomsPluginRoutesOptions extends PluginRoutesOptions {
90
+ /**
91
+ * 是否启用路由扫描插件
92
+ * @default true
93
+ */
94
+ enable?: boolean;
95
+ }
96
+ interface AtomsPluginOptions {
97
+ /**
98
+ * 404 页面插件配置
99
+ */
100
+ '404'?: Plugin404Options;
101
+
102
+ /**
103
+ * 路由扫描插件配置
104
+ */
105
+ routes?: AtomsPluginRoutesOptions;
106
+ }
107
+ //#endregion
108
+ //#region src/plugins/vite-plugin-atoms.d.ts
54
109
  /**
55
- * Vite 插件:解析 React Router 的 Route 组件,生成路由信息
110
+ * Atoms Vite 插件容器
111
+ *
112
+ * 整合了 404 页面插件和路由扫描插件
113
+ *
114
+ * @example
115
+ * ```ts
116
+ * // vite.config.ts
117
+ * import { atoms } from '@metagptx/web-sdk/plugins';
118
+ *
119
+ * export default defineConfig({
120
+ * plugins: [
121
+ * atoms(),
122
+ * ],
123
+ * });
124
+ * ```
125
+ *
126
+ * @example
127
+ * ```ts
128
+ * // 自定义配置
129
+ * atomsPlugins({
130
+ * '404': { enable: true },
131
+ * routes: {
132
+ * enable: true,
133
+ * routeFile: 'src/App.tsx',
134
+ * notifyParent: true,
135
+ * },
136
+ * })
137
+ * ```
56
138
  */
57
- declare function vitePluginRoutes(options?: PluginOptions): Plugin;
139
+ declare function atoms(options?: AtomsPluginOptions): Plugin[];
58
140
  //#endregion
59
- export { type RouteInfo, type RoutesManifest, vitePlugin404, vitePluginRoutes };
141
+ export { type AtomsPluginOptions, type AtomsPluginRoutesOptions, type Plugin404Options, type PluginRoutesOptions, type RouteInfo, type RoutesManifest, atoms };
package/dist/plugins.js CHANGED
@@ -79,4 +79,4 @@ export const pageCount = routesManifest.pageCount;
79
79
  export const total = routesManifest.total;
80
80
  ${r}
81
81
  export default routesManifest;
82
- `}},transform(e,n){let r=n.replace(/\\/g,`/`),i=t.resolve(p,s).replace(/\\/g,`/`);if(r===i&&l){let t=`import "${c}";\n`;return e.includes(c)?null:{code:t+e,map:null}}return null},configureServer(e){let n=t.resolve(p,a);e.watcher.add(n),e.watcher.on(`change`,t=>{if(t===n){let t=e.moduleGraph.getModuleById(f);t&&(e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`}))}})}}}export{a as vitePlugin404,s as vitePluginRoutes};
82
+ `}},transform(e,n){let r=n.replace(/\\/g,`/`),i=t.resolve(p,s).replace(/\\/g,`/`);if(r===i&&l){let t=`import "${c}";\n`;return e.includes(c)?null:{code:t+e,map:null}}return null},configureServer(e){let n=t.resolve(p,a);e.watcher.add(n),e.watcher.on(`change`,t=>{if(t===n){let t=e.moduleGraph.getModuleById(f);t&&(e.moduleGraph.invalidateModule(t),e.ws.send({type:`full-reload`}))}})}}}function c(e={}){let{404:t={},routes:n={}}=e,{enable:r=!0}=t,{enable:i=!0,...o}=n,c=[];return r&&c.push(a()),i&&c.push(s(o)),c}export{c as atoms};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@metagptx/web-sdk",
3
3
  "type": "module",
4
- "version": "0.0.52-beta.12",
4
+ "version": "0.0.52-beta.13",
5
5
  "packageManager": "pnpm@10.15.0+sha512.486ebc259d3e999a4e8691ce03b5cac4a71cbeca39372a9b762cb500cfdf0873e2cb16abe3d951b1ee2cf012503f027b98b6584e4df22524e0c7450d9ec7aa7b",
6
6
  "description": "TypeScript SDK for interacting with FuncSea API",
7
7
  "author": "MetaGPTX",