@opencloud-eu/extension-sdk 8.1.0 → 8.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extension-sdk.js +76 -74
- package/dist/src/vitest.setup.d.ts +0 -0
- package/dist/vitest.setup.js +3 -0
- package/package.json +1 -1
package/dist/extension-sdk.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { mergeConfig as e } from "vite";
|
|
2
|
-
import {
|
|
3
|
-
import { cwd as
|
|
4
|
-
import {
|
|
5
|
-
import s from "
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
2
|
+
import { dirname as t, join as n, posix as r } from "path";
|
|
3
|
+
import { cwd as i } from "process";
|
|
4
|
+
import { fileURLToPath as a } from "url";
|
|
5
|
+
import { existsSync as o, readFileSync as s, watch as c } from "fs";
|
|
6
|
+
import l from "@tailwindcss/vite";
|
|
7
|
+
import u from "@vitejs/plugin-basic-ssl";
|
|
8
|
+
import d from "@vitejs/plugin-vue";
|
|
9
|
+
import { federation as f } from "@module-federation/vite";
|
|
10
|
+
import p from "https";
|
|
11
|
+
import m from "http";
|
|
11
12
|
//#region src/externalModules.ts
|
|
12
|
-
var
|
|
13
|
+
var h = [
|
|
13
14
|
"vue",
|
|
14
15
|
"luxon",
|
|
15
16
|
"pinia",
|
|
@@ -28,9 +29,9 @@ var p = [
|
|
|
28
29
|
];
|
|
29
30
|
//#endregion
|
|
30
31
|
//#region src/plugins/federationRegistrationClient.ts
|
|
31
|
-
function
|
|
32
|
+
function g(e, { method: t = "GET", body: n } = {}) {
|
|
32
33
|
return new Promise((r, i) => {
|
|
33
|
-
let a = (new URL(e).protocol === "https:" ?
|
|
34
|
+
let a = (new URL(e).protocol === "https:" ? p : m).request(e, {
|
|
34
35
|
method: t,
|
|
35
36
|
rejectUnauthorized: !1
|
|
36
37
|
}, (e) => {
|
|
@@ -44,18 +45,18 @@ function m(e, { method: t = "GET", body: n } = {}) {
|
|
|
44
45
|
a.on("error", i), n && (a.setHeader("Content-Type", "application/json"), a.write(n)), a.end();
|
|
45
46
|
});
|
|
46
47
|
}
|
|
47
|
-
function
|
|
48
|
+
function _({ hostUrl: e, name: t, entryPoint: n, getMetadata: r, interval: i = 5e3, path: a = "/_dev/remotes", metadataWatchFiles: o = [] }) {
|
|
48
49
|
return {
|
|
49
50
|
name: "federation-registration-client",
|
|
50
51
|
apply: "serve",
|
|
51
|
-
configureServer(
|
|
52
|
-
if (
|
|
52
|
+
configureServer(s) {
|
|
53
|
+
if (s.config.mode === "test") return;
|
|
53
54
|
let l = null, u = "", d = [];
|
|
54
55
|
async function f() {
|
|
55
56
|
if (!u) return;
|
|
56
57
|
let n = r?.(), i = `${e}${a}`;
|
|
57
58
|
try {
|
|
58
|
-
let e = await
|
|
59
|
+
let e = await g(i, {
|
|
59
60
|
method: "POST",
|
|
60
61
|
body: JSON.stringify({
|
|
61
62
|
id: t,
|
|
@@ -66,16 +67,16 @@ function h({ hostUrl: e, name: t, entryPoint: n, getMetadata: r, interval: i = 5
|
|
|
66
67
|
e.ok || console.warn(`[federation-registration] Registration failed: ${e.status}`);
|
|
67
68
|
} catch {}
|
|
68
69
|
}
|
|
69
|
-
|
|
70
|
-
let e =
|
|
71
|
-
u = `https://${typeof
|
|
72
|
-
for (let e of
|
|
73
|
-
let t =
|
|
70
|
+
s.httpServer?.on("listening", () => {
|
|
71
|
+
let e = s.httpServer.address(), t = typeof e == "object" ? e?.port : e;
|
|
72
|
+
u = `https://${typeof s.config.server.host == "string" ? s.config.server.host : "localhost"}:${t}/${n}`, f(), l = setInterval(f, i);
|
|
73
|
+
for (let e of o) try {
|
|
74
|
+
let t = c(e, { persistent: !1 }, () => {
|
|
74
75
|
console.log(`[federation-registration] ${e} changed, re-registering...`), f();
|
|
75
76
|
});
|
|
76
77
|
d.push(t);
|
|
77
78
|
} catch {}
|
|
78
|
-
}),
|
|
79
|
+
}), s.httpServer?.on("close", () => {
|
|
79
80
|
l &&= (clearInterval(l), null);
|
|
80
81
|
for (let e of d) e.close();
|
|
81
82
|
});
|
|
@@ -84,8 +85,8 @@ function h({ hostUrl: e, name: t, entryPoint: n, getMetadata: r, interval: i = 5
|
|
|
84
85
|
}
|
|
85
86
|
//#endregion
|
|
86
87
|
//#region src/plugins/manifest.ts
|
|
87
|
-
var
|
|
88
|
-
function
|
|
88
|
+
var v = "manifest.json", y = n("./src/", v);
|
|
89
|
+
function b(e, t) {
|
|
89
90
|
let r = "";
|
|
90
91
|
return {
|
|
91
92
|
name: "manifest",
|
|
@@ -94,21 +95,21 @@ function v(e, n) {
|
|
|
94
95
|
r = e.build.outDir;
|
|
95
96
|
},
|
|
96
97
|
buildStart() {
|
|
97
|
-
this.addWatchFile(
|
|
98
|
+
this.addWatchFile(y);
|
|
98
99
|
},
|
|
99
|
-
generateBundle(
|
|
100
|
-
let c =
|
|
101
|
-
if (
|
|
100
|
+
generateBundle(i, a) {
|
|
101
|
+
let c = n(r, v);
|
|
102
|
+
if (o(c)) {
|
|
102
103
|
this.warn(`${c} already exists in output directory (likely from public/), skipping generation\nConsider using --emptyOutDir if outDir is outside of project root.`);
|
|
103
104
|
return;
|
|
104
105
|
}
|
|
105
|
-
let l = Object.values(
|
|
106
|
+
let l = Object.values(a).find((t) => t.type === "chunk" && t.name === e);
|
|
106
107
|
l || this.error("No entry chunk found");
|
|
107
108
|
let u = {};
|
|
108
|
-
if (
|
|
109
|
-
u = JSON.parse(
|
|
109
|
+
if (o(y)) try {
|
|
110
|
+
u = JSON.parse(s(y).toString());
|
|
110
111
|
} catch (e) {
|
|
111
|
-
this.error(`Failed to parse manifest.json at ${
|
|
112
|
+
this.error(`Failed to parse manifest.json at ${y}: ${e.message}\nPlease ensure manifest.json contains a valid JSON object.`);
|
|
112
113
|
}
|
|
113
114
|
[
|
|
114
115
|
"name",
|
|
@@ -117,10 +118,10 @@ function v(e, n) {
|
|
|
117
118
|
"license",
|
|
118
119
|
"author"
|
|
119
120
|
].forEach((e) => {
|
|
120
|
-
|
|
121
|
+
t[e] && typeof t[e] == "string" && (u[e] = t[e]);
|
|
121
122
|
}), u.entrypoint = l.fileName, this.emitFile({
|
|
122
123
|
type: "asset",
|
|
123
|
-
fileName:
|
|
124
|
+
fileName: v,
|
|
124
125
|
source: JSON.stringify(u, null, 2)
|
|
125
126
|
});
|
|
126
127
|
}
|
|
@@ -128,32 +129,32 @@ function v(e, n) {
|
|
|
128
129
|
}
|
|
129
130
|
//#endregion
|
|
130
131
|
//#region src/utils.ts
|
|
131
|
-
function
|
|
132
|
+
function x(e, t) {
|
|
132
133
|
let n = { ...e };
|
|
133
134
|
for (let r of Object.keys(t)) {
|
|
134
135
|
let i = e[r], a = t[r];
|
|
135
|
-
n[r] = a && typeof a == "object" && !Array.isArray(a) && i && typeof i == "object" && !Array.isArray(i) ?
|
|
136
|
+
n[r] = a && typeof a == "object" && !Array.isArray(a) && i && typeof i == "object" && !Array.isArray(i) ? x(i, a) : a;
|
|
136
137
|
}
|
|
137
138
|
return n;
|
|
138
139
|
}
|
|
139
140
|
//#endregion
|
|
140
141
|
//#region src/index.ts
|
|
141
|
-
var
|
|
142
|
-
key:
|
|
143
|
-
cert:
|
|
144
|
-
} : null,
|
|
145
|
-
function
|
|
146
|
-
return ({ mode:
|
|
147
|
-
let
|
|
148
|
-
function
|
|
142
|
+
var S = process.env.OPENCLOUD_EXTENSION_DIST_DIR || "dist", C = process.env.OPENCLOUD_CERTS_DIR, w = C ? {
|
|
143
|
+
key: s(n(C, "server.key")),
|
|
144
|
+
cert: s(n(C, "server.crt"))
|
|
145
|
+
} : null, T = n("./src/", "config.json"), E = "remoteEntry", D = ".mjs";
|
|
146
|
+
function O(c = {}) {
|
|
147
|
+
return ({ mode: p }) => {
|
|
148
|
+
let m = p === "production", g = p === "test", v = JSON.parse(s(n(i(), "package.json")).toString()), C = c.name || v.name, { port: O = 9210 } = c?.server || {}, k = c?.opencloudWebHostUrl || process.env.OPENCLOUD_WEB_HOST_URL || "https://host.docker.internal:9201";
|
|
149
|
+
function A() {
|
|
149
150
|
let e = {};
|
|
150
|
-
if (
|
|
151
|
-
let t = JSON.parse(
|
|
151
|
+
if (o(y)) try {
|
|
152
|
+
let t = JSON.parse(s(y).toString());
|
|
152
153
|
t.config && (e = t.config);
|
|
153
154
|
} catch {}
|
|
154
|
-
if (
|
|
155
|
-
let t = JSON.parse(
|
|
156
|
-
e =
|
|
155
|
+
if (o(T)) try {
|
|
156
|
+
let t = JSON.parse(s(T).toString());
|
|
157
|
+
e = x(e, t);
|
|
157
158
|
} catch {}
|
|
158
159
|
return Object.keys(e).length > 0 ? e : void 0;
|
|
159
160
|
}
|
|
@@ -161,22 +162,22 @@ function E(o = {}) {
|
|
|
161
162
|
base: "./",
|
|
162
163
|
build: {
|
|
163
164
|
cssCodeSplit: !0,
|
|
164
|
-
minify:
|
|
165
|
-
outDir:
|
|
165
|
+
minify: m,
|
|
166
|
+
outDir: S,
|
|
166
167
|
rollupOptions: {
|
|
167
|
-
input: { [
|
|
168
|
+
input: { [C]: "./src/index.ts" },
|
|
168
169
|
output: {
|
|
169
|
-
entryFileNames:
|
|
170
|
-
chunkFileNames:
|
|
170
|
+
entryFileNames: r.join("js", `[name]${m ? "-[hash]" : ""}${D}`),
|
|
171
|
+
chunkFileNames: r.join("js", `[name]-[hash]${D}`)
|
|
171
172
|
}
|
|
172
173
|
}
|
|
173
174
|
},
|
|
174
175
|
plugins: [
|
|
175
|
-
|
|
176
|
+
d({
|
|
176
177
|
customElement: !1,
|
|
177
|
-
...
|
|
178
|
+
...g && { template: { compilerOptions: { whitespace: "preserve" } } }
|
|
178
179
|
}),
|
|
179
|
-
...
|
|
180
|
+
...w ? [] : [u({ name: "opencloud" })],
|
|
180
181
|
{
|
|
181
182
|
name: "fix-sec-fetch-dest",
|
|
182
183
|
configureServer(e) {
|
|
@@ -185,40 +186,41 @@ function E(o = {}) {
|
|
|
185
186
|
});
|
|
186
187
|
}
|
|
187
188
|
},
|
|
188
|
-
...
|
|
189
|
-
name:
|
|
189
|
+
...g ? [] : [f({
|
|
190
|
+
name: C,
|
|
190
191
|
exposes: { ".": "./src/index.ts" },
|
|
191
|
-
filename: `${
|
|
192
|
+
filename: `${E}${m ? "-[hash]" : ""}${D}`,
|
|
192
193
|
ignoreOrigin: !0,
|
|
193
|
-
shared: Object.fromEntries(
|
|
194
|
+
shared: Object.fromEntries(h.map((e) => [e, {
|
|
194
195
|
singleton: !0,
|
|
195
196
|
import: !1
|
|
196
197
|
}])),
|
|
197
198
|
manifest: !1,
|
|
198
199
|
dts: !1
|
|
199
200
|
})],
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
hostUrl:
|
|
204
|
-
name:
|
|
205
|
-
entryPoint: `${
|
|
206
|
-
getMetadata:
|
|
207
|
-
metadataWatchFiles: [
|
|
201
|
+
l(),
|
|
202
|
+
b(E, v),
|
|
203
|
+
_({
|
|
204
|
+
hostUrl: k,
|
|
205
|
+
name: C,
|
|
206
|
+
entryPoint: `${E}${D}`,
|
|
207
|
+
getMetadata: A,
|
|
208
|
+
metadataWatchFiles: [y, T]
|
|
208
209
|
})
|
|
209
210
|
],
|
|
210
211
|
server: {
|
|
211
|
-
origin: `https://host.docker.internal:${
|
|
212
|
+
origin: `https://host.docker.internal:${O}`,
|
|
212
213
|
host: "host.docker.internal",
|
|
213
|
-
port:
|
|
214
|
+
port: O,
|
|
214
215
|
cors: !0,
|
|
215
216
|
watch: { ignored: ["**/.__mf__temp/**"] },
|
|
216
|
-
...
|
|
217
|
+
...w && { https: w }
|
|
217
218
|
},
|
|
218
219
|
test: {
|
|
219
220
|
globals: !0,
|
|
220
221
|
environment: "happy-dom",
|
|
221
222
|
clearMocks: !0,
|
|
223
|
+
setupFiles: [n(t(a(import.meta.url)), "vitest.setup.js")],
|
|
222
224
|
include: ["**/*.spec.ts"],
|
|
223
225
|
exclude: [
|
|
224
226
|
"**/node_modules/**",
|
|
@@ -235,8 +237,8 @@ function E(o = {}) {
|
|
|
235
237
|
reporter: "lcov"
|
|
236
238
|
}
|
|
237
239
|
}
|
|
238
|
-
},
|
|
240
|
+
}, c);
|
|
239
241
|
};
|
|
240
242
|
}
|
|
241
243
|
//#endregion
|
|
242
|
-
export {
|
|
244
|
+
export { O as defineConfig };
|
|
File without changes
|