@emotionalamo/plugin-extratheme 0.0.5

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.
Files changed (48) hide show
  1. package/README.md +153 -0
  2. package/README.zh-CN.md +137 -0
  3. package/client-v2.d.ts +2 -0
  4. package/client-v2.js +1 -0
  5. package/client.d.ts +2 -0
  6. package/client.js +1 -0
  7. package/dist/client/index.d.ts +1 -0
  8. package/dist/client/index.js +10 -0
  9. package/dist/client/plugin.d.ts +5 -0
  10. package/dist/client/selectors.d.ts +1 -0
  11. package/dist/client/settings/LivePreview.d.ts +8 -0
  12. package/dist/client/settings/SettingsPage.d.ts +3 -0
  13. package/dist/client/settings/controls.d.ts +17 -0
  14. package/dist/client/useT.d.ts +2 -0
  15. package/dist/client-v2/index.d.ts +1 -0
  16. package/dist/client-v2/index.js +10 -0
  17. package/dist/client-v2/plugin.d.ts +5 -0
  18. package/dist/client-v2/selectors.d.ts +1 -0
  19. package/dist/externalVersion.js +19 -0
  20. package/dist/index.d.ts +2 -0
  21. package/dist/index.js +48 -0
  22. package/dist/locale/en-US.json +80 -0
  23. package/dist/locale/zh-CN.json +80 -0
  24. package/dist/server/collections/extraThemeSettings.d.ts +2 -0
  25. package/dist/server/collections/extraThemeSettings.js +39 -0
  26. package/dist/server/index.d.ts +2 -0
  27. package/dist/server/index.js +48 -0
  28. package/dist/server/plugin.d.ts +6 -0
  29. package/dist/server/plugin.js +64 -0
  30. package/dist/server/resources/extraTheme.d.ts +24 -0
  31. package/dist/server/resources/extraTheme.js +65 -0
  32. package/dist/shared/buildTheme.d.ts +35 -0
  33. package/dist/shared/buildTheme.js +72 -0
  34. package/dist/shared/color.d.ts +44 -0
  35. package/dist/shared/color.js +122 -0
  36. package/dist/shared/defaults.d.ts +22 -0
  37. package/dist/shared/defaults.js +109 -0
  38. package/dist/shared/generateCss.d.ts +5 -0
  39. package/dist/shared/generateCss.js +116 -0
  40. package/dist/shared/injector.d.ts +15 -0
  41. package/dist/shared/injector.js +88 -0
  42. package/dist/shared/selectors.d.ts +17 -0
  43. package/dist/shared/selectors.js +48 -0
  44. package/dist/shared/types.d.ts +97 -0
  45. package/dist/shared/types.js +24 -0
  46. package/package.json +42 -0
  47. package/server.d.ts +2 -0
  48. package/server.js +1 -0
package/dist/index.js ADDED
@@ -0,0 +1,48 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
+ // If the importer is in node compatibility mode or this is not an ESM
31
+ // file that has been converted to a CommonJS file using a Babel-
32
+ // compatible transform (i.e. "__esModule" has not been set), then set
33
+ // "default" to the CommonJS "module.exports" for node compatibility.
34
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
+ mod
36
+ ));
37
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
+ var src_exports = {};
39
+ __export(src_exports, {
40
+ default: () => import_server.default
41
+ });
42
+ module.exports = __toCommonJS(src_exports);
43
+ __reExport(src_exports, require("./server"), module.exports);
44
+ var import_server = __toESM(require("./server"));
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ ...require("./server")
48
+ });
@@ -0,0 +1,80 @@
1
+ {
2
+ "ExtraTheme": "ExtraTheme",
3
+ "主题增强": "ExtraTheme",
4
+ "工作区外观": "Workspace",
5
+ "登录页外观": "Sign-in page",
6
+ "总开关": "Enable",
7
+ "背景": "Background",
8
+ "类型": "Type",
9
+ "纯色": "Solid",
10
+ "渐变": "Gradient",
11
+ "图片": "Image",
12
+ "背景颜色": "Background color",
13
+ "渐变预设": "Preset",
14
+ "自定义": "Custom",
15
+ "角度": "Angle",
16
+ "自定义色标": "Custom stops",
17
+ "图片 URL": "Image URL",
18
+ "需公网可读": "Must be public",
19
+ "上传": "Upload",
20
+ "铺法": "Fit",
21
+ "铺满": "Cover",
22
+ "适应": "Contain",
23
+ "拉伸": "Stretch",
24
+ "平铺": "Repeat",
25
+ "暗化遮罩": "Dim",
26
+ "内容区卡片": "Content cards",
27
+ "卡片不透明度": "Card opacity",
28
+ "背景模糊": "Blur",
29
+ "浅色描边": "Light border",
30
+ "风格": "Style",
31
+ "实色": "Solid",
32
+ "毛玻璃": "Frosted",
33
+ "不透明度": "Opacity",
34
+ "文字颜色": "Text color",
35
+ "深色": "Dark",
36
+ "浅色": "Light",
37
+ "登录卡片": "Login card",
38
+ "圆角": "Radius",
39
+ "投影": "Shadow",
40
+ "顶部导航栏": "Top navigation",
41
+ "侧边导航栏": "Side navigation",
42
+ "颜色由主题编辑器管理,这里只叠加透明度与模糊。": "Color is managed by the theme editor — here you only add opacity and blur.",
43
+ "滚动条": "Scrollbar",
44
+ "显示方式": "Display",
45
+ "始终显示": "Always show",
46
+ "始终隐藏": "Always hide",
47
+ "“始终显示”为常驻细滚动条;“始终隐藏”完全隐藏滚动条(内容仍可滚动)。": "“Always show” is a persistent slim scrollbar; “Always hide” removes the scrollbar (content still scrolls).",
48
+ "全局字体": "Global font",
49
+ "字体": "Font",
50
+ "自定义字体": "Custom font",
51
+ "字体预览": "Preview",
52
+ "字体来源": "Font source",
53
+ "系统字体": "System font",
54
+ "上传字体": "Upload font",
55
+ "上传字体文件": "Upload font file",
56
+ "选择字体文件": "Choose font file",
57
+ "字体名称": "Font name",
58
+ "已上传": "Uploaded",
59
+ "重新上传": "Replace",
60
+ "移除": "Remove",
61
+ "提示:字体需系统已安装才生效;“无衬线/系统默认”通常与本机默认字体一致,选“楷体/宋体”等可看到明显变化。": "The font must be installed on the viewer's system. “Sans / System default” usually matches the OS default — pick e.g. Kaiti / Songti to see a clear change.",
62
+ "提示:上传字体对所有访问者生效,无需本机安装;中文字体文件较大,建议使用 woff2 或先做子集化以加快加载。": "An uploaded font works for every viewer without a local install. CJK font files are large — prefer woff2 or subset the font to speed up loading.",
63
+ "上传成功": "Uploaded",
64
+ "上传失败": "Upload failed",
65
+ "已保存并应用": "Saved and applied",
66
+ "保存失败": "Save failed",
67
+ "保存并应用": "Save & apply",
68
+ "重置本组": "Reset",
69
+ "实时预览": "Live preview",
70
+ "提示:默认关闭,开启总开关并保存后才生效;关闭插件或关闭开关立即恢复原生外观。": "Off by default — turn on the switch and save to apply; disabling the plugin or the switch restores the native look instantly.",
71
+ "概览": "Overview",
72
+ "数据": "Data",
73
+ "设置": "Settings",
74
+ "菜单": "Menu",
75
+ "订单": "Orders",
76
+ "报表": "Reports",
77
+ "内容卡片": "Content card",
78
+ "欢迎登录": "Welcome back",
79
+ "登录": "Sign in"
80
+ }
@@ -0,0 +1,80 @@
1
+ {
2
+ "ExtraTheme": "主题增强",
3
+ "主题增强": "主题增强",
4
+ "工作区外观": "工作区外观",
5
+ "登录页外观": "登录页外观",
6
+ "总开关": "总开关",
7
+ "背景": "背景",
8
+ "类型": "类型",
9
+ "纯色": "纯色",
10
+ "渐变": "渐变",
11
+ "图片": "图片",
12
+ "背景颜色": "背景颜色",
13
+ "渐变预设": "渐变预设",
14
+ "自定义": "自定义",
15
+ "角度": "角度",
16
+ "自定义色标": "自定义色标",
17
+ "图片 URL": "图片 URL",
18
+ "需公网可读": "需公网可读",
19
+ "上传": "上传",
20
+ "铺法": "铺法",
21
+ "铺满": "铺满",
22
+ "适应": "适应",
23
+ "拉伸": "拉伸",
24
+ "平铺": "平铺",
25
+ "暗化遮罩": "暗化遮罩",
26
+ "内容区卡片": "内容区卡片",
27
+ "卡片不透明度": "卡片不透明度",
28
+ "背景模糊": "背景模糊",
29
+ "浅色描边": "浅色描边",
30
+ "风格": "风格",
31
+ "实色": "实色",
32
+ "毛玻璃": "毛玻璃",
33
+ "不透明度": "不透明度",
34
+ "文字颜色": "文字颜色",
35
+ "深色": "深色",
36
+ "浅色": "浅色",
37
+ "登录卡片": "登录卡片",
38
+ "圆角": "圆角",
39
+ "投影": "投影",
40
+ "顶部导航栏": "顶部导航栏",
41
+ "侧边导航栏": "侧边导航栏",
42
+ "颜色由主题编辑器管理,这里只叠加透明度与模糊。": "颜色由主题编辑器管理,这里只叠加透明度与模糊。",
43
+ "滚动条": "滚动条",
44
+ "显示方式": "显示方式",
45
+ "始终显示": "始终显示",
46
+ "始终隐藏": "始终隐藏",
47
+ "“始终显示”为常驻细滚动条;“始终隐藏”完全隐藏滚动条(内容仍可滚动)。": "“始终显示”为常驻细滚动条;“始终隐藏”完全隐藏滚动条(内容仍可滚动)。",
48
+ "全局字体": "全局字体",
49
+ "字体": "字体",
50
+ "自定义字体": "自定义字体",
51
+ "字体预览": "预览",
52
+ "字体来源": "字体来源",
53
+ "系统字体": "系统字体",
54
+ "上传字体": "上传字体",
55
+ "上传字体文件": "上传字体文件",
56
+ "选择字体文件": "选择字体文件",
57
+ "字体名称": "字体名称",
58
+ "已上传": "已上传",
59
+ "重新上传": "重新上传",
60
+ "移除": "移除",
61
+ "提示:字体需系统已安装才生效;“无衬线/系统默认”通常与本机默认字体一致,选“楷体/宋体”等可看到明显变化。": "提示:字体需系统已安装才生效;“无衬线/系统默认”通常与本机默认字体一致,选“楷体/宋体”等可看到明显变化。",
62
+ "提示:上传字体对所有访问者生效,无需本机安装;中文字体文件较大,建议使用 woff2 或先做子集化以加快加载。": "提示:上传字体对所有访问者生效,无需本机安装;中文字体文件较大,建议使用 woff2 或先做子集化以加快加载。",
63
+ "上传成功": "上传成功",
64
+ "上传失败": "上传失败",
65
+ "已保存并应用": "已保存并应用",
66
+ "保存失败": "保存失败",
67
+ "保存并应用": "保存并应用",
68
+ "重置本组": "重置本组",
69
+ "实时预览": "实时预览",
70
+ "提示:默认关闭,开启总开关并保存后才生效;关闭插件或关闭开关立即恢复原生外观。": "提示:默认关闭,开启总开关并保存后才生效;关闭插件或关闭开关立即恢复原生外观。",
71
+ "概览": "概览",
72
+ "数据": "数据",
73
+ "设置": "设置",
74
+ "菜单": "菜单",
75
+ "订单": "订单",
76
+ "报表": "报表",
77
+ "内容卡片": "内容卡片",
78
+ "欢迎登录": "欢迎登录",
79
+ "登录": "登录"
80
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@nocobase/database").CollectionOptions;
2
+ export default _default;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var extraThemeSettings_exports = {};
28
+ __export(extraThemeSettings_exports, {
29
+ default: () => extraThemeSettings_default
30
+ });
31
+ module.exports = __toCommonJS(extraThemeSettings_exports);
32
+ var import_database = require("@nocobase/database");
33
+ var extraThemeSettings_default = (0, import_database.defineCollection)({
34
+ name: "extraThemeSettings",
35
+ fields: [
36
+ { type: "string", name: "key", unique: true },
37
+ { type: "json", name: "config" }
38
+ ]
39
+ });
@@ -0,0 +1,2 @@
1
+ export * from './plugin';
2
+ export { default } from './plugin';
@@ -0,0 +1,48 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
+ // If the importer is in node compatibility mode or this is not an ESM
31
+ // file that has been converted to a CommonJS file using a Babel-
32
+ // compatible transform (i.e. "__esModule" has not been set), then set
33
+ // "default" to the CommonJS "module.exports" for node compatibility.
34
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
+ mod
36
+ ));
37
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
+ var server_exports = {};
39
+ __export(server_exports, {
40
+ default: () => import_plugin.default
41
+ });
42
+ module.exports = __toCommonJS(server_exports);
43
+ __reExport(server_exports, require("./plugin"), module.exports);
44
+ var import_plugin = __toESM(require("./plugin"));
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ ...require("./plugin")
48
+ });
@@ -0,0 +1,6 @@
1
+ import { Plugin } from '@nocobase/server';
2
+ export declare class PluginExtraThemeServer extends Plugin {
3
+ load(): Promise<void>;
4
+ install(): Promise<void>;
5
+ }
6
+ export default PluginExtraThemeServer;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
+ var plugin_exports = {};
38
+ __export(plugin_exports, {
39
+ PluginExtraThemeServer: () => PluginExtraThemeServer,
40
+ default: () => plugin_default
41
+ });
42
+ module.exports = __toCommonJS(plugin_exports);
43
+ var import_server = require("@nocobase/server");
44
+ var import_extraTheme = __toESM(require("./resources/extraTheme"));
45
+ const SNIPPET = "pm.extra-theme";
46
+ class PluginExtraThemeServer extends import_server.Plugin {
47
+ async load() {
48
+ this.app.resourceManager.define(import_extraTheme.default);
49
+ this.app.acl.allow("extraTheme", "getPublic", "public");
50
+ this.app.acl.registerSnippet({ name: SNIPPET, actions: ["extraTheme:set"] });
51
+ }
52
+ async install() {
53
+ const repo = this.db.getRepository("extraThemeSettings");
54
+ for (const key of ["app", "login"]) {
55
+ const found = await repo.findOne({ filter: { key } });
56
+ if (!found) await repo.create({ values: { key, config: { enabled: false } } });
57
+ }
58
+ }
59
+ }
60
+ var plugin_default = PluginExtraThemeServer;
61
+ // Annotate the CommonJS export names for ESM import in node:
62
+ 0 && (module.exports = {
63
+ PluginExtraThemeServer
64
+ });
@@ -0,0 +1,24 @@
1
+ /**
2
+ * `extraTheme` — a collection-less resource with two actions:
3
+ * - getPublic (anonymous, see ACL in plugin.ts) → the raw stored config for
4
+ * both scopes: `{ app, login }` (null when not yet saved). The client fills
5
+ * defaults via shared `mergeConfig`, so this stays free of shared imports
6
+ * (the NocoBase server build only compiles src/server/**).
7
+ * - set (admin, gated by the `pm.extra-theme` snippet) → upsert one
8
+ * scope's config. body: { scope: 'app' | 'login', config: {...} }.
9
+ * NB: a CUSTOM action name (not the built-in `update`) so the resourcer
10
+ * routes to this handler instead of the reserved built-in update action.
11
+ */
12
+ import { Context, Next } from '@nocobase/actions';
13
+ declare const _default: {
14
+ name: string;
15
+ actions: {
16
+ getPublic: {
17
+ handler: (ctx: Context, next: Next) => Promise<void>;
18
+ };
19
+ set: {
20
+ handler: (ctx: Context, next: Next) => Promise<never>;
21
+ };
22
+ };
23
+ };
24
+ export default _default;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var extraTheme_exports = {};
28
+ __export(extraTheme_exports, {
29
+ default: () => extraTheme_default
30
+ });
31
+ module.exports = __toCommonJS(extraTheme_exports);
32
+ const SCOPES = ["app", "login"];
33
+ var extraTheme_default = {
34
+ name: "extraTheme",
35
+ actions: {
36
+ getPublic: {
37
+ handler: async (ctx, next) => {
38
+ const repo = ctx.db.getRepository("extraThemeSettings");
39
+ const rows = await repo.find();
40
+ const out = { app: null, login: null };
41
+ for (const r of rows) {
42
+ const key = r.get("key");
43
+ if (key === "app" || key === "login") out[key] = r.get("config") ?? null;
44
+ }
45
+ ctx.body = out;
46
+ await next();
47
+ }
48
+ },
49
+ set: {
50
+ handler: async (ctx, next) => {
51
+ var _a, _b;
52
+ const values = ((_b = (_a = ctx.action) == null ? void 0 : _a.params) == null ? void 0 : _b.values) || {};
53
+ const { scope, config } = values;
54
+ if (!SCOPES.includes(scope)) return ctx.throw(400, "invalid scope");
55
+ if (config == null || typeof config !== "object") return ctx.throw(400, "invalid config");
56
+ const repo = ctx.db.getRepository("extraThemeSettings");
57
+ const existing = await repo.findOne({ filter: { key: scope } });
58
+ if (existing) await repo.update({ filter: { key: scope }, values: { config } });
59
+ else await repo.create({ values: { key: scope, config } });
60
+ ctx.body = { ok: true };
61
+ await next();
62
+ }
63
+ }
64
+ }
65
+ };
@@ -0,0 +1,35 @@
1
+ import type { AppConfig } from './types';
2
+ /**
3
+ * Builds the antd ThemeConfig that ExtraTheme applies through NocoBase's global
4
+ * theme (a `themeConfig` record + `useGlobalTheme().setTheme`). Changing tokens
5
+ * at the global source is what penetrates isolated "code-block" React roots —
6
+ * NocoBase re-bridges the merged ConfigProvider theme into every nested root
7
+ * (flow-engine provider.tsx -> ReactView.tsx), which raw CSS cannot reach.
8
+ *
9
+ * Token map (verified against @nocobase/client-v2 defaultTheme / customAlgorithm):
10
+ * colorBgContainer → Card/surface bodies (make translucent)
11
+ * colorBgLayout → page body (transparent so the bg image shows through)
12
+ * colorBgHeader → NocoBase custom token: top nav bar
13
+ * colorBgSider → NocoBase custom token: side nav bar
14
+ * colorBgElevated → ALL overlays (Modal/Drawer/Dropdown/Popover/Select-panel/
15
+ * DatePicker/Message/Notification) — KEEP opaque #fff.
16
+ * The "leak set" (Input/Select/Table/... also read colorBgContainer) is pinned
17
+ * back to #fff via components.<C>.colorBgContainer so controls stay readable.
18
+ */
19
+ /** Components that also read colorBgContainer — pin opaque so they stay usable over a translucent theme. */
20
+ export declare const KEEP_OPAQUE_COMPONENTS: Record<string, any>;
21
+ export interface ExtraThemeConfigOut {
22
+ name: string;
23
+ token: Record<string, any>;
24
+ components: Record<string, any>;
25
+ cssVar: boolean;
26
+ }
27
+ /**
28
+ * @param app the 工作区外观 config
29
+ * @param baseToken the current theme token (pass theme.token) — carries the user's
30
+ * own non-managed customizations (colorPrimary, etc.) which pass through.
31
+ * @param nativeToken the pristine NocoBase token (pass defaultTheme.token) — the source
32
+ * of truth for chrome tokens that must stay set when a section is off
33
+ * (e.g. colorBgHeader is a NocoBase custom token; losing it breaks the header).
34
+ */
35
+ export declare function buildThemeConfig(app: AppConfig, baseToken?: Record<string, any>, nativeToken?: Record<string, any>): ExtraThemeConfigOut;
@@ -0,0 +1,72 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var buildTheme_exports = {};
28
+ __export(buildTheme_exports, {
29
+ KEEP_OPAQUE_COMPONENTS: () => KEEP_OPAQUE_COMPONENTS,
30
+ buildThemeConfig: () => buildThemeConfig
31
+ });
32
+ module.exports = __toCommonJS(buildTheme_exports);
33
+ var import_color = require("./color");
34
+ const KEEP_OPAQUE_COMPONENTS = {
35
+ Table: { colorBgContainer: "#ffffff" },
36
+ Input: { colorBgContainer: "#ffffff" },
37
+ InputNumber: { colorBgContainer: "#ffffff" },
38
+ Select: { colorBgContainer: "#ffffff" },
39
+ TreeSelect: { colorBgContainer: "#ffffff" },
40
+ Cascader: { colorBgContainer: "#ffffff" },
41
+ Mentions: { colorBgContainer: "#ffffff" },
42
+ DatePicker: { colorBgContainer: "#ffffff" }
43
+ };
44
+ const MANAGED_TOKENS = ["colorBgContainer", "colorBgLayout", "fontFamily"];
45
+ function buildThemeConfig(app, baseToken = {}, nativeToken = {}) {
46
+ var _a;
47
+ const token = { ...baseToken };
48
+ for (const k of MANAGED_TOKENS) delete token[k];
49
+ token.colorBgElevated = "#ffffff";
50
+ if (app.enabled) {
51
+ token.colorBgLayout = "transparent";
52
+ if (app.card.glass) {
53
+ token.colorBgContainer = (0, import_color.hexToRgba)("#ffffff", app.card.opacity / 100);
54
+ }
55
+ }
56
+ const font = app.font;
57
+ if (font == null ? void 0 : font.enabled) {
58
+ if (font.source === "upload" && ((_a = font.upload) == null ? void 0 : _a.url)) {
59
+ const name = (0, import_color.sanitizeFontFamily)(font.upload.name || "").replace(/["']/g, "");
60
+ if (name) token.fontFamily = `"${name}"`;
61
+ } else if (font.source !== "upload") {
62
+ const fam = (0, import_color.sanitizeFontFamily)(font.family || "");
63
+ if (fam) token.fontFamily = fam;
64
+ }
65
+ }
66
+ return { name: "Modern", token, components: { ...KEEP_OPAQUE_COMPONENTS }, cssVar: true };
67
+ }
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ KEEP_OPAQUE_COMPONENTS,
71
+ buildThemeConfig
72
+ });
@@ -0,0 +1,44 @@
1
+ import type { BackgroundConfig } from './types';
2
+ /**
3
+ * Sanitize a (possibly hand-typed) CSS font-family stack so it can't break out of
4
+ * the injected declaration or corrupt the whole <style>. A font-family only needs
5
+ * letters/digits/space/comma/quotes/hyphen. Strip:
6
+ * - `;{}<>\` — declaration/rule breakout chars,
7
+ * - `/` and `*` — CSS comment markers (a lone `/​*` would comment out the rest of
8
+ * the injected stylesheet, silently killing every rule after the font),
9
+ * - control chars (collapsed to a space),
10
+ * then drop quotes if unbalanced (a lone quote runs a CSS string past the `}`), and
11
+ * cap the length. Returns '' for empty.
12
+ */
13
+ export declare function sanitizeFontFamily(family: string): string;
14
+ /** Map a font file URL's extension to an @font-face src `format()` value (''=unknown). */
15
+ export declare function fontFormatFromUrl(url: string): string;
16
+ /** Make a URL safe to drop inside CSS `url("...")` — strip chars that could close the string/rule. */
17
+ export declare function sanitizeCssUrl(url: string): string;
18
+ /** '#ffffff', 0.9 -> 'rgba(255,255,255,0.9)'. Accepts 3/6-digit hex, with or without '#'. */
19
+ export declare function hexToRgba(hex: string, alpha: number): string;
20
+ /**
21
+ * Strict allow-list for a CSS color that gets interpolated into a declaration. Accepts
22
+ * only #hex (3/4/6/8), rgb()/rgba()/hsl()/hsla() built from digits/%/./,//space, or a
23
+ * bare word (named color — no breakout chars possible). ANYTHING else → 'transparent'.
24
+ * This is the security boundary: config values are admin-writable but the compiled CSS
25
+ * is served to every visitor incl. the anonymous sign-in page, so a value like
26
+ * `red}body::before{...}` MUST NOT reach the stylesheet.
27
+ */
28
+ export declare function safeCssColor(color: string): string;
29
+ /** Coerce to a finite number (default 0) — for numeric CSS values interpolated raw. */
30
+ export declare function safeNum(v: any, def?: number): number;
31
+ /** Drop any alpha and return a solid 'rgb(r,g,b)'. Unparseable → safe black (never raw). */
32
+ export declare function toSolidRgb(color: string): string;
33
+ /** Apply an alpha to a hex/rgb/rgba color; RGB preserved. Unparseable → 'transparent'
34
+ * (never echo the raw value into the declaration — that was a CSS-injection sink). */
35
+ export declare function withAlpha(color: string, alpha: number): string;
36
+ /** Resolve a BackgroundConfig into CSS background-* values. Every interpolated value is
37
+ * sanitized (color → safeCssColor, angle → safeNum, url → sanitizeCssUrl) so nothing
38
+ * can break out of the injected declaration. */
39
+ export declare function buildBackground(bg: BackgroundConfig): {
40
+ image: string;
41
+ size: string;
42
+ repeat: string;
43
+ position: string;
44
+ };