web-extend-plugin-vue2 0.2.0 → 0.2.2
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/README.md +120 -0
- package/dist/index.cjs +3373 -148
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +3368 -152
- package/dist/index.mjs.map +1 -1
- package/index.d.ts +126 -0
- package/package.json +8 -4
package/index.d.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 稳定对外 API 的 TypeScript 声明(宿主需自行安装 vue / vue-router 类型时可再收紧 any)。
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export type ManifestFetchContext = { manifestUrl: string; credentials: RequestCredentials }
|
|
6
|
+
|
|
7
|
+
export type ManifestFetchResult = {
|
|
8
|
+
ok: boolean
|
|
9
|
+
status?: number
|
|
10
|
+
data?: unknown
|
|
11
|
+
error?: unknown
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type ManifestFetchFn = (ctx: ManifestFetchContext) => Promise<ManifestFetchResult>
|
|
15
|
+
|
|
16
|
+
export type ManifestFetchCacheOptions = {
|
|
17
|
+
ttlMs?: number
|
|
18
|
+
storage?: 'memory' | 'session' | 'local'
|
|
19
|
+
storageKeyPrefix?: string
|
|
20
|
+
cacheKey?: (ctx: ManifestFetchContext) => string
|
|
21
|
+
shouldCache?: (result: ManifestFetchResult) => boolean
|
|
22
|
+
maxEntries?: number
|
|
23
|
+
now?: () => number
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const WebExtendPluginVue2: Readonly<{
|
|
27
|
+
install: (Vue: unknown, router: unknown, options?: Record<string, unknown>) => Promise<void>
|
|
28
|
+
runtime: Readonly<{
|
|
29
|
+
bootstrapPlugins: (
|
|
30
|
+
router: unknown,
|
|
31
|
+
createHostApiFactory: (id: string, r: unknown, kit?: unknown) => unknown,
|
|
32
|
+
runtimeOptions?: Record<string, unknown>
|
|
33
|
+
) => Promise<void>
|
|
34
|
+
resolveRuntimeOptions: (user?: Record<string, unknown>) => Record<string, unknown>
|
|
35
|
+
defaultFetchWebPluginManifest: (ctx: {
|
|
36
|
+
manifestUrl: string
|
|
37
|
+
credentials: RequestCredentials
|
|
38
|
+
}) => Promise<{ ok: boolean; status?: number; data?: unknown; error?: unknown }>
|
|
39
|
+
composeManifestFetch: (
|
|
40
|
+
inner: ManifestFetchFn,
|
|
41
|
+
...middlewares: Array<(next: ManifestFetchFn) => ManifestFetchFn>
|
|
42
|
+
) => ManifestFetchFn
|
|
43
|
+
manifestFetchCacheMiddleware: (options?: ManifestFetchCacheOptions) => (next: ManifestFetchFn) => ManifestFetchFn
|
|
44
|
+
wrapManifestFetchWithCache: (inner: ManifestFetchFn, options?: ManifestFetchCacheOptions) => ManifestFetchFn
|
|
45
|
+
}>
|
|
46
|
+
host: Readonly<{
|
|
47
|
+
createHostApi: (pluginId: string, router: unknown, hostKit?: unknown) => unknown
|
|
48
|
+
disposeWebPlugin: (pluginId: string) => void
|
|
49
|
+
createRequestBridge: (config?: { allowedPathPrefixes?: string[] }) => {
|
|
50
|
+
request: (path: string, init?: RequestInit) => Promise<Response>
|
|
51
|
+
}
|
|
52
|
+
registries: unknown
|
|
53
|
+
}>
|
|
54
|
+
config: Readonly<{
|
|
55
|
+
defaultWebExtendPluginRuntime: Record<string, unknown>
|
|
56
|
+
setWebExtendPluginEnv: (env: Record<string, unknown> | null | undefined) => void
|
|
57
|
+
}>
|
|
58
|
+
constants: Readonly<{ HOST_PLUGIN_API_VERSION: string }>
|
|
59
|
+
components: Readonly<{ ExtensionPoint: unknown }>
|
|
60
|
+
presets: Readonly<{
|
|
61
|
+
vueCliAxios: Readonly<{
|
|
62
|
+
id: string
|
|
63
|
+
description: string
|
|
64
|
+
createInstallOptions: (
|
|
65
|
+
deps: { request: (config: Record<string, unknown>) => Promise<unknown> },
|
|
66
|
+
extra?: Record<string, unknown>
|
|
67
|
+
) => Record<string, unknown>
|
|
68
|
+
manifestPathForApiBase: (manifestUrl: string, apiBase?: string) => string
|
|
69
|
+
unwrapManifestBody: (body: unknown) => object | null
|
|
70
|
+
}>
|
|
71
|
+
}>
|
|
72
|
+
}>
|
|
73
|
+
|
|
74
|
+
export const defaultWebExtendPluginRuntime: Record<string, unknown>
|
|
75
|
+
export function bootstrapPlugins(
|
|
76
|
+
router: unknown,
|
|
77
|
+
createHostApiFactory: (id: string, r: unknown, kit?: unknown) => unknown,
|
|
78
|
+
runtimeOptions?: Record<string, unknown>
|
|
79
|
+
): Promise<void>
|
|
80
|
+
export function resolveRuntimeOptions(user?: Record<string, unknown>): Record<string, unknown>
|
|
81
|
+
export function defaultFetchWebPluginManifest(ctx: {
|
|
82
|
+
manifestUrl: string
|
|
83
|
+
credentials: RequestCredentials
|
|
84
|
+
}): Promise<{ ok: boolean; status?: number; data?: unknown; error?: unknown }>
|
|
85
|
+
export function createHostApi(pluginId: string, router: unknown, hostKit?: unknown): unknown
|
|
86
|
+
export function disposeWebPlugin(pluginId: string): void
|
|
87
|
+
export const registries: unknown
|
|
88
|
+
export function createRequestBridge(config?: {
|
|
89
|
+
allowedPathPrefixes?: string[]
|
|
90
|
+
}): { request: (path: string, init?: RequestInit) => Promise<Response> }
|
|
91
|
+
export const HOST_PLUGIN_API_VERSION: string
|
|
92
|
+
export function setWebExtendPluginEnv(env: Record<string, unknown> | null | undefined): void
|
|
93
|
+
export function installWebExtendPluginVue2(
|
|
94
|
+
Vue: unknown,
|
|
95
|
+
router: unknown,
|
|
96
|
+
options?: Record<string, unknown>
|
|
97
|
+
): Promise<void>
|
|
98
|
+
export const ExtensionPoint: unknown
|
|
99
|
+
|
|
100
|
+
export function createVueCliAxiosInstallOptions(
|
|
101
|
+
deps: { request: (config: Record<string, unknown>) => Promise<unknown> },
|
|
102
|
+
extra?: Record<string, unknown>
|
|
103
|
+
): Record<string, unknown>
|
|
104
|
+
export function manifestPathForVueCliApiBase(manifestUrl: string, apiBase?: string): string
|
|
105
|
+
export function unwrapTableStyleManifestBody(body: unknown): object | null
|
|
106
|
+
export const presetVueCliAxios: Readonly<{
|
|
107
|
+
id: string
|
|
108
|
+
description: string
|
|
109
|
+
createInstallOptions: typeof createVueCliAxiosInstallOptions
|
|
110
|
+
manifestPathForApiBase: typeof manifestPathForVueCliApiBase
|
|
111
|
+
unwrapManifestBody: typeof unwrapTableStyleManifestBody
|
|
112
|
+
}>
|
|
113
|
+
|
|
114
|
+
export function composeManifestFetch(
|
|
115
|
+
inner: ManifestFetchFn,
|
|
116
|
+
...middlewares: Array<(next: ManifestFetchFn) => ManifestFetchFn>
|
|
117
|
+
): ManifestFetchFn
|
|
118
|
+
|
|
119
|
+
export function manifestFetchCacheMiddleware(
|
|
120
|
+
options?: ManifestFetchCacheOptions
|
|
121
|
+
): (next: ManifestFetchFn) => ManifestFetchFn
|
|
122
|
+
|
|
123
|
+
export function wrapManifestFetchWithCache(
|
|
124
|
+
inner: ManifestFetchFn,
|
|
125
|
+
options?: ManifestFetchCacheOptions
|
|
126
|
+
): ManifestFetchFn
|
package/package.json
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web-extend-plugin-vue2",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"description": "Vue 2 host runtime for web-extend-plugin: manifest bootstrap, hostApi, registries, ExtensionPoint",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./dist/index.cjs",
|
|
10
|
-
"
|
|
10
|
+
"types": "./index.d.ts",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
+
"types": "./index.d.ts",
|
|
13
14
|
"import": "./dist/index.mjs",
|
|
14
|
-
"require": "./dist/index.cjs"
|
|
15
|
+
"require": "./dist/index.cjs",
|
|
16
|
+
"default": "./dist/index.cjs"
|
|
15
17
|
}
|
|
16
18
|
},
|
|
17
19
|
"files": [
|
|
18
|
-
"dist"
|
|
20
|
+
"dist",
|
|
21
|
+
"index.d.ts"
|
|
19
22
|
],
|
|
20
23
|
"peerDependencies": {
|
|
21
24
|
"vue": ">=2.6.14 <3.0.0",
|
|
@@ -25,6 +28,7 @@
|
|
|
25
28
|
"semver": "^7.6.3"
|
|
26
29
|
},
|
|
27
30
|
"devDependencies": {
|
|
31
|
+
"@rollup/plugin-commonjs": "^29.0.2",
|
|
28
32
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
29
33
|
"rollup": "^4.28.0",
|
|
30
34
|
"vitest": "^2.1.9"
|