every-plugin 0.9.0 → 2.2.3
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/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +15 -1
- package/dist/_virtual/{rolldown_runtime.mjs → _rolldown/runtime.mjs} +15 -2
- package/dist/build/rspack/dev-server-middleware.cjs +15 -4
- package/dist/build/rspack/dev-server-middleware.cjs.map +1 -1
- package/dist/build/rspack/dev-server-middleware.mjs +15 -4
- package/dist/build/rspack/dev-server-middleware.mjs.map +1 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.cjs +44 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.cjs.map +1 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts +11 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts.map +1 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts +11 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts.map +1 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.mjs +43 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.mjs.map +1 -0
- package/dist/build/rspack/index.cjs +8 -4
- package/dist/build/rspack/index.d.cts +3 -2
- package/dist/build/rspack/index.d.mts +3 -2
- package/dist/build/rspack/index.mjs +3 -2
- package/dist/build/rspack/module-federation.cjs +3 -3
- package/dist/build/rspack/module-federation.cjs.map +1 -1
- package/dist/build/rspack/module-federation.mjs +1 -1
- package/dist/build/rspack/module-federation.mjs.map +1 -1
- package/dist/build/rspack/plugin.cjs +83 -5
- package/dist/build/rspack/plugin.cjs.map +1 -1
- package/dist/build/rspack/plugin.d.cts +12 -1
- package/dist/build/rspack/plugin.d.cts.map +1 -1
- package/dist/build/rspack/plugin.d.mts +12 -1
- package/dist/build/rspack/plugin.d.mts.map +1 -1
- package/dist/build/rspack/plugin.mjs +80 -5
- package/dist/build/rspack/plugin.mjs.map +1 -1
- package/dist/build/rspack/utils.cjs +5 -4
- package/dist/build/rspack/utils.cjs.map +1 -1
- package/dist/build/rspack/utils.mjs +3 -2
- package/dist/build/rspack/utils.mjs.map +1 -1
- package/dist/build/shared-deps.cjs +50 -42
- package/dist/build/shared-deps.cjs.map +1 -1
- package/dist/build/shared-deps.d.cts +27 -2
- package/dist/build/shared-deps.d.cts.map +1 -1
- package/dist/build/shared-deps.d.mts +27 -2
- package/dist/build/shared-deps.d.mts.map +1 -1
- package/dist/build/shared-deps.mjs +48 -43
- package/dist/build/shared-deps.mjs.map +1 -1
- package/dist/errors.cjs +1 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs.map +1 -1
- package/dist/index.cjs +2 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/orpc-client.cjs +17 -0
- package/dist/orpc-client.d.cts +2 -0
- package/dist/orpc-client.d.mts +2 -0
- package/dist/orpc-client.mjs +5 -0
- package/dist/orpc-openapi.cjs +17 -0
- package/dist/orpc-openapi.d.cts +2 -0
- package/dist/orpc-openapi.d.mts +2 -0
- package/dist/orpc-openapi.mjs +5 -0
- package/dist/orpc.cjs +8 -7
- package/dist/plugin.cjs +9 -7
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +23 -24
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +23 -24
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +8 -7
- package/dist/plugin.mjs.map +1 -1
- package/dist/runtime/errors.cjs +2 -2
- package/dist/runtime/errors.cjs.map +1 -1
- package/dist/runtime/errors.d.cts +4 -4
- package/dist/runtime/errors.d.cts.map +1 -1
- package/dist/runtime/errors.d.mts +4 -4
- package/dist/runtime/errors.d.mts.map +1 -1
- package/dist/runtime/errors.mjs +1 -1
- package/dist/runtime/errors.mjs.map +1 -1
- package/dist/runtime/index.cjs +41 -37
- package/dist/runtime/index.cjs.map +1 -1
- package/dist/runtime/index.d.cts +3 -3
- package/dist/runtime/index.d.cts.map +1 -1
- package/dist/runtime/index.d.mts +3 -3
- package/dist/runtime/index.d.mts.map +1 -1
- package/dist/runtime/index.mjs +12 -9
- package/dist/runtime/index.mjs.map +1 -1
- package/dist/runtime/mf-config.cjs +33 -0
- package/dist/runtime/mf-config.cjs.map +1 -0
- package/dist/runtime/mf-config.d.cts +41 -0
- package/dist/runtime/mf-config.d.cts.map +1 -0
- package/dist/runtime/mf-config.d.mts +41 -0
- package/dist/runtime/mf-config.d.mts.map +1 -0
- package/dist/runtime/mf-config.mjs +29 -0
- package/dist/runtime/mf-config.mjs.map +1 -0
- package/dist/runtime/services/module-federation.service.cjs +19 -56
- package/dist/runtime/services/module-federation.service.cjs.map +1 -1
- package/dist/runtime/services/module-federation.service.d.cts.map +1 -1
- package/dist/runtime/services/module-federation.service.d.mts.map +1 -1
- package/dist/runtime/services/module-federation.service.mjs +18 -55
- package/dist/runtime/services/module-federation.service.mjs.map +1 -1
- package/dist/runtime/services/normalize.cjs +3 -2
- package/dist/runtime/services/normalize.cjs.map +1 -1
- package/dist/runtime/services/normalize.mjs +2 -2
- package/dist/runtime/services/normalize.mjs.map +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.cjs +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.cjs.map +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.d.cts.map +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.d.mts.map +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.mjs.map +1 -1
- package/dist/runtime/services/plugin-loader.service.cjs +3 -3
- package/dist/runtime/services/plugin-loader.service.cjs.map +1 -1
- package/dist/runtime/services/plugin-loader.service.d.cts +1 -1
- package/dist/runtime/services/plugin-loader.service.d.cts.map +1 -1
- package/dist/runtime/services/plugin-loader.service.d.mts +1 -1
- package/dist/runtime/services/plugin-loader.service.d.mts.map +1 -1
- package/dist/runtime/services/plugin-loader.service.mjs +2 -2
- package/dist/runtime/services/plugin-loader.service.mjs.map +1 -1
- package/dist/runtime/services/plugin.service.cjs +1 -1
- package/dist/runtime/services/plugin.service.cjs.map +1 -1
- package/dist/runtime/services/plugin.service.d.cts +6 -7
- package/dist/runtime/services/plugin.service.d.cts.map +1 -1
- package/dist/runtime/services/plugin.service.d.mts +6 -7
- package/dist/runtime/services/plugin.service.d.mts.map +1 -1
- package/dist/runtime/services/plugin.service.mjs.map +1 -1
- package/dist/runtime/services/secrets.service.cjs +1 -1
- package/dist/runtime/services/secrets.service.cjs.map +1 -1
- package/dist/runtime/services/secrets.service.d.cts.map +1 -1
- package/dist/runtime/services/secrets.service.d.mts.map +1 -1
- package/dist/runtime/services/secrets.service.mjs.map +1 -1
- package/dist/runtime/validation.cjs +1 -1
- package/dist/runtime/validation.cjs.map +1 -1
- package/dist/runtime/validation.mjs.map +1 -1
- package/dist/testing/index.cjs +2 -1
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +0 -2
- package/dist/testing/index.d.cts.map +1 -1
- package/dist/testing/index.d.mts +0 -2
- package/dist/testing/index.d.mts.map +1 -1
- package/dist/testing/index.mjs +1 -1
- package/dist/testing/index.mjs.map +1 -1
- package/dist/types.d.cts +6 -6
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +6 -6
- package/dist/types.d.mts.map +1 -1
- package/dist/zod.cjs +4 -3
- package/dist/zod.mjs +2 -2
- package/package.json +200 -182
- package/src/build/rspack/dev-server-middleware.ts +233 -0
- package/src/build/rspack/fix-mf-data-uri-plugin.ts +49 -0
- package/src/build/rspack/index.ts +14 -0
- package/src/build/rspack/module-federation.ts +6 -0
- package/src/build/rspack/plugin.ts +252 -0
- package/src/build/rspack/utils.ts +60 -0
- package/src/build/shared-deps.ts +79 -0
- package/src/effect.ts +1 -0
- package/src/errors.ts +140 -0
- package/src/index.ts +26 -0
- package/src/orpc-client.ts +2 -0
- package/src/orpc-openapi.ts +2 -0
- package/src/orpc.ts +9 -0
- package/src/plugin.ts +220 -0
- package/src/runtime/errors.ts +332 -0
- package/src/runtime/index.ts +258 -0
- package/src/runtime/mf-config.ts +39 -0
- package/src/runtime/services/module-federation.service.ts +181 -0
- package/src/runtime/services/normalize.ts +18 -0
- package/src/runtime/services/plugin-lifecycle.service.ts +86 -0
- package/src/runtime/services/plugin-loader.service.ts +254 -0
- package/src/runtime/services/plugin.service.ts +66 -0
- package/src/runtime/services/secrets.service.ts +74 -0
- package/src/runtime/services.ts +5 -0
- package/src/runtime/validation.ts +23 -0
- package/src/testing/index.ts +87 -0
- package/src/testing/mocks/module-federation.service.ts +41 -0
- package/src/types.ts +309 -0
- package/src/zod-core.ts +4 -0
- package/src/zod.ts +1 -0
- package/dist/package.cjs +0 -45
- package/dist/package.cjs.map +0 -1
- package/dist/package.mjs +0 -27
- package/dist/package.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,184 +1,202 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
2
|
+
"name": "every-plugin",
|
|
3
|
+
"version": "2.2.3",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"main": "./dist/index.cjs",
|
|
9
|
+
"module": "./dist/index.mjs",
|
|
10
|
+
"types": "./dist/index.d.mts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"development": {
|
|
14
|
+
"types": "./src/index.ts",
|
|
15
|
+
"import": "./src/index.ts"
|
|
16
|
+
},
|
|
17
|
+
"types": "./dist/index.d.mts",
|
|
18
|
+
"import": "./dist/index.mjs",
|
|
19
|
+
"require": "./dist/index.cjs"
|
|
20
|
+
},
|
|
21
|
+
"./runtime": {
|
|
22
|
+
"development": {
|
|
23
|
+
"types": "./src/runtime/index.ts",
|
|
24
|
+
"import": "./src/runtime/index.ts"
|
|
25
|
+
},
|
|
26
|
+
"types": "./dist/runtime/index.d.mts",
|
|
27
|
+
"import": "./dist/runtime/index.mjs",
|
|
28
|
+
"require": "./dist/runtime/index.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./testing": {
|
|
31
|
+
"development": {
|
|
32
|
+
"types": "./src/testing/index.ts",
|
|
33
|
+
"import": "./src/testing/index.ts"
|
|
34
|
+
},
|
|
35
|
+
"types": "./dist/testing/index.d.mts",
|
|
36
|
+
"import": "./dist/testing/index.mjs",
|
|
37
|
+
"require": "./dist/testing/index.cjs"
|
|
38
|
+
},
|
|
39
|
+
"./normalize": {
|
|
40
|
+
"development": {
|
|
41
|
+
"types": "./src/runtime/services/normalize.ts",
|
|
42
|
+
"import": "./src/runtime/services/normalize.ts"
|
|
43
|
+
},
|
|
44
|
+
"types": "./dist/runtime/services/normalize.d.mts",
|
|
45
|
+
"import": "./dist/runtime/services/normalize.mjs",
|
|
46
|
+
"require": "./dist/runtime/services/normalize.cjs"
|
|
47
|
+
},
|
|
48
|
+
"./effect": {
|
|
49
|
+
"development": {
|
|
50
|
+
"types": "./src/effect.ts",
|
|
51
|
+
"import": "./src/effect.ts"
|
|
52
|
+
},
|
|
53
|
+
"types": "./dist/effect.d.mts",
|
|
54
|
+
"import": "./dist/effect.mjs",
|
|
55
|
+
"require": "./dist/effect.cjs"
|
|
56
|
+
},
|
|
57
|
+
"./zod": {
|
|
58
|
+
"development": {
|
|
59
|
+
"types": "./src/zod.ts",
|
|
60
|
+
"import": "./src/zod.ts"
|
|
61
|
+
},
|
|
62
|
+
"types": "./dist/zod.d.mts",
|
|
63
|
+
"import": "./dist/zod.mjs",
|
|
64
|
+
"require": "./dist/zod.cjs"
|
|
65
|
+
},
|
|
66
|
+
"./zod/v4/core": {
|
|
67
|
+
"development": {
|
|
68
|
+
"types": "./src/zod-core.ts",
|
|
69
|
+
"import": "./src/zod-core.ts"
|
|
70
|
+
},
|
|
71
|
+
"types": "./dist/zod-core.d.mts",
|
|
72
|
+
"import": "./dist/zod-core.mjs",
|
|
73
|
+
"require": "./dist/zod-core.cjs"
|
|
74
|
+
},
|
|
75
|
+
"./orpc": {
|
|
76
|
+
"development": {
|
|
77
|
+
"types": "./src/orpc.ts",
|
|
78
|
+
"import": "./src/orpc.ts"
|
|
79
|
+
},
|
|
80
|
+
"types": "./dist/orpc.d.mts",
|
|
81
|
+
"import": "./dist/orpc.mjs",
|
|
82
|
+
"require": "./dist/orpc.cjs"
|
|
83
|
+
},
|
|
84
|
+
"./orpc/client": {
|
|
85
|
+
"development": {
|
|
86
|
+
"types": "./src/orpc-client.ts",
|
|
87
|
+
"import": "./src/orpc-client.ts"
|
|
88
|
+
},
|
|
89
|
+
"types": "./dist/orpc-client.d.mts",
|
|
90
|
+
"import": "./dist/orpc-client.mjs",
|
|
91
|
+
"require": "./dist/orpc-client.cjs"
|
|
92
|
+
},
|
|
93
|
+
"./orpc/openapi": {
|
|
94
|
+
"development": {
|
|
95
|
+
"types": "./src/orpc-openapi.ts",
|
|
96
|
+
"import": "./src/orpc-openapi.ts"
|
|
97
|
+
},
|
|
98
|
+
"types": "./dist/orpc-openapi.d.mts",
|
|
99
|
+
"import": "./dist/orpc-openapi.mjs",
|
|
100
|
+
"require": "./dist/orpc-openapi.cjs"
|
|
101
|
+
},
|
|
102
|
+
"./errors": {
|
|
103
|
+
"development": {
|
|
104
|
+
"types": "./src/errors.ts",
|
|
105
|
+
"import": "./src/errors.ts"
|
|
106
|
+
},
|
|
107
|
+
"types": "./dist/errors.d.mts",
|
|
108
|
+
"import": "./dist/errors.mjs",
|
|
109
|
+
"require": "./dist/errors.cjs"
|
|
110
|
+
},
|
|
111
|
+
"./types": {
|
|
112
|
+
"development": {
|
|
113
|
+
"types": "./src/types.ts",
|
|
114
|
+
"import": "./src/types.ts"
|
|
115
|
+
},
|
|
116
|
+
"types": "./dist/types.d.mts",
|
|
117
|
+
"import": "./dist/types.mjs",
|
|
118
|
+
"require": "./dist/types.cjs"
|
|
119
|
+
},
|
|
120
|
+
"./build/rspack": {
|
|
121
|
+
"development": {
|
|
122
|
+
"types": "./src/build/rspack/index.ts",
|
|
123
|
+
"import": "./src/build/rspack/index.ts"
|
|
124
|
+
},
|
|
125
|
+
"types": {
|
|
126
|
+
"import": "./dist/build/rspack/index.d.mts",
|
|
127
|
+
"require": "./dist/build/rspack/index.d.cts"
|
|
128
|
+
},
|
|
129
|
+
"import": "./dist/build/rspack/index.mjs",
|
|
130
|
+
"require": "./dist/build/rspack/index.cjs"
|
|
131
|
+
},
|
|
132
|
+
"./package.json": "./package.json"
|
|
133
|
+
},
|
|
134
|
+
"files": [
|
|
135
|
+
"dist",
|
|
136
|
+
"src"
|
|
137
|
+
],
|
|
138
|
+
"scripts": {
|
|
139
|
+
"build": "tsdown",
|
|
140
|
+
"build:test": "cd tests/fixtures/test-plugin && bun run build",
|
|
141
|
+
"test": "vitest run --config vitest.config.ts",
|
|
142
|
+
"test:unit": "vitest run --config vitest.config.ts",
|
|
143
|
+
"test:integration": "bun run build:test && vitest run --config vitest.integration.config.ts",
|
|
144
|
+
"test:all": "bun run test:unit && bun run test:integration",
|
|
145
|
+
"test:watch": "vitest --config vitest.config.ts --watch",
|
|
146
|
+
"typecheck": "tsc --noEmit"
|
|
147
|
+
},
|
|
148
|
+
"peerDependencies": {
|
|
149
|
+
"@rspack/core": "1.7.4",
|
|
150
|
+
"typescript": "^5.9.3",
|
|
151
|
+
"effect": "^3.21.0",
|
|
152
|
+
"zod": "^4.3.6",
|
|
153
|
+
"@orpc/contract": "^1.13.4",
|
|
154
|
+
"@orpc/server": "^1.13.4",
|
|
155
|
+
"@orpc/client": "^1.13.4",
|
|
156
|
+
"@orpc/openapi": "^1.13.4",
|
|
157
|
+
"@orpc/zod": "^1.13.4",
|
|
158
|
+
"@orpc/react-query": "^1.13.4"
|
|
159
|
+
},
|
|
160
|
+
"devDependencies": {
|
|
161
|
+
"@effect/language-service": "^0.84.3",
|
|
162
|
+
"@effect/vitest": "^0.29.0",
|
|
163
|
+
"@orpc/client": "^1.13.4",
|
|
164
|
+
"@orpc/openapi": "^1.13.4",
|
|
165
|
+
"@rspack/cli": "^1.7.4",
|
|
166
|
+
"@types/bun": "^1.3.7",
|
|
167
|
+
"@types/node": "^25.1.0",
|
|
168
|
+
"@vitest/ui": "4.1.2",
|
|
169
|
+
"bun-types": "^1.3.7",
|
|
170
|
+
"sirv": "^3.0.2",
|
|
171
|
+
"tsdown": "^0.21.7",
|
|
172
|
+
"vite-tsconfig-paths": "^6.0.5",
|
|
173
|
+
"vitest": "^4.0.18"
|
|
174
|
+
},
|
|
175
|
+
"dependencies": {
|
|
176
|
+
"@module-federation/enhanced": "^2.3.2",
|
|
177
|
+
"@module-federation/node": "^2.7.40",
|
|
178
|
+
"@module-federation/runtime-core": "^2.3.2",
|
|
179
|
+
"@orpc/contract": "^1.13.4",
|
|
180
|
+
"@orpc/experimental-publisher": "^1.13.4",
|
|
181
|
+
"@orpc/server": "^1.13.4",
|
|
182
|
+
"@orpc/tanstack-query": "^1.13.4"
|
|
183
|
+
},
|
|
184
|
+
"keywords": [
|
|
185
|
+
"plugin",
|
|
186
|
+
"module-federation",
|
|
187
|
+
"orpc",
|
|
188
|
+
"zod",
|
|
189
|
+
"typescript"
|
|
190
|
+
],
|
|
191
|
+
"author": "plugin.every.near",
|
|
192
|
+
"license": "MIT",
|
|
193
|
+
"repository": {
|
|
194
|
+
"type": "git",
|
|
195
|
+
"url": "https://github.com/NEARBuilders/everything-dev",
|
|
196
|
+
"directory": "packages/every-plugin"
|
|
197
|
+
},
|
|
198
|
+
"bugs": {
|
|
199
|
+
"url": "https://github.com/nearbuilders/everything-dev/issues"
|
|
200
|
+
},
|
|
201
|
+
"homepage": "https://everything.dev"
|
|
184
202
|
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import type { PluginInfo } from "./utils";
|
|
2
|
+
|
|
3
|
+
const corsHeaders = {
|
|
4
|
+
"Access-Control-Allow-Origin": "*",
|
|
5
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
6
|
+
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization",
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const applyCorsHeaders = (res: any) => {
|
|
10
|
+
Object.entries(corsHeaders).forEach(([key, value]) => {
|
|
11
|
+
res.setHeader(key, value);
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const normalizePrefix = (prefix?: string): string => {
|
|
16
|
+
if (!prefix) return "";
|
|
17
|
+
const cleaned = prefix.replace(/^\/+|\/+$/g, "");
|
|
18
|
+
return cleaned ? `/${cleaned}` : "";
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export function setupPluginMiddleware(
|
|
22
|
+
devServer: any,
|
|
23
|
+
pluginInfo: PluginInfo,
|
|
24
|
+
devConfig: any,
|
|
25
|
+
port: number,
|
|
26
|
+
) {
|
|
27
|
+
const rpcPrefix = normalizePrefix(devConfig?.prefix);
|
|
28
|
+
const handlers: { rpc: any; api: any } = { rpc: null, api: null };
|
|
29
|
+
let cleanup: (() => Promise<void>) | null = null;
|
|
30
|
+
|
|
31
|
+
const performCleanup = async () => {
|
|
32
|
+
if (cleanup) {
|
|
33
|
+
await cleanup();
|
|
34
|
+
cleanup = null;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
(async () => {
|
|
39
|
+
await performCleanup();
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const { createPluginRuntime } = await import("every-plugin");
|
|
43
|
+
const { RPCHandler } = await import("@orpc/server/fetch");
|
|
44
|
+
const { OpenAPIHandler } = await import("@orpc/openapi/fetch");
|
|
45
|
+
const { OpenAPIReferencePlugin } = await import("@orpc/openapi/plugins");
|
|
46
|
+
const { ZodToJsonSchemaConverter } = await import("@orpc/zod/zod4");
|
|
47
|
+
const { onError } = await import("every-plugin/orpc");
|
|
48
|
+
const { formatORPCError } = await import("every-plugin/errors");
|
|
49
|
+
|
|
50
|
+
const pluginId = devConfig?.pluginId || pluginInfo.normalizedName;
|
|
51
|
+
|
|
52
|
+
const runtime = createPluginRuntime({
|
|
53
|
+
registry: {
|
|
54
|
+
[pluginId]: {
|
|
55
|
+
remote: `http://localhost:${port}/remoteEntry.js`,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const defaultConfig = { variables: {}, secrets: {} };
|
|
61
|
+
|
|
62
|
+
// @ts-expect-error we don't know the plugin id
|
|
63
|
+
const loaded = await runtime.usePlugin(pluginId, (devConfig?.config ?? defaultConfig) as any);
|
|
64
|
+
|
|
65
|
+
cleanup = async () => {
|
|
66
|
+
if (loaded && typeof (loaded as any).dispose === "function") {
|
|
67
|
+
await (loaded as any).dispose();
|
|
68
|
+
}
|
|
69
|
+
if (runtime && typeof (runtime as any).cleanup === "function") {
|
|
70
|
+
await (runtime as any).cleanup();
|
|
71
|
+
}
|
|
72
|
+
handlers.rpc = null;
|
|
73
|
+
handlers.api = null;
|
|
74
|
+
if (devServer.app.locals.handlers) {
|
|
75
|
+
devServer.app.locals.handlers = null;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
handlers.rpc = new RPCHandler(loaded.router, {
|
|
80
|
+
interceptors: [
|
|
81
|
+
onError((error: any) => {
|
|
82
|
+
formatORPCError(error);
|
|
83
|
+
}),
|
|
84
|
+
],
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
handlers.api = new OpenAPIHandler(loaded.router, {
|
|
88
|
+
plugins: [
|
|
89
|
+
new OpenAPIReferencePlugin({
|
|
90
|
+
schemaConverters: [new ZodToJsonSchemaConverter()],
|
|
91
|
+
}),
|
|
92
|
+
],
|
|
93
|
+
interceptors: [
|
|
94
|
+
onError((error: any) => {
|
|
95
|
+
formatORPCError(error);
|
|
96
|
+
}),
|
|
97
|
+
],
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
console.log(`╭─────────────────────────────────────────────`);
|
|
101
|
+
console.log(`│ ✅ Plugin dev server ready: `);
|
|
102
|
+
console.log(`├─────────────────────────────────────────────`);
|
|
103
|
+
console.log(`│ 📡 RPC: http://localhost:${port}/api/rpc${rpcPrefix}`);
|
|
104
|
+
console.log(`│ 📖 Docs: http://localhost:${port}/api`);
|
|
105
|
+
console.log(`│ 💚 Health: http://localhost:${port}/`);
|
|
106
|
+
console.log(`╰─────────────────────────────────────────────`);
|
|
107
|
+
|
|
108
|
+
devServer.app.locals.handlers = handlers;
|
|
109
|
+
|
|
110
|
+
if (devServer.server) {
|
|
111
|
+
devServer.server.once("close", async () => {
|
|
112
|
+
await performCleanup();
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
} catch (error) {
|
|
116
|
+
console.error("❌ Failed to load plugin:", error);
|
|
117
|
+
await performCleanup();
|
|
118
|
+
}
|
|
119
|
+
})();
|
|
120
|
+
|
|
121
|
+
process.once("SIGINT", async () => {
|
|
122
|
+
const timeout = setTimeout(() => process.exit(0), 3000);
|
|
123
|
+
await performCleanup();
|
|
124
|
+
clearTimeout(timeout);
|
|
125
|
+
});
|
|
126
|
+
process.once("SIGTERM", async () => {
|
|
127
|
+
const timeout = setTimeout(() => process.exit(0), 3000);
|
|
128
|
+
await performCleanup();
|
|
129
|
+
clearTimeout(timeout);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
devServer.app.options("*", (_req: any, res: any) => {
|
|
133
|
+
applyCorsHeaders(res);
|
|
134
|
+
res.status(200).end();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
devServer.app.get("/", (_req: any, res: any) => {
|
|
138
|
+
applyCorsHeaders(res);
|
|
139
|
+
res.json({
|
|
140
|
+
ok: true,
|
|
141
|
+
plugin: pluginInfo.normalizedName,
|
|
142
|
+
version: pluginInfo.version,
|
|
143
|
+
status: devServer.app.locals.handlers?.rpc ? "ready" : "loading",
|
|
144
|
+
endpoints: {
|
|
145
|
+
health: "/",
|
|
146
|
+
docs: "/api",
|
|
147
|
+
rpc: `/api/rpc${rpcPrefix}`,
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
devServer.app.get("/health", (_req: any, res: any) => {
|
|
153
|
+
applyCorsHeaders(res);
|
|
154
|
+
res.status(200).send("OK");
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
const handleApiRequest = async (req: any, res: any) => {
|
|
158
|
+
applyCorsHeaders(res);
|
|
159
|
+
const apiHandler = devServer.app.locals.handlers?.api;
|
|
160
|
+
if (!apiHandler) {
|
|
161
|
+
return res.status(503).json({ error: "Plugin still loading..." });
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
try {
|
|
165
|
+
const url = `http://${req.headers.host}${req.url}`;
|
|
166
|
+
const webRequest = new Request(url, {
|
|
167
|
+
method: req.method,
|
|
168
|
+
headers: req.headers,
|
|
169
|
+
body: req.method !== "GET" && req.method !== "HEAD" ? req : undefined,
|
|
170
|
+
duplex: req.method !== "GET" && req.method !== "HEAD" ? "half" : undefined,
|
|
171
|
+
} as RequestInit);
|
|
172
|
+
|
|
173
|
+
const result = await apiHandler.handle(webRequest, {
|
|
174
|
+
prefix: "/api",
|
|
175
|
+
context: {},
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
if (result.response) {
|
|
179
|
+
res.status(result.response.status);
|
|
180
|
+
result.response.headers.forEach((value: string, key: string) => {
|
|
181
|
+
res.setHeader(key, value);
|
|
182
|
+
});
|
|
183
|
+
const text = await result.response.text();
|
|
184
|
+
res.send(text);
|
|
185
|
+
} else {
|
|
186
|
+
res.status(404).send("Not Found");
|
|
187
|
+
}
|
|
188
|
+
} catch (error) {
|
|
189
|
+
console.error("OpenAPI error:", error);
|
|
190
|
+
res.status(500).json({ error: (error as Error).message });
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
devServer.app.all(`/api/rpc${rpcPrefix}/*`, async (req: any, res: any) => {
|
|
195
|
+
applyCorsHeaders(res);
|
|
196
|
+
const rpcHandler = devServer.app.locals.handlers?.rpc;
|
|
197
|
+
if (!rpcHandler) {
|
|
198
|
+
return res.status(503).json({ error: "Plugin still loading..." });
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
try {
|
|
202
|
+
const url = `http://${req.headers.host}${req.url}`;
|
|
203
|
+
const webRequest = new Request(url, {
|
|
204
|
+
method: req.method,
|
|
205
|
+
headers: req.headers,
|
|
206
|
+
body: req.method !== "GET" && req.method !== "HEAD" ? req : undefined,
|
|
207
|
+
duplex: req.method !== "GET" && req.method !== "HEAD" ? "half" : undefined,
|
|
208
|
+
} as RequestInit);
|
|
209
|
+
|
|
210
|
+
const result = await rpcHandler.handle(webRequest, {
|
|
211
|
+
prefix: `/api/rpc${rpcPrefix}`,
|
|
212
|
+
context: {},
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
if (result.response) {
|
|
216
|
+
res.status(result.response.status);
|
|
217
|
+
result.response.headers.forEach((value: string, key: string) => {
|
|
218
|
+
res.setHeader(key, value);
|
|
219
|
+
});
|
|
220
|
+
const text = await result.response.text();
|
|
221
|
+
res.send(text);
|
|
222
|
+
} else {
|
|
223
|
+
res.status(404).send("Not Found");
|
|
224
|
+
}
|
|
225
|
+
} catch (error) {
|
|
226
|
+
console.error("RPC error:", error);
|
|
227
|
+
res.status(500).json({ error: (error as Error).message });
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
devServer.app.all("/api", handleApiRequest);
|
|
232
|
+
devServer.app.all("/api/*", handleApiRequest);
|
|
233
|
+
}
|