@axium/office 0.0.1 → 0.1.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/README.md +15 -5
- package/dist/common.d.ts +258 -0
- package/dist/common.js +2 -0
- package/dist/hooks.d.ts +4 -0
- package/dist/hooks.js +12 -0
- package/dist/server/api.js +60 -0
- package/dist/server/cli.d.ts +1 -0
- package/dist/server/documentserver.d.ts +14 -0
- package/dist/server/documentserver.js +6 -1
- package/dist/server/image.d.ts +17 -0
- package/dist/server/image.js +161 -0
- package/dist/server/jwt.d.ts +6 -0
- package/dist/server/jwt.js +37 -0
- package/dist/server/patches.json +57 -0
- package/dist/server/themes.d.ts +9 -0
- package/dist/server/themes.js +179 -0
- package/dist/web_hook.d.ts +1 -0
- package/dist/web_hook.js +7 -0
- package/locales/en.json +1 -0
- package/package.json +3 -2
- /package/dist/{.locale.js → server/api.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -21,17 +21,23 @@ services:
|
|
|
21
21
|
restart: unless-stopped
|
|
22
22
|
ports:
|
|
23
23
|
- 127.0.0.1:8080:80
|
|
24
|
+
- '[::1]:8080:80'
|
|
24
25
|
environment:
|
|
25
26
|
JWT_SECRET: ${OFFICE_SECRET} # the plugin's `secret`
|
|
26
27
|
volumes:
|
|
27
|
-
- ./documentserver/data:/var/www/euro-office/Data
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
- ./fonts:/usr/share/fonts/truetype/custom:ro
|
|
28
|
+
- ./documentserver/data:/var/www/euro-office/Data:z
|
|
29
|
+
- logs:/var/log/euro-office/documentserver
|
|
30
|
+
- cache:/var/lib/euro-office/documentserver
|
|
31
|
+
- database:/var/lib/postgresql
|
|
32
|
+
- ./fonts:/usr/share/fonts/truetype/custom:ro,z
|
|
32
33
|
# Only if `internal_url` points at this host rather than Axium's public origin
|
|
33
34
|
# extra_hosts:
|
|
34
35
|
# - host.docker.internal:host-gateway
|
|
36
|
+
|
|
37
|
+
volumes:
|
|
38
|
+
logs:
|
|
39
|
+
cache:
|
|
40
|
+
database:
|
|
35
41
|
```
|
|
36
42
|
|
|
37
43
|
- **Secret:** `JWT_SECRET` must equal the plugin's `secret`. Generate one with `openssl rand -hex 32`.
|
|
@@ -40,6 +46,9 @@ services:
|
|
|
40
46
|
- `cache` holds the files of open sessions.
|
|
41
47
|
- `database` holds the session state that lets editing survive a restart.
|
|
42
48
|
- `logs` is for troubleshooting.
|
|
49
|
+
- `logs`, `cache` and `database` must be named volumes. Docker fills a named volume with the directories the image has at that path (the Postgres cluster, each service's log directory, the converter's working directories), while an empty bind mount hides them and the server exits at startup.
|
|
50
|
+
- `:z` relabels bind mounts for SELinux. Without it, hosts that enforce SELinux deny the container's writes and it exits at startup.
|
|
51
|
+
- **Ports:** `localhost` may resolve to `::1` first, e.g. in `cloudflared`, so the port is published on both loopback addresses.
|
|
43
52
|
- **Fonts:** fonts in `/usr/share/fonts/truetype/custom` are indexed when the container starts. Documents whose fonts are missing are laid out with substitutes, so lines and pages break differently; e.g. Palatino Linotype is not included. Add the fonts your documents use (licensed copies, or metric-compatible ones such as TeX Gyre Pagella or URW P052 for Palatino).
|
|
44
53
|
- **Autosave:** the image saves open documents with changes every 5 minutes, not only when the last editor closes or someone presses Save.
|
|
45
54
|
|
|
@@ -48,4 +57,5 @@ services:
|
|
|
48
57
|
- **Cloudflare Tunnel:** route a hostname such as `documents.example.com` to `http://localhost:8080` and set `server_url` to `https://documents.example.com`. TLS ends at Cloudflare, and the container serves plain HTTP. The tunnel forwards `X-Forwarded-Proto: https` and the public `Host`, which the server uses for the absolute URLs it generates, so no setting is needed.
|
|
49
58
|
- **Other reverse proxies** must forward `Host` (or `X-Forwarded-Host`) and `X-Forwarded-Proto`. To serve the server under a path, the proxy strips the path and sends it as `X-Forwarded-Prefix`, and `server_url` includes it. A hostname of its own is simpler.
|
|
50
59
|
- **TLS in the container:** mount a certificate and key, set `SSL_CERTIFICATE_PATH` and `SSL_KEY_PATH` to their paths, and publish port 443, e.g. `8443:443` for the default `server_url`.
|
|
60
|
+
- **`server_internal_url`:** where Axium downloads saved documents from the document server; it defaults to `server_url`. Set it to a local address, e.g. `http://localhost:8080`, when requests from Axium to `server_url` would be blocked or slowed, as Cloudflare's bot protection does.
|
|
51
61
|
- **`internal_url`:** the container can reach Axium through its public origin, the default, which goes through the tunnel and needs no host mapping. Or it can use a local address, e.g. `https://host.docker.internal` with the `extra_hosts` entry above. That address needs a certificate the server trusts, or set `USE_UNAUTHORIZED_STORAGE=true`. Local Axium addresses also need `ALLOW_PRIVATE_IP_ADDRESS=true`.
|
package/dist/common.d.ts
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export declare const kinds: readonly ["document", "spreadsheet", "presentation"];
|
|
3
|
+
export declare const Kind: z.ZodLiteral<"document" | "spreadsheet" | "presentation">;
|
|
4
|
+
export type Kind = z.infer<typeof Kind>;
|
|
5
|
+
export interface Format {
|
|
6
|
+
extension: string;
|
|
7
|
+
type: string;
|
|
8
|
+
kind: Kind;
|
|
9
|
+
}
|
|
10
|
+
export declare const formats: readonly Format[];
|
|
11
|
+
/** The format new documents of each kind are created in */
|
|
12
|
+
export declare const newFormats: {
|
|
13
|
+
document: Format;
|
|
14
|
+
spreadsheet: Format;
|
|
15
|
+
presentation: Format;
|
|
16
|
+
};
|
|
17
|
+
export declare const icons: {
|
|
18
|
+
document: string;
|
|
19
|
+
spreadsheet: string;
|
|
20
|
+
presentation: string;
|
|
21
|
+
};
|
|
22
|
+
/** Matches by MIME type first, since browsers set it on upload, then by extension */
|
|
23
|
+
export declare function formatOf(item: {
|
|
24
|
+
name: string;
|
|
25
|
+
type: string;
|
|
26
|
+
}): Format | undefined;
|
|
27
|
+
export declare const Config: z.ZodObject<{
|
|
28
|
+
server_url: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
|
|
29
|
+
internal_url: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
|
|
30
|
+
server_internal_url: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
|
|
31
|
+
secret: z.ZodString;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export interface Config extends z.infer<typeof Config> {
|
|
34
|
+
}
|
|
35
|
+
declare module '@axium/core/plugins' {
|
|
36
|
+
interface $PluginConfigs {
|
|
37
|
+
'@axium/office': Config;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export declare const EditorOptions: z.ZodObject<{
|
|
41
|
+
mobile: z.ZodBoolean;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
export interface EditorOptions extends z.infer<typeof EditorOptions> {
|
|
44
|
+
}
|
|
45
|
+
export declare const Editor: z.ZodObject<{
|
|
46
|
+
url: z.ZodURL;
|
|
47
|
+
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
export interface Editor extends z.infer<typeof Editor> {
|
|
50
|
+
}
|
|
51
|
+
export declare const EditorSession: z.ZodObject<{
|
|
52
|
+
item: z.ZodObject<{
|
|
53
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
54
|
+
dataURL: z.ZodString;
|
|
55
|
+
hash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
56
|
+
id: z.ZodUUID;
|
|
57
|
+
immutable: z.ZodBoolean;
|
|
58
|
+
modifiedAt: z.ZodCoercedDate<unknown>;
|
|
59
|
+
name: z.ZodString;
|
|
60
|
+
userId: z.ZodUUID;
|
|
61
|
+
parentId: z.ZodNullable<z.ZodUUID>;
|
|
62
|
+
size: z.ZodCoercedBigInt<unknown>;
|
|
63
|
+
trashedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
64
|
+
type: z.ZodString;
|
|
65
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
66
|
+
acl: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
67
|
+
itemId: z.ZodUUID;
|
|
68
|
+
userId: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
|
|
69
|
+
role: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
70
|
+
tag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
71
|
+
user: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
72
|
+
id: z.ZodUUID;
|
|
73
|
+
name: z.ZodString;
|
|
74
|
+
username: z.ZodString;
|
|
75
|
+
email: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodEmail>>>;
|
|
76
|
+
emailVerified: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodCoercedDate<unknown>>>>;
|
|
77
|
+
preferences: z.ZodOptional<z.ZodLazy<z.ZodObject<{
|
|
78
|
+
debug: z.ZodDefault<z.ZodBoolean>;
|
|
79
|
+
theme: z.ZodDefault<z.ZodLiteral<"default" | "light" | "forest" | "midnight" | "beach" | "cherry" | "volcano">>;
|
|
80
|
+
time_zone: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<string>, z.ZodString]>>;
|
|
81
|
+
}, z.core.$strip>>>;
|
|
82
|
+
roles: z.ZodArray<z.ZodString>;
|
|
83
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
84
|
+
registeredAt: z.ZodCoercedDate<unknown>;
|
|
85
|
+
isAdmin: z.ZodOptional<z.ZodBoolean>;
|
|
86
|
+
isSuspended: z.ZodOptional<z.ZodBoolean>;
|
|
87
|
+
}, z.core.$strip>>>;
|
|
88
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
89
|
+
}, z.core.$catchall<z.ZodBoolean>>>>;
|
|
90
|
+
parents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
91
|
+
id: z.ZodUUID;
|
|
92
|
+
name: z.ZodString;
|
|
93
|
+
}, z.core.$strip>>>;
|
|
94
|
+
sync: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
95
|
+
rules: z.ZodArray<z.ZodTemplateLiteral<`+${string}` | `-${string}`>>;
|
|
96
|
+
hidden: z.ZodBoolean;
|
|
97
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
98
|
+
devices: z.ZodArray<z.ZodObject<{
|
|
99
|
+
host: z.ZodString;
|
|
100
|
+
localPath: z.ZodString;
|
|
101
|
+
lastSynced: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
102
|
+
itemId: z.ZodUUID;
|
|
103
|
+
userId: z.ZodUUID;
|
|
104
|
+
}, z.core.$strip>>;
|
|
105
|
+
}, z.core.$strip>>>;
|
|
106
|
+
}, z.core.$strip>;
|
|
107
|
+
readOnly: z.ZodBoolean;
|
|
108
|
+
canRename: z.ZodBoolean;
|
|
109
|
+
editor: z.ZodObject<{
|
|
110
|
+
url: z.ZodURL;
|
|
111
|
+
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
}, z.core.$strip>;
|
|
114
|
+
export interface EditorSession extends z.infer<typeof EditorSession> {
|
|
115
|
+
}
|
|
116
|
+
export declare const NewDocument: z.ZodObject<{
|
|
117
|
+
kind: z.ZodLiteral<"document" | "spreadsheet" | "presentation">;
|
|
118
|
+
name: z.ZodString;
|
|
119
|
+
parentId: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
export interface NewDocument extends z.infer<typeof NewDocument> {
|
|
122
|
+
}
|
|
123
|
+
declare const OfficeAPI: {
|
|
124
|
+
readonly office: {
|
|
125
|
+
readonly PUT: readonly [z.ZodObject<{
|
|
126
|
+
kind: z.ZodLiteral<"document" | "spreadsheet" | "presentation">;
|
|
127
|
+
name: z.ZodString;
|
|
128
|
+
parentId: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
|
|
129
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
130
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
131
|
+
dataURL: z.ZodString;
|
|
132
|
+
hash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
133
|
+
id: z.ZodUUID;
|
|
134
|
+
immutable: z.ZodBoolean;
|
|
135
|
+
modifiedAt: z.ZodCoercedDate<unknown>;
|
|
136
|
+
name: z.ZodString;
|
|
137
|
+
userId: z.ZodUUID;
|
|
138
|
+
parentId: z.ZodNullable<z.ZodUUID>;
|
|
139
|
+
size: z.ZodCoercedBigInt<unknown>;
|
|
140
|
+
trashedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
141
|
+
type: z.ZodString;
|
|
142
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
143
|
+
acl: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
144
|
+
itemId: z.ZodUUID;
|
|
145
|
+
userId: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
|
|
146
|
+
role: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
147
|
+
tag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
148
|
+
user: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
149
|
+
id: z.ZodUUID;
|
|
150
|
+
name: z.ZodString;
|
|
151
|
+
username: z.ZodString;
|
|
152
|
+
email: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodEmail>>>;
|
|
153
|
+
emailVerified: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodCoercedDate<unknown>>>>;
|
|
154
|
+
preferences: z.ZodOptional<z.ZodLazy<z.ZodObject<{
|
|
155
|
+
debug: z.ZodDefault<z.ZodBoolean>;
|
|
156
|
+
theme: z.ZodDefault<z.ZodLiteral<"default" | "light" | "forest" | "midnight" | "beach" | "cherry" | "volcano">>;
|
|
157
|
+
time_zone: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<string>, z.ZodString]>>;
|
|
158
|
+
}, z.core.$strip>>>;
|
|
159
|
+
roles: z.ZodArray<z.ZodString>;
|
|
160
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
161
|
+
registeredAt: z.ZodCoercedDate<unknown>;
|
|
162
|
+
isAdmin: z.ZodOptional<z.ZodBoolean>;
|
|
163
|
+
isSuspended: z.ZodOptional<z.ZodBoolean>;
|
|
164
|
+
}, z.core.$strip>>>;
|
|
165
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
166
|
+
}, z.core.$catchall<z.ZodBoolean>>>>;
|
|
167
|
+
parents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
168
|
+
id: z.ZodUUID;
|
|
169
|
+
name: z.ZodString;
|
|
170
|
+
}, z.core.$strip>>>;
|
|
171
|
+
sync: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
172
|
+
rules: z.ZodArray<z.ZodTemplateLiteral<`+${string}` | `-${string}`>>;
|
|
173
|
+
hidden: z.ZodBoolean;
|
|
174
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
175
|
+
devices: z.ZodArray<z.ZodObject<{
|
|
176
|
+
host: z.ZodString;
|
|
177
|
+
localPath: z.ZodString;
|
|
178
|
+
lastSynced: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
179
|
+
itemId: z.ZodUUID;
|
|
180
|
+
userId: z.ZodUUID;
|
|
181
|
+
}, z.core.$strip>>;
|
|
182
|
+
}, z.core.$strip>>>;
|
|
183
|
+
}, z.core.$strip>];
|
|
184
|
+
};
|
|
185
|
+
readonly 'office/:id': {
|
|
186
|
+
readonly GET: readonly [z.ZodObject<{
|
|
187
|
+
mobile: z.ZodBoolean;
|
|
188
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
189
|
+
item: z.ZodObject<{
|
|
190
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
191
|
+
dataURL: z.ZodString;
|
|
192
|
+
hash: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
193
|
+
id: z.ZodUUID;
|
|
194
|
+
immutable: z.ZodBoolean;
|
|
195
|
+
modifiedAt: z.ZodCoercedDate<unknown>;
|
|
196
|
+
name: z.ZodString;
|
|
197
|
+
userId: z.ZodUUID;
|
|
198
|
+
parentId: z.ZodNullable<z.ZodUUID>;
|
|
199
|
+
size: z.ZodCoercedBigInt<unknown>;
|
|
200
|
+
trashedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
201
|
+
type: z.ZodString;
|
|
202
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
203
|
+
acl: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
204
|
+
itemId: z.ZodUUID;
|
|
205
|
+
userId: z.ZodOptional<z.ZodNullable<z.ZodUUID>>;
|
|
206
|
+
role: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
207
|
+
tag: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
208
|
+
user: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
209
|
+
id: z.ZodUUID;
|
|
210
|
+
name: z.ZodString;
|
|
211
|
+
username: z.ZodString;
|
|
212
|
+
email: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodEmail>>>;
|
|
213
|
+
emailVerified: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodCoercedDate<unknown>>>>;
|
|
214
|
+
preferences: z.ZodOptional<z.ZodLazy<z.ZodObject<{
|
|
215
|
+
debug: z.ZodDefault<z.ZodBoolean>;
|
|
216
|
+
theme: z.ZodDefault<z.ZodLiteral<"default" | "light" | "forest" | "midnight" | "beach" | "cherry" | "volcano">>;
|
|
217
|
+
time_zone: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<string>, z.ZodString]>>;
|
|
218
|
+
}, z.core.$strip>>>;
|
|
219
|
+
roles: z.ZodArray<z.ZodString>;
|
|
220
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
221
|
+
registeredAt: z.ZodCoercedDate<unknown>;
|
|
222
|
+
isAdmin: z.ZodOptional<z.ZodBoolean>;
|
|
223
|
+
isSuspended: z.ZodOptional<z.ZodBoolean>;
|
|
224
|
+
}, z.core.$strip>>>;
|
|
225
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
226
|
+
}, z.core.$catchall<z.ZodBoolean>>>>;
|
|
227
|
+
parents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
228
|
+
id: z.ZodUUID;
|
|
229
|
+
name: z.ZodString;
|
|
230
|
+
}, z.core.$strip>>>;
|
|
231
|
+
sync: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
232
|
+
rules: z.ZodArray<z.ZodTemplateLiteral<`+${string}` | `-${string}`>>;
|
|
233
|
+
hidden: z.ZodBoolean;
|
|
234
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
235
|
+
devices: z.ZodArray<z.ZodObject<{
|
|
236
|
+
host: z.ZodString;
|
|
237
|
+
localPath: z.ZodString;
|
|
238
|
+
lastSynced: z.ZodNullable<z.ZodCoercedDate<unknown>>;
|
|
239
|
+
itemId: z.ZodUUID;
|
|
240
|
+
userId: z.ZodUUID;
|
|
241
|
+
}, z.core.$strip>>;
|
|
242
|
+
}, z.core.$strip>>>;
|
|
243
|
+
}, z.core.$strip>;
|
|
244
|
+
readOnly: z.ZodBoolean;
|
|
245
|
+
canRename: z.ZodBoolean;
|
|
246
|
+
editor: z.ZodObject<{
|
|
247
|
+
url: z.ZodURL;
|
|
248
|
+
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
249
|
+
}, z.core.$strip>;
|
|
250
|
+
}, z.core.$strip>];
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
type OfficeAPI = typeof OfficeAPI;
|
|
254
|
+
declare module '@axium/core/api' {
|
|
255
|
+
interface $API extends OfficeAPI {
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
export {};
|
package/dist/common.js
CHANGED
|
@@ -34,6 +34,8 @@ export const Config = z
|
|
|
34
34
|
server_url: z.url().nullish(),
|
|
35
35
|
/** Where the document server reaches Axium */
|
|
36
36
|
internal_url: z.url().nullish(),
|
|
37
|
+
/** Where Axium reaches the document server */
|
|
38
|
+
server_internal_url: z.url().nullish(),
|
|
37
39
|
/** The document server's JWT secret */
|
|
38
40
|
secret: z.string().register(locales.zod, { secret: true }),
|
|
39
41
|
})
|
package/dist/hooks.d.ts
ADDED
package/dist/hooks.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import serverConfig from '@axium/server/config';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import tls from 'node:tls';
|
|
4
|
+
import './common.js';
|
|
5
|
+
import './server/api.js';
|
|
6
|
+
/** Trusts the certificate Axium serves with, which a self-hosted document server may share */
|
|
7
|
+
export function load() {
|
|
8
|
+
const { ssl_cert } = serverConfig.web;
|
|
9
|
+
if (!existsSync(ssl_cert))
|
|
10
|
+
return;
|
|
11
|
+
tls.setDefaultCACertificates([...tls.getCACertificates('default'), readFileSync(ssl_cert, 'utf8')]);
|
|
12
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { authSessionForItem, requireSession } from '@axium/server/auth';
|
|
2
|
+
import { error, isResponseError, parseBody, parseSearch } from '@axium/server/requests';
|
|
3
|
+
import { addRoute } from '@axium/server/routes';
|
|
4
|
+
import { parseItem } from '@axium/storage/server/db';
|
|
5
|
+
import { checkNewItem, createNewItem } from '@axium/storage/server/item';
|
|
6
|
+
import { createHash } from 'node:crypto';
|
|
7
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import * as z from 'zod';
|
|
10
|
+
import { EditorOptions, formatOf, NewDocument, newFormats } from '../common.js';
|
|
11
|
+
import { editorFor } from './documentserver.js';
|
|
12
|
+
async function isAllowed(itemId, permissions, session) {
|
|
13
|
+
return await authSessionForItem('storage', itemId, permissions, session, true).then(() => true, (e) => {
|
|
14
|
+
if (isResponseError(e) && e.status == 403)
|
|
15
|
+
return false;
|
|
16
|
+
throw e;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @todo reduce DB round trips (currently 3)
|
|
21
|
+
*/
|
|
22
|
+
addRoute({
|
|
23
|
+
path: '/api/office/:id',
|
|
24
|
+
params: { id: z.uuid() },
|
|
25
|
+
async GET(request, { id }) {
|
|
26
|
+
const options = parseSearch(request, EditorOptions);
|
|
27
|
+
const session = await requireSession(request);
|
|
28
|
+
const { item: rawItem } = await authSessionForItem('storage', id, { read: true }, session, true);
|
|
29
|
+
const item = parseItem(rawItem);
|
|
30
|
+
if (item.trashedAt)
|
|
31
|
+
error(410, 'Trashed items can not be opened');
|
|
32
|
+
const format = formatOf(item);
|
|
33
|
+
if (!format || item.type == 'inode/directory')
|
|
34
|
+
error(415, 'Office can not open this kind of file');
|
|
35
|
+
const isOwner = item.userId == session.userId;
|
|
36
|
+
const canWrite = !item.immutable && (isOwner || (await isAllowed(id, { write: true }, session)));
|
|
37
|
+
const canRename = isOwner || (await isAllowed(id, { manage: true }, session));
|
|
38
|
+
const editor = editorFor({ item, format, user: session.user, canWrite, options });
|
|
39
|
+
return { item, readOnly: !canWrite, canRename, editor };
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
const assets = join(import.meta.dirname, '../../assets/');
|
|
43
|
+
addRoute({
|
|
44
|
+
path: '/api/office',
|
|
45
|
+
async PUT(request) {
|
|
46
|
+
const { kind, name, parentId } = await parseBody(request, NewDocument);
|
|
47
|
+
const session = await requireSession(request);
|
|
48
|
+
const format = newFormats[kind];
|
|
49
|
+
const content = readFileSync(join(assets, `blank.${format.extension}`));
|
|
50
|
+
const init = {
|
|
51
|
+
name: `${name}.${format.extension}`,
|
|
52
|
+
size: BigInt(content.byteLength),
|
|
53
|
+
type: format.type,
|
|
54
|
+
parentId,
|
|
55
|
+
hash: createHash('BLAKE2b512').update(content).digest('hex'),
|
|
56
|
+
};
|
|
57
|
+
await checkNewItem(init, session);
|
|
58
|
+
return await createNewItem(init, session.userId, path => writeFileSync(path, content));
|
|
59
|
+
},
|
|
60
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type User } from '@axium/core';
|
|
2
|
+
import type { StorageItemMetadata } from '@axium/storage/common';
|
|
3
|
+
import type { Editor, EditorOptions, Format } from '../common.js';
|
|
4
|
+
/** An item the document server may open: it exists, is not trashed, and is not a directory */
|
|
5
|
+
export declare function getItem(itemId: string): Promise<StorageItemMetadata>;
|
|
6
|
+
export interface EditorRequest {
|
|
7
|
+
item: StorageItemMetadata;
|
|
8
|
+
format: Format;
|
|
9
|
+
user: User;
|
|
10
|
+
canWrite: boolean;
|
|
11
|
+
options: EditorOptions;
|
|
12
|
+
}
|
|
13
|
+
/** Everything the browser needs to open `item` in the document server's editor */
|
|
14
|
+
export declare function editorFor({ item, format, user, canWrite, options }: EditorRequest): Editor;
|
|
@@ -26,6 +26,11 @@ function serverURL() {
|
|
|
26
26
|
const { protocol, hostname } = new URL(serverConfig.origin);
|
|
27
27
|
return new URL(`${protocol}//${hostname}:8443`);
|
|
28
28
|
}
|
|
29
|
+
/** Where Axium reaches the document server, which defaults to where browsers reach it */
|
|
30
|
+
function serverInternalURL() {
|
|
31
|
+
const { server_internal_url } = getConfig('@axium/office');
|
|
32
|
+
return server_internal_url ? new URL(server_internal_url) : serverURL();
|
|
33
|
+
}
|
|
29
34
|
/** Where the document server reaches Axium */
|
|
30
35
|
function internalURL() {
|
|
31
36
|
return getConfig('@axium/office').internal_url ?? serverConfig.origin;
|
|
@@ -127,7 +132,7 @@ addRoute({
|
|
|
127
132
|
/** The document server only offers saved documents from itself, so this refuses to download from anywhere else */
|
|
128
133
|
async function save(itemId, location) {
|
|
129
134
|
const url = new URL(location);
|
|
130
|
-
const server =
|
|
135
|
+
const server = serverInternalURL();
|
|
131
136
|
url.protocol = server.protocol;
|
|
132
137
|
url.host = server.host;
|
|
133
138
|
const response = await fetch(url);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const defaultBase = "ghcr.io/euro-office/documentserver:v9.3.8";
|
|
2
|
+
/** The first container engine that is installed */
|
|
3
|
+
export declare function detectEngine(): string;
|
|
4
|
+
export interface ImageOptions {
|
|
5
|
+
/** The Euro-Office image to patch */
|
|
6
|
+
base: string;
|
|
7
|
+
engine: string;
|
|
8
|
+
/** The directory that receives the build context, which is replaced */
|
|
9
|
+
context: string;
|
|
10
|
+
}
|
|
11
|
+
/** Writes the build context of Axium's document server image: the base image's files patched for Axium, plus Axium's themes */
|
|
12
|
+
export declare function writeContext({ base, engine, context }: ImageOptions): void;
|
|
13
|
+
/** Writes the build context to `context`, or a temporary directory that is removed afterwards, and builds the image as `tag` */
|
|
14
|
+
export declare function buildImage(options: Omit<ImageOptions, 'context'> & {
|
|
15
|
+
context?: string;
|
|
16
|
+
tag: string;
|
|
17
|
+
}): void;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
53
|
+
import { execFileSync, spawnSync } from 'node:child_process';
|
|
54
|
+
import { chmodSync, cpSync, globSync, mkdirSync, mkdtempDisposableSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync, } from 'node:fs';
|
|
55
|
+
import { tmpdir } from 'node:os';
|
|
56
|
+
import { dirname, join } from 'node:path';
|
|
57
|
+
import { brotliCompressSync, gzipSync } from 'node:zlib';
|
|
58
|
+
import patches from './patches.json' with { type: 'json' };
|
|
59
|
+
import { editorThemes } from './themes.js';
|
|
60
|
+
export const defaultBase = 'ghcr.io/euro-office/documentserver:v9.3.8';
|
|
61
|
+
/** The source of the base themes' tokens */
|
|
62
|
+
const stylesheet = 'documenteditor/main/app.css';
|
|
63
|
+
const engines = ['docker', 'podman'];
|
|
64
|
+
/** The first container engine that is installed */
|
|
65
|
+
export function detectEngine() {
|
|
66
|
+
const engine = engines.find(engine => spawnSync(engine, ['--version'], { stdio: 'ignore' }).status === 0);
|
|
67
|
+
if (!engine)
|
|
68
|
+
throw new Error(`Neither ${engines.join(' nor ')} is installed`);
|
|
69
|
+
return engine;
|
|
70
|
+
}
|
|
71
|
+
function container(engine, ...args) {
|
|
72
|
+
return execFileSync(engine, args, { maxBuffer: 2 ** 30 });
|
|
73
|
+
}
|
|
74
|
+
/** The environment variables an image sets */
|
|
75
|
+
function imageEnvironment(engine, image) {
|
|
76
|
+
const entries = JSON.parse(container(engine, 'image', 'inspect', '--format', '{{json .Config.Env}}', image).toString());
|
|
77
|
+
return Object.fromEntries(entries.map(entry => entry.split(/=(.*)/s, 2)));
|
|
78
|
+
}
|
|
79
|
+
/** The tokens of a built-in theme's rule in an editor stylesheet */
|
|
80
|
+
function baseColors(css, themeId) {
|
|
81
|
+
const rule = new RegExp(`:root \\.${themeId}\\s*\\{([^}]*)\\}`).exec(css);
|
|
82
|
+
if (!rule)
|
|
83
|
+
throw new Error(`No rule for ${themeId} in ${stylesheet}`);
|
|
84
|
+
const declarations = rule[1].split(';').filter(declaration => declaration.includes(':'));
|
|
85
|
+
return Object.fromEntries(declarations.map(declaration => {
|
|
86
|
+
const [name, value] = declaration.split(/:(.*)/s, 2);
|
|
87
|
+
return [name.trim().replace(/^--/, ''), value.trim()];
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
/** Applies every patch to the files in `extracted`, failing unless each file holds the anchor exactly `count` times */
|
|
91
|
+
function applyPatches(extracted) {
|
|
92
|
+
const patched = new Map();
|
|
93
|
+
for (const { group, count, anchor, replacement } of patches.patches) {
|
|
94
|
+
for (const file of globSync(patches.groups[group], { cwd: extracted })) {
|
|
95
|
+
const content = patched.get(file) ?? readFileSync(join(extracted, file), 'utf8');
|
|
96
|
+
const found = content.split(anchor).length - 1;
|
|
97
|
+
if (found != count)
|
|
98
|
+
throw new Error(`Expected ${count} of ${JSON.stringify(anchor)} in ${file}, found ${found}`);
|
|
99
|
+
patched.set(file, content.replaceAll(anchor, replacement));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return patched;
|
|
103
|
+
}
|
|
104
|
+
/** Writes the build context of Axium's document server image: the base image's files patched for Axium, plus Axium's themes */
|
|
105
|
+
export function writeContext({ base, engine, context }) {
|
|
106
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
107
|
+
try {
|
|
108
|
+
const extracted = __addDisposableResource(env_1, mkdtempDisposableSync(join(tmpdir(), 'axium-documentserver-base-')), false);
|
|
109
|
+
const patterns = [...new Set(Object.values(patches.groups).flat())];
|
|
110
|
+
const archive = container(engine, 'run', '--rm', '--entrypoint', 'sh', base, '-c', `cd "\${EO_ROOT:?${base} is not a Euro-Office image}/web-apps/apps" && tar -c ${patterns.join(' ')}`);
|
|
111
|
+
execFileSync('tar', ['-x', '-C', extracted.path], { input: archive });
|
|
112
|
+
const { EO_ROOT: root, EO_CONF: configDirectory } = imageEnvironment(engine, base);
|
|
113
|
+
if (!root || !configDirectory)
|
|
114
|
+
throw new Error(`${base} is not a Euro-Office image: it does not set EO_ROOT and EO_CONF`);
|
|
115
|
+
rmSync(context, { recursive: true, force: true });
|
|
116
|
+
const apps = join(context, 'web-apps/apps');
|
|
117
|
+
for (const [file, content] of applyPatches(extracted.path)) {
|
|
118
|
+
const destination = join(apps, file);
|
|
119
|
+
mkdirSync(dirname(destination), { recursive: true });
|
|
120
|
+
writeFileSync(destination, content);
|
|
121
|
+
writeFileSync(destination + '.gz', gzipSync(content));
|
|
122
|
+
writeFileSync(destination + '.br', brotliCompressSync(content));
|
|
123
|
+
for (const path of [destination, destination + '.gz', destination + '.br'])
|
|
124
|
+
chmodSync(path, statSync(join(extracted.path, file)).mode);
|
|
125
|
+
}
|
|
126
|
+
const css = readFileSync(join(extracted.path, stylesheet), 'utf8');
|
|
127
|
+
const themes = join(apps, 'common/main/resources/themes');
|
|
128
|
+
mkdirSync(themes, { recursive: true });
|
|
129
|
+
for (const { base: themeBase, ...theme } of editorThemes()) {
|
|
130
|
+
const complete = { ...theme, colors: { ...baseColors(css, themeBase), ...theme.colors } };
|
|
131
|
+
writeFileSync(join(themes, theme.id.replace(/^theme-/, '') + '.json'), JSON.stringify(complete, null, '\t') + '\n');
|
|
132
|
+
}
|
|
133
|
+
cpSync(join(import.meta.dirname, '../../assets/documentserver.json'), join(context, 'local-production-linux.json'));
|
|
134
|
+
writeFileSync(join(context, 'Containerfile'), `FROM ${base}
|
|
135
|
+
COPY --chown=ds:ds web-apps ${root}/web-apps
|
|
136
|
+
COPY --chown=ds:ds local-production-linux.json ${configDirectory}/
|
|
137
|
+
RUN find ${root}/web-apps -type d -exec chmod 555 {} + && documentserver-flush-cache.sh -r false
|
|
138
|
+
`);
|
|
139
|
+
}
|
|
140
|
+
catch (e_1) {
|
|
141
|
+
env_1.error = e_1;
|
|
142
|
+
env_1.hasError = true;
|
|
143
|
+
}
|
|
144
|
+
finally {
|
|
145
|
+
__disposeResources(env_1);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/** Writes the build context to `context`, or a temporary directory that is removed afterwards, and builds the image as `tag` */
|
|
149
|
+
export function buildImage(options) {
|
|
150
|
+
const context = options.context ?? mkdtempSync(join(tmpdir(), 'axium-documentserver-'));
|
|
151
|
+
try {
|
|
152
|
+
writeContext({ ...options, context });
|
|
153
|
+
execFileSync(options.engine, ['build', '--file', join(context, 'Containerfile'), '--tag', options.tag, context], {
|
|
154
|
+
stdio: 'inherit',
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
if (!options.context)
|
|
159
|
+
rmSync(context, { recursive: true, force: true });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Signs `payload` with HS256 */
|
|
2
|
+
export declare function sign(payload: object, secret: string): string;
|
|
3
|
+
/** Returns the payload of an HS256 token with a valid signature that has not expired, or null */
|
|
4
|
+
export declare function verify<T extends object>(token: string, secret: string): (T & {
|
|
5
|
+
exp?: number;
|
|
6
|
+
}) | null;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import { decodeUTF8, encodeUTF8 } from 'utilium';
|
|
3
|
+
function base64url(bytes) {
|
|
4
|
+
return bytes.toBase64({ alphabet: 'base64url', omitPadding: true });
|
|
5
|
+
}
|
|
6
|
+
const header = base64url(encodeUTF8(JSON.stringify({ alg: 'HS256', typ: 'JWT' })));
|
|
7
|
+
function signature(signingInput, secret) {
|
|
8
|
+
return createHmac('sha256', secret).update(signingInput).digest();
|
|
9
|
+
}
|
|
10
|
+
/** Signs `payload` with HS256 */
|
|
11
|
+
export function sign(payload, secret) {
|
|
12
|
+
const signingInput = `${header}.${base64url(encodeUTF8(JSON.stringify(payload)))}`;
|
|
13
|
+
return `${signingInput}.${base64url(signature(signingInput, secret))}`;
|
|
14
|
+
}
|
|
15
|
+
/** Returns the payload of an HS256 token with a valid signature that has not expired, or null */
|
|
16
|
+
export function verify(token, secret) {
|
|
17
|
+
if (!secret)
|
|
18
|
+
return null;
|
|
19
|
+
const [tokenHeader, body, tokenSignature, ...extra] = token.split('.');
|
|
20
|
+
if (!tokenHeader || !body || !tokenSignature || extra.length)
|
|
21
|
+
return null;
|
|
22
|
+
const expected = signature(`${tokenHeader}.${body}`, secret);
|
|
23
|
+
const actual = Uint8Array.fromBase64(tokenSignature, { alphabet: 'base64url' });
|
|
24
|
+
if (actual.length != expected.length || !timingSafeEqual(actual, expected))
|
|
25
|
+
return null;
|
|
26
|
+
try {
|
|
27
|
+
if (JSON.parse(decodeUTF8(Uint8Array.fromBase64(tokenHeader, { alphabet: 'base64url' }))).alg != 'HS256')
|
|
28
|
+
return null;
|
|
29
|
+
const payload = JSON.parse(decodeUTF8(Uint8Array.fromBase64(body, { alphabet: 'base64url' })));
|
|
30
|
+
if (typeof payload.exp == 'number' && payload.exp * 1000 < Date.now())
|
|
31
|
+
return null;
|
|
32
|
+
return payload;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"groups": {
|
|
3
|
+
"pages": [
|
|
4
|
+
"*/main/index.html",
|
|
5
|
+
"*/main/index_loader.html",
|
|
6
|
+
"spreadsheeteditor/main/index_internal.html",
|
|
7
|
+
"documenteditor/forms/index.html",
|
|
8
|
+
"common/index.html"
|
|
9
|
+
],
|
|
10
|
+
"bundles": ["*/main/app.js", "documenteditor/forms/app.js"],
|
|
11
|
+
"stylesheets": ["*/main/app.css", "documenteditor/forms/app.css"],
|
|
12
|
+
"discussionStylesheets": [
|
|
13
|
+
"documenteditor/main/app.css",
|
|
14
|
+
"pdfeditor/main/app.css",
|
|
15
|
+
"presentationeditor/main/app.css",
|
|
16
|
+
"spreadsheeteditor/main/app.css"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"patches": [
|
|
20
|
+
{
|
|
21
|
+
"group": "pages",
|
|
22
|
+
"count": 2,
|
|
23
|
+
"anchor": "getItem(\"content-theme\") == 'dark'",
|
|
24
|
+
"replacement": "getItem(\"content-theme\") != 'light'"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"group": "bundles",
|
|
28
|
+
"count": 1,
|
|
29
|
+
"anchor": "const check_launched_custom_theme=function(){let theme_id=window.uitheme.id;if(themes_map[theme_id]){if(\"static\"!=themes_map[theme_id].source){",
|
|
30
|
+
"replacement": "const check_launched_custom_theme=function(){let theme_id=window.uitheme.id;if(themes_map[theme_id]){if(\"static\"!=themes_map[theme_id].source){if(themes_map[theme_id].src)return apply_theme.call(Common.UI.Themes,theme_id),void Common.NotificationCenter.trigger(\"uitheme:changed\",theme_id);"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"group": "bundles",
|
|
34
|
+
"count": 1,
|
|
35
|
+
"anchor": "document.getElementsByTagName(\"head\")[0].appendChild(style)}}(t.src.id,function(id,colors){if(colors&&id){var _css_array=[\":root .\",id,\"{\"]",
|
|
36
|
+
"replacement": "document.body.appendChild(style)}}(t.src.id,function(id,colors){if(colors&&id){var _css_array=[\":root body.\",id,\"{\"]"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"group": "pages",
|
|
40
|
+
"count": 1,
|
|
41
|
+
"anchor": "inject_style_tag('.' + objtheme.id + '{'",
|
|
42
|
+
"replacement": "inject_style_tag(':root body.' + objtheme.id + '{'"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"group": "stylesheets",
|
|
46
|
+
"count": 1,
|
|
47
|
+
"anchor": " background: #4A87E7;\n color: #fff;",
|
|
48
|
+
"replacement": " background: var(--background-primary-dialog-button);\n color: var(--text-inverse);"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"group": "discussionStylesheets",
|
|
52
|
+
"count": 1,
|
|
53
|
+
"anchor": " background: #3494fb;\n color: white;",
|
|
54
|
+
"replacement": " background: var(--highlight-text-select);\n color: var(--text-inverse);"
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface EditorTheme {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
type: 'dark' | 'light';
|
|
5
|
+
/** The built-in theme that supplies every color not set here */
|
|
6
|
+
base: string;
|
|
7
|
+
colors: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
export declare function editorThemes(): EditorTheme[];
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// The document server's Axium themes, one per Axium theme.
|
|
2
|
+
import { themeStyles } from '@axium/client/themes';
|
|
3
|
+
import { hslToHex } from 'utilium/color';
|
|
4
|
+
/** The defaults in `@axium/client/assets/theme.css`, which the `default` theme uses */
|
|
5
|
+
const defaults = {
|
|
6
|
+
'color-scheme': 'dark',
|
|
7
|
+
hue: '240',
|
|
8
|
+
'fg-light': '73%',
|
|
9
|
+
'bg-light': '13.3%',
|
|
10
|
+
'light-step': '6.6%',
|
|
11
|
+
};
|
|
12
|
+
/** `saturation` and `lightness` are percentages, `hue` is in degrees */
|
|
13
|
+
function hex(hue, saturation, lightness) {
|
|
14
|
+
const fraction = (value) => Math.min(100, Math.max(0, value)) / 100;
|
|
15
|
+
return '#' + hslToHex(hue / 360, fraction(saturation), fraction(lightness));
|
|
16
|
+
}
|
|
17
|
+
/** Axium's colors, using the formulas in `theme.css` */
|
|
18
|
+
function axiumColors(style) {
|
|
19
|
+
const hue = parseFloat(style.hue);
|
|
20
|
+
const foreground = parseFloat(style['fg-light']);
|
|
21
|
+
const background = parseFloat(style['bg-light']);
|
|
22
|
+
const step = parseFloat(style['light-step']);
|
|
23
|
+
return {
|
|
24
|
+
'bg-normal': hex(0, 0, background),
|
|
25
|
+
'bg-menu': hex(0, 0, background - step),
|
|
26
|
+
'bg-accent': hex(hue, 15, background + step * 2),
|
|
27
|
+
'bg-alt': hex(hue, 5, background + step),
|
|
28
|
+
'bg-strong': hex(hue, 20, background + step),
|
|
29
|
+
'fg-normal': hex(0, 0, foreground),
|
|
30
|
+
'fg-accent': hex(hue, 15, foreground),
|
|
31
|
+
'fg-disabled': hex(0, 0, foreground - step),
|
|
32
|
+
'border-accent': hex(hue, 10, background + step * 3),
|
|
33
|
+
'border-strong': hex(hue, 20, background + step * 3),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const perEditor = (token) => ['document', 'spreadsheet', 'presentation', 'pdf', 'visio'].map(editor => `${token}-${editor}`);
|
|
37
|
+
/**
|
|
38
|
+
* Editor color tokens by the Axium color they take.
|
|
39
|
+
* The base theme keeps status colors (alt key hints, badges, form filling, sheet views, red and green icons), overlays, shadows,
|
|
40
|
+
* the spreadsheet's fixed header shades and the page itself.
|
|
41
|
+
*/
|
|
42
|
+
function editorColors(axium) {
|
|
43
|
+
const mapping = {
|
|
44
|
+
'bg-normal': [
|
|
45
|
+
...perEditor('toolbar-header'),
|
|
46
|
+
...perEditor('text-toolbar-header-on-background'),
|
|
47
|
+
'background-normal',
|
|
48
|
+
'background-toolbar',
|
|
49
|
+
'background-toolbar-tab',
|
|
50
|
+
'border-toolbar-active-panel-top',
|
|
51
|
+
'canvas-ruler-background',
|
|
52
|
+
'canvas-cell-title-background',
|
|
53
|
+
'slider-thumb-border-normal',
|
|
54
|
+
'text-inverse',
|
|
55
|
+
],
|
|
56
|
+
'bg-menu': ['background-pane', 'background-contrast-popover', 'canvas-background'],
|
|
57
|
+
'bg-alt': [
|
|
58
|
+
'background-toolbar-additional',
|
|
59
|
+
'canvas-ruler-margins-background',
|
|
60
|
+
'canvas-cell-title-background-hover',
|
|
61
|
+
'canvas-scroll-thumb',
|
|
62
|
+
'highlight-comment-hover',
|
|
63
|
+
'highlight-category-button-hover',
|
|
64
|
+
],
|
|
65
|
+
'bg-strong': [
|
|
66
|
+
'background-notification-popover',
|
|
67
|
+
'highlight-button-pressed',
|
|
68
|
+
'highlight-header-button-pressed',
|
|
69
|
+
'highlight-comment-pressed',
|
|
70
|
+
'highlight-category-button-pressed',
|
|
71
|
+
'highlight-primary-dialog-button-pressed',
|
|
72
|
+
],
|
|
73
|
+
'bg-accent': [
|
|
74
|
+
'eo-app-accent',
|
|
75
|
+
'highlight-button-hover',
|
|
76
|
+
'highlight-button-pressed-hover',
|
|
77
|
+
'highlight-header-button-hover',
|
|
78
|
+
'chb-background-normal-hover',
|
|
79
|
+
'chb-background-checked-hover',
|
|
80
|
+
'rb-background-normal-hover',
|
|
81
|
+
'rb-background-checked-hover',
|
|
82
|
+
'canvas-cell-title-background-selected',
|
|
83
|
+
'canvas-scroll-thumb-hover',
|
|
84
|
+
'canvas-scroll-thumb-pressed',
|
|
85
|
+
'icon-blue-secondary',
|
|
86
|
+
],
|
|
87
|
+
'border-accent': [
|
|
88
|
+
'border-toolbar',
|
|
89
|
+
'border-divider',
|
|
90
|
+
'border-color-shading',
|
|
91
|
+
'border-contrast-popover',
|
|
92
|
+
'canvas-ruler-border',
|
|
93
|
+
'canvas-ruler-handle-border-disabled',
|
|
94
|
+
'canvas-cell-title-border',
|
|
95
|
+
'canvas-scroll-thumb-border',
|
|
96
|
+
'slider-track-background-normal',
|
|
97
|
+
],
|
|
98
|
+
'border-strong': [
|
|
99
|
+
'border-regular-control',
|
|
100
|
+
'border-preview-hover',
|
|
101
|
+
'chb-border-normal',
|
|
102
|
+
'chb-border-checked',
|
|
103
|
+
'rb-border-normal',
|
|
104
|
+
'rb-border-checked',
|
|
105
|
+
'canvas-cell-title-border-hover',
|
|
106
|
+
'canvas-high-contrast-disabled',
|
|
107
|
+
'canvas-scroll-thumb-border-hover',
|
|
108
|
+
],
|
|
109
|
+
'fg-normal': [
|
|
110
|
+
'text-normal',
|
|
111
|
+
'text-normal-pressed',
|
|
112
|
+
'text-toolbar-header',
|
|
113
|
+
'text-link-hover',
|
|
114
|
+
'text-link-active',
|
|
115
|
+
'icon-normal',
|
|
116
|
+
'icon-normal-pressed',
|
|
117
|
+
'icon-toolbar-header',
|
|
118
|
+
'icon-gray-primary',
|
|
119
|
+
'canvas-high-contrast',
|
|
120
|
+
'canvas-scroll-arrow',
|
|
121
|
+
'canvas-scroll-arrow-hover',
|
|
122
|
+
'canvas-scroll-arrow-pressed',
|
|
123
|
+
'canvas-scroll-thumb-target',
|
|
124
|
+
'canvas-scroll-thumb-target-hover',
|
|
125
|
+
'canvas-scroll-thumb-target-pressed',
|
|
126
|
+
'highlight-primary-dialog-button-hover',
|
|
127
|
+
'slider-thumb-background-hover',
|
|
128
|
+
],
|
|
129
|
+
'fg-accent': [
|
|
130
|
+
...perEditor('highlight-header-tab-underline'),
|
|
131
|
+
...perEditor('highlight-toolbar-tab-underline'),
|
|
132
|
+
'text-secondary',
|
|
133
|
+
'text-link',
|
|
134
|
+
'text-link-visited',
|
|
135
|
+
'icon-gray-secondary',
|
|
136
|
+
'icon-blue-primary',
|
|
137
|
+
'canvas-cell-title-text',
|
|
138
|
+
'background-primary-dialog-button',
|
|
139
|
+
'background-accent-button',
|
|
140
|
+
'highlight-text-select',
|
|
141
|
+
'border-preview-select',
|
|
142
|
+
'border-control-focus',
|
|
143
|
+
'border-button-pressed-focus',
|
|
144
|
+
'border-fill-input-focused',
|
|
145
|
+
'chb-border-normal-focus',
|
|
146
|
+
'chb-border-checked-focus',
|
|
147
|
+
'rb-border-normal-focus',
|
|
148
|
+
'rb-border-checked-focus',
|
|
149
|
+
'slider-track-background-filled',
|
|
150
|
+
'slider-thumb-background-normal',
|
|
151
|
+
'slider-thumb-background-active',
|
|
152
|
+
],
|
|
153
|
+
'fg-disabled': [
|
|
154
|
+
'text-tertiary',
|
|
155
|
+
'chb-border-normal-hover',
|
|
156
|
+
'chb-border-checked-hover',
|
|
157
|
+
'rb-border-normal-hover',
|
|
158
|
+
'rb-border-checked-hover',
|
|
159
|
+
'canvas-ruler-mark',
|
|
160
|
+
'canvas-ruler-handle-border',
|
|
161
|
+
'canvas-cell-title-border-selected',
|
|
162
|
+
'canvas-scroll-thumb-border-pressed',
|
|
163
|
+
],
|
|
164
|
+
};
|
|
165
|
+
return Object.fromEntries(Object.entries(mapping).flatMap(([color, tokens]) => tokens.map(token => [token, axium[color]])));
|
|
166
|
+
}
|
|
167
|
+
export function editorThemes() {
|
|
168
|
+
return [['default', {}], ...Object.entries(themeStyles)].map(([name, overrides]) => {
|
|
169
|
+
const style = { ...defaults, ...overrides };
|
|
170
|
+
const type = style['color-scheme'] == 'light' ? 'light' : 'dark';
|
|
171
|
+
return {
|
|
172
|
+
id: `theme-axium-${name}`,
|
|
173
|
+
name: name == 'default' ? 'Axium' : `Axium ${name}`,
|
|
174
|
+
type,
|
|
175
|
+
base: type == 'dark' ? 'theme-night' : 'theme-white',
|
|
176
|
+
colors: editorColors(axiumColors(style)),
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/web_hook.js
ADDED
package/locales/en.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axium/office",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"author": "James Prevett <axium@jamespre.dev>",
|
|
5
5
|
"description": "Office documents for Axium, edited with Euro-Office or OnlyOffice",
|
|
6
6
|
"funding": {
|
|
@@ -64,8 +64,9 @@
|
|
|
64
64
|
"config": {
|
|
65
65
|
"server_url": null,
|
|
66
66
|
"internal_url": null,
|
|
67
|
+
"server_internal_url": null,
|
|
67
68
|
"secret": ""
|
|
68
69
|
},
|
|
69
|
-
"update_checks":
|
|
70
|
+
"update_checks": true
|
|
70
71
|
}
|
|
71
72
|
}
|
|
File without changes
|