every-plugin 0.5.0 → 0.5.1
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/{chunk-zltIcp7o.cjs → _virtual/rolldown_runtime.cjs} +3 -18
- package/dist/{chunk-QQAxy9l9.mjs → _virtual/rolldown_runtime.mjs} +1 -1
- package/dist/build/rspack/dev-server-middleware.cjs +201 -0
- package/dist/build/rspack/dev-server-middleware.cjs.map +1 -0
- package/dist/build/rspack/dev-server-middleware.mjs +200 -0
- package/dist/build/rspack/dev-server-middleware.mjs.map +1 -0
- package/dist/build/rspack/index.cjs +2 -362
- package/dist/build/rspack/index.d.cts +2 -20
- package/dist/build/rspack/index.d.mts +2 -20
- package/dist/build/rspack/index.mjs +2 -360
- package/dist/build/rspack/module-federation.cjs +47 -0
- package/dist/build/rspack/module-federation.cjs.map +1 -0
- package/dist/build/rspack/module-federation.mjs +47 -0
- package/dist/build/rspack/module-federation.mjs.map +1 -0
- package/dist/build/rspack/plugin.cjs +90 -0
- package/dist/build/rspack/plugin.cjs.map +1 -0
- package/dist/build/rspack/plugin.d.cts +20 -0
- package/dist/build/rspack/plugin.d.cts.map +1 -0
- package/dist/build/rspack/plugin.d.mts +20 -0
- package/dist/build/rspack/plugin.d.mts.map +1 -0
- package/dist/build/rspack/plugin.mjs +89 -0
- package/dist/build/rspack/plugin.mjs.map +1 -0
- package/dist/build/rspack/utils.cjs +41 -0
- package/dist/build/rspack/utils.cjs.map +1 -0
- package/dist/build/rspack/utils.mjs +38 -0
- package/dist/build/rspack/utils.mjs.map +1 -0
- package/dist/errors.cjs +62 -3
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +75 -3
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.mts +75 -3
- package/dist/errors.d.mts.map +1 -0
- package/dist/errors.mjs +62 -3
- package/dist/errors.mjs.map +1 -0
- package/dist/index.cjs +8 -55
- package/dist/index.d.cts +6 -5
- package/dist/index.d.mts +6 -5
- package/dist/index.mjs +5 -51
- package/dist/orpc.cjs +1 -1
- package/dist/{package-DyTuSutr.cjs → package.cjs} +22 -7
- package/dist/package.cjs.map +1 -0
- package/dist/{package-CaRYwbRi.mjs → package.mjs} +22 -5
- package/dist/package.mjs.map +1 -0
- package/dist/plugin.cjs +48 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.cts +62 -0
- package/dist/plugin.d.cts.map +1 -0
- package/dist/plugin.d.mts +62 -0
- package/dist/plugin.d.mts.map +1 -0
- package/dist/plugin.mjs +47 -0
- package/dist/plugin.mjs.map +1 -0
- package/dist/runtime/errors.cjs +45 -0
- package/dist/runtime/errors.cjs.map +1 -0
- package/dist/runtime/errors.d.cts +27 -0
- package/dist/runtime/errors.d.cts.map +1 -0
- package/dist/runtime/errors.d.mts +27 -0
- package/dist/runtime/errors.d.mts.map +1 -0
- package/dist/runtime/errors.mjs +41 -0
- package/dist/runtime/errors.mjs.map +1 -0
- package/dist/runtime/index.cjs +157 -5
- package/dist/runtime/index.cjs.map +1 -0
- package/dist/runtime/index.d.cts +43 -5
- package/dist/runtime/index.d.cts.map +1 -0
- package/dist/runtime/index.d.mts +43 -5
- package/dist/runtime/index.d.mts.map +1 -0
- package/dist/runtime/index.mjs +155 -4
- package/dist/runtime/index.mjs.map +1 -0
- package/dist/runtime/services/module-federation.service.cjs +143 -0
- package/dist/runtime/services/module-federation.service.cjs.map +1 -0
- package/dist/runtime/services/module-federation.service.d.cts +15 -0
- package/dist/runtime/services/module-federation.service.d.cts.map +1 -0
- package/dist/runtime/services/module-federation.service.d.mts +15 -0
- package/dist/runtime/services/module-federation.service.d.mts.map +1 -0
- package/dist/runtime/services/module-federation.service.mjs +143 -0
- package/dist/runtime/services/module-federation.service.mjs.map +1 -0
- package/dist/runtime/services/normalize.cjs +22 -2
- package/dist/runtime/services/normalize.cjs.map +1 -0
- package/dist/runtime/services/normalize.d.cts +21 -2
- package/dist/runtime/services/normalize.d.cts.map +1 -0
- package/dist/runtime/services/normalize.d.mts +21 -2
- package/dist/runtime/services/normalize.d.mts.map +1 -0
- package/dist/runtime/services/normalize.mjs +21 -2
- package/dist/runtime/services/normalize.mjs.map +1 -0
- package/dist/runtime/services/plugin-lifecycle.service.cjs +33 -0
- package/dist/runtime/services/plugin-lifecycle.service.cjs.map +1 -0
- package/dist/runtime/services/plugin-lifecycle.service.d.cts +17 -0
- package/dist/runtime/services/plugin-lifecycle.service.d.cts.map +1 -0
- package/dist/runtime/services/plugin-lifecycle.service.d.mts +17 -0
- package/dist/runtime/services/plugin-lifecycle.service.d.mts.map +1 -0
- package/dist/runtime/services/plugin-lifecycle.service.mjs +32 -0
- package/dist/runtime/services/plugin-lifecycle.service.mjs.map +1 -0
- package/dist/runtime/services/plugin-loader.service.cjs +125 -0
- package/dist/runtime/services/plugin-loader.service.cjs.map +1 -0
- package/dist/runtime/services/plugin-loader.service.d.cts +54 -0
- package/dist/runtime/services/plugin-loader.service.d.cts.map +1 -0
- package/dist/runtime/services/plugin-loader.service.d.mts +54 -0
- package/dist/runtime/services/plugin-loader.service.d.mts.map +1 -0
- package/dist/runtime/services/plugin-loader.service.mjs +121 -0
- package/dist/runtime/services/plugin-loader.service.mjs.map +1 -0
- package/dist/runtime/services/plugin.service.cjs +33 -0
- package/dist/runtime/services/plugin.service.cjs.map +1 -0
- package/dist/runtime/services/plugin.service.d.cts +42 -0
- package/dist/runtime/services/plugin.service.d.cts.map +1 -0
- package/dist/runtime/services/plugin.service.d.mts +42 -0
- package/dist/runtime/services/plugin.service.d.mts.map +1 -0
- package/dist/runtime/services/plugin.service.mjs +32 -0
- package/dist/runtime/services/plugin.service.mjs.map +1 -0
- package/dist/runtime/services/secrets.service.cjs +50 -0
- package/dist/runtime/services/secrets.service.cjs.map +1 -0
- package/dist/runtime/services/secrets.service.d.cts +16 -0
- package/dist/runtime/services/secrets.service.d.cts.map +1 -0
- package/dist/runtime/services/secrets.service.d.mts +16 -0
- package/dist/runtime/services/secrets.service.d.mts.map +1 -0
- package/dist/runtime/services/secrets.service.mjs +48 -0
- package/dist/runtime/services/secrets.service.mjs.map +1 -0
- package/dist/runtime/validation.cjs +18 -0
- package/dist/runtime/validation.cjs.map +1 -0
- package/dist/runtime/validation.mjs +17 -0
- package/dist/runtime/validation.mjs.map +1 -0
- package/dist/testing/index.cjs +2 -4
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +4 -4
- package/dist/testing/index.d.mts +4 -4
- package/dist/testing/index.mjs +1 -3
- package/dist/testing/index.mjs.map +1 -1
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +261 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +261 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +1 -0
- package/dist/zod-core.cjs +9 -0
- package/dist/zod-core.d.cts +1 -0
- package/dist/zod-core.d.mts +1 -0
- package/dist/zod-core.mjs +3 -0
- package/dist/zod.cjs +13 -1
- package/dist/zod.cjs.map +1 -0
- package/dist/zod.d.cts +8 -2
- package/dist/zod.d.cts.map +1 -0
- package/dist/zod.d.mts +8 -2
- package/dist/zod.d.mts.map +1 -0
- package/dist/zod.mjs +9 -2
- package/dist/zod.mjs.map +1 -0
- package/package.json +17 -2
- package/dist/build/rspack/index.cjs.map +0 -1
- package/dist/build/rspack/index.d.cts.map +0 -1
- package/dist/build/rspack/index.d.mts.map +0 -1
- package/dist/build/rspack/index.mjs.map +0 -1
- package/dist/errors-9sNpYLv5.d.mts +0 -75
- package/dist/errors-9sNpYLv5.d.mts.map +0 -1
- package/dist/errors-CVnoPl9v.cjs +0 -68
- package/dist/errors-CVnoPl9v.cjs.map +0 -1
- package/dist/errors-D7keKf7a.mjs +0 -63
- package/dist/errors-D7keKf7a.mjs.map +0 -1
- package/dist/errors-DKPPPYYT.d.cts +0 -75
- package/dist/errors-DKPPPYYT.d.cts.map +0 -1
- package/dist/fetch-8DauUFDh.mjs +0 -335
- package/dist/fetch-8DauUFDh.mjs.map +0 -1
- package/dist/fetch-CrBvwsZ4.cjs +0 -336
- package/dist/fetch-CrBvwsZ4.cjs.map +0 -1
- package/dist/index-Bu2wtZrA.d.mts +0 -463
- package/dist/index-Bu2wtZrA.d.mts.map +0 -1
- package/dist/index-DtTqwV4f.d.cts +0 -462
- package/dist/index-DtTqwV4f.d.cts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/normalize-BW7kk8Lk.d.cts +0 -21
- package/dist/normalize-BW7kk8Lk.d.cts.map +0 -1
- package/dist/normalize-D4Qh0wVk.cjs +0 -28
- package/dist/normalize-D4Qh0wVk.cjs.map +0 -1
- package/dist/normalize-D7nae0Hn.mjs +0 -22
- package/dist/normalize-D7nae0Hn.mjs.map +0 -1
- package/dist/normalize-eB_j86fm.d.mts +0 -21
- package/dist/normalize-eB_j86fm.d.mts.map +0 -1
- package/dist/package-CaRYwbRi.mjs.map +0 -1
- package/dist/package-DyTuSutr.cjs.map +0 -1
- package/dist/plugins-C6MGKdD-.mjs +0 -790
- package/dist/plugins-C6MGKdD-.mjs.map +0 -1
- package/dist/plugins-DNaNtkG7.cjs +0 -791
- package/dist/plugins-DNaNtkG7.cjs.map +0 -1
- package/dist/runtime-BNcFgWDG.cjs +0 -558
- package/dist/runtime-BNcFgWDG.cjs.map +0 -1
- package/dist/runtime-CAWcnrAk.mjs +0 -547
- package/dist/runtime-CAWcnrAk.mjs.map +0 -1
- package/dist/standard-CkH8zNkx.mjs +0 -584
- package/dist/standard-CkH8zNkx.mjs.map +0 -1
- package/dist/standard-v75BC6Z5.cjs +0 -685
- package/dist/standard-v75BC6Z5.cjs.map +0 -1
- package/dist/zod-A7Pti5IV.d.cts +0 -4
- package/dist/zod-A7Pti5IV.d.cts.map +0 -1
- package/dist/zod-BVo51kgJ.mjs +0 -10
- package/dist/zod-BVo51kgJ.mjs.map +0 -1
- package/dist/zod-DYghWCz1.cjs +0 -14
- package/dist/zod-DYghWCz1.cjs.map +0 -1
- package/dist/zod-Zw8dlP3j.d.mts +0 -4
- package/dist/zod-Zw8dlP3j.d.mts.map +0 -1
|
@@ -1,363 +1,3 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_normalize = require('../../normalize-D4Qh0wVk.cjs');
|
|
3
|
-
const require_package$1 = require('../../package-DyTuSutr.cjs');
|
|
4
|
-
let __module_federation_enhanced_rspack = require("@module-federation/enhanced/rspack");
|
|
5
|
-
let node_path = require("node:path");
|
|
6
|
-
node_path = require_chunk.__toESM(node_path);
|
|
7
|
-
let node_fs = require("node:fs");
|
|
8
|
-
node_fs = require_chunk.__toESM(node_fs);
|
|
1
|
+
const require_plugin = require('./plugin.cjs');
|
|
9
2
|
|
|
10
|
-
|
|
11
|
-
const corsHeaders = {
|
|
12
|
-
"Access-Control-Allow-Origin": "*",
|
|
13
|
-
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
14
|
-
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
|
|
15
|
-
};
|
|
16
|
-
const applyCorsHeaders = (res) => {
|
|
17
|
-
Object.entries(corsHeaders).forEach(([key, value]) => {
|
|
18
|
-
res.setHeader(key, value);
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
const normalizePrefix = (prefix) => {
|
|
22
|
-
if (!prefix) return "";
|
|
23
|
-
const cleaned = prefix.replace(/^\/+|\/+$/g, "");
|
|
24
|
-
return cleaned ? `/${cleaned}` : "";
|
|
25
|
-
};
|
|
26
|
-
function setupPluginMiddleware(devServer, pluginInfo, devConfig, port) {
|
|
27
|
-
const rpcPrefix = normalizePrefix(devConfig?.prefix);
|
|
28
|
-
let handlers = {
|
|
29
|
-
rpc: null,
|
|
30
|
-
api: null
|
|
31
|
-
};
|
|
32
|
-
let cleanup = null;
|
|
33
|
-
const performCleanup = async () => {
|
|
34
|
-
if (cleanup) {
|
|
35
|
-
await cleanup();
|
|
36
|
-
cleanup = null;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
(async () => {
|
|
40
|
-
await performCleanup();
|
|
41
|
-
try {
|
|
42
|
-
const { createPluginRuntime } = await Promise.resolve().then(() => require("../../index.cjs"));
|
|
43
|
-
const { RPCHandler } = await import("@orpc/server/fetch");
|
|
44
|
-
const { onError } = await import("@orpc/server");
|
|
45
|
-
const { OpenAPIHandler } = await Promise.resolve().then(() => require("../../fetch-CrBvwsZ4.cjs"));
|
|
46
|
-
const { OpenAPIReferencePlugin } = await Promise.resolve().then(() => require("../../plugins-DNaNtkG7.cjs"));
|
|
47
|
-
const { ZodToJsonSchemaConverter } = await import("@orpc/zod/zod4");
|
|
48
|
-
const pluginId = devConfig?.pluginId || pluginInfo.normalizedName;
|
|
49
|
-
const runtime = createPluginRuntime({ registry: { [pluginId]: { remoteUrl: `http://localhost:${port}/remoteEntry.js` } } });
|
|
50
|
-
const loaded = await runtime.usePlugin(pluginId, devConfig?.config);
|
|
51
|
-
cleanup = async () => {
|
|
52
|
-
if (loaded && typeof loaded.dispose === "function") await loaded.dispose();
|
|
53
|
-
if (runtime && typeof runtime.cleanup === "function") await runtime.cleanup();
|
|
54
|
-
handlers.rpc = null;
|
|
55
|
-
handlers.api = null;
|
|
56
|
-
if (devServer.app.locals.handlers) devServer.app.locals.handlers = null;
|
|
57
|
-
};
|
|
58
|
-
const formatError = (error, context) => {
|
|
59
|
-
const lines = [`\n🔴 ${context} Error: ${error.message || "Unknown error"}`];
|
|
60
|
-
if (error.cause?.issues && Array.isArray(error.cause.issues)) {
|
|
61
|
-
lines.push("\n📋 Validation Issues:");
|
|
62
|
-
error.cause.issues.forEach((issue, index) => {
|
|
63
|
-
lines.push(` ${index + 1}. ${issue.path?.join(".") || "root"}`);
|
|
64
|
-
lines.push(` ├─ Code: ${issue.code || "unknown"}`);
|
|
65
|
-
lines.push(` ├─ Message: ${issue.message || "No message"}`);
|
|
66
|
-
if (issue.expected !== void 0) lines.push(` ├─ Expected: ${JSON.stringify(issue.expected)}`);
|
|
67
|
-
if (issue.received !== void 0) lines.push(` └─ Received: ${JSON.stringify(issue.received)}`);
|
|
68
|
-
else lines.push(` └─ (end)`);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
if (error.data && typeof error.data === "object" && Object.keys(error.data).length > 0) {
|
|
72
|
-
lines.push("\n📊 Error Data:");
|
|
73
|
-
try {
|
|
74
|
-
JSON.stringify(error.data, null, 2).split("\n").forEach((line) => {
|
|
75
|
-
lines.push(` ${line}`);
|
|
76
|
-
});
|
|
77
|
-
} catch {
|
|
78
|
-
lines.push(` ${String(error.data)}`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (error.cause?.data) {
|
|
82
|
-
lines.push("\n📦 Request Data:");
|
|
83
|
-
try {
|
|
84
|
-
JSON.stringify(error.cause.data, null, 2).split("\n").forEach((line) => {
|
|
85
|
-
lines.push(` ${line}`);
|
|
86
|
-
});
|
|
87
|
-
} catch {
|
|
88
|
-
lines.push(` ${String(error.cause.data)}`);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
if (error.code) lines.push(`\n⚠️ Error Code: ${error.code}`);
|
|
92
|
-
if (error.status) lines.push(`📍 Status: ${error.status}`);
|
|
93
|
-
lines.push("");
|
|
94
|
-
console.error(lines.join("\n"));
|
|
95
|
-
};
|
|
96
|
-
handlers.rpc = new RPCHandler(loaded.router, { interceptors: [onError((error) => {
|
|
97
|
-
formatError(error, "RPC");
|
|
98
|
-
})] });
|
|
99
|
-
handlers.api = new OpenAPIHandler(loaded.router, {
|
|
100
|
-
plugins: [new OpenAPIReferencePlugin({ schemaConverters: [new ZodToJsonSchemaConverter()] })],
|
|
101
|
-
interceptors: [onError((error) => {
|
|
102
|
-
formatError(error, "OpenAPI");
|
|
103
|
-
})]
|
|
104
|
-
});
|
|
105
|
-
console.log(`╭─────────────────────────────────────────────`);
|
|
106
|
-
console.log(`│ ✅ Plugin dev server ready: `);
|
|
107
|
-
console.log(`├─────────────────────────────────────────────`);
|
|
108
|
-
console.log(`│ 📡 RPC: http://localhost:${port}/api/rpc${rpcPrefix}`);
|
|
109
|
-
console.log(`│ 📖 Docs: http://localhost:${port}/api`);
|
|
110
|
-
console.log(`│ 💚 Health: http://localhost:${port}/`);
|
|
111
|
-
console.log(`╰─────────────────────────────────────────────`);
|
|
112
|
-
devServer.app.locals.handlers = handlers;
|
|
113
|
-
if (devServer.server) devServer.server.once("close", async () => {
|
|
114
|
-
await performCleanup();
|
|
115
|
-
});
|
|
116
|
-
} catch (error) {
|
|
117
|
-
console.error("❌ Failed to load plugin:", error);
|
|
118
|
-
await performCleanup();
|
|
119
|
-
}
|
|
120
|
-
})();
|
|
121
|
-
process.once("SIGINT", async () => {
|
|
122
|
-
await performCleanup();
|
|
123
|
-
});
|
|
124
|
-
process.once("SIGTERM", async () => {
|
|
125
|
-
await performCleanup();
|
|
126
|
-
});
|
|
127
|
-
devServer.app.options("*", (req, res) => {
|
|
128
|
-
applyCorsHeaders(res);
|
|
129
|
-
res.status(200).end();
|
|
130
|
-
});
|
|
131
|
-
devServer.app.get("/", (req, res) => {
|
|
132
|
-
applyCorsHeaders(res);
|
|
133
|
-
res.json({
|
|
134
|
-
ok: true,
|
|
135
|
-
plugin: pluginInfo.normalizedName,
|
|
136
|
-
version: pluginInfo.version,
|
|
137
|
-
status: devServer.app.locals.handlers?.rpc ? "ready" : "loading",
|
|
138
|
-
endpoints: {
|
|
139
|
-
health: "/",
|
|
140
|
-
docs: "/api",
|
|
141
|
-
rpc: `/api/rpc${rpcPrefix}`
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
const handleApiRequest = async (req, res) => {
|
|
146
|
-
applyCorsHeaders(res);
|
|
147
|
-
const apiHandler = devServer.app.locals.handlers?.api;
|
|
148
|
-
if (!apiHandler) return res.status(503).json({ error: "Plugin still loading..." });
|
|
149
|
-
try {
|
|
150
|
-
const url = `http://${req.headers.host}${req.url}`;
|
|
151
|
-
const webRequest = new Request(url, {
|
|
152
|
-
method: req.method,
|
|
153
|
-
headers: req.headers,
|
|
154
|
-
body: req.method !== "GET" && req.method !== "HEAD" ? req : void 0,
|
|
155
|
-
duplex: req.method !== "GET" && req.method !== "HEAD" ? "half" : void 0
|
|
156
|
-
});
|
|
157
|
-
const result = await apiHandler.handle(webRequest, {
|
|
158
|
-
prefix: "/api",
|
|
159
|
-
context: {}
|
|
160
|
-
});
|
|
161
|
-
if (result.response) {
|
|
162
|
-
res.status(result.response.status);
|
|
163
|
-
result.response.headers.forEach((value, key) => {
|
|
164
|
-
res.setHeader(key, value);
|
|
165
|
-
});
|
|
166
|
-
const text = await result.response.text();
|
|
167
|
-
res.send(text);
|
|
168
|
-
} else res.status(404).send("Not Found");
|
|
169
|
-
} catch (error) {
|
|
170
|
-
console.error("OpenAPI error:", error);
|
|
171
|
-
res.status(500).json({ error: error.message });
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
devServer.app.all("/api", handleApiRequest);
|
|
175
|
-
devServer.app.all("/api/*", handleApiRequest);
|
|
176
|
-
devServer.app.all(`/api/rpc${rpcPrefix}/*`, async (req, res) => {
|
|
177
|
-
applyCorsHeaders(res);
|
|
178
|
-
const rpcHandler = devServer.app.locals.handlers?.rpc;
|
|
179
|
-
if (!rpcHandler) return res.status(503).json({ error: "Plugin still loading..." });
|
|
180
|
-
try {
|
|
181
|
-
const url = `http://${req.headers.host}${req.url}`;
|
|
182
|
-
const webRequest = new Request(url, {
|
|
183
|
-
method: req.method,
|
|
184
|
-
headers: req.headers,
|
|
185
|
-
body: req.method !== "GET" && req.method !== "HEAD" ? req : void 0,
|
|
186
|
-
duplex: req.method !== "GET" && req.method !== "HEAD" ? "half" : void 0
|
|
187
|
-
});
|
|
188
|
-
const result = await rpcHandler.handle(webRequest, {
|
|
189
|
-
prefix: `/api/rpc${rpcPrefix}`,
|
|
190
|
-
context: {}
|
|
191
|
-
});
|
|
192
|
-
if (result.response) {
|
|
193
|
-
res.status(result.response.status);
|
|
194
|
-
result.response.headers.forEach((value, key) => {
|
|
195
|
-
res.setHeader(key, value);
|
|
196
|
-
});
|
|
197
|
-
const text = await result.response.text();
|
|
198
|
-
res.send(text);
|
|
199
|
-
} else res.status(404).send("Not Found");
|
|
200
|
-
} catch (error) {
|
|
201
|
-
console.error("RPC error:", error);
|
|
202
|
-
res.status(500).json({ error: error.message });
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
//#endregion
|
|
208
|
-
//#region src/build/rspack/module-federation.ts
|
|
209
|
-
function buildSharedDependencies(pluginInfo) {
|
|
210
|
-
const everyPluginPkg = require_package$1.require_package();
|
|
211
|
-
return {
|
|
212
|
-
"every-plugin": {
|
|
213
|
-
version: everyPluginPkg.version,
|
|
214
|
-
singleton: true,
|
|
215
|
-
requiredVersion: `${everyPluginPkg.version}`,
|
|
216
|
-
strictVersion: false,
|
|
217
|
-
eager: false
|
|
218
|
-
},
|
|
219
|
-
effect: {
|
|
220
|
-
version: everyPluginPkg.dependencies.effect,
|
|
221
|
-
singleton: true,
|
|
222
|
-
requiredVersion: `${everyPluginPkg.dependencies.effect}`,
|
|
223
|
-
strictVersion: false,
|
|
224
|
-
eager: false
|
|
225
|
-
},
|
|
226
|
-
zod: {
|
|
227
|
-
version: everyPluginPkg.dependencies.zod,
|
|
228
|
-
singleton: true,
|
|
229
|
-
requiredVersion: `${everyPluginPkg.dependencies.zod}`,
|
|
230
|
-
strictVersion: false,
|
|
231
|
-
eager: false
|
|
232
|
-
},
|
|
233
|
-
"@orpc/contract": {
|
|
234
|
-
version: everyPluginPkg.dependencies["@orpc/contract"],
|
|
235
|
-
singleton: true,
|
|
236
|
-
requiredVersion: `${everyPluginPkg.dependencies["@orpc/contract"]}`,
|
|
237
|
-
strictVersion: false,
|
|
238
|
-
eager: false
|
|
239
|
-
},
|
|
240
|
-
"@orpc/server": {
|
|
241
|
-
version: everyPluginPkg.dependencies["@orpc/server"],
|
|
242
|
-
singleton: true,
|
|
243
|
-
requiredVersion: `${everyPluginPkg.dependencies["@orpc/server"]}`,
|
|
244
|
-
strictVersion: false,
|
|
245
|
-
eager: false
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
//#endregion
|
|
251
|
-
//#region src/build/rspack/utils.ts
|
|
252
|
-
function getPluginInfo(context) {
|
|
253
|
-
const pkgPath = node_path.default.join(context, "package.json");
|
|
254
|
-
const pkg = JSON.parse(node_fs.default.readFileSync(pkgPath, "utf-8"));
|
|
255
|
-
return {
|
|
256
|
-
name: pkg.name,
|
|
257
|
-
version: pkg.version,
|
|
258
|
-
normalizedName: require_normalize.getNormalizedRemoteName(pkg.name),
|
|
259
|
-
dependencies: pkg.dependencies || {},
|
|
260
|
-
peerDependencies: pkg.peerDependencies || {}
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
const loadedModules = /* @__PURE__ */ new Set();
|
|
264
|
-
function loadDevConfig(devConfigPath) {
|
|
265
|
-
try {
|
|
266
|
-
const fullPath = node_path.default.resolve(devConfigPath);
|
|
267
|
-
if (loadedModules.has(fullPath)) {
|
|
268
|
-
delete require.cache[fullPath];
|
|
269
|
-
const dirPath = node_path.default.dirname(fullPath);
|
|
270
|
-
for (const key of Object.keys(require.cache)) if (key.startsWith(dirPath) && key !== fullPath) delete require.cache[key];
|
|
271
|
-
}
|
|
272
|
-
const module$1 = require(fullPath).default;
|
|
273
|
-
loadedModules.add(fullPath);
|
|
274
|
-
return module$1;
|
|
275
|
-
} catch (error) {
|
|
276
|
-
console.warn(`Could not load dev config from ${devConfigPath}:`, error.message);
|
|
277
|
-
return null;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
//#endregion
|
|
282
|
-
//#region src/build/rspack/plugin.ts
|
|
283
|
-
var EveryPluginDevServer = class {
|
|
284
|
-
name = "EveryPluginDevServer";
|
|
285
|
-
constructor(options = {}) {
|
|
286
|
-
this.options = options;
|
|
287
|
-
}
|
|
288
|
-
apply(compiler) {
|
|
289
|
-
const pluginInfo = getPluginInfo(compiler.options.context || process.cwd());
|
|
290
|
-
const devConfig = loadDevConfig(this.options.devConfigPath || "./plugin.dev.ts");
|
|
291
|
-
const port = this.options.port || devConfig?.port || 3999;
|
|
292
|
-
this.configureDefaults(compiler, pluginInfo);
|
|
293
|
-
if (!compiler.options.devServer) compiler.options.devServer = {};
|
|
294
|
-
this.configureDevServer(compiler, pluginInfo, devConfig, port);
|
|
295
|
-
new __module_federation_enhanced_rspack.ModuleFederationPlugin({
|
|
296
|
-
name: pluginInfo.normalizedName,
|
|
297
|
-
filename: "remoteEntry.js",
|
|
298
|
-
dts: false,
|
|
299
|
-
runtimePlugins: [require.resolve("@module-federation/node/runtimePlugin")],
|
|
300
|
-
library: { type: "commonjs-module" },
|
|
301
|
-
exposes: { "./plugin": "./src/index.ts" },
|
|
302
|
-
shared: buildSharedDependencies(pluginInfo)
|
|
303
|
-
}).apply(compiler);
|
|
304
|
-
}
|
|
305
|
-
configureDefaults(compiler, pluginInfo) {
|
|
306
|
-
const context = compiler.options.context || process.cwd();
|
|
307
|
-
if (!compiler.options.output) compiler.options.output = {};
|
|
308
|
-
compiler.options.output.uniqueName = pluginInfo.normalizedName;
|
|
309
|
-
compiler.options.output.publicPath = "auto";
|
|
310
|
-
compiler.options.output.path = node_path.default.resolve(context, "dist");
|
|
311
|
-
compiler.options.output.clean = true;
|
|
312
|
-
compiler.options.output.library = { type: "commonjs-module" };
|
|
313
|
-
if (!compiler.options.target) compiler.options.target = "async-node";
|
|
314
|
-
if (!compiler.options.mode) compiler.options.mode = process.env.NODE_ENV === "development" ? "development" : "production";
|
|
315
|
-
if (!compiler.options.devtool) compiler.options.devtool = "source-map";
|
|
316
|
-
if (!compiler.options.infrastructureLogging) compiler.options.infrastructureLogging = { level: "warn" };
|
|
317
|
-
this.ensureTypeScriptLoader(compiler);
|
|
318
|
-
if (!compiler.options.resolve) compiler.options.resolve = {};
|
|
319
|
-
compiler.options.resolve.extensions = [
|
|
320
|
-
"...",
|
|
321
|
-
".tsx",
|
|
322
|
-
".ts"
|
|
323
|
-
];
|
|
324
|
-
}
|
|
325
|
-
ensureTypeScriptLoader(compiler) {
|
|
326
|
-
if (!compiler.options.module) compiler.options.module = { rules: [] };
|
|
327
|
-
if (!compiler.options.module.rules) compiler.options.module.rules = [];
|
|
328
|
-
if (!compiler.options.module.rules.some((rule) => typeof rule === "object" && rule !== null && "test" in rule && rule.test instanceof RegExp && rule.test.test(".ts"))) compiler.options.module.rules.push({
|
|
329
|
-
test: /\.tsx?$/,
|
|
330
|
-
use: "builtin:swc-loader",
|
|
331
|
-
exclude: /node_modules/
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
configureDevServer(compiler, pluginInfo, devConfig, port) {
|
|
335
|
-
if (!compiler.options.devServer) return;
|
|
336
|
-
const context = compiler.options.context || process.cwd();
|
|
337
|
-
const originalSetup = compiler.options.devServer.setupMiddlewares;
|
|
338
|
-
compiler.options.devServer.port = port;
|
|
339
|
-
compiler.options.devServer.static = node_path.default.join(context, "dist");
|
|
340
|
-
compiler.options.devServer.hot = true;
|
|
341
|
-
compiler.options.devServer.devMiddleware = { writeToDisk: true };
|
|
342
|
-
compiler.options.devServer.headers = {
|
|
343
|
-
"Access-Control-Allow-Origin": "*",
|
|
344
|
-
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
345
|
-
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
|
|
346
|
-
};
|
|
347
|
-
compiler.options.devServer.client = {
|
|
348
|
-
logging: "warn",
|
|
349
|
-
overlay: {
|
|
350
|
-
warnings: false,
|
|
351
|
-
errors: true
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
compiler.options.devServer.setupMiddlewares = (middlewares, devServer) => {
|
|
355
|
-
setupPluginMiddleware(devServer, pluginInfo, devConfig, port);
|
|
356
|
-
return originalSetup ? originalSetup(middlewares, devServer) : middlewares;
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
|
|
361
|
-
//#endregion
|
|
362
|
-
exports.EveryPluginDevServer = EveryPluginDevServer;
|
|
363
|
-
//# sourceMappingURL=index.cjs.map
|
|
3
|
+
exports.EveryPluginDevServer = require_plugin.EveryPluginDevServer;
|
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/build/rspack/plugin.d.ts
|
|
4
|
-
interface EveryPluginOptions {
|
|
5
|
-
devConfigPath?: string;
|
|
6
|
-
port?: number;
|
|
7
|
-
pluginId?: string;
|
|
8
|
-
}
|
|
9
|
-
declare class EveryPluginDevServer implements RspackPluginInstance {
|
|
10
|
-
private options;
|
|
11
|
-
name: string;
|
|
12
|
-
constructor(options?: EveryPluginOptions);
|
|
13
|
-
apply(compiler: Compiler): void;
|
|
14
|
-
private configureDefaults;
|
|
15
|
-
private ensureTypeScriptLoader;
|
|
16
|
-
private configureDevServer;
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
|
-
export { EveryPluginDevServer, type EveryPluginOptions };
|
|
20
|
-
//# sourceMappingURL=index.d.cts.map
|
|
1
|
+
import { EveryPluginDevServer, EveryPluginOptions } from "./plugin.cjs";
|
|
2
|
+
export { EveryPluginDevServer, type EveryPluginOptions };
|
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/build/rspack/plugin.d.ts
|
|
4
|
-
interface EveryPluginOptions {
|
|
5
|
-
devConfigPath?: string;
|
|
6
|
-
port?: number;
|
|
7
|
-
pluginId?: string;
|
|
8
|
-
}
|
|
9
|
-
declare class EveryPluginDevServer implements RspackPluginInstance {
|
|
10
|
-
private options;
|
|
11
|
-
name: string;
|
|
12
|
-
constructor(options?: EveryPluginOptions);
|
|
13
|
-
apply(compiler: Compiler): void;
|
|
14
|
-
private configureDefaults;
|
|
15
|
-
private ensureTypeScriptLoader;
|
|
16
|
-
private configureDevServer;
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
|
-
export { EveryPluginDevServer, type EveryPluginOptions };
|
|
20
|
-
//# sourceMappingURL=index.d.mts.map
|
|
1
|
+
import { EveryPluginDevServer, EveryPluginOptions } from "./plugin.mjs";
|
|
2
|
+
export { EveryPluginDevServer, type EveryPluginOptions };
|