@opencloud-eu/extension-sdk 7.1.2 → 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 +84 -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",
|
|
@@ -20,14 +20,15 @@ var m = [
|
|
|
20
20
|
"@opencloud-eu/web-client/graph",
|
|
21
21
|
"@opencloud-eu/web-client/graph/generated",
|
|
22
22
|
"@opencloud-eu/web-client/ocs",
|
|
23
|
+
"@opencloud-eu/web-client/ox",
|
|
23
24
|
"@opencloud-eu/web-client/sse",
|
|
24
25
|
"@opencloud-eu/web-client/webdav"
|
|
25
26
|
];
|
|
26
27
|
//#endregion
|
|
27
28
|
//#region src/plugins/federationRegistrationClient.ts
|
|
28
|
-
function
|
|
29
|
+
function m(e, { method: t = "GET", body: n } = {}) {
|
|
29
30
|
return new Promise((r, i) => {
|
|
30
|
-
let a = (new URL(e).protocol === "https:" ?
|
|
31
|
+
let a = (new URL(e).protocol === "https:" ? d : f).request(e, {
|
|
31
32
|
method: t,
|
|
32
33
|
rejectUnauthorized: !1
|
|
33
34
|
}, (e) => {
|
|
@@ -41,7 +42,7 @@ function h(e, { method: t = "GET", body: n } = {}) {
|
|
|
41
42
|
a.on("error", i), n && (a.setHeader("Content-Type", "application/json"), a.write(n)), a.end();
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
|
-
function
|
|
45
|
+
function h({ hostUrl: e, name: t, entryPoint: n, getMetadata: r, interval: i = 5e3, path: a = "/_dev/remotes", metadataWatchFiles: s = [] }) {
|
|
45
46
|
return {
|
|
46
47
|
name: "federation-registration-client",
|
|
47
48
|
apply: "serve",
|
|
@@ -52,7 +53,7 @@ function g({ hostUrl: e, name: t, entryPoint: n, getMetadata: r, interval: i = 5
|
|
|
52
53
|
if (!u) return;
|
|
53
54
|
let n = r?.(), i = `${e}${a}`;
|
|
54
55
|
try {
|
|
55
|
-
let e = await
|
|
56
|
+
let e = await m(i, {
|
|
56
57
|
method: "POST",
|
|
57
58
|
body: JSON.stringify({
|
|
58
59
|
id: t,
|
|
@@ -66,8 +67,8 @@ function g({ hostUrl: e, name: t, entryPoint: n, getMetadata: r, interval: i = 5
|
|
|
66
67
|
c.httpServer?.on("listening", () => {
|
|
67
68
|
let e = c.httpServer.address(), t = typeof e == "object" ? e?.port : e;
|
|
68
69
|
u = `https://${typeof c.config.server.host == "string" ? c.config.server.host : "localhost"}:${t}/${n}`, f(), l = setInterval(f, i);
|
|
69
|
-
for (let e of
|
|
70
|
-
let t =
|
|
70
|
+
for (let e of s) try {
|
|
71
|
+
let t = o(e, { persistent: !1 }, () => {
|
|
71
72
|
console.log(`[federation-registration] ${e} changed, re-registering...`), f();
|
|
72
73
|
});
|
|
73
74
|
d.push(t);
|
|
@@ -81,68 +82,76 @@ function g({ hostUrl: e, name: t, entryPoint: n, getMetadata: r, interval: i = 5
|
|
|
81
82
|
}
|
|
82
83
|
//#endregion
|
|
83
84
|
//#region src/plugins/manifest.ts
|
|
84
|
-
var
|
|
85
|
-
function
|
|
86
|
-
let
|
|
85
|
+
var g = "manifest.json", _ = t("./src/", g);
|
|
86
|
+
function v(e, n) {
|
|
87
|
+
let r = "";
|
|
87
88
|
return {
|
|
88
89
|
name: "manifest",
|
|
89
90
|
apply: "build",
|
|
90
91
|
configResolved(e) {
|
|
91
|
-
|
|
92
|
+
r = e.build.outDir;
|
|
92
93
|
},
|
|
93
94
|
buildStart() {
|
|
94
|
-
this.addWatchFile(
|
|
95
|
+
this.addWatchFile(_);
|
|
95
96
|
},
|
|
96
|
-
generateBundle(
|
|
97
|
-
let
|
|
98
|
-
if (
|
|
99
|
-
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.`);
|
|
100
101
|
return;
|
|
101
102
|
}
|
|
102
|
-
let
|
|
103
|
-
|
|
104
|
-
let
|
|
105
|
-
if (
|
|
106
|
-
|
|
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());
|
|
107
108
|
} catch (e) {
|
|
108
|
-
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.`);
|
|
109
110
|
}
|
|
110
|
-
|
|
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({
|
|
111
120
|
type: "asset",
|
|
112
|
-
fileName:
|
|
113
|
-
source: JSON.stringify(
|
|
121
|
+
fileName: g,
|
|
122
|
+
source: JSON.stringify(u, null, 2)
|
|
114
123
|
});
|
|
115
124
|
}
|
|
116
125
|
};
|
|
117
126
|
}
|
|
118
127
|
//#endregion
|
|
119
128
|
//#region src/utils.ts
|
|
120
|
-
function
|
|
129
|
+
function y(e, t) {
|
|
121
130
|
let n = { ...e };
|
|
122
131
|
for (let r of Object.keys(t)) {
|
|
123
132
|
let i = e[r], a = t[r];
|
|
124
|
-
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;
|
|
125
134
|
}
|
|
126
135
|
return n;
|
|
127
136
|
}
|
|
128
137
|
//#endregion
|
|
129
138
|
//#region src/index.ts
|
|
130
|
-
var
|
|
131
|
-
key:
|
|
132
|
-
cert:
|
|
133
|
-
} : null,
|
|
134
|
-
function
|
|
135
|
-
return ({ mode:
|
|
136
|
-
let
|
|
137
|
-
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() {
|
|
138
147
|
let e = {};
|
|
139
|
-
if (
|
|
140
|
-
let t = JSON.parse(
|
|
148
|
+
if (i(_)) try {
|
|
149
|
+
let t = JSON.parse(a(_).toString());
|
|
141
150
|
t.config && (e = t.config);
|
|
142
151
|
} catch {}
|
|
143
|
-
if (
|
|
144
|
-
let t = JSON.parse(
|
|
145
|
-
e =
|
|
152
|
+
if (i(C)) try {
|
|
153
|
+
let t = JSON.parse(a(C).toString());
|
|
154
|
+
e = y(e, t);
|
|
146
155
|
} catch {}
|
|
147
156
|
return Object.keys(e).length > 0 ? e : void 0;
|
|
148
157
|
}
|
|
@@ -150,22 +159,22 @@ function D(s = {}) {
|
|
|
150
159
|
base: "./",
|
|
151
160
|
build: {
|
|
152
161
|
cssCodeSplit: !0,
|
|
153
|
-
minify:
|
|
154
|
-
outDir:
|
|
162
|
+
minify: f,
|
|
163
|
+
outDir: b,
|
|
155
164
|
rollupOptions: {
|
|
156
|
-
input: { [
|
|
165
|
+
input: { [x]: "./src/index.ts" },
|
|
157
166
|
output: {
|
|
158
|
-
entryFileNames:
|
|
159
|
-
chunkFileNames:
|
|
167
|
+
entryFileNames: n.join("js", `[name]${f ? "-[hash]" : ""}${T}`),
|
|
168
|
+
chunkFileNames: n.join("js", `[name]-[hash]${T}`)
|
|
160
169
|
}
|
|
161
170
|
}
|
|
162
171
|
},
|
|
163
172
|
plugins: [
|
|
164
|
-
|
|
173
|
+
l({
|
|
165
174
|
customElement: !1,
|
|
166
|
-
...
|
|
175
|
+
...m && { template: { compilerOptions: { whitespace: "preserve" } } }
|
|
167
176
|
}),
|
|
168
|
-
...
|
|
177
|
+
...S ? [] : [c({ name: "opencloud" })],
|
|
169
178
|
{
|
|
170
179
|
name: "fix-sec-fetch-dest",
|
|
171
180
|
configureServer(e) {
|
|
@@ -174,33 +183,33 @@ function D(s = {}) {
|
|
|
174
183
|
});
|
|
175
184
|
}
|
|
176
185
|
},
|
|
177
|
-
...
|
|
178
|
-
name:
|
|
186
|
+
...m ? [] : [u({
|
|
187
|
+
name: x,
|
|
179
188
|
exposes: { ".": "./src/index.ts" },
|
|
180
|
-
filename: `${
|
|
181
|
-
shared: Object.fromEntries(
|
|
189
|
+
filename: `${w}${f ? "-[hash]" : ""}${T}`,
|
|
190
|
+
shared: Object.fromEntries(p.map((e) => [e, {
|
|
182
191
|
singleton: !0,
|
|
183
192
|
import: !1
|
|
184
193
|
}])),
|
|
185
194
|
manifest: !1,
|
|
186
195
|
dts: !1
|
|
187
196
|
})],
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
hostUrl:
|
|
192
|
-
name:
|
|
193
|
-
entryPoint: `${
|
|
194
|
-
getMetadata:
|
|
195
|
-
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]
|
|
196
205
|
})
|
|
197
206
|
],
|
|
198
207
|
server: {
|
|
199
|
-
origin: `https://host.docker.internal:${
|
|
208
|
+
origin: `https://host.docker.internal:${E}`,
|
|
200
209
|
host: "host.docker.internal",
|
|
201
|
-
port:
|
|
210
|
+
port: E,
|
|
202
211
|
cors: !0,
|
|
203
|
-
...
|
|
212
|
+
...S && { https: S }
|
|
204
213
|
},
|
|
205
214
|
test: {
|
|
206
215
|
globals: !0,
|
|
@@ -222,8 +231,8 @@ function D(s = {}) {
|
|
|
222
231
|
reporter: "lcov"
|
|
223
232
|
}
|
|
224
233
|
}
|
|
225
|
-
},
|
|
234
|
+
}, o);
|
|
226
235
|
};
|
|
227
236
|
}
|
|
228
237
|
//#endregion
|
|
229
|
-
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;
|