@axium/office 0.0.0-stage → 0.1.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.
@@ -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;
@@ -0,0 +1,211 @@
1
+ import { getConfig } from '@axium/core';
2
+ import feature from '@axium/core/features';
3
+ import serverConfig from '@axium/server/config';
4
+ import { error, json, withError } from '@axium/server/requests';
5
+ import { addRoute } from '@axium/server/routes';
6
+ import { streamRead } from '@axium/storage/node';
7
+ import { getLimits } from '@axium/storage/server/config';
8
+ import { get, getUserStats } from '@axium/storage/server/db';
9
+ import { finishItemUpdate } from '@axium/storage/server/item';
10
+ import * as io from 'ioium';
11
+ import { createHash } from 'node:crypto';
12
+ import { writeFileSync } from 'node:fs';
13
+ import { join } from 'node:path';
14
+ import * as z from 'zod';
15
+ import * as jwt from './jwt.js';
16
+ const documentTypes = {
17
+ document: 'word',
18
+ spreadsheet: 'cell',
19
+ presentation: 'slide',
20
+ };
21
+ /** Where browsers reach the document server, which defaults to port 8443 on the host of Axium's origin */
22
+ function serverURL() {
23
+ const { server_url } = getConfig('@axium/office');
24
+ if (server_url)
25
+ return new URL(server_url);
26
+ const { protocol, hostname } = new URL(serverConfig.origin);
27
+ return new URL(`${protocol}//${hostname}:8443`);
28
+ }
29
+ /** Where the document server reaches Axium */
30
+ function internalURL() {
31
+ return getConfig('@axium/office').internal_url ?? serverConfig.origin;
32
+ }
33
+ function secret() {
34
+ const { secret } = getConfig('@axium/office');
35
+ if (!secret)
36
+ error(503, 'Office is not configured: set the document server secret');
37
+ return secret;
38
+ }
39
+ /** The document server signs its requests to Axium into the `Authorization` header, or the body if it is configured to */
40
+ function verifySignature(request, body) {
41
+ const header = request.headers.get('Authorization')?.replace(/^Bearer /i, '');
42
+ const token = typeof body?.token == 'string' ? body.token : header;
43
+ const claims = token && jwt.verify(token, secret());
44
+ if (!claims)
45
+ error(401, 'Invalid document server token');
46
+ return claims.payload ?? claims;
47
+ }
48
+ /** Route parameters are only parsed for API routes, so other routes check the ID themselves */
49
+ function itemIdFrom({ id }) {
50
+ const result = z.uuid().safeParse(id);
51
+ if (!result.success)
52
+ error(400, 'Invalid item ID');
53
+ return result.data;
54
+ }
55
+ /** An item the document server may open: it exists, is not trashed, and is not a directory */
56
+ export async function getItem(itemId) {
57
+ const item = await get(itemId).catch(withError('Could not find the item'));
58
+ if (item.trashedAt)
59
+ error(410, 'Trashed items can not be opened');
60
+ if (item.type == 'inode/directory')
61
+ error(409, 'Directories do not have content');
62
+ return item;
63
+ }
64
+ /**
65
+ * Co-editing sessions that have force-saved, by item ID.
66
+ * A force save changes the item but not the session, so new editors must still get the session's key.
67
+ * This is held in memory, so a restart during such a session gives new editors a separate session.
68
+ */
69
+ const sessions = new Map();
70
+ /** Unique per item version, and at most 128 characters of `[0-9a-zA-Z.=_-]` */
71
+ function versionKey(item) {
72
+ const version = createHash('sha256').update(`${item.hash}:${item.modifiedAt.getTime()}`).digest('hex');
73
+ return `${item.id}-${version.slice(0, 32)}`;
74
+ }
75
+ function documentKey(item) {
76
+ const session = sessions.get(item.id);
77
+ return session && session.hash == item.hash ? session.key : versionKey(item);
78
+ }
79
+ /** Everything the browser needs to open `item` in the document server's editor */
80
+ export function editorFor({ item, format, user, canWrite, options }) {
81
+ const theme = feature('themes') ? user.preferences.theme : 'default';
82
+ const config = {
83
+ type: options.mobile ? 'mobile' : 'desktop',
84
+ documentType: documentTypes[format.kind],
85
+ document: {
86
+ fileType: format.extension,
87
+ key: documentKey(item),
88
+ title: item.name,
89
+ url: new URL(`/raw/office/${item.id}/content`, internalURL()).href,
90
+ permissions: { edit: canWrite },
91
+ },
92
+ editorConfig: {
93
+ mode: canWrite ? 'edit' : 'view',
94
+ callbackUrl: new URL(`/raw/office/${item.id}/callback`, internalURL()).href,
95
+ user: { id: user.id, name: user.name },
96
+ customization: {
97
+ compactHeader: true,
98
+ toolbarHideFileName: true,
99
+ forcesave: true,
100
+ uiTheme: `theme-axium-${theme}`,
101
+ logo: { visible: false },
102
+ layout: { header: { user: false } },
103
+ feedback: false,
104
+ suggestFeature: false,
105
+ },
106
+ },
107
+ };
108
+ return { url: serverURL().href, config: { ...config, token: jwt.sign(config, secret()) } };
109
+ }
110
+ const ContentRequest = z.looseObject({ url: z.url() });
111
+ addRoute({
112
+ path: '/raw/office/:id/content',
113
+ params: { id: z.uuid() },
114
+ async GET(request, params) {
115
+ const itemId = itemIdFrom(params);
116
+ const signed = ContentRequest.safeParse(verifySignature(request));
117
+ if (!signed.success || new URL(signed.data.url).pathname != new URL(request.url).pathname)
118
+ error(403, 'This token is for another document');
119
+ const item = await getItem(itemId);
120
+ if (!item.size)
121
+ return null;
122
+ return new Response(streamRead(join(getConfig('@axium/storage').data, item.id)), {
123
+ headers: { 'Content-Type': 'application/octet-stream', 'Content-Length': String(item.size) },
124
+ });
125
+ },
126
+ });
127
+ /** The document server only offers saved documents from itself, so this refuses to download from anywhere else */
128
+ async function save(itemId, location) {
129
+ const url = new URL(location);
130
+ const server = serverURL();
131
+ url.protocol = server.protocol;
132
+ url.host = server.host;
133
+ const response = await fetch(url);
134
+ if (!response.ok)
135
+ throw new Error(`${url.origin} responded with ${response.status}`);
136
+ const content = await response.bytes();
137
+ const item = await getItem(itemId);
138
+ if (item.immutable)
139
+ error(405, 'Item is immutable');
140
+ const size = BigInt(content.byteLength);
141
+ const [usage, limits] = await Promise.all([getUserStats(item.userId), getLimits(item.userId)]).catch(withError('Could not fetch usage and/or limits'));
142
+ if (limits.user_size && (usage.usedBytes + size - item.size) / 1000000n >= limits.user_size)
143
+ error(413, 'Not enough space');
144
+ if (limits.item_size && content.byteLength > limits.item_size * 1_000_000)
145
+ error(413, 'File size exceeds maximum size');
146
+ const hash = createHash('BLAKE2b512').update(content).digest();
147
+ return await finishItemUpdate(itemId, size, hash, path => writeFileSync(path, content));
148
+ }
149
+ function endSession(itemId, key) {
150
+ if (sessions.get(itemId)?.key == key)
151
+ sessions.delete(itemId);
152
+ }
153
+ const Callback = z.looseObject({
154
+ key: z.string(),
155
+ status: z.int(),
156
+ url: z.url().optional(),
157
+ });
158
+ var Status;
159
+ (function (Status) {
160
+ Status[Status["ReadyForSaving"] = 2] = "ReadyForSaving";
161
+ Status[Status["SaveFailed"] = 3] = "SaveFailed";
162
+ Status[Status["ClosedUnchanged"] = 4] = "ClosedUnchanged";
163
+ Status[Status["ForceSaved"] = 6] = "ForceSaved";
164
+ Status[Status["ForceSaveFailed"] = 7] = "ForceSaveFailed";
165
+ })(Status || (Status = {}));
166
+ async function handleCallback(itemId, callback) {
167
+ switch (callback.status) {
168
+ case Status.ReadyForSaving:
169
+ if (!callback.url)
170
+ error(400, 'Missing document URL');
171
+ await save(itemId, callback.url);
172
+ endSession(itemId, callback.key);
173
+ return;
174
+ case Status.ForceSaved: {
175
+ if (!callback.url)
176
+ error(400, 'Missing document URL');
177
+ const saved = await save(itemId, callback.url);
178
+ sessions.set(itemId, { key: callback.key, hash: saved.hash });
179
+ return;
180
+ }
181
+ case Status.ClosedUnchanged:
182
+ endSession(itemId, callback.key);
183
+ return;
184
+ case Status.SaveFailed:
185
+ case Status.ForceSaveFailed:
186
+ io.warn(`The document server could not save ${itemId} (status ${callback.status})`);
187
+ return;
188
+ }
189
+ }
190
+ addRoute({
191
+ path: '/raw/office/:id/callback',
192
+ params: { id: z.uuid() },
193
+ async POST(request, params) {
194
+ const itemId = itemIdFrom(params);
195
+ const body = await request.json().catch(() => error(400, 'Invalid JSON in request body'));
196
+ const parsed = Callback.safeParse(verifySignature(request, body));
197
+ if (!parsed.success)
198
+ error(400, 'Invalid callback');
199
+ const callback = parsed.data;
200
+ if (!callback.key.startsWith(itemId + '-'))
201
+ error(403, 'This callback is for another document');
202
+ try {
203
+ await handleCallback(itemId, callback);
204
+ return json({ error: 0 });
205
+ }
206
+ catch (e) {
207
+ io.error(`Document server callback for ${itemId} failed: ${io.errorText(e)}`);
208
+ return json({ error: 1 });
209
+ }
210
+ },
211
+ });
@@ -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[];