@opencloud-eu/extension-sdk 7.2.0 → 7.3.0-alpha.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/extension-sdk.js +83 -75
- package/dist/src/plugins/manifest.d.ts +1 -1
- package/package.json +1 -1
package/dist/extension-sdk.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { mergeConfig as e
|
|
2
|
-
import { join as
|
|
3
|
-
import { cwd as
|
|
4
|
-
import { existsSync as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { federation as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
1
|
+
import { mergeConfig as e } from "vite";
|
|
2
|
+
import { join as t, posix as n } from "path";
|
|
3
|
+
import { cwd as r } from "process";
|
|
4
|
+
import { existsSync as i, readFileSync as a, watch as o } from "fs";
|
|
5
|
+
import s from "@tailwindcss/vite";
|
|
6
|
+
import c from "@vitejs/plugin-basic-ssl";
|
|
7
|
+
import l from "@vitejs/plugin-vue";
|
|
8
|
+
import { federation as u } from "@module-federation/vite";
|
|
9
|
+
import d from "https";
|
|
10
|
+
import f from "http";
|
|
11
11
|
//#region src/externalModules.ts
|
|
12
|
-
var
|
|
12
|
+
var p = [
|
|
13
13
|
"vue",
|
|
14
14
|
"luxon",
|
|
15
15
|
"pinia",
|
|
@@ -26,9 +26,9 @@ var m = [
|
|
|
26
26
|
];
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region src/plugins/federationRegistrationClient.ts
|
|
29
|
-
function
|
|
29
|
+
function m(e, { method: t = "GET", body: n } = {}) {
|
|
30
30
|
return new Promise((r, i) => {
|
|
31
|
-
let a = (new URL(e).protocol === "https:" ?
|
|
31
|
+
let a = (new URL(e).protocol === "https:" ? d : f).request(e, {
|
|
32
32
|
method: t,
|
|
33
33
|
rejectUnauthorized: !1
|
|
34
34
|
}, (e) => {
|
|
@@ -42,7 +42,7 @@ function h(e, { method: t = "GET", body: n } = {}) {
|
|
|
42
42
|
a.on("error", i), n && (a.setHeader("Content-Type", "application/json"), a.write(n)), a.end();
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function h({ hostUrl: e, name: t, entryPoint: n, getMetadata: r, interval: i = 5e3, path: a = "/_dev/remotes", metadataWatchFiles: s = [] }) {
|
|
46
46
|
return {
|
|
47
47
|
name: "federation-registration-client",
|
|
48
48
|
apply: "serve",
|
|
@@ -53,7 +53,7 @@ function g({ hostUrl: e, name: t, entryPoint: n, getMetadata: r, interval: i = 5
|
|
|
53
53
|
if (!u) return;
|
|
54
54
|
let n = r?.(), i = `${e}${a}`;
|
|
55
55
|
try {
|
|
56
|
-
let e = await
|
|
56
|
+
let e = await m(i, {
|
|
57
57
|
method: "POST",
|
|
58
58
|
body: JSON.stringify({
|
|
59
59
|
id: t,
|
|
@@ -67,8 +67,8 @@ function g({ hostUrl: e, name: t, entryPoint: n, getMetadata: r, interval: i = 5
|
|
|
67
67
|
c.httpServer?.on("listening", () => {
|
|
68
68
|
let e = c.httpServer.address(), t = typeof e == "object" ? e?.port : e;
|
|
69
69
|
u = `https://${typeof c.config.server.host == "string" ? c.config.server.host : "localhost"}:${t}/${n}`, f(), l = setInterval(f, i);
|
|
70
|
-
for (let e of
|
|
71
|
-
let t =
|
|
70
|
+
for (let e of s) try {
|
|
71
|
+
let t = o(e, { persistent: !1 }, () => {
|
|
72
72
|
console.log(`[federation-registration] ${e} changed, re-registering...`), f();
|
|
73
73
|
});
|
|
74
74
|
d.push(t);
|
|
@@ -82,68 +82,76 @@ function g({ hostUrl: e, name: t, entryPoint: n, getMetadata: r, interval: i = 5
|
|
|
82
82
|
}
|
|
83
83
|
//#endregion
|
|
84
84
|
//#region src/plugins/manifest.ts
|
|
85
|
-
var
|
|
86
|
-
function
|
|
87
|
-
let
|
|
85
|
+
var g = "manifest.json", _ = t("./src/", g);
|
|
86
|
+
function v(e, n) {
|
|
87
|
+
let r = "";
|
|
88
88
|
return {
|
|
89
89
|
name: "manifest",
|
|
90
90
|
apply: "build",
|
|
91
91
|
configResolved(e) {
|
|
92
|
-
|
|
92
|
+
r = e.build.outDir;
|
|
93
93
|
},
|
|
94
94
|
buildStart() {
|
|
95
|
-
this.addWatchFile(
|
|
95
|
+
this.addWatchFile(_);
|
|
96
96
|
},
|
|
97
|
-
generateBundle(
|
|
98
|
-
let
|
|
99
|
-
if (
|
|
100
|
-
this.warn(`${
|
|
97
|
+
generateBundle(o, s) {
|
|
98
|
+
let c = t(r, g);
|
|
99
|
+
if (i(c)) {
|
|
100
|
+
this.warn(`${c} already exists in output directory (likely from public/), skipping generation\nConsider using --emptyOutDir if outDir is outside of project root.`);
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
|
-
let
|
|
104
|
-
|
|
105
|
-
let
|
|
106
|
-
if (
|
|
107
|
-
|
|
103
|
+
let l = Object.values(s).find((t) => t.type === "chunk" && t.name === e);
|
|
104
|
+
l || this.error("No entry chunk found");
|
|
105
|
+
let u = {};
|
|
106
|
+
if (i(_)) try {
|
|
107
|
+
u = JSON.parse(a(_).toString());
|
|
108
108
|
} catch (e) {
|
|
109
|
-
this.error(`Failed to parse manifest.json at ${
|
|
109
|
+
this.error(`Failed to parse manifest.json at ${_}: ${e.message}\nPlease ensure manifest.json contains a valid JSON object.`);
|
|
110
110
|
}
|
|
111
|
-
|
|
111
|
+
[
|
|
112
|
+
"name",
|
|
113
|
+
"version",
|
|
114
|
+
"description",
|
|
115
|
+
"license",
|
|
116
|
+
"author"
|
|
117
|
+
].forEach((e) => {
|
|
118
|
+
n[e] && typeof n[e] == "string" && (u[e] = n[e]);
|
|
119
|
+
}), u.entrypoint = l.fileName, this.emitFile({
|
|
112
120
|
type: "asset",
|
|
113
|
-
fileName:
|
|
114
|
-
source: JSON.stringify(
|
|
121
|
+
fileName: g,
|
|
122
|
+
source: JSON.stringify(u, null, 2)
|
|
115
123
|
});
|
|
116
124
|
}
|
|
117
125
|
};
|
|
118
126
|
}
|
|
119
127
|
//#endregion
|
|
120
128
|
//#region src/utils.ts
|
|
121
|
-
function
|
|
129
|
+
function y(e, t) {
|
|
122
130
|
let n = { ...e };
|
|
123
131
|
for (let r of Object.keys(t)) {
|
|
124
132
|
let i = e[r], a = t[r];
|
|
125
|
-
a && typeof a == "object" && !Array.isArray(a) && i && typeof i == "object" && !Array.isArray(i) ? n[r] =
|
|
133
|
+
a && typeof a == "object" && !Array.isArray(a) && i && typeof i == "object" && !Array.isArray(i) ? n[r] = y(i, a) : n[r] = a;
|
|
126
134
|
}
|
|
127
135
|
return n;
|
|
128
136
|
}
|
|
129
137
|
//#endregion
|
|
130
138
|
//#region src/index.ts
|
|
131
|
-
var
|
|
132
|
-
key:
|
|
133
|
-
cert:
|
|
134
|
-
} : null,
|
|
135
|
-
function
|
|
136
|
-
return ({ mode:
|
|
137
|
-
let
|
|
138
|
-
function
|
|
139
|
+
var b = process.env.OPENCLOUD_EXTENSION_DIST_DIR || "dist", x = process.env.OPENCLOUD_CERTS_DIR, S = x ? {
|
|
140
|
+
key: a(t(x, "server.key")),
|
|
141
|
+
cert: a(t(x, "server.crt"))
|
|
142
|
+
} : null, C = t("./src/", "config.json"), w = "remoteEntry", T = ".mjs";
|
|
143
|
+
function E(o = {}) {
|
|
144
|
+
return ({ mode: d }) => {
|
|
145
|
+
let f = d === "production", m = d === "test", g = JSON.parse(a(t(r(), "package.json")).toString()), x = o.name || g.name, { port: E = 9210 } = o?.server || {}, D = o?.opencloudWebHostUrl || process.env.OPENCLOUD_WEB_HOST_URL || "https://host.docker.internal:9201";
|
|
146
|
+
function O() {
|
|
139
147
|
let e = {};
|
|
140
|
-
if (
|
|
141
|
-
let t = JSON.parse(
|
|
148
|
+
if (i(_)) try {
|
|
149
|
+
let t = JSON.parse(a(_).toString());
|
|
142
150
|
t.config && (e = t.config);
|
|
143
151
|
} catch {}
|
|
144
|
-
if (
|
|
145
|
-
let t = JSON.parse(
|
|
146
|
-
e =
|
|
152
|
+
if (i(C)) try {
|
|
153
|
+
let t = JSON.parse(a(C).toString());
|
|
154
|
+
e = y(e, t);
|
|
147
155
|
} catch {}
|
|
148
156
|
return Object.keys(e).length > 0 ? e : void 0;
|
|
149
157
|
}
|
|
@@ -151,22 +159,22 @@ function D(s = {}) {
|
|
|
151
159
|
base: "./",
|
|
152
160
|
build: {
|
|
153
161
|
cssCodeSplit: !0,
|
|
154
|
-
minify:
|
|
155
|
-
outDir:
|
|
162
|
+
minify: f,
|
|
163
|
+
outDir: b,
|
|
156
164
|
rollupOptions: {
|
|
157
|
-
input: { [
|
|
165
|
+
input: { [x]: "./src/index.ts" },
|
|
158
166
|
output: {
|
|
159
|
-
entryFileNames:
|
|
160
|
-
chunkFileNames:
|
|
167
|
+
entryFileNames: n.join("js", `[name]${f ? "-[hash]" : ""}${T}`),
|
|
168
|
+
chunkFileNames: n.join("js", `[name]-[hash]${T}`)
|
|
161
169
|
}
|
|
162
170
|
}
|
|
163
171
|
},
|
|
164
172
|
plugins: [
|
|
165
|
-
|
|
173
|
+
l({
|
|
166
174
|
customElement: !1,
|
|
167
|
-
...
|
|
175
|
+
...m && { template: { compilerOptions: { whitespace: "preserve" } } }
|
|
168
176
|
}),
|
|
169
|
-
...
|
|
177
|
+
...S ? [] : [c({ name: "opencloud" })],
|
|
170
178
|
{
|
|
171
179
|
name: "fix-sec-fetch-dest",
|
|
172
180
|
configureServer(e) {
|
|
@@ -175,33 +183,33 @@ function D(s = {}) {
|
|
|
175
183
|
});
|
|
176
184
|
}
|
|
177
185
|
},
|
|
178
|
-
...
|
|
179
|
-
name:
|
|
186
|
+
...m ? [] : [u({
|
|
187
|
+
name: x,
|
|
180
188
|
exposes: { ".": "./src/index.ts" },
|
|
181
|
-
filename: `${
|
|
182
|
-
shared: Object.fromEntries(
|
|
189
|
+
filename: `${w}${f ? "-[hash]" : ""}${T}`,
|
|
190
|
+
shared: Object.fromEntries(p.map((e) => [e, {
|
|
183
191
|
singleton: !0,
|
|
184
192
|
import: !1
|
|
185
193
|
}])),
|
|
186
194
|
manifest: !1,
|
|
187
195
|
dts: !1
|
|
188
196
|
})],
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
hostUrl:
|
|
193
|
-
name:
|
|
194
|
-
entryPoint: `${
|
|
195
|
-
getMetadata:
|
|
196
|
-
metadataWatchFiles: [
|
|
197
|
+
s(),
|
|
198
|
+
v(w, g),
|
|
199
|
+
h({
|
|
200
|
+
hostUrl: D,
|
|
201
|
+
name: x,
|
|
202
|
+
entryPoint: `${w}${T}`,
|
|
203
|
+
getMetadata: O,
|
|
204
|
+
metadataWatchFiles: [_, C]
|
|
197
205
|
})
|
|
198
206
|
],
|
|
199
207
|
server: {
|
|
200
|
-
origin: `https://host.docker.internal:${
|
|
208
|
+
origin: `https://host.docker.internal:${E}`,
|
|
201
209
|
host: "host.docker.internal",
|
|
202
|
-
port:
|
|
210
|
+
port: E,
|
|
203
211
|
cors: !0,
|
|
204
|
-
...
|
|
212
|
+
...S && { https: S }
|
|
205
213
|
},
|
|
206
214
|
test: {
|
|
207
215
|
globals: !0,
|
|
@@ -223,8 +231,8 @@ function D(s = {}) {
|
|
|
223
231
|
reporter: "lcov"
|
|
224
232
|
}
|
|
225
233
|
}
|
|
226
|
-
},
|
|
234
|
+
}, o);
|
|
227
235
|
};
|
|
228
236
|
}
|
|
229
237
|
//#endregion
|
|
230
|
-
export {
|
|
238
|
+
export { E as defineConfig };
|
|
@@ -3,4 +3,4 @@ export declare const manifestPath: string;
|
|
|
3
3
|
/**
|
|
4
4
|
* Generates manifest.json for OpenCloud app discovery.
|
|
5
5
|
*/
|
|
6
|
-
export declare function manifestPlugin(remoteEntryName: string): Plugin;
|
|
6
|
+
export declare function manifestPlugin(remoteEntryName: string, packageJson: Record<string, unknown>): Plugin;
|