every-plugin 0.9.0 → 2.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.
Files changed (179) hide show
  1. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +15 -1
  2. package/dist/_virtual/{rolldown_runtime.mjs → _rolldown/runtime.mjs} +15 -2
  3. package/dist/build/rspack/dev-server-middleware.cjs +15 -4
  4. package/dist/build/rspack/dev-server-middleware.cjs.map +1 -1
  5. package/dist/build/rspack/dev-server-middleware.mjs +15 -4
  6. package/dist/build/rspack/dev-server-middleware.mjs.map +1 -1
  7. package/dist/build/rspack/fix-mf-data-uri-plugin.cjs +44 -0
  8. package/dist/build/rspack/fix-mf-data-uri-plugin.cjs.map +1 -0
  9. package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts +11 -0
  10. package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts.map +1 -0
  11. package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts +11 -0
  12. package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts.map +1 -0
  13. package/dist/build/rspack/fix-mf-data-uri-plugin.mjs +43 -0
  14. package/dist/build/rspack/fix-mf-data-uri-plugin.mjs.map +1 -0
  15. package/dist/build/rspack/index.cjs +8 -4
  16. package/dist/build/rspack/index.d.cts +3 -2
  17. package/dist/build/rspack/index.d.mts +3 -2
  18. package/dist/build/rspack/index.mjs +3 -2
  19. package/dist/build/rspack/module-federation.cjs +3 -3
  20. package/dist/build/rspack/module-federation.cjs.map +1 -1
  21. package/dist/build/rspack/module-federation.mjs +1 -1
  22. package/dist/build/rspack/module-federation.mjs.map +1 -1
  23. package/dist/build/rspack/plugin.cjs +83 -5
  24. package/dist/build/rspack/plugin.cjs.map +1 -1
  25. package/dist/build/rspack/plugin.d.cts +12 -1
  26. package/dist/build/rspack/plugin.d.cts.map +1 -1
  27. package/dist/build/rspack/plugin.d.mts +12 -1
  28. package/dist/build/rspack/plugin.d.mts.map +1 -1
  29. package/dist/build/rspack/plugin.mjs +80 -5
  30. package/dist/build/rspack/plugin.mjs.map +1 -1
  31. package/dist/build/rspack/utils.cjs +5 -4
  32. package/dist/build/rspack/utils.cjs.map +1 -1
  33. package/dist/build/rspack/utils.mjs +3 -2
  34. package/dist/build/rspack/utils.mjs.map +1 -1
  35. package/dist/build/shared-deps.cjs +50 -42
  36. package/dist/build/shared-deps.cjs.map +1 -1
  37. package/dist/build/shared-deps.d.cts +27 -2
  38. package/dist/build/shared-deps.d.cts.map +1 -1
  39. package/dist/build/shared-deps.d.mts +27 -2
  40. package/dist/build/shared-deps.d.mts.map +1 -1
  41. package/dist/build/shared-deps.mjs +48 -43
  42. package/dist/build/shared-deps.mjs.map +1 -1
  43. package/dist/errors.cjs +1 -0
  44. package/dist/errors.cjs.map +1 -1
  45. package/dist/errors.d.cts.map +1 -1
  46. package/dist/errors.d.mts.map +1 -1
  47. package/dist/errors.mjs.map +1 -1
  48. package/dist/index.cjs +2 -0
  49. package/dist/index.d.cts +2 -2
  50. package/dist/index.d.mts +2 -2
  51. package/dist/index.mjs +2 -2
  52. package/dist/orpc-client.cjs +17 -0
  53. package/dist/orpc-client.d.cts +2 -0
  54. package/dist/orpc-client.d.mts +2 -0
  55. package/dist/orpc-client.mjs +5 -0
  56. package/dist/orpc-openapi.cjs +17 -0
  57. package/dist/orpc-openapi.d.cts +2 -0
  58. package/dist/orpc-openapi.d.mts +2 -0
  59. package/dist/orpc-openapi.mjs +5 -0
  60. package/dist/orpc.cjs +8 -7
  61. package/dist/plugin.cjs +9 -7
  62. package/dist/plugin.cjs.map +1 -1
  63. package/dist/plugin.d.cts +23 -24
  64. package/dist/plugin.d.cts.map +1 -1
  65. package/dist/plugin.d.mts +23 -24
  66. package/dist/plugin.d.mts.map +1 -1
  67. package/dist/plugin.mjs +8 -7
  68. package/dist/plugin.mjs.map +1 -1
  69. package/dist/runtime/errors.cjs +2 -2
  70. package/dist/runtime/errors.cjs.map +1 -1
  71. package/dist/runtime/errors.d.cts +4 -4
  72. package/dist/runtime/errors.d.cts.map +1 -1
  73. package/dist/runtime/errors.d.mts +4 -4
  74. package/dist/runtime/errors.d.mts.map +1 -1
  75. package/dist/runtime/errors.mjs +1 -1
  76. package/dist/runtime/errors.mjs.map +1 -1
  77. package/dist/runtime/index.cjs +41 -37
  78. package/dist/runtime/index.cjs.map +1 -1
  79. package/dist/runtime/index.d.cts +3 -3
  80. package/dist/runtime/index.d.cts.map +1 -1
  81. package/dist/runtime/index.d.mts +3 -3
  82. package/dist/runtime/index.d.mts.map +1 -1
  83. package/dist/runtime/index.mjs +12 -9
  84. package/dist/runtime/index.mjs.map +1 -1
  85. package/dist/runtime/mf-config.cjs +33 -0
  86. package/dist/runtime/mf-config.cjs.map +1 -0
  87. package/dist/runtime/mf-config.d.cts +41 -0
  88. package/dist/runtime/mf-config.d.cts.map +1 -0
  89. package/dist/runtime/mf-config.d.mts +41 -0
  90. package/dist/runtime/mf-config.d.mts.map +1 -0
  91. package/dist/runtime/mf-config.mjs +29 -0
  92. package/dist/runtime/mf-config.mjs.map +1 -0
  93. package/dist/runtime/services/module-federation.service.cjs +19 -56
  94. package/dist/runtime/services/module-federation.service.cjs.map +1 -1
  95. package/dist/runtime/services/module-federation.service.d.cts.map +1 -1
  96. package/dist/runtime/services/module-federation.service.d.mts.map +1 -1
  97. package/dist/runtime/services/module-federation.service.mjs +18 -55
  98. package/dist/runtime/services/module-federation.service.mjs.map +1 -1
  99. package/dist/runtime/services/normalize.cjs +3 -2
  100. package/dist/runtime/services/normalize.cjs.map +1 -1
  101. package/dist/runtime/services/normalize.mjs +2 -2
  102. package/dist/runtime/services/normalize.mjs.map +1 -1
  103. package/dist/runtime/services/plugin-lifecycle.service.cjs +1 -1
  104. package/dist/runtime/services/plugin-lifecycle.service.cjs.map +1 -1
  105. package/dist/runtime/services/plugin-lifecycle.service.d.cts.map +1 -1
  106. package/dist/runtime/services/plugin-lifecycle.service.d.mts.map +1 -1
  107. package/dist/runtime/services/plugin-lifecycle.service.mjs.map +1 -1
  108. package/dist/runtime/services/plugin-loader.service.cjs +3 -3
  109. package/dist/runtime/services/plugin-loader.service.cjs.map +1 -1
  110. package/dist/runtime/services/plugin-loader.service.d.cts +1 -1
  111. package/dist/runtime/services/plugin-loader.service.d.cts.map +1 -1
  112. package/dist/runtime/services/plugin-loader.service.d.mts +1 -1
  113. package/dist/runtime/services/plugin-loader.service.d.mts.map +1 -1
  114. package/dist/runtime/services/plugin-loader.service.mjs +2 -2
  115. package/dist/runtime/services/plugin-loader.service.mjs.map +1 -1
  116. package/dist/runtime/services/plugin.service.cjs +1 -1
  117. package/dist/runtime/services/plugin.service.cjs.map +1 -1
  118. package/dist/runtime/services/plugin.service.d.cts +6 -7
  119. package/dist/runtime/services/plugin.service.d.cts.map +1 -1
  120. package/dist/runtime/services/plugin.service.d.mts +6 -7
  121. package/dist/runtime/services/plugin.service.d.mts.map +1 -1
  122. package/dist/runtime/services/plugin.service.mjs.map +1 -1
  123. package/dist/runtime/services/secrets.service.cjs +1 -1
  124. package/dist/runtime/services/secrets.service.cjs.map +1 -1
  125. package/dist/runtime/services/secrets.service.d.cts.map +1 -1
  126. package/dist/runtime/services/secrets.service.d.mts.map +1 -1
  127. package/dist/runtime/services/secrets.service.mjs.map +1 -1
  128. package/dist/runtime/validation.cjs +1 -1
  129. package/dist/runtime/validation.cjs.map +1 -1
  130. package/dist/runtime/validation.mjs.map +1 -1
  131. package/dist/testing/index.cjs +2 -1
  132. package/dist/testing/index.cjs.map +1 -1
  133. package/dist/testing/index.d.cts +0 -2
  134. package/dist/testing/index.d.cts.map +1 -1
  135. package/dist/testing/index.d.mts +0 -2
  136. package/dist/testing/index.d.mts.map +1 -1
  137. package/dist/testing/index.mjs +1 -1
  138. package/dist/testing/index.mjs.map +1 -1
  139. package/dist/types.d.cts +6 -6
  140. package/dist/types.d.cts.map +1 -1
  141. package/dist/types.d.mts +6 -6
  142. package/dist/types.d.mts.map +1 -1
  143. package/dist/zod.cjs +4 -3
  144. package/dist/zod.mjs +2 -2
  145. package/package.json +204 -182
  146. package/src/build/rspack/dev-server-middleware.ts +233 -0
  147. package/src/build/rspack/fix-mf-data-uri-plugin.ts +49 -0
  148. package/src/build/rspack/index.ts +14 -0
  149. package/src/build/rspack/module-federation.ts +6 -0
  150. package/src/build/rspack/plugin.ts +252 -0
  151. package/src/build/rspack/utils.ts +60 -0
  152. package/src/build/shared-deps.ts +79 -0
  153. package/src/effect.ts +1 -0
  154. package/src/errors.ts +140 -0
  155. package/src/index.ts +26 -0
  156. package/src/orpc-client.ts +2 -0
  157. package/src/orpc-openapi.ts +2 -0
  158. package/src/orpc.ts +9 -0
  159. package/src/plugin.ts +220 -0
  160. package/src/runtime/errors.ts +332 -0
  161. package/src/runtime/index.ts +258 -0
  162. package/src/runtime/mf-config.ts +29 -0
  163. package/src/runtime/services/module-federation.service.ts +181 -0
  164. package/src/runtime/services/normalize.ts +18 -0
  165. package/src/runtime/services/plugin-lifecycle.service.ts +86 -0
  166. package/src/runtime/services/plugin-loader.service.ts +254 -0
  167. package/src/runtime/services/plugin.service.ts +66 -0
  168. package/src/runtime/services/secrets.service.ts +74 -0
  169. package/src/runtime/services.ts +5 -0
  170. package/src/runtime/validation.ts +23 -0
  171. package/src/testing/index.ts +87 -0
  172. package/src/testing/mocks/module-federation.service.ts +41 -0
  173. package/src/types.ts +309 -0
  174. package/src/zod-core.ts +4 -0
  175. package/src/zod.ts +1 -0
  176. package/dist/package.cjs +0 -45
  177. package/dist/package.cjs.map +0 -1
  178. package/dist/package.mjs +0 -27
  179. package/dist/package.mjs.map +0 -1
package/package.json CHANGED
@@ -1,184 +1,206 @@
1
1
  {
2
- "name": "every-plugin",
3
- "version": "0.9.0",
4
- "type": "module",
5
- "main": "./dist/index.cjs",
6
- "module": "./dist/index.mjs",
7
- "types": "./dist/index.d.mts",
8
- "exports": {
9
- ".": {
10
- "types": {
11
- "import": "./dist/index.d.mts",
12
- "require": "./dist/index.d.cts"
13
- },
14
- "import": "./dist/index.mjs",
15
- "require": "./dist/index.cjs"
16
- },
17
- "./runtime": {
18
- "types": {
19
- "import": "./dist/runtime/index.d.mts",
20
- "require": "./dist/runtime/index.d.cts"
21
- },
22
- "import": "./dist/runtime/index.mjs",
23
- "require": "./dist/runtime/index.cjs"
24
- },
25
- "./testing": {
26
- "types": {
27
- "import": "./dist/testing/index.d.mts",
28
- "require": "./dist/testing/index.d.cts"
29
- },
30
- "import": "./dist/testing/index.mjs",
31
- "require": "./dist/testing/index.cjs"
32
- },
33
- "./normalize": {
34
- "types": {
35
- "import": "./dist/runtime/services/normalize.d.mts",
36
- "require": "./dist/runtime/services/normalize.d.cts"
37
- },
38
- "import": "./dist/runtime/services/normalize.mjs",
39
- "require": "./dist/runtime/services/normalize.cjs"
40
- },
41
- "./effect": {
42
- "types": {
43
- "import": "./dist/effect.d.mts",
44
- "require": "./dist/effect.d.cts"
45
- },
46
- "import": "./dist/effect.mjs",
47
- "require": "./dist/effect.cjs"
48
- },
49
- "./zod": {
50
- "types": {
51
- "import": "./dist/zod.d.mts",
52
- "require": "./dist/zod.d.cts"
53
- },
54
- "import": "./dist/zod.mjs",
55
- "require": "./dist/zod.cjs"
56
- },
57
- "./zod/v4/core": {
58
- "types": {
59
- "import": "./dist/zod-core.d.mts",
60
- "require": "./dist/zod-core.d.cts"
61
- },
62
- "import": "./dist/zod-core.mjs",
63
- "require": "./dist/zod-core.cjs"
64
- },
65
- "./orpc": {
66
- "types": {
67
- "import": "./dist/orpc.d.mts",
68
- "require": "./dist/orpc.d.cts"
69
- },
70
- "import": "./dist/orpc.mjs",
71
- "require": "./dist/orpc.cjs"
72
- },
73
- "./orpc/client": {
74
- "types": {
75
- "import": "./dist/orpc-client.d.mts",
76
- "require": "./dist/orpc-client.d.cts"
77
- },
78
- "import": "./dist/orpc-client.mjs",
79
- "require": "./dist/orpc-client.cjs"
80
- },
81
- "./orpc/openapi": {
82
- "types": {
83
- "import": "./dist/orpc-openapi.d.mts",
84
- "require": "./dist/orpc-openapi.d.cts"
85
- },
86
- "import": "./dist/orpc-openapi.mjs",
87
- "require": "./dist/orpc-openapi.cjs"
88
- },
89
- "./errors": {
90
- "types": {
91
- "import": "./dist/errors.d.mts",
92
- "require": "./dist/errors.d.cts"
93
- },
94
- "import": "./dist/errors.mjs",
95
- "require": "./dist/errors.cjs"
96
- },
97
- "./types": {
98
- "types": {
99
- "import": "./dist/types.d.mts",
100
- "require": "./dist/types.d.cts"
101
- },
102
- "import": "./dist/types.mjs",
103
- "require": "./dist/types.cjs"
104
- },
105
- "./build/rspack": {
106
- "types": {
107
- "import": "./dist/build/rspack/index.d.mts",
108
- "require": "./dist/build/rspack/index.d.cts"
109
- },
110
- "import": "./dist/build/rspack/index.mjs",
111
- "require": "./dist/build/rspack/index.cjs"
112
- },
113
- "./package.json": "./package.json"
114
- },
115
- "files": [
116
- "dist"
117
- ],
118
- "scripts": {
119
- "build": "tsdown",
120
- "build:test": "cd tests/fixtures/test-plugin && bun run build",
121
- "test": "vitest run --config vitest.config.ts",
122
- "test:unit": "vitest run --config vitest.config.ts",
123
- "test:integration": "bun run build:test && vitest run --config vitest.integration.config.ts",
124
- "test:all": "bun run test:unit && bun run test:integration",
125
- "test:watch": "vitest --config vitest.config.ts --watch",
126
- "typecheck": "tsc --noEmit"
127
- },
128
- "peerDependencies": {
129
- "@rspack/core": "1.7.4",
130
- "typescript": "^5.9.3",
131
- "effect": "^3.19.15",
132
- "zod": "^4.3.6",
133
- "@orpc/contract": "^1.13.4",
134
- "@orpc/server": "^1.13.4"
135
- },
136
- "devDependencies": {
137
- "@effect/language-service": "^0.72.0",
138
- "@effect/vitest": "^0.27.0",
139
- "@orpc/client": "^1.13.4",
140
- "@orpc/openapi": "^1.13.4",
141
- "@rspack/cli": "^1.7.4",
142
- "@types/bun": "^1.3.7",
143
- "@types/node": "^25.1.0",
144
- "@vitest/ui": "4.0.18",
145
- "bun-types": "^1.3.7",
146
- "sirv": "^3.0.2",
147
- "tsdown": "^0.20.1",
148
- "vite-tsconfig-paths": "^6.0.5",
149
- "vitest": "^4.0.18"
150
- },
151
- "dependencies": {
152
- "@module-federation/enhanced": "^0.23.0",
153
- "@module-federation/node": "^2.7.28",
154
- "@module-federation/runtime-core": "^0.23.0",
155
- "@orpc/client": "^1.13.4",
156
- "@orpc/contract": "^1.13.4",
157
- "@orpc/experimental-publisher": "^1.13.4",
158
- "@orpc/openapi": "^1.13.4",
159
- "@orpc/react-query": "^1.13.4",
160
- "@orpc/server": "^1.13.4",
161
- "@orpc/tanstack-query": "^1.13.4",
162
- "@orpc/zod": "^1.13.4"
163
- },
164
- "keywords": [
165
- "plugin",
166
- "module-federation",
167
- "orpc",
168
- "zod",
169
- "typescript"
170
- ],
171
- "author": "plugin.every.near",
172
- "license": "MIT",
173
- "repository": {
174
- "type": "git",
175
- "url": "https://github.com/near-everything/every-plugin.git"
176
- },
177
- "bugs": {
178
- "url": "https://github.com/near-everything/every-plugin/issues"
179
- },
180
- "homepage": "https://plugin.everything.dev",
181
- "workspaces": [
182
- "tests/fixtures/*"
183
- ]
2
+ "name": "every-plugin",
3
+ "version": "2.2.2",
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
+ "prepublishOnly": "tsdown",
142
+ "test": "vitest run --config vitest.config.ts",
143
+ "test:unit": "vitest run --config vitest.config.ts",
144
+ "test:integration": "bun run build:test && vitest run --config vitest.integration.config.ts",
145
+ "test:all": "bun run test:unit && bun run test:integration",
146
+ "test:watch": "vitest --config vitest.config.ts --watch",
147
+ "typecheck": "tsc --noEmit"
148
+ },
149
+ "peerDependencies": {
150
+ "@rspack/core": "1.7.4",
151
+ "typescript": "^5.9.3",
152
+ "effect": "^3.21.0",
153
+ "zod": "^4.3.6",
154
+ "@orpc/contract": "^1.13.4",
155
+ "@orpc/server": "^1.13.4",
156
+ "@orpc/client": "^1.13.4",
157
+ "@orpc/openapi": "^1.13.4",
158
+ "@orpc/zod": "^1.13.4",
159
+ "@orpc/react-query": "^1.13.4"
160
+ },
161
+ "devDependencies": {
162
+ "@effect/language-service": "^0.84.3",
163
+ "@effect/vitest": "^0.29.0",
164
+ "@orpc/client": "^1.13.4",
165
+ "@orpc/openapi": "^1.13.4",
166
+ "@rspack/cli": "^1.7.4",
167
+ "@types/bun": "^1.3.7",
168
+ "@types/node": "^25.1.0",
169
+ "@vitest/ui": "4.1.2",
170
+ "bun-types": "^1.3.7",
171
+ "sirv": "^3.0.2",
172
+ "tsdown": "^0.21.7",
173
+ "vite-tsconfig-paths": "^6.0.5",
174
+ "vitest": "^4.0.18"
175
+ },
176
+ "dependencies": {
177
+ "@module-federation/enhanced": "catalog:",
178
+ "@module-federation/node": "catalog:",
179
+ "@module-federation/runtime-core": "catalog:",
180
+ "@orpc/contract": "^1.13.4",
181
+ "@orpc/experimental-publisher": "^1.13.4",
182
+ "@orpc/server": "^1.13.4",
183
+ "@orpc/tanstack-query": "^1.13.4"
184
+ },
185
+ "keywords": [
186
+ "plugin",
187
+ "module-federation",
188
+ "orpc",
189
+ "zod",
190
+ "typescript"
191
+ ],
192
+ "author": "plugin.every.near",
193
+ "license": "MIT",
194
+ "repository": {
195
+ "type": "git",
196
+ "url": "https://github.com/NEARBuilders/everything-dev",
197
+ "directory": "packages/every-plugin"
198
+ },
199
+ "bugs": {
200
+ "url": "https://github.com/nearbuilders/everything-dev/issues"
201
+ },
202
+ "homepage": "https://everything.dev",
203
+ "workspaces": [
204
+ "tests/fixtures/*"
205
+ ]
184
206
  }
@@ -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
+ }