@danielng23/dsh-cyber-client-ui-theme-terminal 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.
- package/lib/client.js +124 -0
- package/lib/index.js +6 -0
- package/lib/types/client/TerminalThemeRow.d.ts +22 -0
- package/lib/types/client/index.d.ts +24 -0
- package/lib/types/client/locales.d.ts +16 -0
- package/lib/types/index.d.ts +4 -0
- package/package.json +63 -0
package/lib/client.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "@danielng23/dsh-cyber-client-ui-theme-terminal",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
+
//#region src/client/locales.ts
|
|
9
|
+
/** `theme-terminal` namespace dictionaries (the Appearance row label). */
|
|
10
|
+
/** Dictionary namespace owned by this plugin. */
|
|
11
|
+
const NS = "theme-terminal";
|
|
12
|
+
/** Simplified Chinese dictionary. */
|
|
13
|
+
const zh = { "appearance.terminal": "终端" };
|
|
14
|
+
/** English dictionary. */
|
|
15
|
+
const en = { "appearance.terminal": "Terminal" };
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region \0dsh-css:/Users/daniel/workspace/arisos/dsh-edex-ui-cyber/packages/ui-theme-terminal/src/client/TerminalThemeRow.module.css.mjs
|
|
18
|
+
const css = ".VBKBea_row{justify-content:space-between;align-items:center;gap:12px;padding:8px 0;display:flex}.VBKBea_label{color:var(--dsw-alias-label-primary,inherit);font-size:13px}.VBKBea_toggle{border:1px solid var(--dsw-alias-border-l1,currentColor);color:var(--dsw-alias-label-secondary,currentColor);cursor:pointer;background:0 0;padding:2px 8px;font-family:monospace;font-size:16px;line-height:1}.VBKBea_toggle:hover,.VBKBea_toggle[data-active]{color:var(--dsw-alias-brand-primary,currentColor);border-color:var(--dsw-alias-brand-primary,currentColor)}";
|
|
19
|
+
const tagId = "@danielng23/dsh-cyber-client-ui-theme-terminal/TerminalThemeRow.module.css";
|
|
20
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
21
|
+
const tag = document.createElement("style");
|
|
22
|
+
tag.dataset.plugin = "@danielng23/dsh-cyber-client-ui-theme-terminal";
|
|
23
|
+
tag.dataset.pluginCss = tagId;
|
|
24
|
+
tag.textContent = css;
|
|
25
|
+
document.head.appendChild(tag);
|
|
26
|
+
}
|
|
27
|
+
var TerminalThemeRow_module_css_default = {
|
|
28
|
+
"toggle": "VBKBea_toggle",
|
|
29
|
+
"label": "VBKBea_label",
|
|
30
|
+
"row": "VBKBea_row"
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/client/TerminalThemeRow.tsx
|
|
34
|
+
/** The Appearance row: label + toggle. */
|
|
35
|
+
function TerminalThemeRow({ useTerminalActive, setTerminal, t }) {
|
|
36
|
+
const active = useTerminalActive((s) => s);
|
|
37
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
38
|
+
className: TerminalThemeRow_module_css_default.row,
|
|
39
|
+
"data-testid": "appearance-terminal",
|
|
40
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
41
|
+
className: TerminalThemeRow_module_css_default.label,
|
|
42
|
+
children: t("appearance.terminal")
|
|
43
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
44
|
+
type: "button",
|
|
45
|
+
className: TerminalThemeRow_module_css_default.toggle,
|
|
46
|
+
"data-active": active ? "" : void 0,
|
|
47
|
+
"aria-pressed": active,
|
|
48
|
+
onClick: setTerminal,
|
|
49
|
+
children: active ? "▣" : "▢"
|
|
50
|
+
})]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/client/index.ts
|
|
55
|
+
/** Theme id this plugin registers (the setTheme argument). */
|
|
56
|
+
const THEME_ID = "terminal";
|
|
57
|
+
/**
|
|
58
|
+
* CRT palette as alias-token overrides. The presenter writes these as inline
|
|
59
|
+
* CSS variables over the dark base palette, so the whole default UI (and any
|
|
60
|
+
* widget registered into its slots) is recolored.
|
|
61
|
+
*/
|
|
62
|
+
const TOKENS = {
|
|
63
|
+
"--dsw-alias-bg-base": "#000a00",
|
|
64
|
+
"--dsw-alias-bg-layer-1": "#02120a",
|
|
65
|
+
"--dsw-alias-bg-layer-2": "#031d10",
|
|
66
|
+
"--dsw-alias-bg-overlay": "#000a00",
|
|
67
|
+
"--dsw-alias-border-l1": "#1d7a3f",
|
|
68
|
+
"--dsw-alias-border-l2": "#2ea854",
|
|
69
|
+
"--dsw-alias-brand-primary": "#35e06a",
|
|
70
|
+
"--dsw-alias-label-primary": "#35e06a",
|
|
71
|
+
"--dsw-alias-label-secondary": "#2ea854",
|
|
72
|
+
"--dsw-alias-state-error-primary": "#e05a5a",
|
|
73
|
+
"--dsw-alias-state-success-primary": "#35e06a",
|
|
74
|
+
"--dsw-alias-state-warn-primary": "#e0c05a",
|
|
75
|
+
"--dsw-specific-sidebar-fill": "#001408"
|
|
76
|
+
};
|
|
77
|
+
/** Required services: slot registry for the Appearance row, the theme service, and locale. */
|
|
78
|
+
const inject = [
|
|
79
|
+
"slots",
|
|
80
|
+
"theme",
|
|
81
|
+
"locale"
|
|
82
|
+
];
|
|
83
|
+
/**
|
|
84
|
+
* Client plugin body: register the terminal theme and the Appearance row that
|
|
85
|
+
* selects it.
|
|
86
|
+
* @param ctx - client root context.
|
|
87
|
+
*/
|
|
88
|
+
function apply(ctx) {
|
|
89
|
+
ctx.effect(() => ctx.locale.register(NS, {
|
|
90
|
+
zh,
|
|
91
|
+
en
|
|
92
|
+
}), "ui-theme-terminal: dictionaries");
|
|
93
|
+
const disposeTheme = ctx.theme.register({
|
|
94
|
+
id: THEME_ID,
|
|
95
|
+
colorScheme: "dark",
|
|
96
|
+
tokens: TOKENS
|
|
97
|
+
});
|
|
98
|
+
ctx.effect(() => () => void disposeTheme(), "ui-theme-terminal: theme registration");
|
|
99
|
+
const terminalActiveSource = {
|
|
100
|
+
getSnapshot: () => ctx.theme.getTheme().active.id === THEME_ID,
|
|
101
|
+
subscribe: (listener) => ctx.on("theme/change", () => listener())
|
|
102
|
+
};
|
|
103
|
+
ctx.slots.inject("settings.general.item", () => ctx.slots.register({
|
|
104
|
+
name: "settings.general.item",
|
|
105
|
+
id: "appearance-terminal",
|
|
106
|
+
order: 11,
|
|
107
|
+
locale: NS,
|
|
108
|
+
inject: () => ({
|
|
109
|
+
setTerminal: () => {
|
|
110
|
+
ctx.theme.setTheme(THEME_ID);
|
|
111
|
+
},
|
|
112
|
+
hooks: { terminalActive: terminalActiveSource }
|
|
113
|
+
})
|
|
114
|
+
}, TerminalThemeRow));
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
exports.THEME_ID = THEME_ID;
|
|
118
|
+
exports.apply = apply;
|
|
119
|
+
exports.inject = inject;
|
|
120
|
+
return module.exports;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
//# sourceMappingURL=client.js.map
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Appearance row that activates the terminal theme. Mirrors the built-in
|
|
3
|
+
* Appearance row's shape: one settings.general.item entry with a toggle that
|
|
4
|
+
* calls theme.setTheme('terminal'); the active state rides the theme/change
|
|
5
|
+
* hook seat.
|
|
6
|
+
*/
|
|
7
|
+
import type { InjectFace, PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
|
|
8
|
+
import type { ObservableSource } from './index.ts';
|
|
9
|
+
/** The row's inject face: the setter plus the active-state hook source. */
|
|
10
|
+
export interface TerminalThemeRowInjected {
|
|
11
|
+
/** Activate the terminal theme (theme.setTheme('terminal')). */
|
|
12
|
+
setTerminal: () => void;
|
|
13
|
+
/** Bare observable "terminal theme is active" source bound to useTerminalActive. */
|
|
14
|
+
hooks: {
|
|
15
|
+
terminalActive: ObservableSource<boolean>;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** Full composed props of the row. */
|
|
19
|
+
export type TerminalThemeRowProps = PropsLocale<'theme-terminal'> & InjectFace<TerminalThemeRowInjected>;
|
|
20
|
+
/** The Appearance row: label + toggle. */
|
|
21
|
+
export declare function TerminalThemeRow({ useTerminalActive, setTerminal, t, }: TerminalThemeRowProps): import("react").JSX.Element;
|
|
22
|
+
//# sourceMappingURL=TerminalThemeRow.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal theme plugin, browser half: registers the CRT `terminal` theme with
|
|
3
|
+
* the theme service (alias-token overrides over the dark base palette) and
|
|
4
|
+
* contributes one Appearance row that activates it. Purely additive — the
|
|
5
|
+
* default surface is untouched, so every existing slot/widget keeps working
|
|
6
|
+
* and picks up the palette automatically.
|
|
7
|
+
*/
|
|
8
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
9
|
+
/** Theme id this plugin registers (the setTheme argument). */
|
|
10
|
+
export declare const THEME_ID = "terminal";
|
|
11
|
+
/** Bare observable snapshot source (getSnapshot + subscribe). */
|
|
12
|
+
export interface ObservableSource<T> {
|
|
13
|
+
getSnapshot(): T;
|
|
14
|
+
subscribe(listener: () => void): () => void;
|
|
15
|
+
}
|
|
16
|
+
/** Required services: slot registry for the Appearance row, the theme service, and locale. */
|
|
17
|
+
export declare const inject: string[];
|
|
18
|
+
/**
|
|
19
|
+
* Client plugin body: register the terminal theme and the Appearance row that
|
|
20
|
+
* selects it.
|
|
21
|
+
* @param ctx - client root context.
|
|
22
|
+
*/
|
|
23
|
+
export declare function apply(ctx: Context): void;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** `theme-terminal` namespace dictionaries (the Appearance row label). */
|
|
2
|
+
/** Dictionary namespace owned by this plugin. */
|
|
3
|
+
export declare const NS = "theme-terminal";
|
|
4
|
+
/** The dictionary key set (source of truth for both locales). */
|
|
5
|
+
export type ThemeTerminalKey = 'appearance.terminal';
|
|
6
|
+
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
7
|
+
interface LocaleNamespaceMap {
|
|
8
|
+
/** The terminal theme's Appearance row copy. */
|
|
9
|
+
'theme-terminal': ThemeTerminalKey;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/** Simplified Chinese dictionary. */
|
|
13
|
+
export declare const zh: Record<ThemeTerminalKey, string>;
|
|
14
|
+
/** English dictionary. */
|
|
15
|
+
export declare const en: Record<ThemeTerminalKey, string>;
|
|
16
|
+
//# sourceMappingURL=locales.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@danielng23/dsh-cyber-client-ui-theme-terminal",
|
|
3
|
+
"description": "Terminal (CRT) theme for the web UI: registers a green-on-black alias-token theme and an Appearance row to pick it",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/ph4310822/dsh-edex-cyber-ui.git",
|
|
11
|
+
"directory": "packages/ui-theme-terminal"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"types": "lib/types/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/types/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./client": {
|
|
22
|
+
"types": "./lib/types/client/index.d.ts",
|
|
23
|
+
"default": "./lib/client.js"
|
|
24
|
+
},
|
|
25
|
+
"./src/*": "./src/*",
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"dsh": {
|
|
29
|
+
"client": {
|
|
30
|
+
"inject": [
|
|
31
|
+
"@deepseek-ai/dsh-client-runtime",
|
|
32
|
+
"@deepseek-ai/dsh-client-ui-theme",
|
|
33
|
+
"@deepseek-ai/dsh-client-locale"
|
|
34
|
+
],
|
|
35
|
+
"platform": "web"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"lib/index.js",
|
|
40
|
+
"lib/client.js",
|
|
41
|
+
"lib/types/**/*.d.ts"
|
|
42
|
+
],
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@deepseek-ai/dsh-client-locale": "*",
|
|
45
|
+
"@deepseek-ai/dsh-client-runtime": "*",
|
|
46
|
+
"@deepseek-ai/dsh-client-ui-slots": "*",
|
|
47
|
+
"@deepseek-ai/dsh-client-ui-theme": "*",
|
|
48
|
+
"@deepseek-ai/cordis": "*",
|
|
49
|
+
"react": "^18.2.0",
|
|
50
|
+
"react-dom": "^18.2.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@deepseek-ai/cordis": "*",
|
|
54
|
+
"@deepseek-ai/dsh-client-runtime": "*",
|
|
55
|
+
"@deepseek-ai/dsh-client-ui-slots": "*",
|
|
56
|
+
"@deepseek-ai/dsh-client-ui-theme": "*",
|
|
57
|
+
"@types/react": "~18.3.1",
|
|
58
|
+
"@types/react-dom": "~18.3.0",
|
|
59
|
+
"react": "^18.2.0",
|
|
60
|
+
"react-dom": "^18.2.0"
|
|
61
|
+
},
|
|
62
|
+
"license": "MIT"
|
|
63
|
+
}
|