@opencloud-eu/extension-sdk 6.0.0 → 6.2.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.
- package/README.md +2 -12
- package/dist/extension-sdk.js +228 -0
- package/dist/src/externalModules.d.ts +1 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/plugins/federationRegistrationClient.d.ts +24 -0
- package/dist/src/plugins/index.d.ts +2 -0
- package/dist/src/plugins/manifest.d.ts +6 -0
- package/dist/src/utils.d.ts +1 -0
- package/dist/tailwind.css +62 -0
- package/package.json +26 -5
- package/index.mjs +0 -172
- package/tailwind.css +0 -14
package/README.md
CHANGED
|
@@ -18,23 +18,13 @@ $ yarn add @opencloud-eu/extension-sdk --dev
|
|
|
18
18
|
|
|
19
19
|
## Usage
|
|
20
20
|
|
|
21
|
-
You can use the OpenCloud vite config via the `defineConfig` method provided by this package. The following example showcases
|
|
21
|
+
You can use the OpenCloud vite config via the `defineConfig` method provided by this package. The following example showcases what your `vite.config.ts` file could look like:
|
|
22
22
|
|
|
23
23
|
```ts
|
|
24
24
|
import { defineConfig } from '@opencloud-eu/extension-sdk'
|
|
25
25
|
|
|
26
26
|
export default defineConfig({
|
|
27
|
-
name: 'your-app'
|
|
28
|
-
server: {
|
|
29
|
-
port: 9700
|
|
30
|
-
},
|
|
31
|
-
build: {
|
|
32
|
-
rollupOptions: {
|
|
33
|
-
output: {
|
|
34
|
-
entryFileNames: 'your-app.js'
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
27
|
+
name: 'your-app'
|
|
38
28
|
})
|
|
39
29
|
```
|
|
40
30
|
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { mergeConfig as e, searchForWorkspaceRoot as t } from "vite";
|
|
2
|
+
import { join 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
|
+
//#region src/externalModules.ts
|
|
12
|
+
var p = [
|
|
13
|
+
"vue",
|
|
14
|
+
"luxon",
|
|
15
|
+
"pinia",
|
|
16
|
+
"vue3-gettext",
|
|
17
|
+
"@opencloud-eu/web-pkg",
|
|
18
|
+
"@opencloud-eu/web-client",
|
|
19
|
+
"@opencloud-eu/web-client/graph",
|
|
20
|
+
"@opencloud-eu/web-client/graph/generated",
|
|
21
|
+
"@opencloud-eu/web-client/ocs",
|
|
22
|
+
"@opencloud-eu/web-client/sse",
|
|
23
|
+
"@opencloud-eu/web-client/webdav"
|
|
24
|
+
];
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/plugins/federationRegistrationClient.ts
|
|
27
|
+
function m(e, { method: t = "GET", body: n } = {}) {
|
|
28
|
+
return new Promise((r, i) => {
|
|
29
|
+
let a = (new URL(e).protocol === "https:" ? d : f).request(e, {
|
|
30
|
+
method: t,
|
|
31
|
+
rejectUnauthorized: !1
|
|
32
|
+
}, (e) => {
|
|
33
|
+
let t = "";
|
|
34
|
+
e.on("data", (e) => t += e), e.on("end", () => r({
|
|
35
|
+
ok: e.statusCode >= 200 && e.statusCode < 300,
|
|
36
|
+
status: e.statusCode,
|
|
37
|
+
data: t
|
|
38
|
+
}));
|
|
39
|
+
});
|
|
40
|
+
a.on("error", i), n && (a.setHeader("Content-Type", "application/json"), a.write(n)), a.end();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function h({ hostUrl: e, name: t, entryPoint: n, getMetadata: r, interval: i = 5e3, path: a = "/_dev/remotes", metadataWatchFiles: s = [] }) {
|
|
44
|
+
return {
|
|
45
|
+
name: "federation-registration-client",
|
|
46
|
+
apply: "serve",
|
|
47
|
+
configureServer(c) {
|
|
48
|
+
if (c.config.mode === "test") return;
|
|
49
|
+
let l = null, u = "", d = [];
|
|
50
|
+
async function f() {
|
|
51
|
+
if (!u) return;
|
|
52
|
+
let n = r?.(), i = `${e}${a}`;
|
|
53
|
+
try {
|
|
54
|
+
let e = await m(i, {
|
|
55
|
+
method: "POST",
|
|
56
|
+
body: JSON.stringify({
|
|
57
|
+
id: t,
|
|
58
|
+
path: u,
|
|
59
|
+
...n && { metadata: n }
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
e.ok || console.warn(`[federation-registration] Registration failed: ${e.status}`);
|
|
63
|
+
} catch {}
|
|
64
|
+
}
|
|
65
|
+
c.httpServer?.on("listening", () => {
|
|
66
|
+
let e = c.httpServer.address(), t = typeof e == "object" ? e?.port : e;
|
|
67
|
+
u = `https://${typeof c.config.server.host == "string" ? c.config.server.host : "localhost"}:${t}/${n}`, f(), l = setInterval(f, i);
|
|
68
|
+
for (let e of s) try {
|
|
69
|
+
let t = o(e, { persistent: !1 }, () => {
|
|
70
|
+
console.log(`[federation-registration] ${e} changed, re-registering...`), f();
|
|
71
|
+
});
|
|
72
|
+
d.push(t);
|
|
73
|
+
} catch {}
|
|
74
|
+
}), c.httpServer?.on("close", () => {
|
|
75
|
+
l &&= (clearInterval(l), null);
|
|
76
|
+
for (let e of d) e.close();
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/plugins/manifest.ts
|
|
83
|
+
var g = "manifest.json", _ = n("./src/", g);
|
|
84
|
+
function v(e) {
|
|
85
|
+
let t = "";
|
|
86
|
+
return {
|
|
87
|
+
name: "manifest",
|
|
88
|
+
apply: "build",
|
|
89
|
+
configResolved(e) {
|
|
90
|
+
t = e.build.outDir;
|
|
91
|
+
},
|
|
92
|
+
buildStart() {
|
|
93
|
+
this.addWatchFile(_);
|
|
94
|
+
},
|
|
95
|
+
generateBundle(r, o) {
|
|
96
|
+
let s = n(t, g);
|
|
97
|
+
if (i(s)) {
|
|
98
|
+
this.warn(`${s} already exists in output directory (likely from public/), skipping generation\nConsider using --emptyOutDir if outDir is outside of project root.`);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
let c = Object.values(o).find((t) => t.type === "chunk" && t.name === e);
|
|
102
|
+
c || this.error("No entry chunk found");
|
|
103
|
+
let l = {};
|
|
104
|
+
if (i(_)) try {
|
|
105
|
+
l = JSON.parse(a(_).toString());
|
|
106
|
+
} catch (e) {
|
|
107
|
+
this.error(`Failed to parse manifest.json at ${_}: ${e.message}\nPlease ensure manifest.json contains a valid JSON object.`);
|
|
108
|
+
}
|
|
109
|
+
l.entrypoint = c.fileName, this.emitFile({
|
|
110
|
+
type: "asset",
|
|
111
|
+
fileName: g,
|
|
112
|
+
source: JSON.stringify(l, null, 2)
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/utils.ts
|
|
119
|
+
function y(e, t) {
|
|
120
|
+
let n = { ...e };
|
|
121
|
+
for (let r of Object.keys(t)) {
|
|
122
|
+
let i = e[r], a = t[r];
|
|
123
|
+
a && typeof a == "object" && !Array.isArray(a) && i && typeof i == "object" && !Array.isArray(i) ? n[r] = y(i, a) : n[r] = a;
|
|
124
|
+
}
|
|
125
|
+
return n;
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/index.ts
|
|
129
|
+
var b = process.env.OPENCLOUD_EXTENSION_DIST_DIR || "dist", x = process.env.OPENCLOUD_CERTS_DIR, S = x ? {
|
|
130
|
+
key: a(n(x, "server.key")),
|
|
131
|
+
cert: a(n(x, "server.crt"))
|
|
132
|
+
} : null, C = n("./src/", "config.json"), w = "remoteEntry", T = ".mjs";
|
|
133
|
+
function E(o = {}) {
|
|
134
|
+
return ({ mode: d }) => {
|
|
135
|
+
let f = d === "production", m = d === "test", g = JSON.parse(a(n(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";
|
|
136
|
+
function O() {
|
|
137
|
+
let e = {};
|
|
138
|
+
if (i(_)) try {
|
|
139
|
+
let t = JSON.parse(a(_).toString());
|
|
140
|
+
t.config && (e = t.config);
|
|
141
|
+
} catch {}
|
|
142
|
+
if (i(C)) try {
|
|
143
|
+
let t = JSON.parse(a(C).toString());
|
|
144
|
+
e = y(e, t);
|
|
145
|
+
} catch {}
|
|
146
|
+
return Object.keys(e).length > 0 ? e : void 0;
|
|
147
|
+
}
|
|
148
|
+
return e({
|
|
149
|
+
base: "./",
|
|
150
|
+
build: {
|
|
151
|
+
cssCodeSplit: !0,
|
|
152
|
+
minify: f,
|
|
153
|
+
outDir: b,
|
|
154
|
+
rollupOptions: {
|
|
155
|
+
input: { [x]: "./src/index.ts" },
|
|
156
|
+
output: {
|
|
157
|
+
entryFileNames: n("js", `[name]${f ? "-[hash]" : ""}${T}`),
|
|
158
|
+
chunkFileNames: n("js", `[name]-[hash]${T}`)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
plugins: [
|
|
163
|
+
l({
|
|
164
|
+
customElement: !1,
|
|
165
|
+
...m && { template: { compilerOptions: { whitespace: "preserve" } } }
|
|
166
|
+
}),
|
|
167
|
+
...S ? [] : [c({ name: "opencloud" })],
|
|
168
|
+
{
|
|
169
|
+
name: "fix-sec-fetch-dest",
|
|
170
|
+
configureServer(e) {
|
|
171
|
+
e.middlewares.use((e, t, n) => {
|
|
172
|
+
(e.url?.endsWith(".js") || e.url?.endsWith(".mjs")) && e.headers["sec-fetch-dest"] === "document" && (e.headers["sec-fetch-dest"] = "script"), n();
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
...m ? [] : [u({
|
|
177
|
+
name: x,
|
|
178
|
+
exposes: { ".": "./src/index.ts" },
|
|
179
|
+
filename: `${w}${f ? "-[hash]" : ""}${T}`,
|
|
180
|
+
shared: Object.fromEntries(p.map((e) => [e, {
|
|
181
|
+
singleton: !0,
|
|
182
|
+
import: !1
|
|
183
|
+
}])),
|
|
184
|
+
manifest: !1,
|
|
185
|
+
dts: !1
|
|
186
|
+
})],
|
|
187
|
+
s(),
|
|
188
|
+
v(w),
|
|
189
|
+
h({
|
|
190
|
+
hostUrl: D,
|
|
191
|
+
name: x,
|
|
192
|
+
entryPoint: `${w}${T}`,
|
|
193
|
+
getMetadata: O,
|
|
194
|
+
metadataWatchFiles: [_, C]
|
|
195
|
+
})
|
|
196
|
+
],
|
|
197
|
+
server: {
|
|
198
|
+
origin: `https://host.docker.internal:${E}`,
|
|
199
|
+
host: "host.docker.internal",
|
|
200
|
+
port: E,
|
|
201
|
+
cors: !0,
|
|
202
|
+
...S && { https: S }
|
|
203
|
+
},
|
|
204
|
+
test: {
|
|
205
|
+
globals: !0,
|
|
206
|
+
environment: "happy-dom",
|
|
207
|
+
clearMocks: !0,
|
|
208
|
+
include: ["**/*.spec.ts"],
|
|
209
|
+
exclude: [
|
|
210
|
+
"**/node_modules/**",
|
|
211
|
+
"**/dist/**",
|
|
212
|
+
"**/cypress/**",
|
|
213
|
+
"**/.{idea,git,cache,output,temp}/**",
|
|
214
|
+
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*",
|
|
215
|
+
".pnpm-store/*",
|
|
216
|
+
"**/e2e/**"
|
|
217
|
+
],
|
|
218
|
+
coverage: {
|
|
219
|
+
provider: "v8",
|
|
220
|
+
reportsDirectory: "./coverage",
|
|
221
|
+
reporter: "lcov"
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}, o);
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
//#endregion
|
|
228
|
+
export { E as defineConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const externalModules: string[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ViteUserConfig } from 'vitest/config';
|
|
2
|
+
export interface ExtensionConfigOverrides extends ViteUserConfig {
|
|
3
|
+
/** Name of the extension, defaults to the package name */
|
|
4
|
+
name?: string;
|
|
5
|
+
/** URL of the OpenCloud host web dev server, defaults to 'https://host.docker.internal:9201' */
|
|
6
|
+
opencloudWebHostUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function defineConfig(overrides?: ExtensionConfigOverrides): ({ mode }: {
|
|
9
|
+
mode: string;
|
|
10
|
+
}) => Record<string, any>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
interface FederationRegistrationClientOptions {
|
|
3
|
+
/** Host dev server URL (e.g. 'https://host.docker.internal:9201') */
|
|
4
|
+
hostUrl: string;
|
|
5
|
+
/** Remote ID used for registration */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Remote entry filename (e.g. 'remoteEntry.mjs'), combined with the server address to form the full URL */
|
|
8
|
+
entryPoint: string;
|
|
9
|
+
/** Returns optional metadata to send with registration */
|
|
10
|
+
getMetadata?: () => Record<string, unknown> | undefined;
|
|
11
|
+
/** Re-registration interval in ms (default: 5000) */
|
|
12
|
+
interval?: number;
|
|
13
|
+
/** Host endpoint path (default: '/_dev/remotes') */
|
|
14
|
+
path?: string;
|
|
15
|
+
/** File paths to watch for immediate re-registration on metadata change */
|
|
16
|
+
metadataWatchFiles?: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Vite plugin: remote-side periodic registration with a host dev server.
|
|
20
|
+
* Sends registration data at a fixed interval so the host always knows
|
|
21
|
+
* about this remote, even after the host restarts.
|
|
22
|
+
*/
|
|
23
|
+
export declare function federationRegistrationClient({ hostUrl, name, entryPoint, getMetadata, interval, path, metadataWatchFiles }: FederationRegistrationClientOptions): Plugin;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function deepMerge(target: Record<string, unknown>, source: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
@layer theme, base, components, utilities;
|
|
2
|
+
@import 'tailwindcss/theme.css' layer(theme) prefix(ext);
|
|
3
|
+
@import 'tailwindcss/utilities.css' layer(utilities) prefix(ext);
|
|
4
|
+
|
|
5
|
+
@theme {
|
|
6
|
+
--font-sans: var(--oc-font-family);
|
|
7
|
+
|
|
8
|
+
--spacing: 4px;
|
|
9
|
+
--breakpoint-xs: 580px;
|
|
10
|
+
--breakpoint-sm: 640px;
|
|
11
|
+
--breakpoint-md: 960px;
|
|
12
|
+
--breakpoint-lg: 1200px;
|
|
13
|
+
--breakpoint-xl: 1600px;
|
|
14
|
+
|
|
15
|
+
--z-index-modal: 9999;
|
|
16
|
+
|
|
17
|
+
--color-role-background: var(--oc-role-background);
|
|
18
|
+
--color-role-chrome: var(--oc-role-chrome);
|
|
19
|
+
--color-role-error: var(--oc-role-error);
|
|
20
|
+
--color-role-error-container: var(--oc-role-error-container);
|
|
21
|
+
--color-role-inverse-on-surface: var(--oc-role-inverse-on-surface);
|
|
22
|
+
--color-role-inverse-primary: var(--oc-role-inverse-primary);
|
|
23
|
+
--color-role-inverse-surface: var(--oc-role-inverse-surface);
|
|
24
|
+
--color-role-on-background: var(--oc-role-on-background);
|
|
25
|
+
--color-role-on-chrome: var(--oc-role-on-chrome);
|
|
26
|
+
--color-role-on-error: var(--oc-role-on-error);
|
|
27
|
+
--color-role-on-error-container: var(--oc-role-on-error-container);
|
|
28
|
+
--color-role-on-primary: var(--oc-role-on-primary);
|
|
29
|
+
--color-role-on-primary-container: var(--oc-role-on-primary-container);
|
|
30
|
+
--color-role-on-primary-fixed: var(--oc-role-on-primary-fixed);
|
|
31
|
+
--color-role-on-secondary: var(--oc-role-on-secondary);
|
|
32
|
+
--color-role-on-secondary-container: var(--oc-role-on-secondary-container);
|
|
33
|
+
--color-role-on-secondary-fixed: var(--oc-role-on-secondary-fixed);
|
|
34
|
+
--color-role-on-surface: var(--oc-role-on-surface);
|
|
35
|
+
--color-role-on-surface-variant: var(--oc-role-on-surface-variant);
|
|
36
|
+
--color-role-on-tertiary: var(--oc-role-on-tertiary);
|
|
37
|
+
--color-role-on-tertiary-container: var(--oc-role-on-tertiary-container);
|
|
38
|
+
--color-role-on-tertiary-fixed: var(--oc-role-on-tertiary-fixed);
|
|
39
|
+
--color-role-outline: var(--oc-role-outline);
|
|
40
|
+
--color-role-outline-variant: var(--oc-role-outline-variant);
|
|
41
|
+
--color-role-primary: var(--oc-role-primary);
|
|
42
|
+
--color-role-primary-container: var(--oc-role-primary-container);
|
|
43
|
+
--color-role-primary-fixed: var(--oc-role-primary-fixed);
|
|
44
|
+
--color-role-scrim: var(--oc-role-scrim);
|
|
45
|
+
--color-role-secondary: var(--oc-role-secondary);
|
|
46
|
+
--color-role-secondary-container: var(--oc-role-secondary-container);
|
|
47
|
+
--color-role-secondary-fixed: var(--oc-role-secondary-fixed);
|
|
48
|
+
--color-role-shadow: var(--oc-role-shadow);
|
|
49
|
+
--color-role-surface: var(--oc-role-surface);
|
|
50
|
+
--color-role-surface-bright: var(--oc-role-surface-bright);
|
|
51
|
+
--color-role-surface-container: var(--oc-role-surface-container);
|
|
52
|
+
--color-role-surface-container-high: var(--oc-role-surface-container-high);
|
|
53
|
+
--color-role-surface-container-highest: var(--oc-role-surface-container-highest);
|
|
54
|
+
--color-role-surface-container-low: var(--oc-role-surface-container-low);
|
|
55
|
+
--color-role-surface-container-lowest: var(--oc-role-surface-container-lowest);
|
|
56
|
+
--color-role-surface-dim: var(--oc-role-surface-dim);
|
|
57
|
+
--color-role-surface-tint: var(--oc-role-surface-tint);
|
|
58
|
+
--color-role-surface-variant: var(--oc-role-surface-variant);
|
|
59
|
+
--color-role-tertiary: var(--oc-role-tertiary);
|
|
60
|
+
--color-role-tertiary-container: var(--oc-role-tertiary-container);
|
|
61
|
+
--color-role-tertiary-fixed: var(--oc-role-tertiary-fixed);
|
|
62
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencloud-eu/extension-sdk",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "OpenCloud Web Extension SDK",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
|
-
"main": "
|
|
6
|
+
"main": "dist/extension-sdk.js",
|
|
7
|
+
"types": "dist/src/index.d.ts",
|
|
7
8
|
"type": "module",
|
|
8
9
|
"private": false,
|
|
9
10
|
"author": "OpenCloud GmbH <info@opencloud.eu>",
|
|
@@ -13,11 +14,31 @@
|
|
|
13
14
|
"url": "https://github.com/opencloud-eu/web",
|
|
14
15
|
"directory": "packages/extension-sdk"
|
|
15
16
|
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"default": "./dist/extension-sdk.js",
|
|
23
|
+
"types": "./dist/src/index.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./tailwind.css": "./dist/tailwind.css"
|
|
26
|
+
},
|
|
16
27
|
"dependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"@
|
|
28
|
+
"@module-federation/vite": "^1.13.5",
|
|
29
|
+
"@tailwindcss/vite": "^4.2.2",
|
|
30
|
+
"@vitejs/plugin-basic-ssl": "^2.3.0",
|
|
31
|
+
"@vitejs/plugin-vue": "^6.0.5"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"vite-plugin-static-copy": "^4.0.0"
|
|
19
35
|
},
|
|
20
36
|
"peerDependencies": {
|
|
21
|
-
"vite": "^7.2.0"
|
|
37
|
+
"vite": "^7.2.0 || ^8.0.0",
|
|
38
|
+
"vitest": "^4.0.0"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "vite build && vue-tsc --project tsconfig.build.json",
|
|
42
|
+
"check:types": "vue-tsc --declaration --noEmit --project tsconfig.build.json"
|
|
22
43
|
}
|
|
23
44
|
}
|
package/index.mjs
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
// ATTENTION: this is a .mjs (instead of a .ts) file on purpose,
|
|
2
|
-
// because we don't want to transpile it before publishing
|
|
3
|
-
// c.f. https://github.com/vitejs/vite/issues/5370
|
|
4
|
-
|
|
5
|
-
import { mergeConfig, searchForWorkspaceRoot } from 'vite'
|
|
6
|
-
import { join } from 'path'
|
|
7
|
-
import { cwd } from 'process'
|
|
8
|
-
import { readFileSync, existsSync } from 'fs'
|
|
9
|
-
import tailwindcss from '@tailwindcss/vite'
|
|
10
|
-
|
|
11
|
-
import vue from '@vitejs/plugin-vue'
|
|
12
|
-
|
|
13
|
-
const distDir = process.env.OPENCLOUD_EXTENSION_DIST_DIR || 'dist'
|
|
14
|
-
|
|
15
|
-
const certsDir = process.env.OPENCLOUD_CERTS_DIR
|
|
16
|
-
const defaultHttps = () =>
|
|
17
|
-
certsDir && {
|
|
18
|
-
key: readFileSync(join(certsDir, 'server.key')),
|
|
19
|
-
cert: readFileSync(join(certsDir, 'server.crt'))
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const manifestFile = 'manifest.json'
|
|
23
|
-
const manifestPath = join('./src/', manifestFile)
|
|
24
|
-
const manifestPlugin = () => {
|
|
25
|
-
let outputDir
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
name: 'manifest',
|
|
29
|
-
apply: 'build',
|
|
30
|
-
configResolved(config) {
|
|
31
|
-
outputDir = config.build.outDir
|
|
32
|
-
},
|
|
33
|
-
buildStart() {
|
|
34
|
-
this.addWatchFile(manifestPath)
|
|
35
|
-
},
|
|
36
|
-
generateBundle(options, bundle) {
|
|
37
|
-
const generatedManifestPath = join(outputDir, manifestFile)
|
|
38
|
-
if (existsSync(generatedManifestPath)) {
|
|
39
|
-
this.warn(
|
|
40
|
-
`${generatedManifestPath} already exists in output directory (likely from public/), skipping generation\n` +
|
|
41
|
-
`Consider using --emptyOutDir if outDir is outside of project root.`
|
|
42
|
-
)
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Find the entry chunk
|
|
47
|
-
const entryChunk = Object.values(bundle).find(
|
|
48
|
-
(chunk) => chunk.type === 'chunk' && chunk.isEntry
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
if (!entryChunk) {
|
|
52
|
-
this.error('No entry chunk found')
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
let manifest = {}
|
|
57
|
-
if (existsSync(manifestPath)) {
|
|
58
|
-
try {
|
|
59
|
-
manifest = JSON.parse(readFileSync(manifestPath).toString())
|
|
60
|
-
} catch (err) {
|
|
61
|
-
this.error(
|
|
62
|
-
`Failed to parse manifest.json at ${manifestPath}: ${err.message}\n` +
|
|
63
|
-
`Please ensure manifest.json contains a valid JSON object.`
|
|
64
|
-
)
|
|
65
|
-
return
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// set entryPoint
|
|
70
|
-
manifest.entrypoint = entryChunk.fileName
|
|
71
|
-
|
|
72
|
-
// Add manifest.json to the bundle
|
|
73
|
-
this.emitFile({
|
|
74
|
-
type: 'asset',
|
|
75
|
-
fileName: 'manifest.json',
|
|
76
|
-
source: JSON.stringify(manifest, null, 2)
|
|
77
|
-
})
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export const defineConfig = (overrides = {}) => {
|
|
83
|
-
return ({ mode }) => {
|
|
84
|
-
const isProduction = mode === 'production'
|
|
85
|
-
const isTesting = mode === 'test'
|
|
86
|
-
|
|
87
|
-
// read package name from vite workspace
|
|
88
|
-
const packageJson = JSON.parse(
|
|
89
|
-
readFileSync(join(searchForWorkspaceRoot(cwd()), 'package.json')).toString()
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
const name = overrides.name || packageJson.name
|
|
93
|
-
|
|
94
|
-
// set default config
|
|
95
|
-
const { https = defaultHttps(), port = 9210 } = overrides?.server || {}
|
|
96
|
-
const isHttps = !!https
|
|
97
|
-
|
|
98
|
-
return mergeConfig(
|
|
99
|
-
{
|
|
100
|
-
base: './', // make asset paths relative so imports work from wherever the extension is loaded
|
|
101
|
-
build: {
|
|
102
|
-
cssCodeSplit: true,
|
|
103
|
-
minify: isProduction,
|
|
104
|
-
outDir: distDir,
|
|
105
|
-
rollupOptions: {
|
|
106
|
-
// keep in sync with packages/web-runtime/src/container/application/index.ts
|
|
107
|
-
external: [
|
|
108
|
-
'vue',
|
|
109
|
-
'luxon',
|
|
110
|
-
'pinia',
|
|
111
|
-
'vue3-gettext',
|
|
112
|
-
|
|
113
|
-
'@opencloud-eu/web-client',
|
|
114
|
-
'@opencloud-eu/web-client/graph',
|
|
115
|
-
'@opencloud-eu/web-client/graph/generated',
|
|
116
|
-
'@opencloud-eu/web-client/ocs',
|
|
117
|
-
'@opencloud-eu/web-client/sse',
|
|
118
|
-
'@opencloud-eu/web-client/webdav',
|
|
119
|
-
'@opencloud-eu/web-pkg',
|
|
120
|
-
'web-client',
|
|
121
|
-
'web-pkg'
|
|
122
|
-
],
|
|
123
|
-
preserveEntrySignatures: 'strict',
|
|
124
|
-
input: {
|
|
125
|
-
[name]: './src/index.ts'
|
|
126
|
-
},
|
|
127
|
-
output: {
|
|
128
|
-
format: 'amd',
|
|
129
|
-
chunkFileNames: join('js', 'chunks', '[name]-[hash].mjs'),
|
|
130
|
-
entryFileNames: join('js', `[name]${isProduction ? '-[hash]' : ''}.js`)
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
plugins: [
|
|
135
|
-
vue({
|
|
136
|
-
// set to true when switching to esm
|
|
137
|
-
customElement: false,
|
|
138
|
-
...(isTesting && { template: { compilerOptions: { whitespace: 'preserve' } } })
|
|
139
|
-
}),
|
|
140
|
-
manifestPlugin(),
|
|
141
|
-
tailwindcss()
|
|
142
|
-
],
|
|
143
|
-
server: {
|
|
144
|
-
port,
|
|
145
|
-
strictPort: true,
|
|
146
|
-
...(isHttps && https)
|
|
147
|
-
},
|
|
148
|
-
test: {
|
|
149
|
-
globals: true,
|
|
150
|
-
environment: 'happy-dom',
|
|
151
|
-
clearMocks: true,
|
|
152
|
-
include: ['**/*.spec.ts'],
|
|
153
|
-
exclude: [
|
|
154
|
-
'**/node_modules/**',
|
|
155
|
-
'**/dist/**',
|
|
156
|
-
'**/cypress/**',
|
|
157
|
-
'**/.{idea,git,cache,output,temp}/**',
|
|
158
|
-
'**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*',
|
|
159
|
-
'.pnpm-store/*',
|
|
160
|
-
'**/e2e/**'
|
|
161
|
-
],
|
|
162
|
-
coverage: {
|
|
163
|
-
provider: 'v8',
|
|
164
|
-
reportsDirectory: './coverage',
|
|
165
|
-
reporter: 'lcov'
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
overrides
|
|
170
|
-
)
|
|
171
|
-
}
|
|
172
|
-
}
|
package/tailwind.css
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
@layer theme, base, components, utilities;
|
|
2
|
-
@import 'tailwindcss/theme.css' layer(theme) prefix(ext);
|
|
3
|
-
@import 'tailwindcss/utilities.css' layer(utilities) prefix(ext);
|
|
4
|
-
|
|
5
|
-
@theme {
|
|
6
|
-
--font-sans: var(--oc-font-family);
|
|
7
|
-
|
|
8
|
-
--spacing: 4px;
|
|
9
|
-
--breakpoint-xs: 580px;
|
|
10
|
-
--breakpoint-sm: 640px;
|
|
11
|
-
--breakpoint-md: 960px;
|
|
12
|
-
--breakpoint-lg: 1200px;
|
|
13
|
-
--breakpoint-xl: 1600px;
|
|
14
|
-
}
|