@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.
@@ -1,15 +1,15 @@
1
- import { mergeConfig as e, searchForWorkspaceRoot as t } from "vite";
2
- import { join as n, posix as r } from "path";
3
- import { cwd as i } from "process";
4
- import { existsSync as a, readFileSync as o, watch as s } from "fs";
5
- import c from "@tailwindcss/vite";
6
- import l from "@vitejs/plugin-basic-ssl";
7
- import u from "@vitejs/plugin-vue";
8
- import { federation as d } from "@module-federation/vite";
9
- import f from "https";
10
- import p from "http";
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 m = [
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 h(e, { method: t = "GET", body: n } = {}) {
29
+ function m(e, { method: t = "GET", body: n } = {}) {
29
30
  return new Promise((r, i) => {
30
- let a = (new URL(e).protocol === "https:" ? f : p).request(e, {
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 g({ hostUrl: e, name: t, entryPoint: n, getMetadata: r, interval: i = 5e3, path: a = "/_dev/remotes", metadataWatchFiles: o = [] }) {
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 h(i, {
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 o) try {
70
- let t = s(e, { persistent: !1 }, () => {
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 _ = "manifest.json", v = n("./src/", _);
85
- function y(e) {
86
- let t = "";
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
- t = e.build.outDir;
92
+ r = e.build.outDir;
92
93
  },
93
94
  buildStart() {
94
- this.addWatchFile(v);
95
+ this.addWatchFile(_);
95
96
  },
96
- generateBundle(r, i) {
97
- let s = n(t, _);
98
- if (a(s)) {
99
- this.warn(`${s} already exists in output directory (likely from public/), skipping generation\nConsider using --emptyOutDir if outDir is outside of project root.`);
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 c = Object.values(i).find((t) => t.type === "chunk" && t.name === e);
103
- c || this.error("No entry chunk found");
104
- let l = {};
105
- if (a(v)) try {
106
- l = JSON.parse(o(v).toString());
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 ${v}: ${e.message}\nPlease ensure manifest.json contains a valid JSON object.`);
109
+ this.error(`Failed to parse manifest.json at ${_}: ${e.message}\nPlease ensure manifest.json contains a valid JSON object.`);
109
110
  }
110
- l.entrypoint = c.fileName, this.emitFile({
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(l, null, 2)
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 b(e, t) {
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] = b(i, a) : n[r] = a;
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 x = process.env.OPENCLOUD_EXTENSION_DIST_DIR || "dist", S = process.env.OPENCLOUD_CERTS_DIR, C = S ? {
131
- key: o(n(S, "server.key")),
132
- cert: o(n(S, "server.crt"))
133
- } : null, w = n("./src/", "config.json"), T = "remoteEntry", E = ".mjs";
134
- function D(s = {}) {
135
- return ({ mode: f }) => {
136
- let p = f === "production", h = f === "test", _ = JSON.parse(o(n(t(i()), "package.json")).toString()), S = s.name || _.name, { port: D = 9210 } = s?.server || {}, O = s?.opencloudWebHostUrl || process.env.OPENCLOUD_WEB_HOST_URL || "https://host.docker.internal:9201";
137
- function k() {
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 (a(v)) try {
140
- let t = JSON.parse(o(v).toString());
148
+ if (i(_)) try {
149
+ let t = JSON.parse(a(_).toString());
141
150
  t.config && (e = t.config);
142
151
  } catch {}
143
- if (a(w)) try {
144
- let t = JSON.parse(o(w).toString());
145
- e = b(e, t);
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: p,
154
- outDir: x,
162
+ minify: f,
163
+ outDir: b,
155
164
  rollupOptions: {
156
- input: { [S]: "./src/index.ts" },
165
+ input: { [x]: "./src/index.ts" },
157
166
  output: {
158
- entryFileNames: r.join("js", `[name]${p ? "-[hash]" : ""}${E}`),
159
- chunkFileNames: r.join("js", `[name]-[hash]${E}`)
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
- u({
173
+ l({
165
174
  customElement: !1,
166
- ...h && { template: { compilerOptions: { whitespace: "preserve" } } }
175
+ ...m && { template: { compilerOptions: { whitespace: "preserve" } } }
167
176
  }),
168
- ...C ? [] : [l({ name: "opencloud" })],
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
- ...h ? [] : [d({
178
- name: S,
186
+ ...m ? [] : [u({
187
+ name: x,
179
188
  exposes: { ".": "./src/index.ts" },
180
- filename: `${T}${p ? "-[hash]" : ""}${E}`,
181
- shared: Object.fromEntries(m.map((e) => [e, {
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
- c(),
189
- y(T),
190
- g({
191
- hostUrl: O,
192
- name: S,
193
- entryPoint: `${T}${E}`,
194
- getMetadata: k,
195
- metadataWatchFiles: [v, w]
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:${D}`,
208
+ origin: `https://host.docker.internal:${E}`,
200
209
  host: "host.docker.internal",
201
- port: D,
210
+ port: E,
202
211
  cors: !0,
203
- ...C && { https: C }
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
- }, s);
234
+ }, o);
226
235
  };
227
236
  }
228
237
  //#endregion
229
- export { D as defineConfig };
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencloud-eu/extension-sdk",
3
- "version": "7.1.2",
3
+ "version": "7.3.0-alpha.1",
4
4
  "description": "OpenCloud Web Extension SDK",
5
5
  "license": "AGPL-3.0",
6
6
  "main": "dist/extension-sdk.js",