@yh-mf/runtime 0.0.0-stage → 1.0.0

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/AGENTS.md ADDED
@@ -0,0 +1,15 @@
1
+ # AGENTS.md
2
+
3
+ ## Commands
4
+
5
+ - `pnpm run build` - Build the library for production
6
+ - `pnpm run dev` - Turn on watch mode, watch for changes and rebuild the library
7
+ - `pnpm run test` - Run tests
8
+ - `pnpm run test:watch` - Run tests in watch mode
9
+
10
+ ## Docs
11
+
12
+ - Rslib: https://rslib.rs/llms.txt
13
+ - Rsbuild: https://rsbuild.rs/llms.txt
14
+ - Rspack: https://rspack.rs/llms.txt
15
+ - Rstest: https://rstest.rs/llms.txt
package/README.md CHANGED
@@ -1,3 +1,35 @@
1
- # Temporary Holding Version
1
+ # Rslib project
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ## Setup
4
+
5
+ Install the dependencies:
6
+
7
+ ```bash
8
+ pnpm install
9
+ ```
10
+
11
+ ## Get started
12
+
13
+ Build the library:
14
+
15
+ ```bash
16
+ pnpm run build
17
+ ```
18
+
19
+ Build the library in watch mode:
20
+
21
+ ```bash
22
+ pnpm run dev
23
+ ```
24
+
25
+ Run tests:
26
+
27
+ ```bash
28
+ pnpm run test
29
+ ```
30
+
31
+ Run tests in watch mode:
32
+
33
+ ```bash
34
+ pnpm run test:watch
35
+ ```
package/package.json CHANGED
@@ -1,6 +1,24 @@
1
1
  {
2
2
  "name": "@yh-mf/runtime",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./src/index.ts",
10
+ "default": "./src/index.ts"
11
+ }
12
+ },
13
+ "scripts": {},
14
+ "keywords": [],
15
+ "author": "",
16
+ "license": "ISC",
17
+ "devDependencies": {
18
+ "@module-federation/enhanced": "2.8.1",
19
+ "@types/node": "^26.6.6",
20
+ "typescript": "^7.0.2",
21
+ "vue": "3.5.40",
22
+ "pinia": "3.0.4"
23
+ }
24
+ }
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./useDevMount"
2
+ export * from "./types"
3
+ export * from "./useHooks"
@@ -0,0 +1 @@
1
+ export type ViewsDynamic = Record<string, () => Promise<{ default: unknown }>>;
@@ -0,0 +1,38 @@
1
+ import { loadRemote } from "@module-federation/enhanced/runtime";
2
+ import type { ViewsDynamic } from "./types"
3
+
4
+ const { default: useAuthApp } = (await loadRemote("his_platform_fe/useAuthApp")) as { default: any }
5
+
6
+ declare global {
7
+ interface ImportMeta {
8
+ webpackContext(
9
+ request: string,
10
+ options?: { recursive?: boolean; regExp?: RegExp; mode?: "sync" | "lazy" | "lazy-once" | "eager" },
11
+ ): {
12
+ keys(): string[];
13
+ (key: string): Promise<{ default: unknown }>;
14
+ };
15
+ }
16
+ }
17
+
18
+ function buildViewsDynamic(): ViewsDynamic {
19
+ const ctx = import.meta.webpackContext("@/views", {
20
+ recursive: true,
21
+ regExp: /\.(vue|tsx|jsx)$/,
22
+ });
23
+
24
+ return ctx.keys().reduce((acc, file) => {
25
+ const path = file.replace(/\.(vue|tsx|jsx)$/, "").replace("./", "");
26
+ acc[path] = async () => await ctx(file);
27
+ return acc
28
+ }, {} as ViewsDynamic);
29
+ }
30
+
31
+ export function useDevMount() {
32
+ const appName = process.env.PUBLIC_APP_NAME as string;
33
+ const viewsDynamic = buildViewsDynamic();
34
+
35
+ console.log(viewsDynamic)
36
+ const { app } = useAuthApp({ appName, viewsDynamic })
37
+ app.mount('#root')
38
+ }
@@ -0,0 +1,12 @@
1
+ // const hooksModule = await import('his_platform_fe/hooks')
2
+ // const hooks: Record<string, (...args: any[]) => any> = hooksModule.default()
3
+ // export default hooks
4
+ import { loadRemote } from "@module-federation/enhanced/runtime";
5
+ const { default: hooks } = (await loadRemote("his_platform_fe/hooks")) as { default: any }
6
+
7
+
8
+
9
+ export const useHooks = () => {
10
+ console.log(hooks)
11
+ return hooks
12
+ }
@@ -0,0 +1,27 @@
1
+ import { loadRemote } from "@module-federation/enhanced/runtime";
2
+ import type { Pinia } from "pinia";
3
+
4
+ // 定义 store 函数的类型
5
+ type StoreFunction<T = any> = () => T;
6
+
7
+ // 动态加载 supply 模块的 store
8
+ const supplyStore = await loadRemote('his_platform_fe/store') as {
9
+ default: Pinia;
10
+ usePermissionStore: StoreFunction;
11
+ useCacheViewStore: StoreFunction;
12
+ useUserStore: StoreFunction;
13
+ useAppStore: StoreFunction;
14
+ useThemeStore: StoreFunction;
15
+ useLayoutStore: StoreFunction;
16
+ };
17
+
18
+ // 导出 Pinia 实例作为默认导出
19
+ export default supplyStore.default;
20
+
21
+ // 重新导出所有 store 函数
22
+ export const usePermissionStore: StoreFunction = supplyStore.usePermissionStore;
23
+ export const useCacheViewStore: StoreFunction = supplyStore.useCacheViewStore;
24
+ export const useUserStore: StoreFunction = supplyStore.useUserStore;
25
+ export const useAppStore: StoreFunction = supplyStore.useAppStore;
26
+ export const useThemeStore: StoreFunction = supplyStore.useThemeStore;
27
+ export const useLayoutStore: StoreFunction = supplyStore.useLayoutStore;
@@ -0,0 +1,3 @@
1
+ import { loadRemote } from "@module-federation/enhanced/runtime";
2
+ const { default: utils } = (await loadRemote("his_platform_fe/utils")) as { default: any }
3
+ export default utils
package/tsconfig.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["ES2022"],
4
+ "target": "ES2022",
5
+ "module": "ESNext",
6
+ "noEmit": true,
7
+ "skipLibCheck": true,
8
+ "types": ["node"],
9
+ "useDefineForClassFields": true,
10
+ "rootDir": "src",
11
+
12
+ /* modules */
13
+ "isolatedModules": true,
14
+ "moduleDetection": "force",
15
+ "moduleResolution": "bundler",
16
+ "resolveJsonModule": true,
17
+ "allowImportingTsExtensions": true,
18
+
19
+ /* type checking */
20
+ "noUnusedLocals": true,
21
+ "noUnusedParameters": true
22
+ },
23
+ "include": ["src/**/*", "types/**/*"]
24
+ }