@opencloud-eu/extension-sdk 8.1.0 → 8.2.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,16 @@
1
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";
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 p = [
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 m(e, { method: t = "GET", body: n } = {}) {
32
+ function g(e, { method: t = "GET", body: n } = {}) {
32
33
  return new Promise((r, i) => {
33
- let a = (new URL(e).protocol === "https:" ? d : f).request(e, {
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 h({ hostUrl: e, name: t, entryPoint: n, getMetadata: r, interval: i = 5e3, path: a = "/_dev/remotes", metadataWatchFiles: s = [] }) {
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(c) {
52
- if (c.config.mode === "test") return;
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 m(i, {
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
- c.httpServer?.on("listening", () => {
70
- let e = c.httpServer.address(), t = typeof e == "object" ? e?.port : e;
71
- u = `https://${typeof c.config.server.host == "string" ? c.config.server.host : "localhost"}:${t}/${n}`, f(), l = setInterval(f, i);
72
- for (let e of s) try {
73
- let t = o(e, { persistent: !1 }, () => {
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
- }), c.httpServer?.on("close", () => {
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 g = "manifest.json", _ = t("./src/", g);
88
- function v(e, n) {
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(o, s) {
100
- let c = t(r, g);
101
- if (i(c)) {
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(s).find((t) => t.type === "chunk" && t.name === e);
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 (i(_)) try {
109
- u = JSON.parse(a(_).toString());
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 ${_}: ${e.message}\nPlease ensure manifest.json contains a valid JSON object.`);
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
- n[e] && typeof n[e] == "string" && (u[e] = n[e]);
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: g,
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 y(e, t) {
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) ? y(i, a) : a;
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 b = process.env.OPENCLOUD_EXTENSION_DIST_DIR || "dist", x = process.env.OPENCLOUD_CERTS_DIR, S = x ? {
142
- key: a(t(x, "server.key")),
143
- cert: a(t(x, "server.crt"))
144
- } : null, C = t("./src/", "config.json"), w = "remoteEntry", T = ".mjs";
145
- function E(o = {}) {
146
- return ({ mode: d }) => {
147
- 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";
148
- function O() {
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 (i(_)) try {
151
- let t = JSON.parse(a(_).toString());
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 (i(C)) try {
155
- let t = JSON.parse(a(C).toString());
156
- e = y(e, t);
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: f,
165
- outDir: b,
165
+ minify: m,
166
+ outDir: S,
166
167
  rollupOptions: {
167
- input: { [x]: "./src/index.ts" },
168
+ input: { [C]: "./src/index.ts" },
168
169
  output: {
169
- entryFileNames: n.join("js", `[name]${f ? "-[hash]" : ""}${T}`),
170
- chunkFileNames: n.join("js", `[name]-[hash]${T}`)
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
- l({
176
+ d({
176
177
  customElement: !1,
177
- ...m && { template: { compilerOptions: { whitespace: "preserve" } } }
178
+ ...g && { template: { compilerOptions: { whitespace: "preserve" } } }
178
179
  }),
179
- ...S ? [] : [c({ name: "opencloud" })],
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
- ...m ? [] : [u({
189
- name: x,
189
+ ...g ? [] : [f({
190
+ name: C,
190
191
  exposes: { ".": "./src/index.ts" },
191
- filename: `${w}${f ? "-[hash]" : ""}${T}`,
192
+ filename: `${E}${m ? "-[hash]" : ""}${D}`,
192
193
  ignoreOrigin: !0,
193
- shared: Object.fromEntries(p.map((e) => [e, {
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
- s(),
201
- v(w, g),
202
- h({
203
- hostUrl: D,
204
- name: x,
205
- entryPoint: `${w}${T}`,
206
- getMetadata: O,
207
- metadataWatchFiles: [_, C]
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:${E}`,
212
+ origin: `https://host.docker.internal:${O}`,
212
213
  host: "host.docker.internal",
213
- port: E,
214
+ port: O,
214
215
  cors: !0,
215
216
  watch: { ignored: ["**/.__mf__temp/**"] },
216
- ...S && { https: S }
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
- }, o);
240
+ }, c);
239
241
  };
240
242
  }
241
243
  //#endregion
242
- export { E as defineConfig };
244
+ export { O as defineConfig };
File without changes
@@ -0,0 +1,3 @@
1
+ //#region src/vitest.setup.ts
2
+ document.head.appendChild(Object.assign(document.createElement("base"), { href: "/" }));
3
+ //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencloud-eu/extension-sdk",
3
- "version": "8.1.0",
3
+ "version": "8.2.1",
4
4
  "description": "OpenCloud Web Extension SDK",
5
5
  "license": "AGPL-3.0",
6
6
  "main": "dist/extension-sdk.js",