@opencloud-eu/extension-sdk 7.2.0 → 7.3.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.
@@ -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",
@@ -26,9 +26,9 @@ var m = [
26
26
  ];
27
27
  //#endregion
28
28
  //#region src/plugins/federationRegistrationClient.ts
29
- function h(e, { method: t = "GET", body: n } = {}) {
29
+ function m(e, { method: t = "GET", body: n } = {}) {
30
30
  return new Promise((r, i) => {
31
- let a = (new URL(e).protocol === "https:" ? f : p).request(e, {
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 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 = [] }) {
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 h(i, {
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 o) try {
71
- let t = s(e, { persistent: !1 }, () => {
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 _ = "manifest.json", v = n("./src/", _);
86
- function y(e) {
87
- let t = "";
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
- t = e.build.outDir;
92
+ r = e.build.outDir;
93
93
  },
94
94
  buildStart() {
95
- this.addWatchFile(v);
95
+ this.addWatchFile(_);
96
96
  },
97
- generateBundle(r, i) {
98
- let s = n(t, _);
99
- if (a(s)) {
100
- 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.`);
101
101
  return;
102
102
  }
103
- let c = Object.values(i).find((t) => t.type === "chunk" && t.name === e);
104
- c || this.error("No entry chunk found");
105
- let l = {};
106
- if (a(v)) try {
107
- 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());
108
108
  } catch (e) {
109
- 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.`);
110
110
  }
111
- 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({
112
120
  type: "asset",
113
- fileName: _,
114
- source: JSON.stringify(l, null, 2)
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 b(e, t) {
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] = b(i, a) : n[r] = a;
133
+ n[r] = a && typeof a == "object" && !Array.isArray(a) && i && typeof i == "object" && !Array.isArray(i) ? y(i, a) : a;
126
134
  }
127
135
  return n;
128
136
  }
129
137
  //#endregion
130
138
  //#region src/index.ts
131
- var x = process.env.OPENCLOUD_EXTENSION_DIST_DIR || "dist", S = process.env.OPENCLOUD_CERTS_DIR, C = S ? {
132
- key: o(n(S, "server.key")),
133
- cert: o(n(S, "server.crt"))
134
- } : null, w = n("./src/", "config.json"), T = "remoteEntry", E = ".mjs";
135
- function D(s = {}) {
136
- return ({ mode: f }) => {
137
- 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";
138
- 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() {
139
147
  let e = {};
140
- if (a(v)) try {
141
- let t = JSON.parse(o(v).toString());
148
+ if (i(_)) try {
149
+ let t = JSON.parse(a(_).toString());
142
150
  t.config && (e = t.config);
143
151
  } catch {}
144
- if (a(w)) try {
145
- let t = JSON.parse(o(w).toString());
146
- e = b(e, t);
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: p,
155
- outDir: x,
162
+ minify: f,
163
+ outDir: b,
156
164
  rollupOptions: {
157
- input: { [S]: "./src/index.ts" },
165
+ input: { [x]: "./src/index.ts" },
158
166
  output: {
159
- entryFileNames: r.join("js", `[name]${p ? "-[hash]" : ""}${E}`),
160
- chunkFileNames: r.join("js", `[name]-[hash]${E}`)
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
- u({
173
+ l({
166
174
  customElement: !1,
167
- ...h && { template: { compilerOptions: { whitespace: "preserve" } } }
175
+ ...m && { template: { compilerOptions: { whitespace: "preserve" } } }
168
176
  }),
169
- ...C ? [] : [l({ name: "opencloud" })],
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
- ...h ? [] : [d({
179
- name: S,
186
+ ...m ? [] : [u({
187
+ name: x,
180
188
  exposes: { ".": "./src/index.ts" },
181
- filename: `${T}${p ? "-[hash]" : ""}${E}`,
182
- shared: Object.fromEntries(m.map((e) => [e, {
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
- c(),
190
- y(T),
191
- g({
192
- hostUrl: O,
193
- name: S,
194
- entryPoint: `${T}${E}`,
195
- getMetadata: k,
196
- 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]
197
205
  })
198
206
  ],
199
207
  server: {
200
- origin: `https://host.docker.internal:${D}`,
208
+ origin: `https://host.docker.internal:${E}`,
201
209
  host: "host.docker.internal",
202
- port: D,
210
+ port: E,
203
211
  cors: !0,
204
- ...C && { https: C }
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
- }, s);
234
+ }, o);
227
235
  };
228
236
  }
229
237
  //#endregion
230
- 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.2.0",
3
+ "version": "7.3.0",
4
4
  "description": "OpenCloud Web Extension SDK",
5
5
  "license": "AGPL-3.0",
6
6
  "main": "dist/extension-sdk.js",